summaryrefslogtreecommitdiff
path: root/js/src/vm
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm')
-rw-r--r--js/src/vm/ArgumentsObject.cpp2
-rw-r--r--js/src/vm/ArrayBufferObject.cpp2
-rw-r--r--js/src/vm/Debugger.cpp16
-rw-r--r--js/src/vm/GeneratorObject.cpp10
-rw-r--r--js/src/vm/GlobalObject.cpp40
-rw-r--r--js/src/vm/GlobalObject.h241
-rw-r--r--js/src/vm/RegExpObject.cpp2
-rw-r--r--js/src/vm/SharedArrayObject.cpp3
-rw-r--r--js/src/vm/TypedArrayObject.cpp11
9 files changed, 170 insertions, 157 deletions
diff --git a/js/src/vm/ArgumentsObject.cpp b/js/src/vm/ArgumentsObject.cpp
index 73a9c1ac4b..66e0f40a27 100644
--- a/js/src/vm/ArgumentsObject.cpp
+++ b/js/src/vm/ArgumentsObject.cpp
@@ -214,7 +214,7 @@ ArgumentsObject::createTemplateObject(JSContext* cx, bool mapped)
? &MappedArgumentsObject::class_
: &UnmappedArgumentsObject::class_;
- RootedObject proto(cx, cx->global()->getOrCreateObjectPrototype(cx));
+ RootedObject proto(cx, GlobalObject::getOrCreateObjectPrototype(cx, cx->global()));
if (!proto)
return nullptr;
diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp
index 2c5e2dd256..392724b218 100644
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -140,7 +140,7 @@ static const Class ArrayBufferObjectProtoClass = {
static JSObject*
CreateArrayBufferPrototype(JSContext* cx, JSProtoKey key)
{
- return cx->global()->createBlankPrototype(cx, &ArrayBufferObjectProtoClass);
+ return GlobalObject::createBlankPrototype(cx, cx->global(), &ArrayBufferObjectProtoClass);
}
static const ClassOps ArrayBufferObjectClassOps = {
diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp
index b959740acc..63797be38f 100644
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -7227,8 +7227,8 @@ static const JSFunctionSpec DebuggerSource_methods[] = {
/* static */ NativeObject*
DebuggerFrame::initClass(JSContext* cx, HandleObject dbgCtor, HandleObject obj)
{
- Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
- RootedObject objProto(cx, global->getOrCreateObjectPrototype(cx));
+ Handle<GlobalObject*> global = obj.as<GlobalObject>();
+ RootedObject objProto(cx, GlobalObject::getOrCreateObjectPrototype(cx, global));
return InitClass(cx, dbgCtor, objProto, &class_, construct, 0, properties_,
methods_, nullptr, nullptr);
@@ -9376,8 +9376,8 @@ const JSFunctionSpec DebuggerObject::methods_[] = {
/* static */ NativeObject*
DebuggerObject::initClass(JSContext* cx, HandleObject obj, HandleObject debugCtor)
{
- Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
- RootedObject objProto(cx, global->getOrCreateObjectPrototype(cx));
+ Handle<GlobalObject*> global = obj.as<GlobalObject>();
+ RootedObject objProto(cx, GlobalObject::getOrCreateObjectPrototype(cx, global));
RootedNativeObject objectProto(cx, InitClass(cx, debugCtor, objProto, &class_,
construct, 0, properties_,
@@ -10577,8 +10577,8 @@ const JSFunctionSpec DebuggerEnvironment::methods_[] = {
/* static */ NativeObject*
DebuggerEnvironment::initClass(JSContext* cx, HandleObject dbgCtor, HandleObject obj)
{
- Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
- RootedObject objProto(cx, global->getOrCreateObjectPrototype(cx));
+ Handle<GlobalObject*> global = obj.as<GlobalObject>();
+ RootedObject objProto(cx, GlobalObject::getOrCreateObjectPrototype(cx, global));
return InitClass(cx, dbgCtor, objProto, &DebuggerEnvironment::class_, construct, 0,
properties_, methods_, nullptr, nullptr);
@@ -10943,9 +10943,9 @@ JS_DefineDebuggerObject(JSContext* cx, HandleObject obj)
memoryProto(cx);
RootedObject debuggeeWouldRunProto(cx);
RootedValue debuggeeWouldRunCtor(cx);
- Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
+ Handle<GlobalObject*> global = obj.as<GlobalObject>();
- objProto = global->getOrCreateObjectPrototype(cx);
+ objProto = GlobalObject::getOrCreateObjectPrototype(cx, global);
if (!objProto)
return false;
debugProto = InitClass(cx, obj,
diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp
index 82b774a35f..ba28501e61 100644
--- a/js/src/vm/GeneratorObject.cpp
+++ b/js/src/vm/GeneratorObject.cpp
@@ -256,7 +256,7 @@ static const JSFunctionSpec legacy_generator_methods[] = {
static JSObject*
NewSingletonObjectWithObjectPrototype(JSContext* cx, Handle<GlobalObject*> global)
{
- RootedObject proto(cx, global->getOrCreateObjectPrototype(cx));
+ RootedObject proto(cx, GlobalObject::getOrCreateObjectPrototype(cx, global));
if (!proto)
return nullptr;
return NewObjectWithGivenProto<PlainObject>(cx, proto, SingletonObject);
@@ -265,7 +265,7 @@ NewSingletonObjectWithObjectPrototype(JSContext* cx, Handle<GlobalObject*> globa
JSObject*
js::NewSingletonObjectWithFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global)
{
- RootedObject proto(cx, global->getOrCreateFunctionPrototype(cx));
+ RootedObject proto(cx, GlobalObject::getOrCreateFunctionPrototype(cx, global));
if (!proto)
return nullptr;
return NewObjectWithGivenProto<PlainObject>(cx, proto, SingletonObject);
@@ -297,9 +297,9 @@ GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
if (!iteratorProto)
return false;
- RootedObject genObjectProto(cx, global->createBlankPrototypeInheriting(cx,
- &PlainObject::class_,
- iteratorProto));
+ RootedObject genObjectProto(cx, GlobalObject::createBlankPrototypeInheriting(cx, global,
+ &PlainObject::class_,
+ iteratorProto));
if (!genObjectProto)
return false;
if (!DefinePropertiesAndFunctions(cx, genObjectProto, nullptr, star_generator_methods) ||
diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp
index c431b5f1d6..85707e1c60 100644
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -337,7 +337,7 @@ GlobalObject::createInternal(JSContext* cx, const Class* clasp)
return global;
}
-GlobalObject*
+/* static */ GlobalObject*
GlobalObject::new_(JSContext* cx, const Class* clasp, JSPrincipals* principals,
JS::OnNewGlobalHookOption hookOption,
const JS::CompartmentOptions& options)
@@ -398,7 +398,7 @@ GlobalObject::emptyGlobalScope() const
GlobalObject::getOrCreateEval(JSContext* cx, Handle<GlobalObject*> global,
MutableHandleObject eval)
{
- if (!global->getOrCreateObjectPrototype(cx))
+ if (!getOrCreateObjectPrototype(cx, global))
return false;
eval.set(&global->getSlot(EVAL).toObject());
return true;
@@ -573,7 +573,7 @@ GlobalObject::warnOnceAbout(JSContext* cx, HandleObject obj, WarnOnceFlag flag,
return true;
}
-JSFunction*
+/* static */ JSFunction*
GlobalObject::createConstructor(JSContext* cx, Native ctor, JSAtom* nameArg, unsigned length,
gc::AllocKind kind, const JSJitInfo* jitInfo)
{
@@ -601,22 +601,21 @@ CreateBlankProto(JSContext* cx, const Class* clasp, HandleObject proto, HandleOb
return blankProto;
}
-NativeObject*
-GlobalObject::createBlankPrototype(JSContext* cx, const Class* clasp)
+/* static */ NativeObject*
+GlobalObject::createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global, const Class* clasp)
{
- Rooted<GlobalObject*> self(cx, this);
- RootedObject objectProto(cx, getOrCreateObjectPrototype(cx));
+ RootedObject objectProto(cx, getOrCreateObjectPrototype(cx, global));
if (!objectProto)
return nullptr;
- return CreateBlankProto(cx, clasp, objectProto, self);
+ return CreateBlankProto(cx, clasp, objectProto, global);
}
-NativeObject*
-GlobalObject::createBlankPrototypeInheriting(JSContext* cx, const Class* clasp, HandleObject proto)
+/* static */ NativeObject*
+GlobalObject::createBlankPrototypeInheriting(JSContext* cx, Handle<GlobalObject*> global,
+ const Class* clasp, HandleObject proto)
{
- Rooted<GlobalObject*> self(cx, this);
- return CreateBlankProto(cx, clasp, proto, self);
+ return CreateBlankProto(cx, clasp, proto, global);
}
bool
@@ -729,21 +728,20 @@ GlobalObject::hasRegExpStatics() const
return !getSlot(REGEXP_STATICS).isUndefined();
}
-RegExpStatics*
-GlobalObject::getRegExpStatics(ExclusiveContext* cx) const
+/* static */ RegExpStatics*
+GlobalObject::getRegExpStatics(ExclusiveContext* cx, Handle<GlobalObject*> global)
{
MOZ_ASSERT(cx);
- Rooted<GlobalObject*> self(cx, const_cast<GlobalObject*>(this));
RegExpStaticsObject* resObj = nullptr;
- const Value& val = this->getSlot(REGEXP_STATICS);
+ const Value& val = global->getSlot(REGEXP_STATICS);
if (!val.isObject()) {
MOZ_ASSERT(val.isUndefined());
- resObj = RegExpStatics::create(cx, self);
+ resObj = RegExpStatics::create(cx, global);
if (!resObj)
return nullptr;
- self->initSlot(REGEXP_STATICS, ObjectValue(*resObj));
+ global->initSlot(REGEXP_STATICS, ObjectValue(*resObj));
} else {
resObj = &val.toObject().as<RegExpStaticsObject>();
}
@@ -866,7 +864,7 @@ GlobalObject::addIntrinsicValue(JSContext* cx, Handle<GlobalObject*> global,
/* static */ bool
GlobalObject::ensureModulePrototypesCreated(JSContext *cx, Handle<GlobalObject*> global)
{
- return global->getOrCreateObject(cx, MODULE_PROTO, initModuleProto) &&
- global->getOrCreateObject(cx, IMPORT_ENTRY_PROTO, initImportEntryProto) &&
- global->getOrCreateObject(cx, EXPORT_ENTRY_PROTO, initExportEntryProto);
+ return getOrCreateObject(cx, global, MODULE_PROTO, initModuleProto) &&
+ getOrCreateObject(cx, global, IMPORT_ENTRY_PROTO, initImportEntryProto) &&
+ getOrCreateObject(cx, global, EXPORT_ENTRY_PROTO, initExportEntryProto);
}
diff --git a/js/src/vm/GlobalObject.h b/js/src/vm/GlobalObject.h
index 3534ef2f6c..5aacfc5dcd 100644
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -290,8 +290,8 @@ class GlobalObject : public NativeObject
* Create a constructor function with the specified name and length using
* ctor, a method which creates objects with the given class.
*/
- JSFunction*
- createConstructor(JSContext* cx, JSNative ctor, JSAtom* name, unsigned length,
+ static JSFunction*
+ createConstructor(JSContext* cx, JSNative ctor, JSAtom* name, unsigned length,
gc::AllocKind kind = gc::AllocKind::FUNCTION,
const JSJitInfo* jitInfo = nullptr);
@@ -303,48 +303,44 @@ class GlobalObject : public NativeObject
* complete the minimal initialization to make the returned object safe to
* touch.
*/
- NativeObject* createBlankPrototype(JSContext* cx, const js::Class* clasp);
+ static NativeObject*
+ createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global, const js::Class* clasp);
/*
* Identical to createBlankPrototype, but uses proto as the [[Prototype]]
* of the returned blank prototype.
*/
- NativeObject* createBlankPrototypeInheriting(JSContext* cx, const js::Class* clasp,
- HandleObject proto);
+ static NativeObject*
+ createBlankPrototypeInheriting(JSContext* cx, Handle<GlobalObject*> global,
+ const js::Class* clasp, HandleObject proto);
template <typename T>
- T* createBlankPrototype(JSContext* cx) {
- NativeObject* res = createBlankPrototype(cx, &T::class_);
+ static T*
+ createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ NativeObject* res = createBlankPrototype(cx, global, &T::class_);
return res ? &res->template as<T>() : nullptr;
}
- NativeObject* getOrCreateObjectPrototype(JSContext* cx) {
- if (functionObjectClassesInitialized())
- return &getPrototype(JSProto_Object).toObject().as<NativeObject>();
- RootedGlobalObject self(cx, this);
- if (!ensureConstructor(cx, self, JSProto_Object))
+ static NativeObject*
+ getOrCreateObjectPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ if (global->functionObjectClassesInitialized())
+ return &global->getPrototype(JSProto_Object).toObject().as<NativeObject>();
+ if (!ensureConstructor(cx, global, JSProto_Object))
return nullptr;
- return &self->getPrototype(JSProto_Object).toObject().as<NativeObject>();
- }
-
- static NativeObject* getOrCreateObjectPrototype(JSContext* cx, Handle<GlobalObject*> global) {
- return global->getOrCreateObjectPrototype(cx);
+ return &global->getPrototype(JSProto_Object).toObject().as<NativeObject>();
}
- NativeObject* getOrCreateFunctionPrototype(JSContext* cx) {
- if (functionObjectClassesInitialized())
- return &getPrototype(JSProto_Function).toObject().as<NativeObject>();
- RootedGlobalObject self(cx, this);
- if (!ensureConstructor(cx, self, JSProto_Object))
+ static NativeObject*
+ getOrCreateFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ if (global->functionObjectClassesInitialized())
+ return &global->getPrototype(JSProto_Function).toObject().as<NativeObject>();
+ if (!ensureConstructor(cx, global, JSProto_Object))
return nullptr;
- return &self->getPrototype(JSProto_Function).toObject().as<NativeObject>();
- }
-
- static NativeObject* getOrCreateFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
- return global->getOrCreateFunctionPrototype(cx);
+ return &global->getPrototype(JSProto_Function).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateArrayPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateArrayPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Array))
return nullptr;
return &global->getPrototype(JSProto_Array).toObject().as<NativeObject>();
@@ -356,37 +352,43 @@ class GlobalObject : public NativeObject
return nullptr;
}
- static NativeObject* getOrCreateBooleanPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateBooleanPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Boolean))
return nullptr;
return &global->getPrototype(JSProto_Boolean).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateNumberPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateNumberPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Number))
return nullptr;
return &global->getPrototype(JSProto_Number).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateStringPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateStringPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_String))
return nullptr;
return &global->getPrototype(JSProto_String).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateSymbolPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateSymbolPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Symbol))
return nullptr;
return &global->getPrototype(JSProto_Symbol).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreatePromisePrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreatePromisePrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Promise))
return nullptr;
return &global->getPrototype(JSProto_Promise).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateRegExpPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateRegExpPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_RegExp))
return nullptr;
return &global->getPrototype(JSProto_RegExp).toObject().as<NativeObject>();
@@ -398,28 +400,30 @@ class GlobalObject : public NativeObject
return nullptr;
}
- static NativeObject* getOrCreateSavedFramePrototype(JSContext* cx,
- Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateSavedFramePrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_SavedFrame))
return nullptr;
return &global->getPrototype(JSProto_SavedFrame).toObject().as<NativeObject>();
}
- static JSObject* getOrCreateArrayBufferPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static JSObject*
+ getOrCreateArrayBufferPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_ArrayBuffer))
return nullptr;
return &global->getPrototype(JSProto_ArrayBuffer).toObject();
}
- JSObject* getOrCreateSharedArrayBufferPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static JSObject*
+ getOrCreateSharedArrayBufferPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_SharedArrayBuffer))
return nullptr;
return &global->getPrototype(JSProto_SharedArrayBuffer).toObject();
}
- static JSObject* getOrCreateCustomErrorPrototype(JSContext* cx,
- Handle<GlobalObject*> global,
- JSExnType exnType)
+ static JSObject*
+ getOrCreateCustomErrorPrototype(JSContext* cx, Handle<GlobalObject*> global,
+ JSExnType exnType)
{
JSProtoKey key = GetExceptionProtoKey(exnType);
if (!ensureConstructor(cx, global, key))
@@ -439,35 +443,41 @@ class GlobalObject : public NativeObject
return getOrCreateCustomErrorPrototype(cx, global, JSEXN_ERR);
}
- static NativeObject* getOrCreateSetPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateSetPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_Set))
return nullptr;
return &global->getPrototype(JSProto_Set).toObject().as<NativeObject>();
}
- static NativeObject* getOrCreateWeakSetPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ static NativeObject*
+ getOrCreateWeakSetPrototype(JSContext* cx, Handle<GlobalObject*> global) {
if (!ensureConstructor(cx, global, JSProto_WeakSet))
return nullptr;
return &global->getPrototype(JSProto_WeakSet).toObject().as<NativeObject>();
}
- JSObject* getOrCreateIntlObject(JSContext* cx) {
- return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_Intl, initIntlObject);
+ static JSObject*
+ getOrCreateIntlObject(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, APPLICATION_SLOTS + JSProto_Intl, initIntlObject);
}
- JSObject* getOrCreateTypedObjectModule(JSContext* cx) {
- return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_TypedObject, initTypedObjectModule);
+ static JSObject*
+ getOrCreateTypedObjectModule(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, APPLICATION_SLOTS + JSProto_TypedObject,
+ initTypedObjectModule);
}
- JSObject* getOrCreateSimdGlobalObject(JSContext* cx) {
- return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_SIMD, initSimdObject);
+ static JSObject*
+ getOrCreateSimdGlobalObject(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, APPLICATION_SLOTS + JSProto_SIMD, initSimdObject);
}
// Get the type descriptor for one of the SIMD types.
// simdType is one of the JS_SIMDTYPEREPR_* constants.
// Implemented in builtin/SIMD.cpp.
- static SimdTypeDescr* getOrCreateSimdTypeDescr(JSContext* cx, Handle<GlobalObject*> global,
- SimdType simdType);
+ static SimdTypeDescr*
+ getOrCreateSimdTypeDescr(JSContext* cx, Handle<GlobalObject*> global, SimdType simdType);
TypedObjectModuleObject& getTypedObjectModule() const;
@@ -475,16 +485,19 @@ class GlobalObject : public NativeObject
return &getPrototype(JSProto_Iterator).toObject();
}
- JSObject* getOrCreateCollatorPrototype(JSContext* cx) {
- return getOrCreateObject(cx, COLLATOR_PROTO, initIntlObject);
+ static JSObject*
+ getOrCreateCollatorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, COLLATOR_PROTO, initIntlObject);
}
- JSObject* getOrCreateNumberFormatPrototype(JSContext* cx) {
- return getOrCreateObject(cx, NUMBER_FORMAT_PROTO, initIntlObject);
+ static JSObject*
+ getOrCreateNumberFormatPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, NUMBER_FORMAT_PROTO, initIntlObject);
}
- JSObject* getOrCreateDateTimeFormatPrototype(JSContext* cx) {
- return getOrCreateObject(cx, DATE_TIME_FORMAT_PROTO, initIntlObject);
+ static JSObject*
+ getOrCreateDateTimeFormatPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, DATE_TIME_FORMAT_PROTO, initIntlObject);
}
static bool ensureModulePrototypesCreated(JSContext *cx, Handle<GlobalObject*> global);
@@ -539,88 +552,86 @@ class GlobalObject : public NativeObject
private:
typedef bool (*ObjectInitOp)(JSContext* cx, Handle<GlobalObject*> global);
- JSObject* getOrCreateObject(JSContext* cx, unsigned slot, ObjectInitOp init) {
- Value v = getSlotRef(slot);
+ static JSObject*
+ getOrCreateObject(JSContext* cx, Handle<GlobalObject*> global, unsigned slot,
+ ObjectInitOp init)
+ {
+ Value v = global->getSlotRef(slot);
if (v.isObject())
return &v.toObject();
- RootedGlobalObject self(cx, this);
- if (!init(cx, self))
+ if (!init(cx, global))
return nullptr;
- return &self->getSlot(slot).toObject();
+ return &global->getSlot(slot).toObject();
}
public:
- static NativeObject* getOrCreateIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, ITERATOR_PROTO, initIteratorProto));
+ static NativeObject*
+ getOrCreateIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, ITERATOR_PROTO, initIteratorProto));
}
- static NativeObject* getOrCreateArrayIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, ARRAY_ITERATOR_PROTO, initArrayIteratorProto));
+ static NativeObject*
+ getOrCreateArrayIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, ARRAY_ITERATOR_PROTO,
+ initArrayIteratorProto));
}
- static NativeObject* getOrCreateStringIteratorPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, STRING_ITERATOR_PROTO, initStringIteratorProto));
+ static NativeObject*
+ getOrCreateStringIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, STRING_ITERATOR_PROTO,
+ initStringIteratorProto));
}
- static NativeObject* getOrCreateLegacyGeneratorObjectPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, LEGACY_GENERATOR_OBJECT_PROTO,
- initLegacyGeneratorProto));
+ static NativeObject*
+ getOrCreateLegacyGeneratorObjectPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, LEGACY_GENERATOR_OBJECT_PROTO,
+ initLegacyGeneratorProto));
}
- static NativeObject* getOrCreateStarGeneratorObjectPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
+ static NativeObject*
+ getOrCreateStarGeneratorObjectPrototype(JSContext* cx, Handle<GlobalObject*> global)
{
- return MaybeNativeObject(global->getOrCreateObject(cx, STAR_GENERATOR_OBJECT_PROTO, initStarGenerators));
+ return MaybeNativeObject(getOrCreateObject(cx, global, STAR_GENERATOR_OBJECT_PROTO,
+ initStarGenerators));
}
- static NativeObject* getOrCreateStarGeneratorFunctionPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, STAR_GENERATOR_FUNCTION_PROTO, initStarGenerators));
+ static NativeObject*
+ getOrCreateStarGeneratorFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, STAR_GENERATOR_FUNCTION_PROTO,
+ initStarGenerators));
}
- static JSObject* getOrCreateStarGeneratorFunction(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return global->getOrCreateObject(cx, STAR_GENERATOR_FUNCTION, initStarGenerators);
+ static JSObject*
+ getOrCreateStarGeneratorFunction(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, STAR_GENERATOR_FUNCTION, initStarGenerators);
}
- static NativeObject* getOrCreateAsyncFunctionPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return MaybeNativeObject(global->getOrCreateObject(cx, ASYNC_FUNCTION_PROTO,
- initAsyncFunction));
+ static NativeObject*
+ getOrCreateAsyncFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return MaybeNativeObject(getOrCreateObject(cx, global, ASYNC_FUNCTION_PROTO,
+ initAsyncFunction));
}
- static JSObject* getOrCreateAsyncFunction(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return global->getOrCreateObject(cx, ASYNC_FUNCTION, initAsyncFunction);
+ static JSObject*
+ getOrCreateAsyncFunction(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, ASYNC_FUNCTION, initAsyncFunction);
}
- static JSObject* getOrCreateMapIteratorPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return global->getOrCreateObject(cx, MAP_ITERATOR_PROTO, initMapIteratorProto);
+ static JSObject*
+ getOrCreateMapIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, MAP_ITERATOR_PROTO, initMapIteratorProto);
}
- static JSObject* getOrCreateSetIteratorPrototype(JSContext* cx,
- Handle<GlobalObject*> global)
- {
- return global->getOrCreateObject(cx, SET_ITERATOR_PROTO, initSetIteratorProto);
+ static JSObject*
+ getOrCreateSetIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ return getOrCreateObject(cx, global, SET_ITERATOR_PROTO, initSetIteratorProto);
}
- JSObject* getOrCreateDataViewPrototype(JSContext* cx) {
- RootedGlobalObject self(cx, this);
- if (!ensureConstructor(cx, self, JSProto_DataView))
+ static JSObject*
+ getOrCreateDataViewPrototype(JSContext* cx, Handle<GlobalObject*> global) {
+ if (!ensureConstructor(cx, global, JSProto_DataView))
return nullptr;
- return &self->getPrototype(JSProto_DataView).toObject();
+ return &global->getPrototype(JSProto_DataView).toObject();
}
static JSFunction*
@@ -678,8 +689,9 @@ class GlobalObject : public NativeObject
return true;
}
- static bool getIntrinsicValue(JSContext* cx, Handle<GlobalObject*> global,
- HandlePropertyName name, MutableHandleValue value)
+ static bool
+ getIntrinsicValue(JSContext* cx, Handle<GlobalObject*> global,
+ HandlePropertyName name, MutableHandleValue value)
{
bool exists = false;
if (!GlobalObject::maybeGetIntrinsicValue(cx, global, name, value, &exists))
@@ -709,7 +721,8 @@ class GlobalObject : public NativeObject
unsigned nargs, MutableHandleValue funVal);
bool hasRegExpStatics() const;
- RegExpStatics* getRegExpStatics(ExclusiveContext* cx) const;
+ static RegExpStatics* getRegExpStatics(ExclusiveContext* cx,
+ Handle<GlobalObject*> global);
RegExpStatics* getAlreadyCreatedRegExpStatics() const;
JSObject* getThrowTypeError() const {
@@ -996,7 +1009,7 @@ GenericCreateConstructor(JSContext* cx, JSProtoKey key)
// Note - We duplicate the trick from ClassName() so that we don't need to
// include jsatominlines.h here.
PropertyName* name = (&cx->names().Null)[key];
- return cx->global()->createConstructor(cx, ctor, name, length, kind, jitInfo);
+ return GlobalObject::createConstructor(cx, ctor, name, length, kind, jitInfo);
}
inline JSObject*
@@ -1009,7 +1022,7 @@ GenericCreatePrototype(JSContext* cx, JSProtoKey key)
if (!GlobalObject::ensureConstructor(cx, cx->global(), protoKey))
return nullptr;
RootedObject parentProto(cx, &cx->global()->getPrototype(protoKey).toObject());
- return cx->global()->createBlankPrototypeInheriting(cx, clasp, parentProto);
+ return GlobalObject::createBlankPrototypeInheriting(cx, cx->global(), clasp, parentProto);
}
inline JSProtoKey
diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp
index e0b44e1eb7..6bd7de3010 100644
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -199,7 +199,7 @@ RegExpObject::trace(JSTracer* trc, JSObject* obj)
static JSObject*
CreateRegExpPrototype(JSContext* cx, JSProtoKey key)
{
- return cx->global()->createBlankPrototype(cx, &RegExpObject::protoClass_);
+ return GlobalObject::createBlankPrototype(cx, cx->global(), &RegExpObject::protoClass_);
}
static const ClassOps RegExpObjectClassOps = {
diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp
index c69306aaca..0dff412017 100644
--- a/js/src/vm/SharedArrayObject.cpp
+++ b/js/src/vm/SharedArrayObject.cpp
@@ -366,7 +366,8 @@ static const Class SharedArrayBufferObjectProtoClass = {
static JSObject*
CreateSharedArrayBufferPrototype(JSContext* cx, JSProtoKey key)
{
- return cx->global()->createBlankPrototype(cx, &SharedArrayBufferObjectProtoClass);
+ return GlobalObject::createBlankPrototype(cx, cx->global(),
+ &SharedArrayBufferObjectProtoClass);
}
static const ClassOps SharedArrayBufferObjectClassOps = {
diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp
index ae97be0de0..8b03029174 100644
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -361,7 +361,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
return nullptr;
const Class* clasp = TypedArrayObject::protoClassForType(ArrayTypeID());
- return global->createBlankPrototypeInheriting(cx, clasp, typedArrayProto);
+ return GlobalObject::createBlankPrototypeInheriting(cx, global, clasp, typedArrayProto);
}
static JSObject*
@@ -1892,7 +1892,7 @@ DataViewObject::constructWrapped(JSContext* cx, HandleObject bufobj, const CallA
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
if (!proto) {
- proto = global->getOrCreateDataViewPrototype(cx);
+ proto = GlobalObject::getOrCreateDataViewPrototype(cx, global);
if (!proto)
return false;
}
@@ -2892,12 +2892,13 @@ DataViewObject::initClass(JSContext* cx)
if (global->isStandardClassResolved(JSProto_DataView))
return true;
- RootedNativeObject proto(cx, global->createBlankPrototype(cx, &DataViewObject::protoClass));
+ RootedNativeObject proto(cx, GlobalObject::createBlankPrototype(cx, global,
+ &DataViewObject::protoClass));
if (!proto)
return false;
- RootedFunction ctor(cx, global->createConstructor(cx, DataViewObject::class_constructor,
- cx->names().DataView, 3));
+ RootedFunction ctor(cx, GlobalObject::createConstructor(cx, DataViewObject::class_constructor,
+ cx->names().DataView, 3));
if (!ctor)
return false;