Truly independent web browser
LibJS+LibWeb: Keep skip-when-determining-incumbent counters aside
Andreas Klingee6711da7775
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.Sindex 8ee11ac34c9..e76d21ffbbe 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_336+ cbz x2, .Lasm_GetById.assert_predicate_failure_334ldr 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_256+ cbz x2, .Lasm_Call.assert_predicate_failure_254ldp w0, w4, [x2, #12]cmp x4, x0- b.lo .Lasm_Call.assert_predicate_failure_262+ b.lo .Lasm_Call.assert_predicate_failure_260movn 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_276+ b.lo .Lasm_Call.assert_predicate_failure_274cmp 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_297+ cbz x1, .Lasm_Call.assert_predicate_failure_295stp x1, x1, [x0, #32]stp x6, x2, [x0, #80]movz x1, #0x7ffb, lsl #48@@ -6353,7 +6353,6 @@ asm_handler_Call:stp x1, x1, [x0, #160]str wzr, [x0, #64]str xzr, [x0, #56]- str wzr, [x0, #68]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -6372,7 +6371,7 @@ asm_handler_Call:stp w1, w5, [x0, #108]ldrb w2, [x21, #6]cmp x3, x2- b.lo .Lasm_Call.assert_predicate_failure_357+ b.lo .Lasm_Call.assert_predicate_failure_353add x6, x21, #7add x5, x0, #136add x7, x28, #136@@ -6398,7 +6397,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_379+ cbz x1, .Lasm_Call.assert_predicate_failure_375ldr x26, [x1, #40]cbz x26, .Lasm_Call.assert_failure_6mov x1, x20@@ -6544,7 +6543,6 @@ asm_handler_Call:stp x1, x3, [x0, #80]str wzr, [x0, #64]str xzr, [x0, #56]- str wzr, [x0, #68]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -6585,7 +6583,7 @@ asm_handler_Call:adds x4, x4, x0ldr w0, [x4, #8]cmp x0, #1- b.hs .Lasm_Call.assert_predicate_failure_202+ b.hs .Lasm_Call.assert_predicate_failure_200ldr x2, [x4]cbz x2, .Lasm_Call.assert_failure_25mov x9, x2@@ -6593,10 +6591,10 @@ asm_handler_Call:blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_Call.assert_predicate_failure_209+ b.hs .Lasm_Call.assert_predicate_failure_207cbnz x1, .Lasm_Call.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_Call.assert_predicate_failure_215+ cbz x1, .Lasm_Call.assert_predicate_failure_213mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -14568,7 +14566,6 @@ asm_handler_GetById_cold:stp x3, x1, [x0, #80]str wzr, [x0, #64]str xzr, [x0, #56]- str wzr, [x0, #68]strb wzr, [x0, #78]strb wzr, [x0, #79]strb wzr, [x0, #124]@@ -14593,10 +14590,10 @@ asm_handler_GetById_cold:blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_GetById.assert_predicate_failure_266+ b.hs .Lasm_GetById.assert_predicate_failure_264cbnz x1, .Lasm_GetById.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_GetById.assert_predicate_failure_275+ cbz x1, .Lasm_GetById.assert_predicate_failure_273mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -21470,7 +21467,7 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_1:brk #0-.Lasm_GetById.assert_predicate_failure_336:+.Lasm_GetById.assert_predicate_failure_334:brk #0.Lasm_GetById.assert_failure_2:brk #0@@ -21500,9 +21497,9 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_10:brk #0-.Lasm_GetById.assert_predicate_failure_266:+.Lasm_GetById.assert_predicate_failure_264:brk #0-.Lasm_GetById.assert_predicate_failure_275:+.Lasm_GetById.assert_predicate_failure_273:brk #0.Lasm_GetById.assert_predicate_failure_26:brk #0@@ -21616,21 +21613,21 @@ asm_assertion_failure_traps:brk #0.Lasm_Call.assert_failure_3:brk #0-.Lasm_Call.assert_predicate_failure_256:+.Lasm_Call.assert_predicate_failure_254:brk #0-.Lasm_Call.assert_predicate_failure_262:+.Lasm_Call.assert_predicate_failure_260:brk #0.Lasm_Call.assert_failure_4:brk #0.Lasm_Call.assert_failure_5:brk #0-.Lasm_Call.assert_predicate_failure_276:+.Lasm_Call.assert_predicate_failure_274:brk #0-.Lasm_Call.assert_predicate_failure_297:+.Lasm_Call.assert_predicate_failure_295:brk #0-.Lasm_Call.assert_predicate_failure_357:+.Lasm_Call.assert_predicate_failure_353:brk #0-.Lasm_Call.assert_predicate_failure_379:+.Lasm_Call.assert_predicate_failure_375:brk #0.Lasm_Call.assert_failure_6:brk #0@@ -21658,13 +21655,13 @@ asm_assertion_failure_traps:brk #0.Lasm_Call.assert_failure_24:brk #0-.Lasm_Call.assert_predicate_failure_202:+.Lasm_Call.assert_predicate_failure_200:brk #0.Lasm_Call.assert_failure_25:brk #0-.Lasm_Call.assert_predicate_failure_209:+.Lasm_Call.assert_predicate_failure_207:brk #0-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_213: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 82fa46bdd69..81b33b0f8e4 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_336+ jz .Lasm_GetById.assert_predicate_failure_334cmp 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_256+ jz .Lasm_Call.assert_predicate_failure_254mov eax, DWORD PTR [rdx + 12]mov edi, DWORD PTR [rdx + 16]cmp rdi, rax- jb .Lasm_Call.assert_predicate_failure_262+ jb .Lasm_Call.assert_predicate_failure_260mov 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_276+ jb .Lasm_Call.assert_predicate_failure_274cmp 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_297+ jz .Lasm_Call.assert_predicate_failure_295mov QWORD PTR [rax + 32], rcxmov QWORD PTR [rax + 40], rcxmov QWORD PTR [rax + 80], r9@@ -6418,7 +6418,6 @@ asm_handler_Call:mov QWORD PTR [rax + 168], rcxmov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0- mov DWORD PTR [rax + 68], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -6439,7 +6438,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_357+ jb .Lasm_Call.assert_predicate_failure_353lea r9, [r14 + r13 + 7]lea r8, [rax + 136]lea r10, [rbx]@@ -6466,7 +6465,7 @@ asm_handler_Call:.Lasm_Call.ssa_block_30:mov rcx, QWORD PTR [rax + 88]test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_379+ jz .Lasm_Call.assert_predicate_failure_375mov r14, QWORD PTR [rcx + 40]test r14, r14jz .Lasm_Call.assert_failure_6@@ -6624,7 +6623,6 @@ asm_handler_Call:mov QWORD PTR [rax + 88], rsimov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0- mov DWORD PTR [rax + 68], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -6667,7 +6665,7 @@ asm_handler_Call:add rdi, raxmov eax, DWORD PTR [rdi + 8]cmp rax, 1- jae .Lasm_Call.assert_predicate_failure_202+ jae .Lasm_Call.assert_predicate_failure_200mov rdx, QWORD PTR [rdi]test rdx, rdxjz .Lasm_Call.assert_failure_25@@ -6677,12 +6675,12 @@ asm_handler_Call:mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_Call.assert_predicate_failure_209+ jae .Lasm_Call.assert_predicate_failure_207test rcx, rcxjnz .Lasm_Call.ssa_block_6mov rcx, QWORD PTR [rbx - 40]test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_215+ jz .Lasm_Call.assert_predicate_failure_213mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -14173,7 +14171,6 @@ asm_handler_GetById_cold:mov QWORD PTR [rax + 88], rcxmov DWORD PTR [rax + 64], 0mov QWORD PTR [rax + 56], 0- mov DWORD PTR [rax + 68], 0mov BYTE PTR [rax + 78], 0mov BYTE PTR [rax + 79], 0mov BYTE PTR [rax + 124], 0@@ -14201,12 +14198,12 @@ asm_handler_GetById_cold:mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_GetById.assert_predicate_failure_266+ jae .Lasm_GetById.assert_predicate_failure_264test rcx, rcxjnz .Lasm_GetById.ssa_block_6mov rcx, QWORD PTR [rbx - 40]test rcx, rcx- jz .Lasm_GetById.assert_predicate_failure_275+ jz .Lasm_GetById.assert_predicate_failure_273mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -20851,7 +20848,7 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_1:ud2-.Lasm_GetById.assert_predicate_failure_336:+.Lasm_GetById.assert_predicate_failure_334:ud2.Lasm_GetById.assert_failure_2:ud2@@ -20881,9 +20878,9 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_10:ud2-.Lasm_GetById.assert_predicate_failure_266:+.Lasm_GetById.assert_predicate_failure_264:ud2-.Lasm_GetById.assert_predicate_failure_275:+.Lasm_GetById.assert_predicate_failure_273:ud2.Lasm_GetById.assert_predicate_failure_26:ud2@@ -20997,21 +20994,21 @@ asm_assertion_failure_traps:ud2.Lasm_Call.assert_failure_3:ud2-.Lasm_Call.assert_predicate_failure_256:+.Lasm_Call.assert_predicate_failure_254:ud2-.Lasm_Call.assert_predicate_failure_262:+.Lasm_Call.assert_predicate_failure_260:ud2.Lasm_Call.assert_failure_4:ud2.Lasm_Call.assert_failure_5:ud2-.Lasm_Call.assert_predicate_failure_276:+.Lasm_Call.assert_predicate_failure_274:ud2-.Lasm_Call.assert_predicate_failure_297:+.Lasm_Call.assert_predicate_failure_295:ud2-.Lasm_Call.assert_predicate_failure_357:+.Lasm_Call.assert_predicate_failure_353:ud2-.Lasm_Call.assert_predicate_failure_379:+.Lasm_Call.assert_predicate_failure_375:ud2.Lasm_Call.assert_failure_6:ud2@@ -21039,13 +21036,13 @@ asm_assertion_failure_traps:ud2.Lasm_Call.assert_failure_24:ud2-.Lasm_Call.assert_predicate_failure_202:+.Lasm_Call.assert_predicate_failure_200:ud2.Lasm_Call.assert_failure_25:ud2-.Lasm_Call.assert_predicate_failure_209:+.Lasm_Call.assert_predicate_failure_207:ud2-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_213:ud2.Lasm_Call.assert_predicate_failure_91:ud2diff --git a/Libraries/LibJS/Flap/tests/interpreter-layout.conf b/Libraries/LibJS/Flap/tests/interpreter-layout.confindex 0d1b935241f..9bf9cfe9969 100644--- a/Libraries/LibJS/Flap/tests/interpreter-layout.conf+++ b/Libraries/LibJS/Flap/tests/interpreter-layout.conf@@ -188,8 +188,6 @@ const EXECUTION_CONTEXT_VARIABLE_ENVIRONMENT = 40field ExecutionContext.variable_environment Environment EXECUTION_CONTEXT_VARIABLE_ENVIRONMENT nullable cell environmentsconst EXECUTION_CONTEXT_PRIVATE_ENVIRONMENT = 48field ExecutionContext.private_environment PrivateEnvironment EXECUTION_CONTEXT_PRIVATE_ENVIRONMENT nullable cell-const EXECUTION_CONTEXT_SKIP_WHEN_DETERMINING_INCUMBENT_COUNTER = 68-field ExecutionContext.skip_when_determining_incumbent_counter u32 EXECUTION_CONTEXT_SKIP_WHEN_DETERMINING_INCUMBENT_COUNTER nullable scalarconst EXECUTION_CONTEXT_YIELD_CONTINUATION = 72field ExecutionContext.yield_continuation u32 EXECUTION_CONTEXT_YIELD_CONTINUATION nullable scalarconst EXECUTION_CONTEXT_YIELD_IS_AWAIT = 76diff --git a/Libraries/LibJS/Interpreter/interpreter.flap b/Libraries/LibJS/Interpreter/interpreter.flapindex af6d338806e..6117a682007 100644--- a/Libraries/LibJS/Interpreter/interpreter.flap+++ b/Libraries/LibJS/Interpreter/interpreter.flap@@ -3352,7 +3352,6 @@ handler GetById(native_frame.executable = null;native_frame.program_counter = 0;native_frame.frame_id = 0;- native_frame.skip_when_determining_incumbent_counter = 0;native_frame.caller_is_construct = false;native_frame.frame_initialized = false;native_frame.returns_to_native_caller = false;@@ -4073,7 +4072,6 @@ inline fn enter_ecmascript_function_call(frame.program_counter = 0;# 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;# 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;@@ -4163,7 +4161,6 @@ inline fn call_raw_native_function(native_frame.executable = null;native_frame.program_counter = 0;native_frame.frame_id = 0;- native_frame.skip_when_determining_incumbent_counter = 0;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 6f377dd0d32..940e4ee849e 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/call.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/call.rs@@ -1661,11 +1661,10 @@ 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; 8] {+ pub(super) fn new_frame_constants(&self, returns_to_native_caller: bool) -> [ConstantField; 7] {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_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 a7b243f7fae..91f51d4d315 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; 8] {+ ) -> [super::call::ConstantField; 7] {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 fd3bf6074f1..58f5709bbdd 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs@@ -57,7 +57,6 @@ fn offsets() -> RuntimeOffsets {execution_context_function: 64,execution_context_variable_environment: 96,execution_context_frame_id: 104,- execution_context_skip_when_determining_incumbent_counter: 4,execution_context_yield_continuation: 112,execution_context_yield_is_await: 116,execution_context_yield_value_is_iterator_result: 117,@@ -3858,7 +3857,7 @@ mod direct_calls {assert_eq!(word(64), callee.function.as_ptr() as u64, "function");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(0), 0, "program counter");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);diff --git a/Libraries/LibJS/JIT/Rust/src/snapshot.rs b/Libraries/LibJS/JIT/Rust/src/snapshot.rsindex 87c2f5eef28..c1515101c9e 100644--- a/Libraries/LibJS/JIT/Rust/src/snapshot.rs+++ b/Libraries/LibJS/JIT/Rust/src/snapshot.rs@@ -1653,8 +1653,6 @@ pub struct RuntimeOffsets {pub execution_context_variable_environment: u32,/// `ExecutionContext::frame_id` (u64).pub execution_context_frame_id: u32,- /// `ExecutionContext::skip_when_determining_incumbent_counter` (u32).- pub execution_context_skip_when_determining_incumbent_counter: u32,/// `ExecutionContext::yield_continuation` (u32).pub execution_context_yield_continuation: u32,/// `ExecutionContext::yield_is_await` (bool).diff --git a/Libraries/LibJS/Runtime/ExecutionContext.h b/Libraries/LibJS/Runtime/ExecutionContext.hindex c3df5b9b8a0..25355159ba2 100644--- a/Libraries/LibJS/Runtime/ExecutionContext.h+++ b/Libraries/LibJS/Runtime/ExecutionContext.h@@ -128,9 +128,6 @@ struct JS_API ExecutionContext {u64 frame_id { 0 };u32 program_counter { 0 };- // https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter- u32 skip_when_determining_incumbent_counter { 0 };-static constexpr u32 no_yield_continuation = NumericLimits<u32>::max();u32 yield_continuation { no_yield_continuation };@@ -224,7 +221,6 @@ JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(variable_environment, VARIABLE_ENVIRONMJS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(private_environment_in_frame, PRIVATE_ENVIRONMENT_IN_FRAME)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(frame_id, FRAME_ID)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(program_counter, PROGRAM_COUNTER)-JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(skip_when_determining_incumbent_counter, SKIP_WHEN_DETERMINING_INCUMBENT_COUNTER)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(yield_continuation, YIELD_CONTINUATION)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(yield_is_await, YIELD_IS_AWAIT)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(yield_value_is_iterator_result, YIELD_VALUE_IS_ITERATOR_RESULT)diff --git a/Libraries/LibJS/Rust/generate/layout_header.rs b/Libraries/LibJS/Rust/generate/layout_header.rsindex 5545c8d5290..dfed26354e8 100644--- a/Libraries/LibJS/Rust/generate/layout_header.rs+++ b/Libraries/LibJS/Rust/generate/layout_header.rs@@ -333,7 +333,6 @@ pub fn generate() -> LayoutHeader {private_environment_in_frame,frame_id,program_counter,- skip_when_determining_incumbent_counter,yield_continuation,yield_is_await,yield_value_is_iterator_result,diff --git a/Libraries/LibJS/Rust/generate/layout_table.rs b/Libraries/LibJS/Rust/generate/layout_table.rsindex f4050c907fc..86fbc326f95 100644--- a/Libraries/LibJS/Rust/generate/layout_table.rs+++ b/Libraries/LibJS/Rust/generate/layout_table.rs@@ -337,7 +337,6 @@ pub fn generate(configuration: &LayoutConfiguration) -> LayoutWriter {field!(w, "EXECUTION_CONTEXT_LEXICAL_ENVIRONMENT", "ExecutionContext.lexical_environment", "Environment", ExecutionContext, lexical_environment, 8, "nullable", "cell", "environments");field!(w, "EXECUTION_CONTEXT_VARIABLE_ENVIRONMENT", "ExecutionContext.variable_environment", "Environment", ExecutionContext, variable_environment, 8, "nullable", "cell", "environments");field!(w, "EXECUTION_CONTEXT_PRIVATE_ENVIRONMENT", "ExecutionContext.private_environment", "PrivateEnvironment", ExecutionContext, private_environment_in_frame, 8, "nullable", "cell");- field!(w, "EXECUTION_CONTEXT_SKIP_WHEN_DETERMINING_INCUMBENT_COUNTER", "ExecutionContext.skip_when_determining_incumbent_counter", "u32", ExecutionContext, skip_when_determining_incumbent_counter, 4, "nullable", "scalar");field!(w, "EXECUTION_CONTEXT_YIELD_CONTINUATION", "ExecutionContext.yield_continuation", "u32", ExecutionContext, yield_continuation, 4, "nullable", "scalar");field!(w, "EXECUTION_CONTEXT_YIELD_IS_AWAIT", "ExecutionContext.yield_is_await", "bool", ExecutionContext, yield_is_await, 1, "nullable", "scalar");field!(w, "EXECUTION_CONTEXT_YIELD_VALUE_IS_ITERATOR_RESULT", "ExecutionContext.yield_value_is_iterator_result", "bool", ExecutionContext, yield_value_is_iterator_result, 1, "nullable", "scalar");diff --git a/Libraries/LibJS/Rust/src/interpreter/execution_context.rs b/Libraries/LibJS/Rust/src/interpreter/execution_context.rsindex 9be753a99ec..58438dde528 100644--- a/Libraries/LibJS/Rust/src/interpreter/execution_context.rs+++ b/Libraries/LibJS/Rust/src/interpreter/execution_context.rs@@ -122,7 +122,6 @@ impl ExecutionContext {private_environment_in_frame: Cell::new(None),frame_id: Cell::new(0),program_counter: Cell::new(0),- skip_when_determining_incumbent_counter: Cell::new(0),yield_continuation: Cell::new(ExecutionContext::NO_YIELD_CONTINUATION),yield_is_await: Cell::new(false),yield_value_is_iterator_result: Cell::new(false),diff --git a/Libraries/LibJS/Rust/src/jit/runtime_info.rs b/Libraries/LibJS/Rust/src/jit/runtime_info.rsindex 069c832a913..8204de7c645 100644--- a/Libraries/LibJS/Rust/src/jit/runtime_info.rs+++ b/Libraries/LibJS/Rust/src/jit/runtime_info.rs@@ -147,10 +147,6 @@ fn runtime_offsets() -> RuntimeOffsets {execution_context_function: offset(offset_of!(ExecutionContext, function)),execution_context_variable_environment: offset(offset_of!(ExecutionContext, variable_environment)),execution_context_frame_id: offset(offset_of!(ExecutionContext, frame_id)),- execution_context_skip_when_determining_incumbent_counter: offset(offset_of!(- ExecutionContext,- skip_when_determining_incumbent_counter- )),execution_context_yield_continuation: offset(offset_of!(ExecutionContext, yield_continuation)),execution_context_yield_is_await: offset(offset_of!(ExecutionContext, yield_is_await)),execution_context_yield_value_is_iterator_result: offset(offset_of!(diff --git a/Libraries/LibJS/Rust/src/layout/execution_context.rs b/Libraries/LibJS/Rust/src/layout/execution_context.rsindex 297cdb286fd..a4d7d87ef1c 100644--- a/Libraries/LibJS/Rust/src/layout/execution_context.rs+++ b/Libraries/LibJS/Rust/src/layout/execution_context.rs@@ -92,7 +92,6 @@ pub struct ExecutionContext {/// Vm::frame_id_of()).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>,diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cppindex 2b4297a19a1..9f49af0aa2b 100644--- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp+++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp@@ -2031,6 +2031,38 @@ EnvironmentSettingsObject& EventLoop::top_of_backup_incumbent_realm_stack()return m_backup_incumbent_realm_stack.last();}+u32 EventLoop::skip_when_determining_incumbent_counter(JS::ExecutionContext const& execution_context) const+{+ for (auto const& counter : m_skip_when_determining_incumbent_counters) {+ if (counter.execution_context == &execution_context)+ return counter.count;+ }+ return 0;+}++void EventLoop::increment_skip_when_determining_incumbent_counter(JS::ExecutionContext const& execution_context)+{+ for (auto& counter : m_skip_when_determining_incumbent_counters) {+ if (counter.execution_context == &execution_context) {+ ++counter.count;+ return;+ }+ }+ m_skip_when_determining_incumbent_counters.append({ &execution_context, 1 });+}++void EventLoop::decrement_skip_when_determining_incumbent_counter(JS::ExecutionContext const& execution_context)+{+ auto index = m_skip_when_determining_incumbent_counters.find_first_index_if([&](auto const& counter) {+ return counter.execution_context == &execution_context;+ });+ VERIFY(index.has_value());+ auto& counter = m_skip_when_determining_incumbent_counters[*index];+ VERIFY(counter.count > 0);+ if (--counter.count == 0)+ m_skip_when_determining_incumbent_counters.remove(*index);+}+void EventLoop::register_environment_settings_object(Badge<EnvironmentSettingsObject>, EnvironmentSettingsObject& environment_settings_object){auto result = m_related_environment_settings_objects.set(environment_settings_object.address(), &environment_settings_object);diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.h b/Libraries/LibWeb/HTML/EventLoop/EventLoop.hindex 2bd0e72dda3..e1743b898ca 100644--- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.h+++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.h@@ -172,6 +172,12 @@ public:EnvironmentSettingsObject& top_of_backup_incumbent_realm_stack();bool is_backup_incumbent_realm_stack_empty() const { return m_backup_incumbent_realm_stack.is_empty(); }+ // NB: The skip-when-determining-incumbent counter of an execution context is here, and only native code that runs+ // a callback above the context makes it nonzero, until the callback is done.+ u32 skip_when_determining_incumbent_counter(JS::ExecutionContext const&) const;+ void increment_skip_when_determining_incumbent_counter(JS::ExecutionContext const&);+ void decrement_skip_when_determining_incumbent_counter(JS::ExecutionContext const&);+void register_environment_settings_object(Badge<EnvironmentSettingsObject>, EnvironmentSettingsObject&);void unregister_environment_settings_object(Badge<EnvironmentSettingsObject>, EnvironmentSettingsObject&);GC::Ptr<EnvironmentSettingsObject> environment_settings_object_at(EnvironmentSettingsObjectAddress) const;@@ -312,6 +318,13 @@ private:// https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stackVector<GC::Ref<EnvironmentSettingsObject>> m_backup_incumbent_realm_stack;+ struct SkipWhenDeterminingIncumbentCounter {+ JS::ExecutionContext const* execution_context { nullptr };+ u32 count { 0 };+ };+ // NB: Only the contexts whose counter is nonzero.+ Vector<SkipWhenDeterminingIncumbentCounter, 4> m_skip_when_determining_incumbent_counters;+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#termination-nesting-levelsize_t m_termination_nesting_level { 0 };diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cppindex 7993b32550b..3f15a06f1e8 100644--- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp+++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp@@ -260,7 +260,7 @@ void prepare_to_run_callback(EnvironmentSettingsObject& settings)// 3. If context is not null, increment context's skip-when-determining-incumbent counter.if (context) {- context->skip_when_determining_incumbent_counter++;+ HTML::current_event_loop().increment_skip_when_determining_incumbent_counter(*context);}}@@ -318,7 +318,7 @@ void clean_up_after_running_callback(EnvironmentSettingsObject const& settings)// 2. If context is not null, decrement context's skip-when-determining-incumbent counter.if (context) {- context->skip_when_determining_incumbent_counter--;+ HTML::current_event_loop().decrement_skip_when_determining_incumbent_counter(*context);}// 3. Assert: the topmost entry of the backup incumbent realm stack is settings.@@ -429,7 +429,7 @@ EnvironmentSettingsObject& incumbent_settings_object()auto* context = top_most_script_having_execution_context(vm);// 2. If context is null, or if context's skip-when-determining-incumbent counter is greater than zero, then:- if (!context || context->skip_when_determining_incumbent_counter > 0) {+ if (!context || event_loop.skip_when_determining_incumbent_counter(*context) > 0) {// 1. Assert: the backup incumbent settings object stack is not empty.// 1. Assert: the backup incumbent realm stack is not empty.// NOTE: If this assertion fails, it's because the incumbent realm was used with no involvement of JavaScript.diff --git a/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cpp b/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cppindex 305af6165cd..004d6a5db89 100644--- a/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cpp+++ b/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cpp@@ -25,9 +25,11 @@ TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject&TemporaryExecutionContext::~TemporaryExecutionContext(){- clean_up_after_running_script(m_settings);+ // NB: In the reverse order of the constructor, so that the callback cleanup finds the topmost script-having+ // execution context that its preparation found.if (m_callbacks_enabled == CallbacksEnabled::Yes)clean_up_after_running_callback(m_settings);+ clean_up_after_running_script(m_settings);}}