Truly independent web browser
LibJS: Get the ScriptOrModule of a function frame from its function
Andreas Kling6ba1e9391cc5
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.Sindex 514c7d50548..16ca0688b65 100644--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S@@ -5423,7 +5423,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_343+ cbz x2, .Lasm_GetById.assert_predicate_failure_341ldr x9, [x2, #24]cmp x9, x0b.ne .Lasm_GetById.ssa_block_15@@ -6245,10 +6245,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_263+ cbz x2, .Lasm_Call.assert_predicate_failure_261ldp w0, w4, [x2, #12]cmp x4, x0- b.lo .Lasm_Call.assert_predicate_failure_269+ b.lo .Lasm_Call.assert_predicate_failure_267movn w0, #0subs x0, x0, x4cmp x0, x3@@ -6263,7 +6263,7 @@ asm_handler_Call:add x5, x5, #136adds x5, x5, x0cmp x5, x0- b.lo .Lasm_Call.assert_predicate_failure_283+ b.lo .Lasm_Call.assert_predicate_failure_281cmp x5, x8b.hi .Lasm_Call.ssa_block_1mov x8, x20@@ -6282,33 +6282,28 @@ asm_handler_Call:add x9, x24, w5, uxtw #3cmp w5, #0csel x5, x9, xzr, ne- cbz x5, .Lasm_Call.assert_predicate_failure_310+ cbz x5, .Lasm_Call.assert_predicate_failure_308stp x5, x5, [x0, #32]str xzr, [x0, #48]ldrb w9, [x1, #15]mov w10, #8tst x9, x10b.eq .Lasm_Call.ssa_block_27- ldr w5, [x1, #76]- add x9, x24, w5, uxtw #3- cmp w5, #0- csel x5, x9, xzr, ne- str x5, [x0, #48]+ ldr w1, [x1, #76]+ add x9, x24, w1, uxtw #3+ cmp w1, #0+ csel x1, x9, xzr, ne+ str x1, [x0, #48].Lasm_Call.ssa_block_27:stp x6, x2, [x0, #80]- movz x2, #0x7ffb, lsl #48- stp x2, x2, [x0, #136]+ movz x1, #0x7ffb, lsl #48+ stp x1, x1, [x0, #136]str x6, [x0, #152]- stp x2, x2, [x0, #160]- ldr w1, [x1, #68]- cbz x1, .Lasm_Call.assert_failure_8- add x1, x24, w1, uxtw #3- ldr x1, [x1, #40]- str x1, [x0, #16]+ stp x1, x1, [x0, #160]str wzr, [x0, #64]mov x2, x20ldr x1, [x2, #32]- cbz x1, .Lasm_Call.assert_failure_9+ cbz x1, .Lasm_Call.assert_failure_8str x1, [x0, #56]add x1, x1, #1str x1, [x2, #32]@@ -6335,7 +6330,7 @@ asm_handler_Call:stp w1, w5, [x0, #108]ldrb w2, [x21, #6]cmp x3, x2- b.lo .Lasm_Call.assert_predicate_failure_397+ b.lo .Lasm_Call.assert_predicate_failure_389add x6, x21, #7add x5, x0, #136add x7, x28, #136@@ -6361,9 +6356,9 @@ asm_handler_Call:b .Lasm_Call.ssa_block_33.Lasm_Call.ssa_block_32:ldr x1, [x0, #88]- cbz x1, .Lasm_Call.assert_predicate_failure_420+ cbz x1, .Lasm_Call.assert_predicate_failure_412ldr x26, [x1, #40]- cbz x26, .Lasm_Call.assert_failure_10+ cbz x26, .Lasm_Call.assert_failure_9mov x1, x20str x0, [x1]mov x28, x0@@ -6388,42 +6383,42 @@ asm_handler_Call:mov w13, #32768add x12, x12, x13cmp x14, x12- b.hs .Lasm_Call.values_allocate_12+ b.hs .Lasm_Call.values_allocate_11mov w0, #1- b .Lasm_Call.values_call_done_11-.Lasm_Call.values_allocate_12:-.Lasm_Call.values_probe_13:+ b .Lasm_Call.values_call_done_10+.Lasm_Call.values_allocate_11:+.Lasm_Call.values_probe_12:sub x10, sp, #1, lsl #12cmp x10, x14- b.ls .Lasm_Call.values_allocated_14+ b.ls .Lasm_Call.values_allocated_13add sp, x10, #0str xzr, [sp]- b .Lasm_Call.values_probe_13-.Lasm_Call.values_allocated_14:+ b .Lasm_Call.values_probe_12+.Lasm_Call.values_allocated_13:add sp, x14, #0str x9, [sp]ldrb w12, [x21, #4]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.value_ready_15:+.Lasm_Call.value_ready_14:str x11, [sp, #24]ldrb w12, [x21, #5]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.value_ready_16:+.Lasm_Call.value_ready_15:str x11, [sp, #32]mov w9, #0ldrb w10, [x21, #6]add x14, sp, #40add x3, x21, #7-.Lasm_Call.array_value_next_17:+.Lasm_Call.array_value_next_16:cmp x9, x10- b.hs .Lasm_Call.array_values_end_19+ b.hs .Lasm_Call.array_values_end_18ldrb w12, [x3, x9]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.array_value_ready_18:+.Lasm_Call.array_value_ready_17:str x11, [x14, x9, lsl #3]add x9, x9, #1- b .Lasm_Call.array_value_next_17-.Lasm_Call.array_values_end_19:+ b .Lasm_Call.array_value_next_16+.Lasm_Call.array_values_end_18:mov x0, x20sub w1, w21, w26mov x2, x21@@ -6431,18 +6426,18 @@ asm_handler_Call:bl CSYM(asm_try_inline_call)ldr x9, [x20]cmp x9, x28- b.ne .Lasm_Call.values_restore_stack_20- cbnz x0, .Lasm_Call.values_exceptional_outputs_21+ b.ne .Lasm_Call.values_restore_stack_19+ cbnz x0, .Lasm_Call.values_exceptional_outputs_20ldrb w12, [x21, #3]ldr x11, [sp, #16]str x11, [x27, x12, lsl #3]-.Lasm_Call.skip_output_value_22:- b .Lasm_Call.values_restore_stack_20-.Lasm_Call.values_exceptional_outputs_21:-.Lasm_Call.values_restore_stack_20:+.Lasm_Call.skip_output_value_21:+ b .Lasm_Call.values_restore_stack_19+.Lasm_Call.values_exceptional_outputs_20:+.Lasm_Call.values_restore_stack_19:ldr x9, [sp]add sp, x9, #0-.Lasm_Call.values_call_done_11:+.Lasm_Call.values_call_done_10:cbnz w0, .Lasm_Call.ssa_block_1mov x0, x20ldr x28, [x0]@@ -6451,7 +6446,7 @@ asm_handler_Call:ldr x0, [x28, #88]cbz x0, .Lasm_Call.assert_predicate_failure_17ldr x26, [x0, #40]- cbz x26, .Lasm_Call.assert_failure_23+ cbz x26, .Lasm_Call.assert_failure_22mov w25, #0add x21, x26, w25, uxtwldrb w9, [x21]@@ -6465,8 +6460,8 @@ asm_handler_Call:ldrb w2, [x21, #6]mov x0, x20ldp x0, x5, [x0, #16]- cbz x0, .Lasm_Call.assert_failure_24- cbz x5, .Lasm_Call.assert_failure_25+ cbz x0, .Lasm_Call.assert_failure_23+ cbz x5, .Lasm_Call.assert_failure_24lsl x3, x2, #3add x3, x3, #136adds x3, x3, x0@@ -6487,10 +6482,10 @@ asm_handler_Call:stp w2, w2, [x0, #116]str w2, [x0, #104]ldr w3, [x1, #20]- cbz x3, .Lasm_Call.assert_failure_26+ cbz x3, .Lasm_Call.assert_failure_25add x3, x24, w3, uxtw #3ldr w3, [x3, #12]- cbz x3, .Lasm_Call.assert_failure_27+ cbz x3, .Lasm_Call.assert_failure_26add x3, x24, w3, uxtw #3stp x1, x3, [x0, #0]ldp x1, x3, [x28, #32]@@ -6501,13 +6496,12 @@ asm_handler_Call:str x1, [x0, #48]ldrb w1, [x21, #5]ldr x1, [x27, x1, lsl #3]- str x1, [x0, #80]- str xzr, [x0, #16]- str xzr, [x0, #88]+ mov w3, #0+ stp x1, x3, [x0, #80]str wzr, [x0, #64]mov x3, x20ldr x1, [x3, #32]- cbz x1, .Lasm_Call.assert_failure_28+ cbz x1, .Lasm_Call.assert_failure_27str x1, [x0, #56]add x1, x1, #1str x1, [x3, #32]@@ -6550,24 +6544,24 @@ asm_handler_Call:mov x28, x0add x27, x28, #136ldr x0, [x1, #80]- cbz x0, .Lasm_Call.assert_failure_29+ cbz x0, .Lasm_Call.assert_failure_28and w4, w4, #0xfffflsl x4, x4, #4adds x4, x4, x0ldr w0, [x4, #8]cmp x0, #1- b.hs .Lasm_Call.assert_predicate_failure_208+ b.hs .Lasm_Call.assert_predicate_failure_206ldr x2, [x4]- cbz x2, .Lasm_Call.assert_failure_30+ cbz x2, .Lasm_Call.assert_failure_29mov x9, x2mov x0, x20blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_Call.assert_predicate_failure_215+ b.hs .Lasm_Call.assert_predicate_failure_213cbnz x1, .Lasm_Call.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_Call.assert_predicate_failure_221+ cbz x1, .Lasm_Call.assert_predicate_failure_219mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -14530,9 +14524,8 @@ asm_handler_GetById_cold:and x3, x3, #0x7ffffffffmovz x1, #0xfff9, lsl #48orr x3, x3, x1- str x3, [x0, #80]- str xzr, [x0, #16]- str xzr, [x0, #88]+ mov w1, #0+ stp x3, x1, [x0, #80]str wzr, [x0, #64]str wzr, [x0, #68]movn w9, #0@@ -14563,10 +14556,10 @@ asm_handler_GetById_cold:blr x9and x1, x1, #0xffcmp x1, #2- b.hs .Lasm_GetById.assert_predicate_failure_273+ b.hs .Lasm_GetById.assert_predicate_failure_271cbnz x1, .Lasm_GetById.ssa_block_6ldr x1, [x28, #96]- cbz x1, .Lasm_GetById.assert_predicate_failure_282+ cbz x1, .Lasm_GetById.assert_predicate_failure_280mov x2, x20str x1, [x2]str x28, [x2, #16]@@ -15772,7 +15765,7 @@ asm_handler_Call_cold:ldr x0, [x28, #88]cbz x0, .Lasm_Call.assert_predicate_failure_79ldr x26, [x0, #40]- cbz x26, .Lasm_Call.assert_failure_31+ cbz x26, .Lasm_Call.assert_failure_30ldr w25, [x28, #64]add x21, x26, w25, uxtwldrb w9, [x21]@@ -15792,81 +15785,81 @@ asm_handler_Call_cold:mov w13, #32768add x12, x12, x13cmp x14, x12- b.hs .Lasm_Call.values_allocate_33+ b.hs .Lasm_Call.values_allocate_32mov x0, x20sub w1, w21, w26bl CSYM(asm_slow_path_stack_overflow)- b .Lasm_Call.values_call_done_32-.Lasm_Call.values_allocate_33:-.Lasm_Call.values_probe_34:+ b .Lasm_Call.values_call_done_31+.Lasm_Call.values_allocate_32:+.Lasm_Call.values_probe_33:sub x10, sp, #1, lsl #12cmp x10, x14- b.ls .Lasm_Call.values_allocated_35+ b.ls .Lasm_Call.values_allocated_34add sp, x10, #0str xzr, [sp]- b .Lasm_Call.values_probe_34-.Lasm_Call.values_allocated_35:+ b .Lasm_Call.values_probe_33+.Lasm_Call.values_allocated_34:add sp, x14, #0str x9, [sp]ldrb w12, [x21, #4]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.value_ready_36:+.Lasm_Call.value_ready_35:str x11, [sp, #24]ldrb w12, [x21, #5]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.value_ready_37:+.Lasm_Call.value_ready_36:str x11, [sp, #32]mov w9, #0ldrb w10, [x21, #6]add x14, sp, #40add x3, x21, #7-.Lasm_Call.array_value_next_38:+.Lasm_Call.array_value_next_37:cmp x9, x10- b.hs .Lasm_Call.array_values_end_40+ b.hs .Lasm_Call.array_values_end_39ldrb w12, [x3, x9]ldr x11, [x27, x12, lsl #3]-.Lasm_Call.array_value_ready_39:+.Lasm_Call.array_value_ready_38:str x11, [x14, x9, lsl #3]add x9, x9, #1- b .Lasm_Call.array_value_next_38-.Lasm_Call.array_values_end_40:+ b .Lasm_Call.array_value_next_37+.Lasm_Call.array_values_end_39:mov x0, x20sub w1, w21, w26mov x2, x21add x3, sp, #16bl CSYM(asm_slow_path_call)tbz x0, #63, 1f- b .Lasm_Call.values_exceptional_outputs_42+ b .Lasm_Call.values_exceptional_outputs_411:tbnz x0, #32, 1f- b .Lasm_Call.values_exceptional_outputs_42+ b .Lasm_Call.values_exceptional_outputs_411:ldrb w12, [x21, #3]ldr x11, [sp, #16]str x11, [x27, x12, lsl #3]-.Lasm_Call.skip_output_value_43:+.Lasm_Call.skip_output_value_42:ldr x9, [sp]add sp, x9, #0add x21, x26, w0, uxtwldrb w9, [x21]ldr x10, [x19, x9, lsl #3]br x10-.Lasm_Call.values_exceptional_outputs_42:-.Lasm_Call.values_restore_stack_41:+.Lasm_Call.values_exceptional_outputs_41:+.Lasm_Call.values_restore_stack_40:ldr x9, [sp]add sp, x9, #0-.Lasm_Call.values_call_done_32:+.Lasm_Call.values_call_done_31:tbz x0, #63, 1fb .Lexit1:tbnz x0, #32, 1f- b .Lasm_Call.slow_path_transfer_44+ b .Lasm_Call.slow_path_transfer_431:add x21, x26, w0, uxtwldrb w9, [x21]ldr x10, [x19, x9, lsl #3]br x10-.Lasm_Call.slow_path_transfer_44:+.Lasm_Call.slow_path_transfer_43:ldr x28, [x20]ldr x9, [x28, #88]ldr x26, [x9, #40]@@ -21436,7 +21429,7 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_1:brk #0-.Lasm_GetById.assert_predicate_failure_343:+.Lasm_GetById.assert_predicate_failure_341:brk #0.Lasm_GetById.assert_failure_2:brk #0@@ -21466,9 +21459,9 @@ asm_assertion_failure_traps:brk #0.Lasm_GetById.assert_failure_10:brk #0-.Lasm_GetById.assert_predicate_failure_273:+.Lasm_GetById.assert_predicate_failure_271:brk #0-.Lasm_GetById.assert_predicate_failure_282:+.Lasm_GetById.assert_predicate_failure_280:brk #0.Lasm_GetById.assert_predicate_failure_26:brk #0@@ -21582,71 +21575,69 @@ asm_assertion_failure_traps:brk #0.Lasm_Call.assert_failure_3:brk #0-.Lasm_Call.assert_predicate_failure_263:+.Lasm_Call.assert_predicate_failure_261:brk #0-.Lasm_Call.assert_predicate_failure_269:+.Lasm_Call.assert_predicate_failure_267:brk #0.Lasm_Call.assert_failure_4:brk #0.Lasm_Call.assert_failure_5:brk #0-.Lasm_Call.assert_predicate_failure_283:+.Lasm_Call.assert_predicate_failure_281:brk #0.Lasm_Call.assert_failure_6:brk #0.Lasm_Call.assert_failure_7:brk #0-.Lasm_Call.assert_predicate_failure_310:+.Lasm_Call.assert_predicate_failure_308:brk #0.Lasm_Call.assert_failure_8:brk #0-.Lasm_Call.assert_failure_9:- brk #0-.Lasm_Call.assert_predicate_failure_397:+.Lasm_Call.assert_predicate_failure_389:brk #0-.Lasm_Call.assert_predicate_failure_420:+.Lasm_Call.assert_predicate_failure_412:brk #0-.Lasm_Call.assert_failure_10:+.Lasm_Call.assert_failure_9:brk #0.Lasm_Call.assert_predicate_failure_11:brk #0.Lasm_Call.assert_predicate_failure_17:brk #0+.Lasm_Call.assert_failure_22:+ brk #0.Lasm_Call.assert_failure_23:brk #0.Lasm_Call.assert_failure_24:brk #0-.Lasm_Call.assert_failure_25:- brk #0.Lasm_Call.assert_predicate_failure_41:brk #0.Lasm_Call.assert_predicate_failure_91:brk #0-.Lasm_Call.assert_failure_26:+.Lasm_Call.assert_failure_25:brk #0-.Lasm_Call.assert_failure_27:+.Lasm_Call.assert_failure_26:brk #0.Lasm_Call.assert_predicate_failure_115:brk #0.Lasm_Call.assert_predicate_failure_117:brk #0-.Lasm_Call.assert_failure_28:+.Lasm_Call.assert_failure_27:brk #0-.Lasm_Call.assert_failure_29:+.Lasm_Call.assert_failure_28:brk #0-.Lasm_Call.assert_predicate_failure_208:+.Lasm_Call.assert_predicate_failure_206:brk #0-.Lasm_Call.assert_failure_30:+.Lasm_Call.assert_failure_29:brk #0-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_213:brk #0-.Lasm_Call.assert_predicate_failure_221:+.Lasm_Call.assert_predicate_failure_219:brk #0.Lasm_Call.assert_predicate_failure_73:brk #0.Lasm_Call.assert_predicate_failure_79:brk #0-.Lasm_Call.assert_failure_31:+.Lasm_Call.assert_failure_30:brk #0.Lasm_ObjectPropertyIteratorNext.assert_predicate_failure_9:brk #0diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.Sindex d25cf0eb2b6..2e76a6be00c 100644--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S@@ -5422,7 +5422,7 @@ asm_handler_GetById:jz .Lasm_GetById.ssa_block_1and rdx, -4test rdx, rdx- jz .Lasm_GetById.assert_predicate_failure_343+ jz .Lasm_GetById.assert_predicate_failure_341cmp QWORD PTR [rdx + 24], raxjne .Lasm_GetById.ssa_block_15mov ecx, DWORD PTR [rdx]@@ -6301,11 +6301,11 @@ asm_handler_Call:mov rsi, rdi.Lasm_Call.ssa_block_23:test rdx, rdx- jz .Lasm_Call.assert_predicate_failure_263+ jz .Lasm_Call.assert_predicate_failure_261mov eax, DWORD PTR [rdx + 12]mov edi, DWORD PTR [rdx + 16]cmp rdi, rax- jb .Lasm_Call.assert_predicate_failure_269+ jb .Lasm_Call.assert_predicate_failure_267mov eax, 4294967295sub rax, rdicmp rax, rsi@@ -6324,7 +6324,7 @@ asm_handler_Call:lea r8, [r8 + 136]add r8, raxcmp r8, rax- jb .Lasm_Call.assert_predicate_failure_283+ jb .Lasm_Call.assert_predicate_failure_281cmp r8, r11ja .Lasm_Call.ssa_block_1mov r11, QWORD PTR [rbp - 48]@@ -6348,37 +6348,31 @@ asm_handler_Call:test r8d, r8dcmovnz r8, r11test r8, r8- jz .Lasm_Call.assert_predicate_failure_310+ jz .Lasm_Call.assert_predicate_failure_308mov QWORD PTR [rax + 32], r8mov QWORD PTR [rax + 40], r8mov QWORD PTR [rax + 48], 0test BYTE PTR [rcx + 15], 8jz .Lasm_Call.ssa_block_27- mov r8d, DWORD PTR [rcx + 76]- lea r11, [r15 + r8 * 8]- test r8d, r8d- cmovnz r8, r11- mov QWORD PTR [rax + 48], r8+ mov ecx, DWORD PTR [rcx + 76]+ lea r11, [r15 + rcx * 8]+ test ecx, ecx+ cmovnz rcx, r11+ mov QWORD PTR [rax + 48], rcx.Lasm_Call.ssa_block_27:mov QWORD PTR [rax + 80], r9mov QWORD PTR [rax + 88], rdx- movabs rdx, 9221964661971222528- mov QWORD PTR [rax + 136], rdx- mov QWORD PTR [rax + 144], rdx+ movabs rcx, 9221964661971222528+ mov QWORD PTR [rax + 136], rcx+ mov QWORD PTR [rax + 144], rcxmov QWORD PTR [rax + 152], r9- mov QWORD PTR [rax + 160], rdx- mov QWORD PTR [rax + 168], rdx- mov ecx, DWORD PTR [rcx + 68]- test rcx, rcx- jz .Lasm_Call.assert_failure_8- lea rcx, [r15 + rcx * 8]- mov rcx, QWORD PTR [rcx + 40]- mov QWORD PTR [rax + 16], rcx+ mov QWORD PTR [rax + 160], rcx+ mov QWORD PTR [rax + 168], rcxmov DWORD PTR [rax + 64], 0mov rdx, QWORD PTR [rbp - 48]mov rcx, QWORD PTR [rdx + 32]test rcx, rcx- jz .Lasm_Call.assert_failure_9+ jz .Lasm_Call.assert_failure_8mov QWORD PTR [rax + 56], rcxlea rcx, [rcx + 1]mov QWORD PTR [rdx + 32], rcx@@ -6406,7 +6400,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_397+ jb .Lasm_Call.assert_predicate_failure_389lea r9, [r14 + r13 + 7]lea r8, [rax + 136]lea r10, [rbx]@@ -6433,10 +6427,10 @@ asm_handler_Call:.Lasm_Call.ssa_block_32:mov rcx, QWORD PTR [rax + 88]test rcx, rcx- jz .Lasm_Call.assert_predicate_failure_420+ jz .Lasm_Call.assert_predicate_failure_412mov r14, QWORD PTR [rcx + 40]test r14, r14- jz .Lasm_Call.assert_failure_10+ jz .Lasm_Call.assert_failure_9mov rcx, QWORD PTR [rbp - 48]mov QWORD PTR [rcx], raxlea rbx, [rax + 136]@@ -6459,40 +6453,40 @@ asm_handler_Call:mov rdx, QWORD PTR [rdx + 40]add rdx, 32768cmp rax, rdx- jae .Lasm_Call.values_allocate_12+ jae .Lasm_Call.values_allocate_11mov eax, 1- jmp .Lasm_Call.values_call_done_11-.Lasm_Call.values_allocate_12:-.Lasm_Call.values_probe_13:+ jmp .Lasm_Call.values_call_done_10+.Lasm_Call.values_allocate_11:+.Lasm_Call.values_probe_12:lea r10, [rsp - 4096]cmp r10, rax- jbe .Lasm_Call.values_allocated_14+ jbe .Lasm_Call.values_allocated_13mov rsp, r10mov QWORD PTR [rsp], 0- jmp .Lasm_Call.values_probe_13-.Lasm_Call.values_allocated_14:+ jmp .Lasm_Call.values_probe_12+.Lasm_Call.values_allocated_13:mov rsp, raxmov QWORD PTR [rsp], r11movzx r10d, BYTE PTR [rcx + 4]mov rax, QWORD PTR [rbx + r10 * 8]-.Lasm_Call.value_ready_15:+.Lasm_Call.value_ready_14:mov QWORD PTR [rsp + 24], raxmovzx r10d, BYTE PTR [rcx + 5]mov rax, QWORD PTR [rbx + r10 * 8]-.Lasm_Call.value_ready_16:+.Lasm_Call.value_ready_15:mov QWORD PTR [rsp + 32], raxmov r11d, 0movzx r10d, BYTE PTR [rcx + 6]-.Lasm_Call.array_value_next_17:+.Lasm_Call.array_value_next_16:cmp r11, r10- jae .Lasm_Call.array_values_end_19+ jae .Lasm_Call.array_values_end_18movzx edx, BYTE PTR [rcx + r11 + 7]mov rax, QWORD PTR [rbx + rdx * 8]-.Lasm_Call.array_value_ready_18:+.Lasm_Call.array_value_ready_17:mov QWORD PTR [rsp + r11 * 8 + 40], raxadd r11, 1- jmp .Lasm_Call.array_value_next_17-.Lasm_Call.array_values_end_19:+ jmp .Lasm_Call.array_value_next_16+.Lasm_Call.array_values_end_18:mov rdi, QWORD PTR [rbp - 48]mov esi, r13dlea rdx, [r14 + r13]@@ -6502,19 +6496,19 @@ asm_handler_Call:mov r10, QWORD PTR [r10]add r10, 136cmp r10, rbx- jne .Lasm_Call.values_restore_stack_20+ jne .Lasm_Call.values_restore_stack_19test rax, rax- jne .Lasm_Call.values_exceptional_outputs_21+ jne .Lasm_Call.values_exceptional_outputs_20lea rcx, [r14 + r13]movzx r10d, BYTE PTR [rcx + 3]mov r11, QWORD PTR [rsp + 16]mov QWORD PTR [rbx + r10 * 8], r11-.Lasm_Call.skip_output_value_22:- jmp .Lasm_Call.values_restore_stack_20-.Lasm_Call.values_exceptional_outputs_21:-.Lasm_Call.values_restore_stack_20:+.Lasm_Call.skip_output_value_21:+ jmp .Lasm_Call.values_restore_stack_19+.Lasm_Call.values_exceptional_outputs_20:+.Lasm_Call.values_restore_stack_19:mov rsp, QWORD PTR [rsp]-.Lasm_Call.values_call_done_11:+.Lasm_Call.values_call_done_10:test eax, eaxjnz .Lasm_Call.ssa_block_1mov rax, QWORD PTR [rbp - 48]@@ -6527,7 +6521,7 @@ asm_handler_Call:jz .Lasm_Call.assert_predicate_failure_17mov r14, QWORD PTR [rax + 40]test r14, r14- jz .Lasm_Call.assert_failure_23+ jz .Lasm_Call.assert_failure_22mov r13d, 0movzx eax, BYTE PTR [r14 + r13]jmp [r12 + rax * 8]@@ -6540,9 +6534,9 @@ asm_handler_Call:mov r8, QWORD PTR [rax + 24]mov rax, QWORD PTR [rax + 16]test rax, rax- jz .Lasm_Call.assert_failure_24+ jz .Lasm_Call.assert_failure_23test r8, r8- jz .Lasm_Call.assert_failure_25+ jz .Lasm_Call.assert_failure_24mov rsi, rdxshl rsi, 3lea rsi, [rsi + 136]@@ -6566,11 +6560,11 @@ asm_handler_Call:mov DWORD PTR [rax + 104], edxmov esi, DWORD PTR [rcx + 20]test rsi, rsi- jz .Lasm_Call.assert_failure_26+ jz .Lasm_Call.assert_failure_25lea rsi, [r15 + rsi * 8]mov esi, DWORD PTR [rsi + 12]test rsi, rsi- jz .Lasm_Call.assert_failure_27+ jz .Lasm_Call.assert_failure_26lea rsi, [r15 + rsi * 8]mov QWORD PTR [rax], rcxmov QWORD PTR [rax + 8], rsi@@ -6586,14 +6580,14 @@ asm_handler_Call:mov QWORD PTR [rax + 48], rcxmovzx ecx, BYTE PTR [r14 + r13 + 5]mov rcx, QWORD PTR [rbx + rcx * 8]+ mov rsi, 0mov QWORD PTR [rax + 80], rcx- mov QWORD PTR [rax + 16], 0- mov QWORD PTR [rax + 88], 0+ mov QWORD PTR [rax + 88], rsimov DWORD PTR [rax + 64], 0mov rsi, QWORD PTR [rbp - 48]mov rcx, QWORD PTR [rsi + 32]test rcx, rcx- jz .Lasm_Call.assert_failure_28+ jz .Lasm_Call.assert_failure_27mov QWORD PTR [rax + 56], rcxlea rcx, [rcx + 1]mov QWORD PTR [rsi + 32], rcx@@ -6637,28 +6631,28 @@ asm_handler_Call:lea rbx, [rax + 136]mov rax, QWORD PTR [rcx + 80]test rax, rax- jz .Lasm_Call.assert_failure_29+ jz .Lasm_Call.assert_failure_28and edi, 65535shl rdi, 4add rdi, raxmov eax, DWORD PTR [rdi + 8]cmp rax, 1- jae .Lasm_Call.assert_predicate_failure_208+ jae .Lasm_Call.assert_predicate_failure_206mov rdx, QWORD PTR [rdi]test rdx, rdx- jz .Lasm_Call.assert_failure_30+ jz .Lasm_Call.assert_failure_29mov r11, rdxmov rdi, QWORD PTR [rbp - 48]call r11mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_Call.assert_predicate_failure_215+ jae .Lasm_Call.assert_predicate_failure_213test 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_219mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -14141,9 +14135,9 @@ asm_handler_GetById_cold:and rsi, rcxmovabs rcx, -1970324836974592or rsi, rcx+ mov rcx, 0mov QWORD PTR [rax + 80], rsi- mov QWORD PTR [rax + 16], 0- mov QWORD PTR [rax + 88], 0+ mov QWORD PTR [rax + 88], rcxmov DWORD PTR [rax + 64], 0mov DWORD PTR [rax + 68], 0mov DWORD PTR [rax + 72], 4294967295@@ -14176,12 +14170,12 @@ asm_handler_GetById_cold:mov rcx, rdxand rcx, 255cmp rcx, 2- jae .Lasm_GetById.assert_predicate_failure_273+ jae .Lasm_GetById.assert_predicate_failure_271test rcx, rcxjnz .Lasm_GetById.ssa_block_6mov rcx, QWORD PTR [rbx - 40]test rcx, rcx- jz .Lasm_GetById.assert_predicate_failure_282+ jz .Lasm_GetById.assert_predicate_failure_280mov rdx, QWORD PTR [rbp - 48]mov QWORD PTR [rdx], rcxlea r11, [rbx - 136]@@ -15345,7 +15339,7 @@ asm_handler_Call_cold:jz .Lasm_Call.assert_predicate_failure_79mov r14, QWORD PTR [rax + 40]test r14, r14- jz .Lasm_Call.assert_failure_31+ jz .Lasm_Call.assert_failure_30mov r13d, DWORD PTR [rbx - 72]movzx eax, BYTE PTR [r14 + r13]jmp [r12 + rax * 8]@@ -15363,73 +15357,73 @@ asm_handler_Call_cold:mov rdx, QWORD PTR [rdx + 40]add rdx, 32768cmp rax, rdx- jae .Lasm_Call.values_allocate_33+ jae .Lasm_Call.values_allocate_32mov rdi, QWORD PTR [rbp - 48]mov esi, r13dlea rdx, [r14 + r13]call CSYM(asm_slow_path_stack_overflow)- jmp .Lasm_Call.values_call_done_32-.Lasm_Call.values_allocate_33:-.Lasm_Call.values_probe_34:+ jmp .Lasm_Call.values_call_done_31+.Lasm_Call.values_allocate_32:+.Lasm_Call.values_probe_33:lea r10, [rsp - 4096]cmp r10, rax- jbe .Lasm_Call.values_allocated_35+ jbe .Lasm_Call.values_allocated_34mov rsp, r10mov QWORD PTR [rsp], 0- jmp .Lasm_Call.values_probe_34-.Lasm_Call.values_allocated_35:+ jmp .Lasm_Call.values_probe_33+.Lasm_Call.values_allocated_34:mov rsp, raxmov QWORD PTR [rsp], r11movzx r10d, BYTE PTR [rcx + 4]mov rax, QWORD PTR [rbx + r10 * 8]-.Lasm_Call.value_ready_36:+.Lasm_Call.value_ready_35:mov QWORD PTR [rsp + 24], raxmovzx r10d, BYTE PTR [rcx + 5]mov rax, QWORD PTR [rbx + r10 * 8]-.Lasm_Call.value_ready_37:+.Lasm_Call.value_ready_36:mov QWORD PTR [rsp + 32], raxmov r11d, 0movzx r10d, BYTE PTR [rcx + 6]-.Lasm_Call.array_value_next_38:+.Lasm_Call.array_value_next_37:cmp r11, r10- jae .Lasm_Call.array_values_end_40+ jae .Lasm_Call.array_values_end_39movzx edx, BYTE PTR [rcx + r11 + 7]mov rax, QWORD PTR [rbx + rdx * 8]-.Lasm_Call.array_value_ready_39:+.Lasm_Call.array_value_ready_38:mov QWORD PTR [rsp + r11 * 8 + 40], raxadd r11, 1- jmp .Lasm_Call.array_value_next_38-.Lasm_Call.array_values_end_40:+ jmp .Lasm_Call.array_value_next_37+.Lasm_Call.array_values_end_39:mov rdi, QWORD PTR [rbp - 48]mov esi, r13dlea rdx, [r14 + r13]lea rcx, [rsp + 16]call CSYM(asm_slow_path_call)test rax, rax- js .Lasm_Call.values_exceptional_outputs_42+ js .Lasm_Call.values_exceptional_outputs_41bt rax, 32- jnc .Lasm_Call.values_exceptional_outputs_42+ jnc .Lasm_Call.values_exceptional_outputs_41lea rcx, [r14 + r13]movzx r10d, BYTE PTR [rcx + 3]mov r11, QWORD PTR [rsp + 16]mov QWORD PTR [rbx + r10 * 8], r11-.Lasm_Call.skip_output_value_43:+.Lasm_Call.skip_output_value_42:mov rsp, QWORD PTR [rsp]mov r13d, eaxmovzx eax, BYTE PTR [r14 + r13]jmp [r12 + rax * 8]-.Lasm_Call.values_exceptional_outputs_42:-.Lasm_Call.values_restore_stack_41:+.Lasm_Call.values_exceptional_outputs_41:+.Lasm_Call.values_restore_stack_40:mov rsp, QWORD PTR [rsp]-.Lasm_Call.values_call_done_32:+.Lasm_Call.values_call_done_31:test rax, raxjs .Lexitbt rax, 32- jnc .Lasm_Call.slow_path_transfer_44+ jnc .Lasm_Call.slow_path_transfer_43mov r13d, eaxmovzx eax, BYTE PTR [r14 + r13]jmp [r12 + rax * 8]-.Lasm_Call.slow_path_transfer_44:+.Lasm_Call.slow_path_transfer_43:mov rcx, QWORD PTR [rbp - 48]mov rbx, QWORD PTR [rcx]add rbx, 136@@ -20822,7 +20816,7 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_1:ud2-.Lasm_GetById.assert_predicate_failure_343:+.Lasm_GetById.assert_predicate_failure_341:ud2.Lasm_GetById.assert_failure_2:ud2@@ -20852,9 +20846,9 @@ asm_assertion_failure_traps:ud2.Lasm_GetById.assert_failure_10:ud2-.Lasm_GetById.assert_predicate_failure_273:+.Lasm_GetById.assert_predicate_failure_271:ud2-.Lasm_GetById.assert_predicate_failure_282:+.Lasm_GetById.assert_predicate_failure_280:ud2.Lasm_GetById.assert_predicate_failure_26:ud2@@ -20968,71 +20962,69 @@ asm_assertion_failure_traps:ud2.Lasm_Call.assert_failure_3:ud2-.Lasm_Call.assert_predicate_failure_263:+.Lasm_Call.assert_predicate_failure_261:ud2-.Lasm_Call.assert_predicate_failure_269:+.Lasm_Call.assert_predicate_failure_267:ud2.Lasm_Call.assert_failure_4:ud2.Lasm_Call.assert_failure_5:ud2-.Lasm_Call.assert_predicate_failure_283:+.Lasm_Call.assert_predicate_failure_281:ud2.Lasm_Call.assert_failure_6:ud2.Lasm_Call.assert_failure_7:ud2-.Lasm_Call.assert_predicate_failure_310:+.Lasm_Call.assert_predicate_failure_308:ud2.Lasm_Call.assert_failure_8:ud2-.Lasm_Call.assert_failure_9:- ud2-.Lasm_Call.assert_predicate_failure_397:+.Lasm_Call.assert_predicate_failure_389:ud2-.Lasm_Call.assert_predicate_failure_420:+.Lasm_Call.assert_predicate_failure_412:ud2-.Lasm_Call.assert_failure_10:+.Lasm_Call.assert_failure_9:ud2.Lasm_Call.assert_predicate_failure_11:ud2.Lasm_Call.assert_predicate_failure_17:ud2+.Lasm_Call.assert_failure_22:+ ud2.Lasm_Call.assert_failure_23:ud2.Lasm_Call.assert_failure_24:ud2-.Lasm_Call.assert_failure_25:- ud2.Lasm_Call.assert_predicate_failure_41:ud2.Lasm_Call.assert_predicate_failure_91:ud2-.Lasm_Call.assert_failure_26:+.Lasm_Call.assert_failure_25:ud2-.Lasm_Call.assert_failure_27:+.Lasm_Call.assert_failure_26:ud2.Lasm_Call.assert_predicate_failure_115:ud2.Lasm_Call.assert_predicate_failure_117:ud2-.Lasm_Call.assert_failure_28:+.Lasm_Call.assert_failure_27:ud2-.Lasm_Call.assert_failure_29:+.Lasm_Call.assert_failure_28:ud2-.Lasm_Call.assert_predicate_failure_208:+.Lasm_Call.assert_predicate_failure_206:ud2-.Lasm_Call.assert_failure_30:+.Lasm_Call.assert_failure_29:ud2-.Lasm_Call.assert_predicate_failure_215:+.Lasm_Call.assert_predicate_failure_213:ud2-.Lasm_Call.assert_predicate_failure_221:+.Lasm_Call.assert_predicate_failure_219:ud2.Lasm_Call.assert_predicate_failure_73:ud2.Lasm_Call.assert_predicate_failure_79:ud2-.Lasm_Call.assert_failure_31:+.Lasm_Call.assert_failure_30:ud2.Lasm_ObjectPropertyIteratorNext.assert_predicate_failure_9:ud2diff --git a/Libraries/LibJS/Flap/tests/interpreter-layout.conf b/Libraries/LibJS/Flap/tests/interpreter-layout.confindex 212a813a5b9..5bb7fa51a82 100644--- a/Libraries/LibJS/Flap/tests/interpreter-layout.conf+++ b/Libraries/LibJS/Flap/tests/interpreter-layout.conf@@ -180,8 +180,8 @@ const EXECUTION_CONTEXT_FUNCTION = 0field ExecutionContext.function Object EXECUTION_CONTEXT_FUNCTION nullable cell function_and_realmconst EXECUTION_CONTEXT_REALM = 8field ExecutionContext.realm Realm EXECUTION_CONTEXT_REALM nullable cell function_and_realm-const EXECUTION_CONTEXT_SCRIPT_OR_MODULE = 16-field ExecutionContext.script_or_module u64 EXECUTION_CONTEXT_SCRIPT_OR_MODULE nullable scalar+const EXECUTION_CONTEXT_SCRIPT_OR_MODULE_WITHOUT_FUNCTION = 16+field ExecutionContext.script_or_module_without_function u64 EXECUTION_CONTEXT_SCRIPT_OR_MODULE_WITHOUT_FUNCTION nullable scalarconst EXECUTION_CONTEXT_LEXICAL_ENVIRONMENT = 32field ExecutionContext.lexical_environment Environment EXECUTION_CONTEXT_LEXICAL_ENVIRONMENT nullable cell environmentsconst EXECUTION_CONTEXT_VARIABLE_ENVIRONMENT = 40diff --git a/Libraries/LibJS/Interpreter/interpreter.flap b/Libraries/LibJS/Interpreter/interpreter.flapindex e0958a2aefa..cc8672cd903 100644--- a/Libraries/LibJS/Interpreter/interpreter.flap+++ b/Libraries/LibJS/Interpreter/interpreter.flap@@ -3328,7 +3328,6 @@ handler GetById(native_frame.private_environment = exec_ctx.private_environment;let receiver: Value = alias(box_object(receiver_object));native_frame.this_value = receiver;- native_frame.script_or_module = 0;native_frame.executable = null;native_frame.program_counter = 0;native_frame.skip_when_determining_incumbent_counter = 0;@@ -4054,8 +4053,6 @@ inline fn enter_ecmascript_function_call(frame.this_value_register = receiver;frame.return_value = empty_tag;frame.saved_lexical_environment = empty_tag;- let frame_shared_data = ecmascript_function.shared_data;- frame.script_or_module = frame_shared_data.script_or_module;frame.program_counter = 0;let frame_id_vm = current_vm();let frame_id = frame_id_vm.interpreter_stack_next_frame_id;@@ -4153,7 +4150,6 @@ inline fn call_raw_native_function(native_frame.private_environment = private_environment;let receiver = load(this_value);native_frame.this_value = receiver;- native_frame.script_or_module = 0;# Raw native frames deliberately have no executable.native_frame.executable = null;native_frame.program_counter = 0;diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/call.rs b/Libraries/LibJS/JIT/Rust/src/codegen/call.rsindex a9cf9d7b57d..919ff627c4c 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/call.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/call.rs@@ -657,7 +657,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {4,u64::from(header.argument_count),),- (offsets.execution_context_script_or_module, 8, fields.script_or_module),(offsets.execution_context_lexical_environment, 8, fields.environment),(offsets.execution_context_variable_environment, 8, fields.environment),(@@ -1483,7 +1482,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {constants.clear();constants.extend(self.new_frame_constants(false));constants.extend([- (offsets.execution_context_script_or_module, 8, 0),(offsets.execution_context_executable, 8, 0),(offsets.execution_context_slot_count, 4, u64::from(argument_count)),(offsets.execution_context_argument_count, 4, u64::from(argument_count)),@@ -1607,7 +1605,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {.store64(&field(offsets.execution_context_caller_frame), self.pinned.frame);constants.extend([(offsets.execution_context_function, 8, header.function.function.0),- (offsets.execution_context_script_or_module, 8, 0),// NB: Frames get their id when the debugger first needs it.(offsets.execution_context_frame_id, 8, 0),]);@@ -1619,7 +1616,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {);constants.extend([(offsets.execution_context_function, 8, header.function.function.0),- (offsets.execution_context_script_or_module, 8, fields.script_or_module),(offsets.execution_context_lexical_environment, 8, fields.environment),(offsets.execution_context_variable_environment, 8, fields.environment),(@@ -1671,14 +1667,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {self.masm.store64(&field(offsets.execution_context_function), function_register);let function_field = |offset: u32| Address::new(function_register, offset as i32);- let shared_data_field = function_field(self.runtime.dynamic_calls.ecmascript_function_shared_data);- self.emit_load_compressed_cell(temp, &shared_data_field);- self.masm.load64(- temp,- &Address::new(temp, offsets.shared_function_script_or_module as i32),- );- self.masm- .store64(&field(offsets.execution_context_script_or_module), temp);// NB: ECMAScript functions always have an environment.self.emit_load_compressed_cell(temp, &function_field(offsets.ecmascript_function_environment));self.masmdiff --git a/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs b/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rsindex 3cb0ea34409..bdf3e5742bf 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/call_stub.rs@@ -1087,10 +1087,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, '_, M> {let mut constants = self.spare_fields.take();constants.clear();constants.extend(self.emit_stub_call_site_fields(native_frame, temp, false));- constants.extend([- (offsets.execution_context_script_or_module, 8, 0),- (offsets.execution_context_executable, 8, 0),- ]);+ constants.extend([(offsets.execution_context_executable, 8, 0)]);self.emit_constant_fields_with_vector(native_frame, temp, &mut constants, Some(M::ARGUMENT_FPRS[0]), &[])?;self.spare_fields = constants;self.masm.load_effective_address(diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rsindex 96233c3d0a2..efbfef0d454 100644--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs@@ -55,7 +55,6 @@ fn offsets() -> RuntimeOffsets {accessor_setter: 16,execution_context_function: 64,execution_context_realm: 72,- execution_context_script_or_module: 80,execution_context_variable_environment: 96,execution_context_frame_id: 104,execution_context_skip_when_determining_incumbent_counter: 4,@@ -76,7 +75,6 @@ fn offsets() -> RuntimeOffsets {execution_context_new_target: 160,ecmascript_function_environment: 0,ecmascript_function_private_environment: 8,- shared_function_script_or_module: 24,object_class_bits: 40,ecmascript_function_flag_has_rare_data: 8,vm_execution_generation: 8 * VM_EXECUTION_GENERATION_WORD as u32,@@ -3858,7 +3856,6 @@ mod direct_calls {let byte = |offset: usize| (frame[offset / 8] >> (8 * (offset % 8))) as u8;assert_eq!(word(64), callee.function.as_ptr() as u64, "function");assert_eq!(word(72), REALM);- assert_eq!(word(80), FUNCTION_WORDS[2]);assert_eq!((word(8), word(96), word(16)),(FUNCTION_WORDS[0], FUNCTION_WORDS[0], FUNCTION_WORDS[1])@@ -4262,7 +4259,6 @@ mod direct_calls {let byte = |offset: usize| (frame[offset / 8] >> (8 * (offset % 8))) as u8;assert_eq!(word(64), callee.function.as_ptr() as u64, "function");assert_eq!(word(72), callee.realm);- assert_eq!(word(80), FUNCTION_WORDS[2]);assert_eq!((word(8), word(96), word(16)),(diff --git a/Libraries/LibJS/JIT/Rust/src/snapshot.rs b/Libraries/LibJS/JIT/Rust/src/snapshot.rsindex 3b66ca387ed..3a04eb9d5b8 100644--- a/Libraries/LibJS/JIT/Rust/src/snapshot.rs+++ b/Libraries/LibJS/JIT/Rust/src/snapshot.rs@@ -665,10 +665,10 @@ pub struct EnvironmentTemplateSnapshot {}/// The words of an ECMAScript function's `[[ScriptOrModule]]`,-/// `[[Environment]]` and private environment, which its frames start with-/// (see `RuntimeOffsets::ecmascript_function_script_or_module` and the-/// fields after it). They stay the same for the function's lifetime, and-/// what they point to lives as long as the function.+/// `[[Environment]]` and private environment. Its frames start with the+/// last two, and code inlined into a frame runs with the frame function's+/// `[[ScriptOrModule]]`. They stay the same for the function's lifetime,+/// and what they point to lives as long as the function.#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]pub struct FunctionFrameFields {pub script_or_module: u64,@@ -1648,8 +1648,6 @@ pub struct RuntimeOffsets {pub execution_context_function: u32,/// `ExecutionContext::realm` (cell pointer).pub execution_context_realm: u32,- /// `ExecutionContext::script_or_module` (8 bytes).- pub execution_context_script_or_module: u32,/// `ExecutionContext::variable_environment` (cell pointer).pub execution_context_variable_environment: u32,/// `ExecutionContext::frame_id` (u64).@@ -1691,8 +1689,6 @@ pub struct RuntimeOffsets {/// `EcmascriptFunctionObjectWithRareData::private_environment` (cell/// pointer), of functions with the flag for it.pub ecmascript_function_private_environment: u32,- /// `SharedFunctionInstanceData::script_or_module` (8 bytes, as in `ExecutionContext`).- pub shared_function_script_or_module: u32,/// `Object::class_bits` (u8).pub object_class_bits: u32,/// The bit of `Object::class_bits` of an ECMAScript function that hasdiff --git a/Libraries/LibJS/Runtime/ExecutionContext.cpp b/Libraries/LibJS/Runtime/ExecutionContext.cppindex 15f0501e795..5f3b5722c0a 100644--- a/Libraries/LibJS/Runtime/ExecutionContext.cpp+++ b/Libraries/LibJS/Runtime/ExecutionContext.cpp@@ -47,6 +47,17 @@ SourceCode const* ExecutionContext::source_code() constreturn reinterpret_cast<SourceCode const*>(js_source_code_of_execution_context(execution_context_to_abi(*this)));}+ScriptOrModule ExecutionContext::script_or_module() const+{+ return bit_cast<ScriptOrModule>(js_execution_context_script_or_module(execution_context_to_abi(*this)));+}++void ExecutionContext::set_script_or_module(ScriptOrModule script_or_module)+{+ VERIFY(!function);+ script_or_module_without_function = script_or_module;+}+Utf16FlyString ExecutionContext::function_name() const{return owned_utf16_string_from_abi(js_execution_context_function_name(execution_context_to_abi(*this)));diff --git a/Libraries/LibJS/Runtime/ExecutionContext.h b/Libraries/LibJS/Runtime/ExecutionContext.hindex 3dc45802443..a7b021bcd96 100644--- a/Libraries/LibJS/Runtime/ExecutionContext.h+++ b/Libraries/LibJS/Runtime/ExecutionContext.h@@ -113,9 +113,11 @@ struct JS_API ExecutionContext {GC_VISITS_THROUGH_FOREIGN_IMPLEMENTATION void visit_edges(GC::Cell::Visitor&);- GC::Ptr<FunctionObject> function; // [[Function]]- GC::Ptr<Realm> realm; // [[Realm]]- ScriptOrModule script_or_module; // [[ScriptOrModule]]+ GC::Ptr<FunctionObject> function; // [[Function]]+ GC::Ptr<Realm> realm; // [[Realm]]+ // The [[ScriptOrModule]] of a context without a function. That of a context with a function comes from the+ // function, and this holds an old value: use script_or_module() and set_script_or_module().+ ScriptOrModule script_or_module_without_function;GC::Ptr<Environment> lexical_environment; // [[LexicalEnvironment]]GC::Ptr<Environment> variable_environment; // [[VariableEnvironment]]GC::Ptr<PrivateEnvironment> private_environment; // [[PrivateEnvironment]]@@ -194,6 +196,10 @@ struct JS_API ExecutionContext {// that runs no bytecode, such as a native function's, has no source code and an empty function name. The source// code is the runtime's own, whose address identifies it.SourceCode const* source_code() const;++ // [[ScriptOrModule]]+ ScriptOrModule script_or_module() const;+ void set_script_or_module(ScriptOrModule);Utf16FlyString function_name() const;};@@ -205,7 +211,7 @@ static_assert(sizeof(Optional<Value>) == sizeof(Value));static_assert(sizeof(ExecutionContext::field) == JS_LAYOUT_EXECUTION_CONTEXT_##layout_name##_SIZE);JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(function, FUNCTION)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(realm, REALM)-JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(script_or_module, SCRIPT_OR_MODULE)+JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(script_or_module_without_function, SCRIPT_OR_MODULE_WITHOUT_FUNCTION)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(lexical_environment, LEXICAL_ENVIRONMENT)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(variable_environment, VARIABLE_ENVIRONMENT)JS_ASSERT_EXECUTION_CONTEXT_FIELD_LAYOUT(private_environment, PRIVATE_ENVIRONMENT)diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cppindex bc275e92444..6e6fa9af236 100644--- a/Libraries/LibJS/Runtime/VM.cpp+++ b/Libraries/LibJS/Runtime/VM.cpp@@ -683,9 +683,10 @@ ScriptOrModule VM::get_active_script_or_module() const// 2. Let ec be the topmost execution context on the execution context stack whose ScriptOrModule component is not null.ScriptOrModule script_or_module = Empty {};for_each_execution_context_top_to_bottom([&](ExecutionContext const& execution_context) {- if (execution_context.script_or_module.has<Empty>())+ auto execution_context_script_or_module = execution_context.script_or_module();+ if (execution_context_script_or_module.has<Empty>())return true;- script_or_module = execution_context.script_or_module;+ script_or_module = execution_context_script_or_module;return false;});diff --git a/Libraries/LibJS/Rust/generate/layout_header.rs b/Libraries/LibJS/Rust/generate/layout_header.rsindex 95b088cc75b..f7d3bf43c43 100644--- a/Libraries/LibJS/Rust/generate/layout_header.rs+++ b/Libraries/LibJS/Rust/generate/layout_header.rs@@ -327,7 +327,7 @@ pub fn generate() -> LayoutHeader {every_field_offset!(w, "EXECUTION_CONTEXT", ExecutionContext {function,realm,- script_or_module,+ script_or_module_without_function,lexical_environment,variable_environment,private_environment,diff --git a/Libraries/LibJS/Rust/generate/layout_table.rs b/Libraries/LibJS/Rust/generate/layout_table.rsindex b0cd10473a4..032fa005fd3 100644--- a/Libraries/LibJS/Rust/generate/layout_table.rs+++ b/Libraries/LibJS/Rust/generate/layout_table.rs@@ -333,7 +333,7 @@ pub fn generate(configuration: &LayoutConfiguration) -> LayoutWriter {assert_eq!(align_of::<ExecutionContext>(), value_size);field!(w, "EXECUTION_CONTEXT_FUNCTION", "ExecutionContext.function", "Object", ExecutionContext, function, 8, "nullable", "cell", "function_and_realm");field!(w, "EXECUTION_CONTEXT_REALM", "ExecutionContext.realm", "Realm", ExecutionContext, realm, 8, "nullable", "cell", "function_and_realm");- field!(w, "EXECUTION_CONTEXT_SCRIPT_OR_MODULE", "ExecutionContext.script_or_module", "u64", ExecutionContext, script_or_module, 8, "nullable", "scalar");+ field!(w, "EXECUTION_CONTEXT_SCRIPT_OR_MODULE_WITHOUT_FUNCTION", "ExecutionContext.script_or_module_without_function", "u64", ExecutionContext, script_or_module_without_function, 8, "nullable", "scalar");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, 8, "nullable", "cell");diff --git a/Libraries/LibJS/Rust/src/embedding/execution_context.rs b/Libraries/LibJS/Rust/src/embedding/execution_context.rsindex 9f78b083771..89f4bba92de 100644--- a/Libraries/LibJS/Rust/src/embedding/execution_context.rs+++ b/Libraries/LibJS/Rust/src/embedding/execution_context.rs@@ -8,8 +8,9 @@//!//! A JSExecutionContext is the runtime's ExecutionContext. LibJS/Embedding/Layout.h gives the offset and size of each//! of its fields as JS_LAYOUT_EXECUTION_CONTEXT_*, and its value slots, the arguments last, follow it directly. An-//! embedder reads and writes the fields there, among them the realm, the ScriptOrModule, the this value and the-//! skip-when-determining-incumbent counter. It also finds the running context at+//! embedder reads and writes the fields there, among them the realm, the this value and the+//! skip-when-determining-incumbent counter. It reads the ScriptOrModule with js_execution_context_script_or_module(),+//! because that of a context with a function comes from the function. It also finds the running context at//! JS_LAYOUT_VM_RUNNING_EXECUTION_CONTEXT_OFFSET in the VM, and with it the current realm and the arguments and this//! value of the running code, without a call.//!@@ -218,6 +219,22 @@ pub unsafe extern "C" fn js_execution_context_restore_stack(vm: *mut JSVM) {vm.restore_execution_context_stack();}+/// ExecutionContext::script_or_module(): the [[ScriptOrModule]] of `execution_context`. That of a context with a+/// function comes from the function, and the field holds it only for a context without one.+///+/// # Safety+///+/// `execution_context` must be a live execution context. Must be called on the thread that runs the VM.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn js_execution_context_script_or_module(+ execution_context: *const JSExecutionContext,+) -> JSScriptOrModule {+ assert!(!execution_context.is_null(), "the embedder passes an execution context");+ // SAFETY: The caller passes a live execution context.+ let execution_context = unsafe { &*execution_context.cast::<ExecutionContext>() };+ execution_context.script_or_module().into()+}+/// ExecutionContext::function_name(): the name of the function whose bytecode the context runs, as an owned/// AK::Utf16String the caller adopts with AK::Utf16String::adopt_raw(). It is empty for a context that runs no/// bytecode, such as that of a native function, and for code that is not the body of a function.diff --git a/Libraries/LibJS/Rust/src/interpreter/execution_context.rs b/Libraries/LibJS/Rust/src/interpreter/execution_context.rsindex b242099eecb..7f0387656ac 100644--- a/Libraries/LibJS/Rust/src/interpreter/execution_context.rs+++ b/Libraries/LibJS/Rust/src/interpreter/execution_context.rs@@ -11,9 +11,29 @@ use std::alloc::{Layout, alloc, dealloc, handle_alloc_error};use crate::gc::visitor::{Trace, Visitor};use crate::layout::execution_context::{ExecutionContext, ScriptOrModule, ScriptOrModuleSlot};use crate::layout::value::Value;+use crate::runtime::ecmascript_function_object::as_ecmascript_function_object;use libjs_abi::register::RESERVED_REGISTER_COUNT;impl ExecutionContext {+ /// The [[ScriptOrModule]] of the context. That of a frame with a function is the function's, which is null for a+ /// native function.+ pub fn script_or_module(&self) -> ScriptOrModule {+ match self.function.get() {+ Some(function) => as_ecmascript_function_object(function)+ .map_or(ScriptOrModule::Empty, |function| function.script_or_module()),+ None => self.script_or_module_without_function.get(),+ }+ }++ /// Sets the [[ScriptOrModule]] of a context without a function.+ pub fn set_script_or_module(&self, script_or_module: ScriptOrModule) {+ debug_assert!(+ self.function.get().is_none(),+ "a context with a function has the function's ScriptOrModule"+ );+ self.script_or_module_without_function.set(script_or_module);+ }+/// Constructs a context for a frame of `slot_count` slots, the last `argument_count` of which hold arguments, at/// `context`.///@@ -32,7 +52,7 @@ impl ExecutionContext {context.write(ExecutionContext {function: Cell::new(None),realm: Cell::new(None),- script_or_module: ScriptOrModuleSlot::new(ScriptOrModule::Empty),+ script_or_module_without_function: ScriptOrModuleSlot::new(ScriptOrModule::Empty),lexical_environment: Cell::new(None),variable_environment: Cell::new(None),private_environment: Cell::new(None),@@ -96,7 +116,8 @@ impl ExecutionContext {let copy = OwnedExecutionContext::create(slot_count - argument_count, 0, argument_count);copy.function.set(self.function.get());copy.realm.set(self.realm.get());- copy.script_or_module.set(self.script_or_module.get());+ copy.script_or_module_without_function+ .set(self.script_or_module_without_function.get());copy.lexical_environment.set(self.lexical_environment.get());copy.variable_environment.set(self.variable_environment.get());copy.private_environment.set(self.private_environment.get());@@ -133,7 +154,8 @@ impl ExecutionContext {let copy = OwnedExecutionContext::create(slot_count - argument_count, 0, argument_count);copy.function.set(self.function.get());copy.realm.set(self.realm.get());- copy.script_or_module.set(self.script_or_module.get());+ copy.script_or_module_without_function+ .set(self.script_or_module_without_function.get());copy.lexical_environment.set(self.lexical_environment.get());copy.variable_environment.set(self.variable_environment.get());copy.private_environment.set(self.private_environment.get());@@ -166,10 +188,13 @@ unsafe impl Trace for ExecutionContext {self.this_value.trace(visitor);self.new_target.trace(visitor);self.executable.trace(visitor);- match self.script_or_module.get() {- ScriptOrModule::Empty => {}- ScriptOrModule::Script(script) => script.trace(visitor),- ScriptOrModule::Module(module) => module.trace(visitor),+ // NB: The field of a frame with a function holds an old value, as script_or_module() says.+ if self.function.get().is_none() {+ match self.script_or_module_without_function.get() {+ ScriptOrModule::Empty => {}+ ScriptOrModule::Script(script) => script.trace(visitor),+ ScriptOrModule::Module(module) => module.trace(visitor),+ }}let slots = self.slots();if self.frame_initialized.get() {diff --git a/Libraries/LibJS/Rust/src/interpreter/run.rs b/Libraries/LibJS/Rust/src/interpreter/run.rsindex d3249b5937f..cd282e2be0a 100644--- a/Libraries/LibJS/Rust/src/interpreter/run.rs+++ b/Libraries/LibJS/Rust/src/interpreter/run.rs@@ -298,9 +298,7 @@ impl Vm {script_context_ref.realm.set(Some(script_record.realm()));// 5. Set the ScriptOrModule of scriptContext to scriptRecord.- script_context_ref- .script_or_module- .set(ScriptOrModule::Script(script_record));+ script_context_ref.set_script_or_module(ScriptOrModule::Script(script_record));// 6. Set the VariableEnvironment of scriptContext to globalEnv.script_context_ref@@ -449,7 +447,7 @@ impl Vm {.function.set(Some(callee_function.as_function_object_gc()));callee_context.realm.set(callee_function.realm());- callee_context.script_or_module.set(callee_function.script_or_module());+ // NB: The context gets its ScriptOrModule from its function.callee_context.new_target.set(new_target.map_or(Value::UNDEFINED, Value::from_object));@@ -499,7 +497,7 @@ impl Vm {callee_context.realm.set(Some(callee_function.realm()));// 7. Set the ScriptOrModule of calleeContext to null.- callee_context.script_or_module.set(ScriptOrModule::Empty);+ // NB: The ScriptOrModule of a context with a native function is null.// 8. Perform any necessary implementation-defined initialization of calleeContext.// NB: Like NativeFunction's [[Call]], which runs these builtins otherwise.diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rsindex 840d42dca3c..6b5ad399035 100644--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs@@ -820,7 +820,7 @@ pub fn get_import_meta(}pub fn get_import(vm: &Vm, pc: u32, instruction: &op::GetImport, values: &mut op::GetImportValues) -> SlowPathControl {- let ScriptOrModule::Module(module) = running_execution_context(vm).script_or_module.get() else {+ let ScriptOrModule::Module(module) = running_execution_context(vm).script_or_module() else {unreachable!("GetImport only runs in the code of a module");};let module = modulediff --git a/Libraries/LibJS/Rust/src/interpreter/vm.rs b/Libraries/LibJS/Rust/src/interpreter/vm.rsindex 7aacfd9d02c..9248057cc22 100644--- a/Libraries/LibJS/Rust/src/interpreter/vm.rs+++ b/Libraries/LibJS/Rust/src/interpreter/vm.rs@@ -2198,7 +2198,7 @@ impl Vm {// 2. Let ec be the topmost execution context on the execution context stack whose ScriptOrModule component is not null.let mut script_or_module = ScriptOrModule::Empty;self.for_each_execution_context_top_to_bottom(|execution_context| {- script_or_module = execution_context.script_or_module.get();+ script_or_module = execution_context.script_or_module();if matches!(script_or_module, ScriptOrModule::Empty) {return ControlFlow::Continue(());}diff --git a/Libraries/LibJS/Rust/src/jit/runtime_info.rs b/Libraries/LibJS/Rust/src/jit/runtime_info.rsindex 92009835aba..f308e5d6578 100644--- a/Libraries/LibJS/Rust/src/jit/runtime_info.rs+++ b/Libraries/LibJS/Rust/src/jit/runtime_info.rs@@ -145,7 +145,6 @@ fn runtime_offsets() -> RuntimeOffsets {accessor_setter: offset(offset_of!(Accessor, setter)),execution_context_function: offset(offset_of!(ExecutionContext, function)),execution_context_realm: offset(offset_of!(ExecutionContext, realm)),- execution_context_script_or_module: offset(offset_of!(ExecutionContext, script_or_module)),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!(@@ -181,7 +180,6 @@ fn runtime_offsets() -> RuntimeOffsets {EcmascriptFunctionObjectWithRareData,private_environment)),- shared_function_script_or_module: offset(offset_of!(SharedFunctionInstanceData, script_or_module)),object_class_bits: offset(offset_of!(Object, class_bits)),ecmascript_function_flag_has_rare_data: ecmascript_function_flags::HAS_RARE_DATA.into(),vm_execution_generation: offset(offset_of!(VmHead, execution_generation)),diff --git a/Libraries/LibJS/Rust/src/jit/snapshot.rs b/Libraries/LibJS/Rust/src/jit/snapshot.rsindex 7be0838d635..f148c74e258 100644--- a/Libraries/LibJS/Rust/src/jit/snapshot.rs+++ b/Libraries/LibJS/Rust/src/jit/snapshot.rs@@ -41,6 +41,7 @@ use crate::gc::root::MarkedVec;use crate::interpreter::vm::Vm;use crate::layout::cell::{CellHeader, Gc};use crate::layout::environment::DeclarativeEnvironment;+use crate::layout::execution_context::ScriptOrModuleSlot;use crate::layout::function_object::{DirectGetterFunction, EcmascriptFunctionObject, FunctionObject, NativeFunction, RawNativeFunction,};@@ -1600,7 +1601,7 @@ pub fn capture_snapshot<'d>(let compiled_function_fields = match function {Some(function) => function_frame_fields(function),None => FunctionFrameFields {- script_or_module: vm.running_execution_context_ref().script_or_module.word(),+ script_or_module: ScriptOrModuleSlot::new(vm.running_execution_context_ref().script_or_module()).word(),..FunctionFrameFields::default()},};diff --git a/Libraries/LibJS/Rust/src/jit/tier_up.rs b/Libraries/LibJS/Rust/src/jit/tier_up.rsindex 1047a0d798f..d5ccd9f77ab 100644--- a/Libraries/LibJS/Rust/src/jit/tier_up.rs+++ b/Libraries/LibJS/Rust/src/jit/tier_up.rs@@ -146,7 +146,7 @@ fn code_to_compile(vm: &Vm) -> Option<CompileTarget> {let Some(function) = frame.function.get() else {// NB: The top-level code of a script or of a module runs once, but its loops can run long. Other code without// a function, like that of eval, is not compiled.- let top_level_executable = match frame.script_or_module.get() {+ let top_level_executable = match frame.script_or_module() {ScriptOrModule::Script(script) => script.cached_executable(),ScriptOrModule::Module(module) => module.downcast_ref::<SourceTextModule>()?.cached_executable(),_ => None,diff --git a/Libraries/LibJS/Rust/src/layout/execution_context.rs b/Libraries/LibJS/Rust/src/layout/execution_context.rsindex 384ddb59001..4026cd4f7ba 100644--- a/Libraries/LibJS/Rust/src/layout/execution_context.rs+++ b/Libraries/LibJS/Rust/src/layout/execution_context.rs@@ -77,7 +77,9 @@ impl ScriptOrModuleSlot {pub struct ExecutionContext {pub function: Cell<Option<Gc<FunctionObject>>>,pub realm: Cell<Option<Gc<Realm>>>,- pub script_or_module: ScriptOrModuleSlot,+ /// The [[ScriptOrModule]] of a frame without a function, which native code makes. A frame with a function gets+ /// it from the function, and this holds an old value: read it through `ExecutionContext::script_or_module()`.+ pub script_or_module_without_function: ScriptOrModuleSlot,pub lexical_environment: Cell<Option<Gc<Environment>>>,pub variable_environment: Cell<Option<Gc<Environment>>>,pub private_environment: Cell<Option<Gc<PrivateEnvironment>>>,diff --git a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rsindex 2b2fc10cd2b..bb7a47c6db3 100644--- a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs+++ b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs@@ -1271,9 +1271,7 @@ pub fn perform_eval(vm: &Vm, x: Value, strict_caller: CallerMode, direct: EvalMoeval_context.realm.set(Some(eval_realm));// 25. Set evalContext's ScriptOrModule to runningContext's ScriptOrModule.- eval_context- .script_or_module- .set(running_context.script_or_module.get());+ eval_context.set_script_or_module(running_context.script_or_module());// 26. Set evalContext's VariableEnvironment to varEnv.eval_context.variable_environment.set(Some(variable_environment));diff --git a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rsindex d6acd3b9559..86fb20a08b9 100644--- a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs+++ b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs@@ -843,7 +843,7 @@ impl EcmascriptFunctionObject {callee_context.realm.set(self.realm());// 6. Set the ScriptOrModule of calleeContext to F.[[ScriptOrModule]].- callee_context.script_or_module.set(self.script_or_module());+ // NB: The context gets its ScriptOrModule from its function.// NB: Frames of functions whose environment has no this binding answer for new.target themselves.callee_contextdiff --git a/Libraries/LibJS/Rust/src/runtime/realm.rs b/Libraries/LibJS/Rust/src/runtime/realm.rsindex 166e52a02b7..5671d750063 100644--- a/Libraries/LibJS/Rust/src/runtime/realm.rs+++ b/Libraries/LibJS/Rust/src/runtime/realm.rs@@ -211,7 +211,7 @@ impl Realm {new_context.realm.set(Some(realm));// 10. Set the ScriptOrModule of newContext to null.- new_context.script_or_module.set(ScriptOrModule::Empty);+ new_context.set_script_or_module(ScriptOrModule::Empty);// 11. Push newContext onto the execution context stack; newContext is now the running execution context.vm.push_execution_context(NonNull::from(new_context));diff --git a/Libraries/LibJS/Rust/src/runtime/source_text_module.rs b/Libraries/LibJS/Rust/src/runtime/source_text_module.rsindex 3b803abbe5c..04d10b116fc 100644--- a/Libraries/LibJS/Rust/src/runtime/source_text_module.rs+++ b/Libraries/LibJS/Rust/src/runtime/source_text_module.rs@@ -554,8 +554,7 @@ impl SourceTextModule {// 12. Set the ScriptOrModule of moduleContext to module.self.execution_context- .script_or_module- .set(ScriptOrModule::Module(self.as_gc()));+ .set_script_or_module(ScriptOrModule::Module(self.as_gc()));// 13. Set the VariableEnvironment of moduleContext to module.[[Environment]].self.execution_context@@ -914,9 +913,7 @@ impl SourceTextModule {module_context_ref.realm.set(Some(self.realm()));// 4. Set the ScriptOrModule of moduleContext to module.- module_context_ref- .script_or_module- .set(ScriptOrModule::Module(self.as_gc()));+ module_context_ref.set_script_or_module(ScriptOrModule::Module(self.as_gc()));// 5. Assert: module has been linked and declarations in its module environment have been instantiated.assert!(!matches!(diff --git a/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs b/Libraries/LibJS/Rust/src/runtime/synthetic_module.rsindex 88b9acd3652..c27941c8ef0 100644--- a/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs+++ b/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs@@ -260,9 +260,7 @@ impl SyntheticModule {module_context_ref.realm.set(Some(realm));// 4. Set the ScriptOrModule of moduleContext to module.- module_context_ref- .script_or_module- .set(ScriptOrModule::Module(self.as_gc()));+ module_context_ref.set_script_or_module(ScriptOrModule::Module(self.as_gc()));// 5. Set the VariableEnvironment of moduleContext to module.[[Environment]].let environment = self.environment().map(Gc::upcast);diff --git a/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Libraries/LibWeb/Bindings/MainThreadVM.cppindex ea21741ce16..954d6d8a6f4 100644--- a/Libraries/LibWeb/Bindings/MainThreadVM.cpp+++ b/Libraries/LibWeb/Bindings/MainThreadVM.cpp@@ -304,7 +304,7 @@ void initialize_agent(HTML::AgentType type)// 1. Let script be the running script.// The running script is the script in the [[HostDefined]] field in the ScriptOrModule component of the running JavaScript execution context.HTML::Script* script { nullptr };- vm.running_execution_context().script_or_module.visit(+ vm.running_execution_context().script_or_module().visit([&script](GC::Ref<JS::Script>& js_script) {script = as<HTML::ClassicScript>(HTML::script_from_host_defined(js_script->host_defined()));},@@ -481,13 +481,13 @@ void initialize_agent(HTML::AgentType type)// IMPLEMENTATION DEFINED: Per the previous "implementation defined" comment, we must now make the script or module the active script or module.// Since the only active execution context currently is the realm execution context of job settings, lets attach it here.- job_settings->realm_execution_context().script_or_module = script_or_module;+ job_settings->realm_execution_context().set_script_or_module(script_or_module);} else {// FIXME: We need to setup a dummy execution context in case a JS::NativeFunction is called when processing the job.// This is because JS::NativeFunction::call excepts something to be on the execution context stack to be able to get the caller context to initialize the environment.// Do note that the JS spec gives _no_ guarantee that the execution context stack has something on it if HostEnqueuePromiseJob was called with a null realm: https://tc39.es/ecma262/#job-preparedtoevaluatecodedummy_execution_context = JS::ExecutionContext::create(0, ReadonlySpan<JS::Value> {}, 0);- dummy_execution_context->script_or_module = script_or_module;+ dummy_execution_context->set_script_or_module(script_or_module);vm.push_execution_context(*dummy_execution_context);}@@ -497,7 +497,7 @@ void initialize_agent(HTML::AgentType type)// 3. If job settings is not null, then clean up after running script with job settings.if (job_settings) {// IMPLEMENTATION DEFINED: Disassociate the realm execution context from the script or module.- job_settings->realm_execution_context().script_or_module = Empty {};+ job_settings->realm_execution_context().set_script_or_module(Empty {});// IMPLEMENTATION DEFINED: See comment above, we need to clean up the non-standard prepare_to_run_callback() call.HTML::clean_up_after_running_callback(*job_settings);@@ -536,11 +536,11 @@ void initialize_agent(HTML::AgentType type)script_execution_context->function = nullptr;script_execution_context->realm = &script->settings_object().realm();if (is<HTML::ClassicScript>(script)) {- script_execution_context->script_or_module = GC::Ref<JS::Script>(*as<HTML::ClassicScript>(script)->script_record());+ script_execution_context->set_script_or_module(GC::Ref<JS::Script>(*as<HTML::ClassicScript>(script)->script_record()));} else if (is<HTML::ModuleScript>(script)) {- script_execution_context->script_or_module = as<HTML::ModuleScript>(script)->record().visit(+ script_execution_context->set_script_or_module(as<HTML::ModuleScript>(script)->record().visit([](Empty) -> JS::ScriptOrModule { return {}; },- [](auto& module) -> JS::ScriptOrModule { return GC::Ref<JS::Module> { module }; });+ [](auto& module) -> JS::ScriptOrModule { return GC::Ref<JS::Module> { module }; }));} else {VERIFY_NOT_REACHED();}@@ -810,7 +810,7 @@ void initialize_agent(HTML::AgentType type)VERIFY(module_execution_context);module_execution_context->realm = realm;if (module)- module_execution_context->script_or_module = GC::Ref { *module };+ module_execution_context->set_script_or_module(GC::Ref { *module });vm.push_execution_context(*module_execution_context);JS::finish_loading_imported_module(referrer, module_request, payload, completion);diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cppindex 5443f134d31..a44175054e1 100644--- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp+++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp@@ -236,7 +236,7 @@ static JS::ExecutionContext* top_most_script_having_execution_context(JS::VM& vm// Here, the topmost script-having execution context is the topmost entry of the JavaScript execution context stack that has a non-null ScriptOrModule component,// or null if there is no such entry in the JavaScript execution context stack.auto execution_context = vm.last_execution_context_matching([&](JS::ExecutionContext* context) {- return !context->script_or_module.has<Empty>();+ return !context->script_or_module().has<Empty>();});if (!execution_context.has_value())diff --git a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cppindex 82040f6c191..d43de20df8a 100644--- a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp+++ b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp@@ -304,7 +304,7 @@ GC::Ptr<WebIDL::Promise> ModuleScript::run(PreventErrorReporting prevent_error_rauto* module_execution_context = stack.allocate(0, ReadonlySpan<JS::Value> {}, 0);VERIFY(module_execution_context);module_execution_context->realm = &realm;- module_execution_context->script_or_module = record;+ module_execution_context->set_script_or_module(record);vm().push_execution_context(*module_execution_context);// 2. Set evaluationPromise to record.Evaluate().