Bug 1688055 - Part 6: Reorder definitions in EnvironmentObject.cpp to match declaration order. r=mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D106523
This commit is contained in:
Jason Orendorff 2021-03-04 11:00:40 +00:00
parent a9b4196135
commit af216cca1c

View File

@ -911,6 +911,14 @@ bool js::CreateNonSyntacticEnvironmentChain(JSContext* cx,
/*****************************************************************************/ /*****************************************************************************/
const JSClass LexicalEnvironmentObject::class_ = {
"LexicalEnvironment",
JSCLASS_HAS_RESERVED_SLOTS(LexicalEnvironmentObject::RESERVED_SLOTS),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS};
/* static */ /* static */
LexicalEnvironmentObject* LexicalEnvironmentObject::createTemplateObject( LexicalEnvironmentObject* LexicalEnvironmentObject::createTemplateObject(
JSContext* cx, HandleShape shape, HandleObject enclosing, JSContext* cx, HandleShape shape, HandleObject enclosing,
@ -935,6 +943,10 @@ LexicalEnvironmentObject* LexicalEnvironmentObject::createTemplateObject(
return env; return env;
} }
bool LexicalEnvironmentObject::isExtensible() const {
return NativeObject::isExtensible();
}
/* static */ /* static */
BlockLexicalEnvironmentObject* BlockLexicalEnvironmentObject::create( BlockLexicalEnvironmentObject* BlockLexicalEnvironmentObject::create(
JSContext* cx, Handle<LexicalScope*> scope, HandleObject enclosing, JSContext* cx, Handle<LexicalScope*> scope, HandleObject enclosing,
@ -967,50 +979,6 @@ BlockLexicalEnvironmentObject* BlockLexicalEnvironmentObject::createForFrame(
return create(cx, scope, enclosing, gc::DefaultHeap); return create(cx, scope, enclosing, gc::DefaultHeap);
} }
/* static */
GlobalLexicalEnvironmentObject* GlobalLexicalEnvironmentObject::create(
JSContext* cx, Handle<GlobalObject*> global) {
MOZ_ASSERT(global);
RootedShape shape(cx, LexicalScope::getEmptyExtensibleEnvironmentShape(cx));
if (!shape) {
return nullptr;
}
auto* env = static_cast<GlobalLexicalEnvironmentObject*>(
createTemplateObject(cx, shape, global, gc::TenuredHeap));
if (!env) {
return nullptr;
}
env->initThisObject(global);
return env;
}
/* static */
NonSyntacticLexicalEnvironmentObject*
NonSyntacticLexicalEnvironmentObject::create(JSContext* cx,
HandleObject enclosing,
HandleObject thisv) {
MOZ_ASSERT(enclosing);
MOZ_ASSERT(!IsSyntacticEnvironment(enclosing));
RootedShape shape(cx, LexicalScope::getEmptyExtensibleEnvironmentShape(cx));
if (!shape) {
return nullptr;
}
auto* env = static_cast<NonSyntacticLexicalEnvironmentObject*>(
createTemplateObject(cx, shape, enclosing, gc::TenuredHeap));
if (!env) {
return nullptr;
}
env->initThisObject(thisv);
return env;
}
/* static */ /* static */
BlockLexicalEnvironmentObject* BlockLexicalEnvironmentObject*
BlockLexicalEnvironmentObject::createHollowForDebug( BlockLexicalEnvironmentObject::createHollowForDebug(
@ -1081,37 +1049,6 @@ BlockLexicalEnvironmentObject* BlockLexicalEnvironmentObject::recreate(
return create(cx, scope, enclosing, gc::DefaultHeap); return create(cx, scope, enclosing, gc::DefaultHeap);
} }
bool LexicalEnvironmentObject::isExtensible() const {
return NativeObject::isExtensible();
}
JSObject* ExtensibleLexicalEnvironmentObject::thisObject() const {
JSObject* obj = &getReservedSlot(THIS_VALUE_OR_SCOPE_SLOT).toObject();
// Windows must never be exposed to script. setWindowProxyThisValue should
// have set this to the WindowProxy.
MOZ_ASSERT(!IsWindow(obj));
// WarpBuilder relies on the return value not being nursery-allocated for the
// global lexical environment.
MOZ_ASSERT_IF(isGlobal(), obj->isTenured());
return obj;
}
void GlobalLexicalEnvironmentObject::setWindowProxyThisObject(JSObject* obj) {
MOZ_ASSERT(IsWindowProxy(obj));
setReservedSlot(THIS_VALUE_OR_SCOPE_SLOT, ObjectValue(*obj));
}
const JSClass LexicalEnvironmentObject::class_ = {
"LexicalEnvironment",
JSCLASS_HAS_RESERVED_SLOTS(LexicalEnvironmentObject::RESERVED_SLOTS),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS};
/* static */ /* static */
NamedLambdaObject* NamedLambdaObject::create(JSContext* cx, NamedLambdaObject* NamedLambdaObject::create(JSContext* cx,
HandleFunction callee, HandleFunction callee,
@ -1161,6 +1098,69 @@ size_t NamedLambdaObject::lambdaSlot() {
return JSSLOT_FREE(&LexicalEnvironmentObject::class_); return JSSLOT_FREE(&LexicalEnvironmentObject::class_);
} }
JSObject* ExtensibleLexicalEnvironmentObject::thisObject() const {
JSObject* obj = &getReservedSlot(THIS_VALUE_OR_SCOPE_SLOT).toObject();
// Windows must never be exposed to script. setWindowProxyThisValue should
// have set this to the WindowProxy.
MOZ_ASSERT(!IsWindow(obj));
// WarpBuilder relies on the return value not being nursery-allocated for the
// global lexical environment.
MOZ_ASSERT_IF(isGlobal(), obj->isTenured());
return obj;
}
/* static */
GlobalLexicalEnvironmentObject* GlobalLexicalEnvironmentObject::create(
JSContext* cx, Handle<GlobalObject*> global) {
MOZ_ASSERT(global);
RootedShape shape(cx, LexicalScope::getEmptyExtensibleEnvironmentShape(cx));
if (!shape) {
return nullptr;
}
auto* env = static_cast<GlobalLexicalEnvironmentObject*>(
createTemplateObject(cx, shape, global, gc::TenuredHeap));
if (!env) {
return nullptr;
}
env->initThisObject(global);
return env;
}
void GlobalLexicalEnvironmentObject::setWindowProxyThisObject(JSObject* obj) {
MOZ_ASSERT(IsWindowProxy(obj));
setReservedSlot(THIS_VALUE_OR_SCOPE_SLOT, ObjectValue(*obj));
}
/* static */
NonSyntacticLexicalEnvironmentObject*
NonSyntacticLexicalEnvironmentObject::create(JSContext* cx,
HandleObject enclosing,
HandleObject thisv) {
MOZ_ASSERT(enclosing);
MOZ_ASSERT(!IsSyntacticEnvironment(enclosing));
RootedShape shape(cx, LexicalScope::getEmptyExtensibleEnvironmentShape(cx));
if (!shape) {
return nullptr;
}
auto* env = static_cast<NonSyntacticLexicalEnvironmentObject*>(
createTemplateObject(cx, shape, enclosing, gc::TenuredHeap));
if (!env) {
return nullptr;
}
env->initThisObject(thisv);
return env;
}
/* static */ /* static */
RuntimeLexicalErrorObject* RuntimeLexicalErrorObject::create( RuntimeLexicalErrorObject* RuntimeLexicalErrorObject::create(
JSContext* cx, HandleObject enclosing, unsigned errorNumber) { JSContext* cx, HandleObject enclosing, unsigned errorNumber) {