1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 19:15:06 +00:00

LibJS/JIT: Compile the Call bytecode instruction

I've left a FIXME about dealing with some throwsy cases.
This commit is contained in:
Andreas Kling 2023-10-20 13:32:59 +02:00
parent 7fc35fde09
commit 640455b1d2
5 changed files with 43 additions and 12 deletions

View file

@ -184,19 +184,17 @@ ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value
return {};
}
template<typename InstructionType>
ThrowCompletionOr<Value> perform_call(Interpreter& interpreter, InstructionType const& call, Value callee, MarkedVector<Value> argument_values)
ThrowCompletionOr<Value> perform_call(Interpreter& interpreter, Value this_value, Op::CallType call_type, Value callee, MarkedVector<Value> argument_values)
{
auto& vm = interpreter.vm();
auto this_value = interpreter.reg(call.this_value());
auto& function = callee.as_function();
Value return_value;
if (call.call_type() == Op::CallType::DirectEval) {
if (call_type == Op::CallType::DirectEval) {
if (callee == interpreter.realm().intrinsics().eval_function())
return_value = TRY(perform_eval(vm, !argument_values.is_empty() ? argument_values[0].value_or(JS::js_undefined()) : js_undefined(), vm.in_strict_mode() ? CallerMode::Strict : CallerMode::NonStrict, EvalMode::Direct));
else
return_value = TRY(JS::call(vm, function, this_value, move(argument_values)));
} else if (call.call_type() == Op::CallType::Call)
} else if (call_type == Op::CallType::Call)
return_value = TRY(JS::call(vm, function, this_value, move(argument_values)));
else
return_value = TRY(construct(vm, function, move(argument_values)));
@ -204,9 +202,6 @@ ThrowCompletionOr<Value> perform_call(Interpreter& interpreter, InstructionType
return return_value;
}
template ThrowCompletionOr<Value> perform_call(Interpreter&, Op::Call const&, Value, MarkedVector<Value>);
template ThrowCompletionOr<Value> perform_call(Interpreter&, Op::CallWithArgumentArray const&, Value, MarkedVector<Value>);
static Completion throw_type_error_for_callee(Bytecode::Interpreter& interpreter, auto& call, StringView callee_type)
{
auto& vm = interpreter.vm();