Skip to content

Commit 2707b49

Browse files
committed
ZJIT: Add new CompileError::NativeStackTooLarge
This helps distinguish an OutOfMemory (intended to be for running out of code space) from a native frame needing too much stack space. On protoboeuf, for example: Top-2 compile error reasons (100.0% of total 5,798,926): out_of_memory: 3,074,342 (53.0%) native_stack_too_large: 2,724,584 (47.0%)
1 parent b1d6132 commit 2707b49

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

zjit/src/backend/arm64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ impl Assembler {
16291629

16301630
let total_stack_slots = asm.stack_base_idx + num_stack_slots;
16311631
if total_stack_slots > Self::MAX_FRAME_STACK_SLOTS {
1632-
return Err(CompileError::OutOfMemory);
1632+
return Err(CompileError::NativeStackTooLarge);
16331633
}
16341634

16351635
// Dump vreg-to-physical-register mapping if requested

zjit/src/backend/x86_64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ impl Assembler {
11641164

11651165
let total_stack_slots = asm.stack_base_idx + num_stack_slots;
11661166
if total_stack_slots > Self::MAX_FRAME_STACK_SLOTS {
1167-
return Err(CompileError::OutOfMemory);
1167+
return Err(CompileError::NativeStackTooLarge);
11681168
}
11691169

11701170
// Dump vreg-to-physical-register mapping if requested

zjit/src/stats.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ make_counters! {
329329
// compile_error_: Compile error reasons
330330
compile_error_iseq_version_limit_reached,
331331
compile_error_iseq_stack_too_large,
332+
compile_error_native_stack_too_large,
332333
compile_error_exception_handler,
333334
compile_error_out_of_memory,
334335
compile_error_label_linking_failure,
@@ -500,6 +501,7 @@ pub fn send_fallback_counter_ptr_for_opcode(opcode: u32) -> *mut u64 {
500501
pub enum CompileError {
501502
IseqVersionLimitReached,
502503
IseqStackTooLarge,
504+
NativeStackTooLarge,
503505
ExceptionHandler,
504506
OutOfMemory,
505507
ParseError(ParseError),
@@ -518,6 +520,7 @@ pub fn exit_counter_for_compile_error(compile_error: &CompileError) -> Counter {
518520
match compile_error {
519521
IseqVersionLimitReached => compile_error_iseq_version_limit_reached,
520522
IseqStackTooLarge => compile_error_iseq_stack_too_large,
523+
NativeStackTooLarge => compile_error_native_stack_too_large,
521524
ExceptionHandler => compile_error_exception_handler,
522525
OutOfMemory => compile_error_out_of_memory,
523526
LabelLinkingFailure => compile_error_label_linking_failure,

0 commit comments

Comments
 (0)