From 892c7d980e3e38b6e11a5764f153867b101c9c87 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 26 Oct 2025 12:33:54 +0100 Subject: [PATCH] LibJS: Let JS::Script remember whether its code is strict mode We don't want to rely on having the AST node just to answer the question "is this script strict mode?" --- Libraries/LibJS/Bytecode/Interpreter.cpp | 2 +- Libraries/LibJS/Script.cpp | 7 +++++-- Libraries/LibJS/Script.h | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index f7a61ab0723..9f8f31bb05e 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -250,7 +250,7 @@ ThrowCompletionOr Interpreter::run(Script& script_record, GC::Ptris_strict_mode = script_record.parse_node().is_strict_mode(); + script_context->is_strict_mode = script_record.is_strict_mode(); // 9. Suspend the currently running execution context. // 10. Push scriptContext onto the execution context stack; scriptContext is now the running execution context. diff --git a/Libraries/LibJS/Script.cpp b/Libraries/LibJS/Script.cpp index 99a80d43528..ab3851aba85 100644 --- a/Libraries/LibJS/Script.cpp +++ b/Libraries/LibJS/Script.cpp @@ -25,15 +25,18 @@ Result, Vector> Script::parse(StringView source_tex if (parser.has_errors()) return parser.errors(); + bool strict_mode = script->is_strict_mode(); + // 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }. - return realm.heap().allocate