Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/JavaScriptCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ set(JavaScriptCore_OBJECT_LUT_SOURCES
runtime/RegExpPrototype.cpp
runtime/RegExpStringIteratorPrototype.cpp
runtime/SetPrototype.cpp
runtime/ShadowRealmObject.cpp
runtime/ShadowRealmPrototype.cpp
runtime/StringConstructor.cpp
runtime/StringPrototype.cpp
runtime/SymbolConstructor.cpp
Expand Down Expand Up @@ -367,6 +369,7 @@ set(JavaScriptCore_BUILTINS_SOURCES
${JAVASCRIPTCORE_DIR}/builtins/RegExpStringIteratorPrototype.js
${JAVASCRIPTCORE_DIR}/builtins/SetIteratorPrototype.js
${JAVASCRIPTCORE_DIR}/builtins/SetPrototype.js
${JAVASCRIPTCORE_DIR}/builtins/ShadowRealmPrototype.js
${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js
${JAVASCRIPTCORE_DIR}/builtins/StringPrototype.js
Expand Down Expand Up @@ -1140,6 +1143,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
runtime/ScriptExecutable.h
runtime/ScriptFetchParameters.h
runtime/ScriptFetcher.h
runtime/ShadowRealmObject.h
runtime/SlowPathFunction.h
runtime/SlowPathReturnType.h
runtime/SmallStrings.h
Expand Down
2 changes: 2 additions & 0 deletions Source/JavaScriptCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ JavaScriptCore_BUILTINS_SOURCES = \
${JavaScriptCore}/builtins/RegExpStringIteratorPrototype.js \
$(JavaScriptCore)/builtins/SetIteratorPrototype.js \
$(JavaScriptCore)/builtins/SetPrototype.js \
$(JavaScriptCore)/builtins/ShadowRealmPrototype.js \
$(JavaScriptCore)/builtins/StringConstructor.js \
$(JavaScriptCore)/builtins/StringIteratorPrototype.js \
$(JavaScriptCore)/builtins/StringPrototype.js \
Expand Down Expand Up @@ -187,6 +188,7 @@ OBJECT_LUT_HEADERS = \
ReflectObject.lut.h \
RegExpConstructor.lut.h \
SetPrototype.lut.h \
ShadowRealmPrototype.lut.h \
StringConstructor.lut.h \
StringPrototype.lut.h \
SymbolConstructor.lut.h \
Expand Down
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,9 @@ runtime/ProxyConstructor.cpp
runtime/ProxyObject.cpp
runtime/ProxyRevoke.cpp
runtime/RandomizingFuzzerAgent.cpp
runtime/ShadowRealmObject.cpp
runtime/ShadowRealmConstructor.cpp
runtime/ShadowRealmPrototype.cpp
runtime/ReflectObject.cpp
runtime/RegExp.cpp
runtime/RegExpCache.cpp
Expand Down
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/builtins/BuiltinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace JSC {
macro(Number) \
macro(Array) \
macro(ArrayBuffer) \
macro(ShadowRealm) \
macro(RegExp) \
macro(min) \
macro(trunc) \
Expand Down Expand Up @@ -115,6 +116,8 @@ namespace JSC {
macro(asyncGeneratorQueueItemNext) \
macro(dateTimeFormat) \
macro(this) \
macro(importInRealm) \
macro(evalInRealm) \
macro(thisTimeValue) \
macro(newTargetLocal) \
macro(derivedConstructor) \
Expand Down
65 changes: 65 additions & 0 deletions Source/JavaScriptCore/builtins/ShadowRealmPrototype.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2021 Phillip Mates <[email protected]>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my (idiomatic) JS is horrible so in general be thorough with this file

@globalPrivate
function wrap(target)
{
"use strict";

if (@isCallable(target)) {
let wrapped = (...args) => {
const wrappedArgs = args.map(@wrap);
const result = target.@apply(@undefined, wrappedArgs);
return @wrap(result);
};
delete wrapped['name'];
delete wrapped['length'];
return wrapped;
} else if (@isObject(target)) {
@throwTypeError("value passing between realms must be callable or primitive");
}
return target;
}

function evaluate(evalStr)
{
"use strict";

let result = @evalInRealm(this, evalStr)
return @wrap(result);
}

function importValue(module, binding)
{
let bindingStr = binding.toString();
let lookupBinding = (m) => {
if (bindingStr in m) {
return @wrap(m[bindingStr]);
Comment on lines +58 to +59

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to do this prop check/lookup?

}

@throwTypeError("import value doesn't exist");
};
return @importInRealm(this, module).then(lookupBinding);
}
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/bytecode/LinkTimeConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class JSGlobalObject;
v(instanceOf, nullptr) \
v(BuiltinLog, nullptr) \
v(BuiltinDescribe, nullptr) \
v(ShadowRealm, nullptr) \
v(RegExp, nullptr) \
v(min, nullptr) \
v(trunc, nullptr) \
Expand All @@ -78,6 +79,8 @@ class JSGlobalObject;
v(hostPromiseRejectionTracker, nullptr) \
v(Set, nullptr) \
v(thisTimeValue, nullptr) \
v(importInRealm, nullptr) \
v(evalInRealm, nullptr) \
v(isConstructor, nullptr) \
v(sameValue, nullptr) \
v(regExpProtoFlagsGetter, nullptr) \
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5094,7 +5094,7 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres
newCount--;
next();
} else {
failIfTrue(match(IDENT), "\"new.\" can only followed with target");
failIfTrue(match(IDENT), "\"new.\" can only be followed with target");
failDueToUnexpectedToken();
}
}
Expand Down Expand Up @@ -5129,7 +5129,7 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres
base = context.createImportMetaExpr(location, createResolveAndUseVariable(context, &m_vm.propertyNames->metaPrivateName, false, expressionStart, location));
next();
} else {
failIfTrue(match(IDENT), "\"import.\" can only followed with meta");
failIfTrue(match(IDENT), "\"import.\" can only be followed with meta");
failDueToUnexpectedToken();
}
} else {
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/runtime/CommonIdentifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
macro(Object) \
macro(PluralRules) \
macro(Promise) \
macro(ShadowRealm) \
macro(Reflect) \
macro(RegExp) \
macro(RelativeTimeFormat) \
Expand Down
29 changes: 28 additions & 1 deletion Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
#include "ProxyConstructor.h"
#include "ProxyObject.h"
#include "ProxyRevoke.h"
#include "ShadowRealmConstructor.h"
#include "ShadowRealmObject.h"
#include "ShadowRealmPrototype.h"
#include "ReflectObject.h"
#include "RegExpConstructor.h"
#include "RegExpMatchesArray.h"
Expand Down Expand Up @@ -914,6 +917,9 @@ void JSGlobalObject::init(VM& vm)
for (unsigned i = 0; i < NumberOfArrayIndexingModes; ++i)
m_arrayStructureForIndexingShapeDuringAllocation[i] = m_originalArrayStructureForIndexingShape[i];

m_shadowRealmPrototype.set(vm, this, ShadowRealmPrototype::create(vm, ShadowRealmPrototype::createStructure(vm, this, m_objectPrototype.get())));
m_shadowRealmStructure.set(vm, this, ShadowRealmObject::createStructure(vm, this, m_shadowRealmPrototype.get()));

m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get())));
m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, this));
Expand Down Expand Up @@ -1018,7 +1024,11 @@ void JSGlobalObject::init(VM& vm)
ArrayConstructor* arrayConstructor = ArrayConstructor::create(vm, this, ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayPrototype.get(), m_speciesGetterSetter.get());
m_arrayConstructor.set(vm, this, arrayConstructor);
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::Array)].set(vm, this, arrayConstructor);


