summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-10 23:17:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-10 23:17:29 +0200
commit93a07ba962c49900845aaebf8992c1d2d10b0044 (patch)
tree03cfe170f37a3b15ad634530df0a6c47a84cdf79 /Userland/Libraries
parentf5feb1d2cd1198eb681592361340c5b02779524f (diff)
downloadserenity-93a07ba962c49900845aaebf8992c1d2d10b0044.zip
LibJS: Remove GlobalObject& argument from VM::construct()
We can just get the global object from the constructor function.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp4
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Op.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ReflectObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp5
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.h2
6 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index b01ea92b40..203bc880eb 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -222,7 +222,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
Object* new_object = nullptr;
Value result;
if (is<NewExpression>(*this)) {
- result = vm.construct(function, function, move(arguments), global_object);
+ result = vm.construct(function, function, move(arguments));
if (result.is_object())
new_object = &result.as_object();
} else if (is<SuperExpression>(*m_callee)) {
@@ -239,7 +239,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, "Super constructor");
return {};
}
- result = vm.construct(static_cast<Function&>(*super_constructor), function, move(arguments), global_object);
+ result = vm.construct(static_cast<Function&>(*super_constructor), function, move(arguments));
if (vm.exception())
return {};
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp
index 8824dbb8f1..f97fd1b538 100644
--- a/Userland/Libraries/LibJS/Bytecode/Op.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp
@@ -209,7 +209,7 @@ void Call::execute(Bytecode::Interpreter& interpreter) const
if (m_type == CallType::Call)
return_value = interpreter.vm().call(function, this_value, move(argument_values));
else
- return_value = interpreter.vm().construct(function, function, move(argument_values), interpreter.global_object());
+ return_value = interpreter.vm().construct(function, function, move(argument_values));
}
interpreter.accumulator() = return_value;
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
index 5dd455f7c6..05e7593010 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
@@ -45,7 +45,7 @@ PromiseCapability new_promise_capability(GlobalObject& global_object, Value cons
MarkedValueList arguments(vm.heap());
arguments.append(executor);
- auto promise = vm.construct(constructor.as_function(), constructor.as_function(), move(arguments), global_object);
+ auto promise = vm.construct(constructor.as_function(), constructor.as_function(), move(arguments));
if (vm.exception())
return {};
diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
index 04d17be774..b61e99eea0 100644
--- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
@@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::construct)
}
new_target = &new_target_value.as_function();
}
- return vm.construct(*target, *new_target, move(arguments), global_object);
+ return vm.construct(*target, *new_target, move(arguments));
}
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index 571be091aa..cac6ad2675 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -378,15 +378,16 @@ Reference VM::get_reference(const FlyString& name)
return { Reference::GlobalVariable, name };
}
-Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject& global_object)
+Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments)
{
+ auto& global_object = function.global_object();
CallFrame call_frame;
call_frame.callee = &function;
if (auto* interpreter = interpreter_if_exists())
call_frame.current_node = interpreter->current_node();
call_frame.is_strict_mode = function.is_strict_mode();
- push_call_frame(call_frame, function.global_object());
+ push_call_frame(call_frame, global_object);
if (exception())
return {};
ArmedScopeGuard call_frame_popper = [&] {
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h
index f897b4a9dd..66e5544793 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.h
+++ b/Userland/Libraries/LibJS/Runtime/VM.h
@@ -213,7 +213,7 @@ public:
return throw_exception(global_object, T::create(global_object, String::formatted(type.message(), forward<Args>(args)...)));
}
- Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject&);
+ Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments);
String join_arguments(size_t start_index = 0) const;