oxc-project
oxc
BlogDocsChangelog

feat(ecmascript): add ARM64 FJCVTZS instruction optimization for ToInt32 with function-specific target features and runtime detection

#12823Merged
Comparing
copilot/fix-0823fc2f-f860-40f2-950c-0f4d0bce529f
(
bc1d716
) with
main
(
c245d9b
)
CodSpeed Performance Gauge
0%
Untouched
34

Benchmarks

Passed

minifier[cal.com.tsx]
tasks/benchmark/benches/minifier.rs::minifier::bench_minifier
CodSpeed Performance Gauge
0%
39.2 ms39 ms
codegen[cal.com.tsx]
tasks/benchmark/benches/codegen.rs::codegen::bench_codegen
CodSpeed Performance Gauge
0%
36.2 ms36.1 ms
transformer[cal.com.tsx]
tasks/benchmark/benches/transformer.rs::transformer::bench_transformer
CodSpeed Performance Gauge
0%
26.4 ms26.4 ms
parser[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/parser.rs::parser::bench_parser
CodSpeed Performance Gauge
0%
83.9 µs83.7 µs
transformer[react.development.js]
tasks/benchmark/benches/transformer.rs::transformer::bench_transformer
CodSpeed Performance Gauge
0%
714.3 µs713.7 µs
minifier[react.development.js]
tasks/benchmark/benches/minifier.rs::minifier::bench_minifier
CodSpeed Performance Gauge
0%
2.7 ms2.7 ms
codegen[react.development.js]
tasks/benchmark/benches/codegen.rs::codegen::bench_codegen
CodSpeed Performance Gauge
0%
1.9 ms1.9 ms
formatter[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/formatter.rs::formatter::bench_formatter
CodSpeed Performance Gauge
0%
308.2 µs307.9 µs
semantic[binder.ts]
tasks/benchmark/benches/semantic.rs::semantic::bench_semantic
CodSpeed Performance Gauge
0%
4.3 ms4.3 ms
formatter[binder.ts]
tasks/benchmark/benches/formatter.rs::formatter::bench_formatter
CodSpeed Performance Gauge
0%
21.3 ms21.3 ms
linter[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
2.5 ms2.5 ms
formatter[cal.com.tsx]
tasks/benchmark/benches/formatter.rs::formatter::bench_formatter
CodSpeed Performance Gauge
0%
169.5 ms169.5 ms
lexer[react.development.js]
tasks/benchmark/benches/lexer.rs::lexer::bench_lexer
CodSpeed Performance Gauge
0%
383.9 µs383.9 µs
estree[checker.ts]
tasks/benchmark/benches/parser.rs::parser::bench_estree
CodSpeed Performance Gauge
0%
104.4 ms104.4 ms
lexer[binder.ts]
tasks/benchmark/benches/lexer.rs::lexer::bench_lexer
CodSpeed Performance Gauge
0%
930.1 µs930 µs
linter[binder.ts]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
146.8 ms146.8 ms
parser[cal.com.tsx]
tasks/benchmark/benches/parser.rs::parser::bench_parser
CodSpeed Performance Gauge
0%
26.8 ms26.8 ms
lexer[cal.com.tsx]
tasks/benchmark/benches/lexer.rs::lexer::bench_lexer
CodSpeed Performance Gauge
0%
5.8 ms5.8 ms
linter[react.development.js]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
52.3 ms52.3 ms
linter[cal.com.tsx]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
1.2 s1.2 s
parser[binder.ts]
tasks/benchmark/benches/parser.rs::parser::bench_parser
CodSpeed Performance Gauge
0%
3.3 ms3.3 ms
parser[react.development.js]
tasks/benchmark/benches/parser.rs::parser::bench_parser
CodSpeed Performance Gauge
0%
1.3 ms1.3 ms
codegen[binder.ts]
tasks/benchmark/benches/codegen.rs::codegen::bench_codegen
CodSpeed Performance Gauge
0%
4.2 ms4.2 ms
transformer[binder.ts]
tasks/benchmark/benches/transformer.rs::transformer::bench_transformer
CodSpeed Performance Gauge
0%
1.7 ms1.7 ms
semantic[cal.com.tsx]
tasks/benchmark/benches/semantic.rs::semantic::bench_semantic
CodSpeed Performance Gauge
0%
27.9 ms27.9 ms
isolated-declarations[vue-id.ts]
tasks/benchmark/benches/transformer.rs::transformer::bench_isolated_declarations
CodSpeed Performance Gauge
0%
57.5 ms57.5 ms
formatter[react.development.js]
tasks/benchmark/benches/formatter.rs::formatter::bench_formatter
CodSpeed Performance Gauge
0%
10.6 ms10.6 ms
minifier[binder.ts]
tasks/benchmark/benches/minifier.rs::minifier::bench_minifier
CodSpeed Performance Gauge
0%
4.9 ms4.9 ms
minifier[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/minifier.rs::minifier::bench_minifier
CodSpeed Performance Gauge
0%
81.1 µs81.1 µs
codegen[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/codegen.rs::codegen::bench_codegen
CodSpeed Performance Gauge
0%
123 µs123.2 µs
semantic[react.development.js]
tasks/benchmark/benches/semantic.rs::semantic::bench_semantic
CodSpeed Performance Gauge
0%
1.7 ms1.7 ms
transformer[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/transformer.rs::transformer::bench_transformer
CodSpeed Performance Gauge
0%
133.3 µs133.4 µs
lexer[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/lexer.rs::lexer::bench_lexer
CodSpeed Performance Gauge
0%
20.7 µs20.7 µs
semantic[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/semantic.rs::semantic::bench_semantic
CodSpeed Performance Gauge
0%
76.3 µs76.7 µs

Commits

Click on a commit to change the comparison range
Base
main
c245d9b
+0.01%
feat(ecmascript): add ARM64 FJCVTZS instruction optimization for ToInt32 with function-specific target features and runtime detection (#12823) This PR ports the ARM64 FJCVTZS instruction optimization from Boa's JavaScript engine to improve ToInt32 conversion performance on ARM64 architectures using function-specific target features and runtime detection. ## Key Features **Hardware-Accelerated Conversion**: Uses the `FJCVTZS` (Floating-point Javascript Convert to Signed fixed-point, rounding toward Zero) instruction on supported ARM64 systems for optimal performance. **Function-Specific Target Features**: Uses `#[target_feature(enable = "jsconv")]` on the ARM64 optimization function following Rust's recommended approach for dynamic CPU feature detection, providing better safety guarantees than global compilation flags. **Optimized Feature Detection**: - **macOS ARM64**: Direct hardware acceleration without runtime detection overhead since macOS ARM64 always supports `jsconv` - **Other ARM64 platforms**: Runtime feature detection using `std::arch::is_aarch64_feature_detected!("jsconv")` with built-in caching to prevent "Illegal instruction" errors on older ARM64 processors **Automatic Fallback**: Seamlessly falls back to the generic implementation on: - Non-ARM64 architectures - ARM64 systems without JSCVT support (ARM v8.0-A through v8.2-A) **ARM64 CI Validation**: Added `ubuntu-24.04-arm` runner to validate the optimization on actual ARM64 hardware and ensure proper feature detection across different ARM64 processor generations. ## Implementation Details The FJCVTZS instruction is specifically designed for ECMAScript's ToInt32 operation and is available on ARM v8.3-A processors and later. The implementation: - Uses function-specific `#[target_feature(enable = "jsconv")]` for precise control and safety - Maintains exact ECMAScript ToInt32 compliance with proper unsafe block usage - Includes proper NaN handling to prevent floating-point exceptions - Provides comprehensive test coverage for edge cases and implementation consistency - Validated on both x86_64 and ARM64 architectures through CI ## Performance Impact - **macOS ARM64**: Maximum performance with direct hardware acceleration, zero runtime detection overhead - **ARM v8.3-A and later (non-macOS)**: Significant performance improvement through dedicated hardware instruction with one-time feature detection - **ARM v8.0-A through v8.2-A**: No performance impact, uses existing generic implementation - **Other architectures**: Zero overhead, existing behavior preserved ## Compatibility ✅ Full API compatibility - no breaking changes ✅ Safe across all ARM64 processor generations ✅ Automatic architecture detection and dispatch ✅ Comprehensive test coverage including consistency validation ✅ ARM64 CI validation on actual hardware ✅ No additional dependencies required ✅ Function-specific target feature configuration following Rust best practices <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
bc1d716
3 months ago
by Copilot
© 2025 CodSpeed Technology
Home Terms Privacy Docs