ShadowRealmConstructor* shadowRealmConstructor = ShadowRealmConstructor::create(vm, ShadowRealmConstructor::createStructure(vm, this, m_functionPrototype.get()), m_shadowRealmPrototype.get(), m_speciesGetterSetter.get());
m_shadowRealmConstructor.set(vm, this, shadowRealmConstructor);
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::ShadowRealm)].set(vm, this, shadowRealmConstructor);

RegExpConstructor* regExpConstructor = RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get(), m_speciesGetterSetter.get());
m_regExpConstructor.set(vm, this, regExpConstructor);
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::RegExp)].set(vm, this, regExpConstructor);
Expand Down Expand Up @@ -1098,6 +1108,7 @@ capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName
m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, regExpConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
m_shadowRealmPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, shadowRealmConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));

putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
Expand Down Expand Up @@ -1242,6 +1253,7 @@ capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName
TemporalObject* temporal = TemporalObject::create(vm, TemporalObject::createStructure(vm, this));
putDirectWithoutTransition(vm, vm.propertyNames->Temporal, temporal, static_cast<unsigned>(PropertyAttribute::DontEnum));
}
putDirectWithoutTransition(vm, vm.propertyNames->ShadowRealm, shadowRealmConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));

m_moduleLoader.initLater(
[] (const Initializer<JSModuleLoader>& init) {
Expand Down Expand Up @@ -1417,6 +1429,12 @@ capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::thisTimeValue)].initLater([] (const Initializer<JSCell>& init) {
init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), dateProtoFuncGetTime, DatePrototypeGetTimeIntrinsic));
});
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::importInRealm)].initLater([] (const Initializer<JSCell>& init) {
init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), importInRealm));
});
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::evalInRealm)].initLater([] (const Initializer<JSCell>& init) {
init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), evalInRealm));
});
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::sameValue)].initLater([] (const Initializer<JSCell>& init) {
init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 2, String(), objectConstructorIs, ObjectIsIntrinsic));
});
Expand Down Expand Up @@ -2098,6 +2116,7 @@ void JSGlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_URIErrorStructure.visit(visitor);
thisObject->m_aggregateErrorStructure.visit(visitor);
visitor.append(thisObject->m_arrayConstructor);
visitor.append(thisObject->m_shadowRealmConstructor);
visitor.append(thisObject->m_regExpConstructor);
visitor.append(thisObject->m_objectConstructor);
visitor.append(thisObject->m_functionConstructor);
Expand Down Expand Up @@ -2194,6 +2213,7 @@ void JSGlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_customSetterFunctionStructure.visit(visitor);
thisObject->m_boundFunctionStructure.visit(visitor);
thisObject->m_nativeStdFunctionStructure.visit(visitor);
visitor.append(thisObject->m_shadowRealmStructure);
visitor.append(thisObject->m_regExpStructure);
visitor.append(thisObject->m_generatorFunctionStructure);
visitor.append(thisObject->m_asyncFunctionStructure);
Expand Down Expand Up @@ -2550,6 +2570,13 @@ JSGlobalObject* JSGlobalObject::create(VM& vm, Structure* structure)
return globalObject;
}

