Skip to content

Commit fdb85a3

Browse files
committed
LibJS: Stop tracking whether execution context is strict mode or not
This was only used for basic testing, and forced us to plumb this flag flag in a bunch of places.
1 parent fb05063 commit fdb85a3

19 files changed

+4
-320
lines changed

Libraries/LibJS/Bytecode/Interpreter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, GC::Ptr<Environ
249249

250250
// 8. Set the PrivateEnvironment of scriptContext to null.
251251

252-
// NOTE: This isn't in the spec, but we require it.
253-
script_context->is_strict_mode = script_record.is_strict_mode();
254-
255252
// 9. Suspend the currently running execution context.
256253
// 10. Push scriptContext onto the execution context stack; scriptContext is now the running execution context.
257254
TRY(vm.push_execution_context(*script_context, {}));

Libraries/LibJS/Runtime/AbstractOperations.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,6 @@ ThrowCompletionOr<Value> perform_eval(VM& vm, Value x, CallerMode strict_caller,
723723
// 28. Set evalContext's PrivateEnvironment to privateEnv.
724724
eval_context->private_environment = private_environment;
725725

726-
// NOTE: This isn't in the spec, but we require it.
727-
eval_context->is_strict_mode = strict_eval;
728-
729726
// 29. Push evalContext onto the execution context stack; evalContext is now the running execution context.
730727
TRY(vm.push_execution_context(*eval_context, {}));
731728

Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,6 @@ void ECMAScriptFunctionObject::make_method(Object& home_object)
689689
// 10.2.1.1 PrepareForOrdinaryCall ( F, newTarget ), https://tc39.es/ecma262/#sec-prepareforordinarycall
690690
void ECMAScriptFunctionObject::prepare_for_ordinary_call(VM& vm, ExecutionContext& callee_context, Object* new_target)
691691
{
692-
// Non-standard
693-
callee_context.is_strict_mode = is_strict_mode();
694-
695692
// 1. Let callerContext be the running execution context.
696693
// 2. Let calleeContext be a new ECMAScript code execution context.
697694

Libraries/LibJS/Runtime/ExecutionContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ NonnullOwnPtr<ExecutionContext> ExecutionContext::copy() const
125125
copy->program_counter = program_counter;
126126
copy->function_name = function_name;
127127
copy->this_value = this_value;
128-
copy->is_strict_mode = is_strict_mode;
129128
copy->executable = executable;
130129
copy->arguments_offset = arguments_offset;
131130
copy->passed_argument_count = passed_argument_count;

Libraries/LibJS/Runtime/ExecutionContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ struct JS_API ExecutionContext {
9595

9696
u32 arguments_offset { 0 };
9797
u32 passed_argument_count { 0 };
98-
bool is_strict_mode { false };
9998

10099
Span<Value> arguments;
101100

Libraries/LibJS/Runtime/NativeFunction.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ ThrowCompletionOr<Value> NativeFunction::internal_call(ExecutionContext& callee_
151151
// calling async_block_start which goes through a NativeFunction here.
152152
callee_context.private_environment = caller_context.private_environment;
153153

154-
// NOTE: This is a LibJS specific hack for NativeFunction to inherit the strictness of its caller.
155-
callee_context.is_strict_mode = caller_context.is_strict_mode;
156-
157154
// </8.> --------------------------------------------------------------------------
158155

159156
// 9. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
@@ -204,9 +201,6 @@ ThrowCompletionOr<GC::Ref<Object>> NativeFunction::internal_construct(ExecutionC
204201
callee_context.lexical_environment = caller_context.lexical_environment;
205202
callee_context.variable_environment = caller_context.variable_environment;
206203

207-
// NOTE: This is a LibJS specific hack for NativeFunction to inherit the strictness of its caller.
208-
callee_context.is_strict_mode = caller_context.is_strict_mode;
209-
210204
// </8.> --------------------------------------------------------------------------
211205

212206
// 9. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.

Libraries/LibJS/Runtime/ShadowRealm.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,6 @@ NonnullOwnPtr<ExecutionContext> get_shadow_realm_context(Realm& shadow_realm, bo
342342
// 10. Set context's PrivateEnvironment to null.
343343
context->private_environment = nullptr;
344344

345-
// Non-standard
346-
context->is_strict_mode = strict_eval;
347-
348345
// 11. Return context.
349346
return context;
350347
}

Libraries/LibJS/Script.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ Result<GC::Ref<Script>, Vector<ParserError>> Script::parse(StringView source_tex
2525
if (parser.has_errors())
2626
return parser.errors();
2727

28-
bool strict_mode = script->is_strict_mode();
29-
3028
// 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }.
31-
return realm.heap().allocate<Script>(realm, filename, move(script), host_defined, strict_mode);
29+
return realm.heap().allocate<Script>(realm, filename, move(script), host_defined);
3230
}
3331

34-
Script::Script(Realm& realm, StringView filename, NonnullRefPtr<Program> parse_node, HostDefined* host_defined, bool strict_mode)
32+
Script::Script(Realm& realm, StringView filename, NonnullRefPtr<Program> parse_node, HostDefined* host_defined)
3533
: m_realm(realm)
3634
, m_parse_node(move(parse_node))
3735
, m_filename(filename)
3836
, m_host_defined(host_defined)
39-
, m_strict_mode(strict_mode)
4037
{
4138
}
4239

Libraries/LibJS/Script.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ class JS_API Script final : public Cell {
4646
HostDefined* host_defined() const { return m_host_defined; }
4747
StringView filename() const LIFETIME_BOUND { return m_filename; }
4848

49-
[[nodiscard]] bool is_strict_mode() const { return m_strict_mode; }
50-
5149
private:
52-
Script(Realm&, StringView filename, NonnullRefPtr<Program>, HostDefined*, bool strict_mode);
50+
Script(Realm&, StringView filename, NonnullRefPtr<Program>, HostDefined*);
5351

5452
virtual void visit_edges(Cell::Visitor&) override;
5553

@@ -60,8 +58,6 @@ class JS_API Script final : public Cell {
6058
// Needed for potential lookups of modules.
6159
ByteString m_filename;
6260
HostDefined* m_host_defined { nullptr }; // [[HostDefined]]
63-
64-
bool m_strict_mode { false };
6561
};
6662

6763
}

Libraries/LibJS/SourceTextModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,6 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, GC::Ptr<Promise
709709
ExecutionContext* module_context = nullptr;
710710
ALLOCATE_EXECUTION_CONTEXT_ON_NATIVE_STACK(module_context, registers_and_constants_and_locals_count, 0);
711711

712-
// NOTE: This is not in the spec but we require it.
713-
module_context->is_strict_mode = true;
714-
715712
// 2. Set the Function of moduleContext to null.
716713

717714
// 3. Set the Realm of moduleContext to module.[[Realm]].

0 commit comments

Comments
 (0)