Modified: branches/safari-613.2.7.0-branch/JSTests/stress/internal-function-subclass-structure-realm.js (293237 => 293238)
--- branches/safari-613.2.7.0-branch/JSTests/stress/internal-function-subclass-structure-realm.js 2022-04-22 19:58:34 UTC (rev 293237)
+++ branches/safari-613.2.7.0-branch/JSTests/stress/internal-function-subclass-structure-realm.js 2022-04-22 20:08:22 UTC (rev 293238)
@@ -13,7 +13,7 @@
]) {
Object.defineProperty(newTarget, "prototype", { value: new r3.Object });
const instance = Reflect.construct(r1[key], [], newTarget);
- if ($vm.globalObjectForObject(instance) !== r3)
+ if ($vm.globalObjectForObject(instance) !== r2)
throw new Error(`Structure of ${key} instance has incorrect global object!`);
}
}
Modified: branches/safari-613.2.7.0-branch/Source/_javascript_Core/runtime/InternalFunction.cpp (293237 => 293238)
--- branches/safari-613.2.7.0-branch/Source/_javascript_Core/runtime/InternalFunction.cpp 2022-04-22 19:58:34 UTC (rev 293237)
+++ branches/safari-613.2.7.0-branch/Source/_javascript_Core/runtime/InternalFunction.cpp 2022-04-22 20:08:22 UTC (rev 293238)
@@ -137,6 +137,7 @@
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
+ JSGlobalObject* baseGlobalObject = baseClass->globalObject();
ASSERT(baseClass->hasMonoProto());
@@ -146,7 +147,7 @@
if (LIKELY(targetFunction)) {
FunctionRareData* rareData = targetFunction->ensureRareData(vm);
Structure* structure = rareData->internalFunctionAllocationStructure();
- if (LIKELY(structure && structure->classInfo() == baseClass->classInfo() && structure->globalObject() == baseClass->globalObject()))
+ if (LIKELY(structure && structure->classInfo() == baseClass->classInfo() && structure->globalObject() == baseGlobalObject))
return structure;
// Note, Reflect.construct might cause the profile to churn but we don't care.
@@ -153,7 +154,7 @@
JSValue prototypeValue = targetFunction->get(globalObject, vm.propertyNames->prototype);
RETURN_IF_EXCEPTION(scope, nullptr);
if (JSObject* prototype = jsDynamicCast<JSObject*>(vm, prototypeValue))
- return rareData->createInternalFunctionAllocationStructureFromBase(vm, prototype->globalObject(vm), prototype, baseClass);
+ return rareData->createInternalFunctionAllocationStructureFromBase(vm, baseGlobalObject, prototype, baseClass);
} else {
JSValue prototypeValue = newTarget->get(globalObject, vm.propertyNames->prototype);
RETURN_IF_EXCEPTION(scope, nullptr);
@@ -160,7 +161,7 @@
if (JSObject* prototype = jsDynamicCast<JSObject*>(vm, prototypeValue)) {
// This only happens if someone Reflect.constructs our builtin constructor with another builtin constructor as the new.target.
// Thus, we don't care about the cost of looking up the structure from our hash table every time.
- return vm.structureCache.emptyStructureForPrototypeFromBaseStructure(prototype->globalObject(vm), prototype, baseClass);
+ return vm.structureCache.emptyStructureForPrototypeFromBaseStructure(baseGlobalObject, prototype, baseClass);
}
}