mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibJS: Add callee realm fallback to ordinary_call_bind_this()
This makes ECMAScriptFunctionObject calls in the bytecode interpreter work again (regressed in #10402).
This commit is contained in:
parent
b9ffa0ad2e
commit
9d352c602c
1 changed files with 10 additions and 0 deletions
|
@ -605,6 +605,8 @@ void ECMAScriptFunctionObject::prepare_for_ordinary_call(ExecutionContext& calle
|
||||||
// 10.2.1.2 OrdinaryCallBindThis ( F, calleeContext, thisArgument ), https://tc39.es/ecma262/#sec-ordinarycallbindthis
|
// 10.2.1.2 OrdinaryCallBindThis ( F, calleeContext, thisArgument ), https://tc39.es/ecma262/#sec-ordinarycallbindthis
|
||||||
void ECMAScriptFunctionObject::ordinary_call_bind_this(ExecutionContext& callee_context, Value this_argument)
|
void ECMAScriptFunctionObject::ordinary_call_bind_this(ExecutionContext& callee_context, Value this_argument)
|
||||||
{
|
{
|
||||||
|
auto& vm = this->vm();
|
||||||
|
|
||||||
// 1. Let thisMode be F.[[ThisMode]].
|
// 1. Let thisMode be F.[[ThisMode]].
|
||||||
auto this_mode = m_this_mode;
|
auto this_mode = m_this_mode;
|
||||||
|
|
||||||
|
@ -614,6 +616,14 @@ void ECMAScriptFunctionObject::ordinary_call_bind_this(ExecutionContext& callee_
|
||||||
|
|
||||||
// 3. Let calleeRealm be F.[[Realm]].
|
// 3. Let calleeRealm be F.[[Realm]].
|
||||||
auto* callee_realm = m_realm;
|
auto* callee_realm = m_realm;
|
||||||
|
// NOTE: This non-standard fallback is needed until we can guarantee that literally
|
||||||
|
// every function has a realm - especially in LibWeb that's sometimes not the case
|
||||||
|
// when a function is created while no JS is running, as we currently need to rely on
|
||||||
|
// that (:acid2:, I know - see set_event_handler_attribute() for an example).
|
||||||
|
// If there's no 'current realm' either, we can't continue and crash.
|
||||||
|
if (!callee_realm)
|
||||||
|
callee_realm = vm.current_realm();
|
||||||
|
VERIFY(callee_realm);
|
||||||
|
|
||||||
// 4. Let localEnv be the LexicalEnvironment of calleeContext.
|
// 4. Let localEnv be the LexicalEnvironment of calleeContext.
|
||||||
auto* local_env = callee_context.lexical_environment;
|
auto* local_env = callee_context.lexical_environment;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue