mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
refactor(lexer): compile JSX angle bracket disambiguation separately for each CPU feature set (#28616)
Part of effort to move to runtime CPU feature detection. Apply `cpu_versions!` to `jsx_over_type_params` and `ts_angle_verdict`, keeping their `#[inline]` attributes. `carve_jsx` passes `cpu` to `jsx_over_type_params`, which passes it on to `ts_angle_verdict`. `ts_angle_verdict` doesn't use `cpu` yet. This changes codegen on x86_64 only. `jsx_over_type_params` is inlined into `carve_jsx` again, as it was before step B1. No change on aarch64.
This commit is contained in:
1 parent
0fb7999f0e
commit
40e9989a32
2 files changed
+13
-3
No files matched your search
@@ -3,6 +3,7 @@ use crate::error::DiagCode;
|
||||
use crate::pipeline::{
|
||||
bitmap::bm_get,
|
||||
bytes::{is_id_start, is_word, line_break_in},
|
||||
cpu::{Cpu, apply, cpu_versions},
|
||||
disambiguate::jsx_over_generic,
|
||||
lanes::Lanes,
|
||||
token_view,
|
||||
@@ -17,6 +18,7 @@ enum AngleVerdict {
|
||||
Ambiguous { gt: usize, lp: usize },
|
||||
}
|
||||
|
||||
#[apply(cpu_versions)]
|
||||
#[inline]
|
||||
pub(super) unsafe fn jsx_over_type_params(
|
||||
src: *const u8,
|
||||
@@ -30,11 +32,12 @@ pub(super) unsafe fn jsx_over_type_params(
|
||||
tpos: usize,
|
||||
ts: bool,
|
||||
lanes: &mut Lanes,
|
||||
cpu: impl Cpu,
|
||||
) -> bool {
|
||||
if !ts {
|
||||
return true;
|
||||
}
|
||||
match ts_angle_verdict(srcs, n, tpos, word) {
|
||||
match ts_angle_verdict(srcs, n, tpos, word, cpu) {
|
||||
AngleVerdict::TypeParams => false,
|
||||
AngleVerdict::Jsx => true,
|
||||
AngleVerdict::Ambiguous { gt, lp } => {
|
||||
@@ -72,8 +75,15 @@ pub(super) unsafe fn jsx_over_type_params(
|
||||
/// has already cleared `word` across Unicode whitespace by the time
|
||||
/// `carve_jsx` runs, so the corrected run is free to read and no byte has to
|
||||
/// be re-scanned for a leading 0x80.
|
||||
#[apply(cpu_versions)]
|
||||
#[inline]
|
||||
unsafe fn ts_angle_verdict(src: &[u8], n: usize, t: usize, word: *const u64) -> AngleVerdict {
|
||||
unsafe fn ts_angle_verdict(
|
||||
src: &[u8],
|
||||
n: usize,
|
||||
t: usize,
|
||||
word: *const u64,
|
||||
_cpu: impl Cpu,
|
||||
) -> AngleVerdict {
|
||||
let mut p = t;
|
||||
// optional `const` type-parameter modifier: `<const T,>`. Like any modifier it must stay
|
||||
// on the line of its parameter; a comment between them is fine.
|
||||
|
||||
@@ -263,7 +263,7 @@ pub(super) unsafe fn carve_jsx(
|
||||
mode = JMode::Tag;
|
||||
} else if is_id_start(tc)
|
||||
&& jsx_over_type_params(
|
||||
src, srcs, st, opch, kind, word, n, s, tpos, ts, lanes,
|
||||
src, srcs, st, opch, kind, word, n, s, tpos, ts, lanes, cpu,
|
||||
)
|
||||
{
|
||||
// Element - unless `.tsx` says this is a
|
||||
|
||||
Reference in new issue
Block a user