Truly independent web browser
LibJS: Stop initializing yield fields in frames that cannot yield
Andreas Klingac516649de65
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.Sindex 6f2fcc40660..8ee11ac34c9 100644--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S@@ -5482,7 +5482,7 @@ asm_handler_GetById:ldr x2, [x2, x4, lsl #3]cbz x2, .Lasm_GetById.ssa_block_1and x2, x2, #0xfffffffffffffffc- cbz x2, .Lasm_GetById.assert_predicate_failure_342+ cbz x2, .Lasm_GetById.assert_predicate_failure_336ldr x9, [x2, #24]cmp x9, x0b.ne .Lasm_GetById.ssa_block_15@@ -6313,10 +6313,10 @@ asm_handler_Call:b.ls .Lasm_Call.ssa_block_23mov x3, x4.Lasm_Call.ssa_block_23:- cbz x2, .Lasm_Call.assert_predicate_failure_262+ cbz x2, .Lasm_Call.assert_predicate_failure_256ldp w0, w4, [x2, #12]cmp x4, x0- b.lo .Lasm_Call.assert_predicate_failure_268+ b.lo .Lasm_Call.assert_predicate_failure_262movn w0, #0subs x0, x0, x4cmp x0, x3@@ -6331,7 +6331,7 @@ asm_handler_Call:add x5, x5, #136adds x5, x5, x0cmp x5, x0- b.lo .Lasm_Call.assert_predicate_failure_282+ b.lo .Lasm_Call.assert_predicate_failure_276cmp x5, x8b.hi .Lasm_Call.ssa_block_1mov x8, x20@@ -6344,7 +6344,7 @@ asm_handler_Call:add x9, x24, w1, uxtw #3cmp w1, #0csel x1, x9, xzr, ne- cbz x1, .Lasm_Call.assert_predicate_failure_303+ cbz x1, .Lasm_Call.assert_predicate_failure_297stp x1, x1, [x0, #32]stp x6, x2, [x0, #80]movz x1, #0x7ffb, lsl #48@@ -6354,10 +6354,6 @@ asm_handler_Call:str wzr, [x0, #64]str xzr, [x0, #56]str wzr, [x0, #68]- movn w9, #0- str w9, [x0, #72]- strb wzr, [x0, #76]- strb wzr, [x0, #77]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -6376,7 +6372,7 @@ asm_handler_Call:stp w1, w5, [x0, #108]ldrb w2, [x21, #6]cmp x3, x2- b.lo .Lasm_Call.assert_predicate_failure_369+ b.lo .Lasm_Call.assert_predicate_failure_357add x6, x21, #7add x5, x0, #136add x7, x28, #136@@ -6402,7 +6398,7 @@ asm_handler_Call:b .Lasm_Call.ssa_block_31.Lasm_Call.ssa_block_30:ldr x1, [x0, #88]- cbz x1, .Lasm_Call.assert_predicate_failure_391+ cbz x1, .Lasm_Call.assert_predicate_failure_379ldr x26, [x1, #40]cbz x26, .Lasm_Call.assert_failure_6mov x1, x20@@ -6549,10 +6545,6 @@ asm_handler_Call:str wzr, [x0, #64]str xzr, [x0, #56]str wzr, [x0, #68]- movn w9, #0- str w9, [x0, #72]- strb wzr, [x0, #76]- strb wzr, [x0, #77]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -6593,7 +6585,7 @@ asm_handler_Call:adds x4, x4, x0ldr w0, [x4, #8]cmp x0, #1- b.hs .Lasm_Call.assert_predicate_failure_208+ b.hs .Lasm_Call.assert_predicate_failure_202ldr x2, [x4]cbz x2, .Lasm_Call.assert_failure_25mov x9, x2@@ -6601,10 +6593,10 @@ asm_handler_Call:blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_Call.assert_predicate_failure_215+ b.hs .Lasm_Call.assert_predicate_failure_209cbnz x1, .Lasm_Call.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_Call.assert_predicate_failure_221+ cbz x1, .Lasm_Call.assert_predicate_failure_215mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -14577,10 +14569,6 @@ asm_handler_GetById_cold:str wzr, [x0, #64]str xzr, [x0, #56]str wzr, [x0, #68]- movn w9, #0- str w9, [x0, #72]- strb wzr, [x0, #76]- strb wzr, [x0, #77]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -14605,10 +14593,10 @@ asm_handler_GetById_cold:blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_GetById.assert_predicate_failure_272+ b.hs .Lasm_GetById.assert_predicate_failure_266cbnz x1, .Lasm_GetById.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_GetById.assert_predicate_failure_281+ cbz x1, .Lasm_GetById.assert_predicate_failure_275mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -21482,7 +21470,7 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_1:brk #0-.Lasm_GetById.assert_predicate_failure_342:+.Lasm_GetById.assert_predicate_failure_336:brk #0.Lasm_GetById.assert_failure_2:brk #0@@ -21512,9 +21500,9 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_10:brk #0-.Lasm_GetById.assert_predicate_failure_272:+.Lasm_GetById.assert_predicate_failure_266:brk #0-.Lasm_GetById.assert_predicate_failure_281:+.Lasm_GetById.assert_predicate_failure_275:brk #0.Lasm_GetById.assert_predicate_failure_26:brk #0@@ -21628,21 +21616,21 @@ asm_assertion_failure_traps:brk #0.Lasm_Call.assert_failure_3:brk #0-.Lasm_Call.assert_predicate_failure_262:+.Lasm_Call.assert_predicate_failure_256:brk #0-.Lasm_Call.assert_predicate_failure_268:+.Lasm_Call.assert_predicate_failure_262:brk #0.Lasm_Call.assert_failure_4:brk #0.Lasm_Call.assert_failure_5:brk #0-.Lasm_Call.assert_predicate_failure_282:+.Lasm_Call.assert_predicate_failure_276:brk #0-.Lasm_Call.assert_predicate_failure_303:+.Lasm_Call.assert_predicate_failure_297:brk #0-.Lasm_Call.assert_predicate_failure_369:+.Lasm_Call.assert_predicate_failure_357:brk #0-.Lasm_Call.assert_predicate_failure_391:+.Lasm_Call.assert_predicate_failure_379:brk #0.Lasm_Call.assert_failure_6:brk #0@@ -21670,13 +21658,13 @@ asm_assertion_failure_traps:brk #0.Lasm_Call.assert_failure_24:brk #0-.Lasm_Call.assert_predicate_failure_208:+.Lasm_Call.assert_predicate_failure_202:brk #0.Lasm_Call.assert_failure_25:brk #0-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_209:brk #0-.Lasm_Call.assert_predicate_failure_221:+.Lasm_Call.assert_predicate_failure_215:brk #0.Lasm_Call.assert_predicate_failure_91:brk #0diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.Sindex 084a6471e98..82fa46bdd69 100644--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S@@ -5480,7 +5480,7 @@ asm_handler_GetById:jz .Lasm_GetById.ssa_block_1and rdx, -4test rdx, rdx- jz .Lasm_GetById.assert_predicate_failure_342+ jz .Lasm_GetById.assert_predicate_failure_336cmp QWORD PTR [rdx + 24], raxjne .Lasm_GetById.ssa_block_15mov ecx, DWORD PTR [rdx]@@ -6367,11 +6367,11 @@ asm_handler_Call:mov rsi, rdi.Lasm_Call.ssa_block_23:test rdx, rdx- jz .Lasm_Call.assert_predicate_failure_262+ jz .Lasm_Call.assert_predicate_failure_256mov eax, DWORD PTR [rdx + 12]mov edi, DWORD PTR [rdx + 16]cmp rdi, rax- jb .Lasm_Call.assert_predicate_failure_268+ jb .Lasm_Call.assert_predicate_failure_262mov eax, 4294967295sub rax, rdicmp rax, rsi@@ -6390,7 +6390,7 @@ asm_handler_Call:lea r8, [r8 + 136]add r8, raxcmp r8, rax- jb .Lasm_Call.assert_predicate_failure_282+ jb .Lasm_Call.assert_predicate_failure_276cmp r8, r11ja .Lasm_Call.ssa_block_1mov r11, QWORD PTR [rbp - 48]@@ -6405,7 +6405,7 @@ asm_handler_Call:test ecx, ecxcmovnz rcx, r11test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_303+ jz .Lasm_Call.assert_predicate_failure_297mov QWORD PTR [rax + 32], rcxmov QWORD PTR [rax + 40], rcxmov QWORD PTR [rax + 80], r9@@ -6419,9 +6419,6 @@ asm_handler_Call:mov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0mov DWORD PTR [rax + 68], 0- mov DWORD PTR [rax + 72], 4294967295- mov BYTE PTR [rax + 76], 0- mov BYTE PTR [rax + 77], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -6442,7 +6439,7 @@ asm_handler_Call:mov DWORD PTR [rax + 112], r8dmovzx edx, BYTE PTR [r14 + r13 + 6]cmp rsi, rdx- jb .Lasm_Call.assert_predicate_failure_369+ jb .Lasm_Call.assert_predicate_failure_357lea r9, [r14 + r13 + 7]lea r8, [rax + 136]lea r10, [rbx]@@ -6469,7 +6466,7 @@ asm_handler_Call:.Lasm_Call.ssa_block_30:mov rcx, QWORD PTR [rax + 88]test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_391+ jz .Lasm_Call.assert_predicate_failure_379mov r14, QWORD PTR [rcx + 40]test r14, r14jz .Lasm_Call.assert_failure_6@@ -6628,9 +6625,6 @@ asm_handler_Call:mov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0mov DWORD PTR [rax + 68], 0- mov DWORD PTR [rax + 72], 4294967295- mov BYTE PTR [rax + 76], 0- mov BYTE PTR [rax + 77], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -6673,7 +6667,7 @@ asm_handler_Call:add rdi, raxmov eax, DWORD PTR [rdi + 8]cmp rax, 1- jae .Lasm_Call.assert_predicate_failure_208+ jae .Lasm_Call.assert_predicate_failure_202mov rdx, QWORD PTR [rdi]test rdx, rdxjz .Lasm_Call.assert_failure_25@@ -6683,12 +6677,12 @@ asm_handler_Call:mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_Call.assert_predicate_failure_215+ jae .Lasm_Call.assert_predicate_failure_209test rcx, rcxjnz .Lasm_Call.ssa_block_6mov rcx, QWORD PTR [rbx - 40]test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_221+ jz .Lasm_Call.assert_predicate_failure_215mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -14180,9 +14174,6 @@ asm_handler_GetById_cold:mov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0mov DWORD PTR [rax + 68], 0- mov DWORD PTR [rax + 72], 4294967295- mov BYTE PTR [rax + 76], 0- mov BYTE PTR [rax + 77], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -14210,12 +14201,12 @@ asm_handler_GetById_cold:mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_GetById.assert_predicate_failure_272+ jae .Lasm_GetById.assert_predicate_failure_266test rcx, rcxjnz .Lasm_GetById.ssa_block_6mov rcx, QWORD PTR [rbx - 40]test rcx, rcx- jz .Lasm_GetById.assert_predicate_failure_281+ jz .Lasm_GetById.assert_predicate_failure_275mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -20860,7 +20851,7 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_1:ud2-.Lasm_GetById.assert_predicate_failure_342:+.Lasm_GetById.assert_predicate_failure_336:ud2.Lasm_GetById.assert_failure_2:ud2@@ -20890,9 +20881,9 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_10:ud2-.Lasm_GetById.assert_predicate_failure_272:+.Lasm_GetById.assert_predicate_failure_266:ud2-.Lasm_GetById.assert_predicate_failure_281:+.Lasm_GetById.assert_predicate_failure_275:ud2.Lasm_GetById.assert_predicate_failure_26:ud2@@ -21006,21 +20997,21 @@ asm_assertion_failure_traps:ud2.Lasm_Call.assert_failure_3:ud2-.Lasm_Call.assert_predicate_failure_262:+.Lasm_Call.assert_predicate_failure_256:ud2-.Lasm_Call.assert_predicate_failure_268:+.Lasm_Call.assert_predicate_failure_262:ud2.Lasm_Call.assert_failure_4:ud2.Lasm_Call.assert_failure_5:ud2-.Lasm_Call.assert_predicate_failure_282:+.Lasm_Call.assert_predicate_failure_276:ud2-.Lasm_Call.assert_predicate_failure_303:+.Lasm_Call.assert_predicate_failure_297:ud2-.Lasm_Call.assert_predicate_failure_369:+.Lasm_Call.assert_predicate_failure_357:ud2-.Lasm_Call.assert_predicate_failure_391:+.Lasm_Call.assert_predicate_failure_379:ud2.Lasm_Call.assert_failure_6:ud2@@ -21048,13 +21039,13 @@ asm_assertion_failure_traps:ud2.Lasm_Call.assert_failure_24:ud2-.Lasm_Call.assert_predicate_failure_208:+.Lasm_Call.assert_predicate_failure_202:ud2.Lasm_Call.assert_failure_25:ud2-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_209:ud2-.Lasm_Call.assert_predicate_failure_221:+.Lasm_Call.assert_predicate_failure_215:ud2.Lasm_Call.assert_predicate_failure_91:ud2diff --git a/Libraries/LibJS/Interpreter/interpreter.flap b/Libraries/LibJS/Interpreter/interpreter.flapindex 54fd79e5f99..af6d338806e 100644--- a/Libraries/LibJS/Interpreter/interpreter.flap+++ b/Libraries/LibJS/Interpreter/interpreter.flap@@ -3353,9 +3353,6 @@ handler GetById(native_frame.program_counter = 0;native_frame.frame_id = 0;native_frame.skip_when_determining_incumbent_counter = 0;- native_frame.yield_continuation = EXECUTION_CONTEXT_NO_YIELD_CONTINUATION;- native_frame.yield_is_await = false;- native_frame.yield_value_is_iterator_result = false;native_frame.caller_is_construct = false;native_frame.frame_initialized = false;native_frame.returns_to_native_caller = false;@@ -4077,9 +4074,7 @@ inline fn enter_ecmascript_function_call(# NB: Frames get their id when something first asks (see Vm::frame_id_of()).frame.frame_id = 0;frame.skip_when_determining_incumbent_counter = 0;- frame.yield_continuation = EXECUTION_CONTEXT_NO_YIELD_CONTINUATION;- frame.yield_is_await = false;- frame.yield_value_is_iterator_result = false;+ # NB: Only frames of code that can yield or await have yield fields, and the runtime makes those.frame.caller_is_construct = false;frame.frame_initialized = false;frame.returns_to_native_caller = false;@@ -4169,9 +4164,6 @@ inline fn call_raw_native_function(native_frame.program_counter = 0;native_frame.frame_id = 0;native_frame.skip_when_determining_incumbent_counter = 0;- native_frame.yield_continuation = EXECUTION_CONTEXT_NO_YIELD_CONTINUATION;- native_frame.yield_is_await = false;- native_frame.yield_value_is_iterator_result = false;native_frame.caller_is_construct = false;native_frame.frame_initialized = false;native_frame.returns_to_native_caller = false;diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/call.rs b/Libraries/LibJS/JIT/Rust/src/codegen/call.rsindex a79adf370f8..6f377dd0d32 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/call.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/call.rs@@ -1661,18 +1661,11 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {/// not initialized, and whether its caller waits for it in native code/// (and so runs it in JIT code until the runtime finishes it, see/// `finish_direct_call`).- pub(super) fn new_frame_constants(&self, returns_to_native_caller: bool) -> [ConstantField; 11] {+ pub(super) fn new_frame_constants(&self, returns_to_native_caller: bool) -> [ConstantField; 8] {let offsets = self.runtime.offsets;[(offsets.execution_context_program_counter, 4, 0),(offsets.execution_context_skip_when_determining_incumbent_counter, 4, 0),- (- offsets.execution_context_yield_continuation,- 4,- u64::from(self.runtime.no_yield_continuation),- ),- (offsets.execution_context_yield_is_await, 1, 0),- (offsets.execution_context_yield_value_is_iterator_result, 1, 0),(offsets.execution_context_caller_is_construct, 1, 0),(offsets.execution_context_caller_is_derived_construct, 1, 0),(offsets.execution_context_frame_initialized, 1, 0),diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs b/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rsindex babac78e8bc..a7b243f7fae 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs@@ -940,7 +940,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {new_frame: crate::asm::Gpr,temp: crate::asm::Gpr,ecmascript: bool,- ) -> [super::call::ConstantField; 11] {+ ) -> [super::call::ConstantField; 8] {let offsets = self.runtime.offsets;let field = |offset: u32| Address::new(new_frame, offset as i32);let argument_count_local = self.stub_local(local::ARGUMENT_COUNT);diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rsindex dc7a5c2375a..fd3bf6074f1 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs@@ -3859,8 +3859,7 @@ mod direct_calls {assert_eq!((word(8), word(96)), (FUNCTION_WORDS[0], FUNCTION_WORDS[0]));assert_eq!(word(104), 0, "no frame id yet");assert_eq!(word(0), 0, "program counter and incumbent counter");- assert_eq!(half(112), u32::MAX, "no yield continuation");- assert_eq!((byte(116), byte(117), byte(118), byte(24)), (0, 0, 0, 0));+ assert_eq!((byte(118), byte(24)), (0, 0), "not a construct call, not initialized");assert_eq!(word(120), value::EMPTY, "no this value");assert_eq!(word(32), callee.executable.as_ptr() as u64);assert_eq!(word(8 * FRAME_CALLER_WORD), machine.frame.as_ptr() as u64);diff --git a/Libraries/LibJS/Rust/src/layout/execution_context.rs b/Libraries/LibJS/Rust/src/layout/execution_context.rsindex d95767b0076..297cdb286fd 100644--- a/Libraries/LibJS/Rust/src/layout/execution_context.rs+++ b/Libraries/LibJS/Rust/src/layout/execution_context.rs@@ -93,6 +93,7 @@ pub struct ExecutionContext {pub frame_id: Cell<u64>,pub program_counter: Cell<u32>,pub skip_when_determining_incumbent_counter: Cell<u32>,+ /// The yield fields are only valid in frames of code that can yield or await, which the runtime makes.pub yield_continuation: Cell<u32>,pub yield_is_await: Cell<bool>,pub yield_value_is_iterator_result: Cell<bool>,