diff --git a/crates/oxc_lexer/src/pipeline/carve/comments.rs b/crates/oxc_lexer/src/pipeline/carve/comments.rs index 775c11667d..69b4f5d06d 100644 --- a/crates/oxc_lexer/src/pipeline/carve/comments.rs +++ b/crates/oxc_lexer/src/pipeline/carve/comments.rs @@ -142,7 +142,7 @@ pub(super) unsafe fn lex_html_open_comment( if lanes.module { lanes.push_diag(s as u32, 4, DiagCode::HtmlCommentInModule); } - let end = find_line_terminator(src, n, s + 4); + let end = find_line_terminator(src, n, s + 4, cpu); *kind.add(s) = tk!(LineComment); if end > s + 1 { bm_clear_range(st, s + 1, end - 1); @@ -193,7 +193,7 @@ pub(super) unsafe fn lex_html_close_comment( let cpu = BASELINE; let start = s - 2; - let end = find_line_terminator(src, n, s + 1); + let end = find_line_terminator(src, n, s + 1, cpu); *kind.add(start) = tk!(LineComment); bm_set(st, start); if end > start + 1 { diff --git a/crates/oxc_lexer/src/pipeline/carve/common.rs b/crates/oxc_lexer/src/pipeline/carve/common.rs index 4f75c2b05f..974f9a7963 100644 --- a/crates/oxc_lexer/src/pipeline/carve/common.rs +++ b/crates/oxc_lexer/src/pipeline/carve/common.rs @@ -3,7 +3,7 @@ use crate::{error::DiagCode, token::tk}; use crate::pipeline::{ bitmap::{bm_clear, bm_clear_range, bm_get, bm_next0}, bytes::hex_val, - cpu::Cpu, + cpu::{Cpu, apply, cpu_versions}, disambiguate::not_operator_position, find::find, lanes::Lanes, @@ -192,8 +192,14 @@ pub(super) unsafe fn skip_unicode_brace_escape(src: *const u8, n: usize, s: usiz /// (U+2028/U+2029). Stops at LS/PS too, so the hashbang scan cannot run /// through one. A 0xE2 that isn't LS/PS keeps scanning; the 2-byte confirm /// past a trailing 0xE2 reads the pad, which can never match 0x80. +#[apply(cpu_versions)] #[inline] -pub(super) unsafe fn find_line_terminator(src: *const u8, n: usize, mut i: usize) -> usize { +pub(super) unsafe fn find_line_terminator( + src: *const u8, + n: usize, + mut i: usize, + _cpu: impl Cpu, +) -> usize { loop { let p = find(src, n, i, [b'\n', b'\r', 0xE2]); if p >= n { diff --git a/crates/oxc_lexer/src/pipeline/carve/js.rs b/crates/oxc_lexer/src/pipeline/carve/js.rs index abd2bb5e3f..9f23a40e61 100644 --- a/crates/oxc_lexer/src/pipeline/carve/js.rs +++ b/crates/oxc_lexer/src/pipeline/carve/js.rs @@ -33,7 +33,7 @@ pub(super) unsafe fn carve_js( let mut depth: Vec = Vec::with_capacity(64); let mut i = 0usize; if n >= 2 && *src == b'#' && *src.add(1) == b'!' { - let end = find_line_terminator(src, n, 2); + let end = find_line_terminator(src, n, 2, cpu); *kind = tk!(Hashbang); bm_clear_range(st, 1, end - 1); if end < n { diff --git a/crates/oxc_lexer/src/pipeline/carve/jsx/mod.rs b/crates/oxc_lexer/src/pipeline/carve/jsx/mod.rs index b1900513c4..7a278f1e72 100644 --- a/crates/oxc_lexer/src/pipeline/carve/jsx/mod.rs +++ b/crates/oxc_lexer/src/pipeline/carve/jsx/mod.rs @@ -104,7 +104,7 @@ pub(super) unsafe fn carve_jsx( let mut text_start = 0usize; let mut i = 0usize; if n >= 2 && *src == b'#' && *src.add(1) == b'!' { - let end = find_line_terminator(src, n, 2); + let end = find_line_terminator(src, n, 2, cpu); *kind = tk!(Hashbang); bm_clear_range(st, 1, end - 1); if end < n { diff --git a/crates/oxc_lexer/src/pipeline/carve/jsx/names.rs b/crates/oxc_lexer/src/pipeline/carve/jsx/names.rs index 05d36e7df6..a96eaf0604 100644 --- a/crates/oxc_lexer/src/pipeline/carve/jsx/names.rs +++ b/crates/oxc_lexer/src/pipeline/carve/jsx/names.rs @@ -78,7 +78,7 @@ pub(super) unsafe fn jsx_skip_trivia( src: *const u8, n: usize, mut i: usize, - _cpu: impl Cpu, + cpu: impl Cpu, ) -> usize { loop { if i >= n { @@ -100,7 +100,7 @@ pub(super) unsafe fn jsx_skip_trivia( continue; } b'/' => { - i = find_line_terminator(src, n, i + 2); + i = find_line_terminator(src, n, i + 2, cpu); continue; } _ => {}