JSGlobalObject* JSGlobalObject::create(VM& vm, Structure* structure, const GlobalObjectMethodTable* methodTable)
{
JSGlobalObject* globalObject = new (NotNull, allocateCell<JSGlobalObject>(vm.heap)) JSGlobalObject(vm, structure, methodTable);
globalObject->finishCreation(vm);
return globalObject;
}
Comment on lines +2573 to +2578

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the best way I could think of creating a new global object with a custom method table. We grab the method table from the original global object in https://github.com/WebKit/WebKit/pull/8/files#diff-44ebd0942590c3af4f75c8833b1b8f2dd9d649fd9e7dcc7a9e1410df5711c22fR33, which might be defined in jsc.cpp or elsewhere in webkit when run in the browser context.


void JSGlobalObject::finishCreation(VM& vm)
{
DeferTermination deferTermination(vm);
Expand Down
8 changes: 8 additions & 0 deletions Source/JavaScriptCore/runtime/JSGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class NullSetterFunction;
class ObjectConstructor;
class ProgramCodeBlock;
class ProgramExecutable;
class ShadowRealmConstructor;
class ShadowRealmPrototype;
class RegExpConstructor;
class RegExpPrototype;
class SetIteratorPrototype;
Expand Down Expand Up @@ -306,6 +308,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {

WriteBarrier<ObjectConstructor> m_objectConstructor;
WriteBarrier<ArrayConstructor> m_arrayConstructor;
WriteBarrier<ShadowRealmConstructor> m_shadowRealmConstructor;
WriteBarrier<RegExpConstructor> m_regExpConstructor;
WriteBarrier<FunctionConstructor> m_functionConstructor;
WriteBarrier<JSPromiseConstructor> m_promiseConstructor;
Expand Down Expand Up @@ -352,6 +355,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {
WriteBarrier<ObjectPrototype> m_objectPrototype;
WriteBarrier<FunctionPrototype> m_functionPrototype;
WriteBarrier<ArrayPrototype> m_arrayPrototype;
WriteBarrier<ShadowRealmPrototype> m_shadowRealmPrototype;
WriteBarrier<RegExpPrototype> m_regExpPrototype;
WriteBarrier<IteratorPrototype> m_iteratorPrototype;
WriteBarrier<AsyncIteratorPrototype> m_asyncIteratorPrototype;
Expand Down Expand Up @@ -408,6 +412,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {
LazyProperty<JSGlobalObject, Structure> m_customSetterFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_nativeStdFunctionStructure;
PropertyOffset m_functionNameOffset;
WriteBarrier<Structure> m_shadowRealmStructure;
WriteBarrier<Structure> m_regExpStructure;
WriteBarrier<AsyncFunctionPrototype> m_asyncFunctionPrototype;
WriteBarrier<AsyncGeneratorFunctionPrototype> m_asyncGeneratorFunctionPrototype;
Expand Down Expand Up @@ -609,6 +614,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {
}

JS_EXPORT_PRIVATE static JSGlobalObject* create(VM&, Structure*);
JS_EXPORT_PRIVATE static JSGlobalObject* create(VM&, Structure*, const GlobalObjectMethodTable*);

DECLARE_EXPORT_INFO;

Expand Down Expand Up @@ -712,6 +718,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {
BigIntPrototype* bigIntPrototype() const { return m_bigIntPrototype.get(); }
JSObject* datePrototype() const { return m_dateStructure.prototype(this); }
JSObject* symbolPrototype() const { return m_symbolObjectStructure.prototypeInitializedOnMainThread(this); }
ShadowRealmPrototype* shadowRealmPrototype() const { return m_shadowRealmPrototype.get(); }
RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
JSObject* errorPrototype() const { return m_errorStructure.prototype(this); }
IteratorPrototype* iteratorPrototype() const { return m_iteratorPrototype.get(); }
Expand Down Expand Up @@ -829,6 +836,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {
PropertyOffset functionNameOffset() const { return m_functionNameOffset; }
Structure* numberObjectStructure() const { return m_numberObjectStructure.get(this); }
Structure* regExpStructure() const { return m_regExpStructure.get(); }
Structure* shadowRealmStructure() const { return m_shadowRealmStructure.get(); }
Structure* generatorStructure() const { return m_generatorStructure.get(); }
Structure* asyncGeneratorStructure() const { return m_asyncGeneratorStructure.get(); }
Structure* generatorFunctionStructure() const { return m_generatorFunctionStructure.get(); }
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/runtime/JSType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void printInternal(PrintStream& out, JSC::JSType type)
CASE(StringType)
CASE(SymbolType)
CASE(HeapBigIntType)
CASE(ShadowRealmType)
CASE(CustomGetterSetterType)
CASE(APIValueWrapperType)
CASE(NativeExecutableType)
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/runtime/JSType.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum JSType : uint8_t {
// End JSScope types.

ModuleNamespaceObjectType,
ShadowRealmType,
RegExpObjectType,
JSDateType,
ProxyObjectType,
Expand Down
49 changes: 49 additions & 0 deletions Source/JavaScriptCore/runtime/ShadowRealmConstructor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "config.h"
#include "ShadowRealmConstructor.h"

#include "ShadowRealmObject.h"
#include "JSCInlines.h"


namespace JSC {

const ClassInfo ShadowRealmConstructor::s_info = { "Function", &InternalFunction::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ShadowRealmConstructor) };

STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ShadowRealmConstructor);

static JSC_DECLARE_HOST_FUNCTION(callShadowRealm);
static JSC_DECLARE_HOST_FUNCTION(constructWithShadowRealmConstructor);

ShadowRealmConstructor::ShadowRealmConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure, callShadowRealm, constructWithShadowRealmConstructor)
{
}

void ShadowRealmConstructor::finishCreation(VM& vm, ShadowRealmPrototype* shadowRealmPrototype)
{
Base::finishCreation(vm, 0, vm.propertyNames->ShadowRealm.string(), PropertyAdditionMode::WithoutStructureTransition);
putDirectWithoutTransition(vm, vm.propertyNames->prototype, shadowRealmPrototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
}

JSObject* constructShadowRealm(JSGlobalObject* globalObject, JSValue, const ArgList&)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Structure* shadowRealmStructure = ShadowRealmObject::createStructure(vm, globalObject, globalObject->shadowRealmPrototype());
return ShadowRealmObject::create(vm, shadowRealmStructure, globalObject->globalObjectMethodTable());
}

JSC_DEFINE_HOST_FUNCTION(constructWithShadowRealmConstructor, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
ArgList args(callFrame);
return JSValue::encode(constructShadowRealm(globalObject, callFrame->newTarget(), args));
}

JSC_DEFINE_HOST_FUNCTION(callShadowRealm, (JSGlobalObject* globalObject, CallFrame*))
{
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(globalObject, scope, "ShadowRealm"));
}

} // namespace JSC

Loading