mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1165486 - Cleanup: use standard object allocation functions when allocating scope objects. (r=terrence)
This commit is contained in:
parent
b5d8533f3c
commit
c137a94660
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
#include "jit/SharedICHelpers.h"
|
||||
#include "jit/VMFunctions.h"
|
||||
#include "vm/ScopeObject.h"
|
||||
#include "vm/TraceLogging.h"
|
||||
|
||||
#include "jsscriptinlines.h"
|
||||
@ -128,7 +129,7 @@ BaselineCompiler::compile()
|
||||
return Method_Error;
|
||||
|
||||
if (fun->isNamedLambda()) {
|
||||
RootedObject declEnvObject(cx, DeclEnvObject::createTemplateObject(cx, fun, gc::TenuredHeap));
|
||||
RootedObject declEnvObject(cx, DeclEnvObject::createTemplateObject(cx, fun, TenuredObject));
|
||||
if (!declEnvObject)
|
||||
return Method_Error;
|
||||
templateScope->as<ScopeObject>().setEnclosingScope(declEnvObject);
|
||||
|
@ -4686,7 +4686,7 @@ CodeGenerator::visitSimdUnbox(LSimdUnbox* lir)
|
||||
bailoutFrom(&bail, lir->snapshot());
|
||||
}
|
||||
|
||||
typedef js::DeclEnvObject* (*NewDeclEnvObjectFn)(JSContext*, HandleFunction, gc::InitialHeap);
|
||||
typedef js::DeclEnvObject* (*NewDeclEnvObjectFn)(JSContext*, HandleFunction, NewObjectKind);
|
||||
static const VMFunction NewDeclEnvObjectInfo =
|
||||
FunctionInfo<NewDeclEnvObjectFn>(DeclEnvObject::createTemplateObject);
|
||||
|
||||
@ -4700,7 +4700,7 @@ CodeGenerator::visitNewDeclEnvObject(LNewDeclEnvObject* lir)
|
||||
|
||||
// If we have a template object, we can inline call object creation.
|
||||
OutOfLineCode* ool = oolCallVM(NewDeclEnvObjectInfo, lir,
|
||||
ArgList(ImmGCPtr(info.funMaybeLazy()), Imm32(gc::DefaultHeap)),
|
||||
ArgList(ImmGCPtr(info.funMaybeLazy()), Imm32(GenericObject)),
|
||||
StoreRegisterTo(objReg));
|
||||
|
||||
bool initContents = ShouldInitFixedSlots(lir, templateObj);
|
||||
|
@ -1076,7 +1076,7 @@ NewObjectGCKind(const js::Class* clasp)
|
||||
|
||||
static inline JSObject*
|
||||
NewObject(ExclusiveContext* cx, HandleObjectGroup group, gc::AllocKind kind,
|
||||
NewObjectKind newKind)
|
||||
NewObjectKind newKind, uint32_t initialShapeFlags = 0)
|
||||
{
|
||||
const Class* clasp = group->clasp();
|
||||
|
||||
@ -1091,7 +1091,8 @@ NewObject(ExclusiveContext* cx, HandleObjectGroup group, gc::AllocKind kind,
|
||||
? GetGCKindSlots(gc::GetGCObjectKind(clasp), clasp)
|
||||
: GetGCKindSlots(kind, clasp);
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, group->proto(), nfixed));
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, group->proto(), nfixed,
|
||||
initialShapeFlags));
|
||||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
@ -1139,7 +1140,8 @@ NewObjectWithTaggedProtoIsCachable(ExclusiveContext* cxArg, Handle<TaggedProto>
|
||||
JSObject*
|
||||
js::NewObjectWithGivenTaggedProto(ExclusiveContext* cxArg, const Class* clasp,
|
||||
Handle<TaggedProto> proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
gc::AllocKind allocKind, NewObjectKind newKind,
|
||||
uint32_t initialShapeFlags)
|
||||
{
|
||||
if (CanBeFinalizedInBackground(allocKind, clasp))
|
||||
allocKind = GetBackgroundAllocKind(allocKind);
|
||||
@ -1161,7 +1163,7 @@ js::NewObjectWithGivenTaggedProto(ExclusiveContext* cxArg, const Class* clasp,
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedObject obj(cxArg, NewObject(cxArg, group, allocKind, newKind));
|
||||
RootedObject obj(cxArg, NewObject(cxArg, group, allocKind, newKind, initialShapeFlags));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
|
@ -603,25 +603,38 @@ typedef AutoVectorRooter<PropertyDescriptor> AutoPropertyDescriptorVector;
|
||||
*/
|
||||
JSObject*
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext* cx, const Class* clasp, Handle<TaggedProto> proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind);
|
||||
gc::AllocKind allocKind, NewObjectKind newKind,
|
||||
uint32_t initialShapeFlags = 0);
|
||||
|
||||
inline JSObject*
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext* cx, const Class* clasp, Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
NewObjectKind newKind = GenericObject,
|
||||
uint32_t initialShapeFlags = 0)
|
||||
{
|
||||
gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind, newKind);
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind, newKind, initialShapeFlags);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T*
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext* cx, Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
NewObjectKind newKind = GenericObject,
|
||||
uint32_t initialShapeFlags = 0)
|
||||
{
|
||||
JSObject* obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind);
|
||||
JSObject* obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind,
|
||||
initialShapeFlags);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T*
|
||||
NewObjectWithNullTaggedProto(ExclusiveContext* cx, NewObjectKind newKind = GenericObject,
|
||||
uint32_t initialShapeFlags = 0)
|
||||
{
|
||||
Rooted<TaggedProto> nullProto(cx, TaggedProto(nullptr));
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, nullProto, newKind, initialShapeFlags);
|
||||
}
|
||||
|
||||
inline JSObject*
|
||||
NewObjectWithGivenProto(ExclusiveContext* cx, const Class* clasp, HandleObject proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
|
@ -323,22 +323,10 @@ const Class DeclEnvObject::class_ = {
|
||||
* scope and callee) or used as a template for jit compilation.
|
||||
*/
|
||||
DeclEnvObject*
|
||||
DeclEnvObject::createTemplateObject(JSContext* cx, HandleFunction fun, gc::InitialHeap heap)
|
||||
DeclEnvObject::createTemplateObject(JSContext* cx, HandleFunction fun, NewObjectKind newKind)
|
||||
{
|
||||
MOZ_ASSERT(IsNurseryAllocable(FINALIZE_KIND));
|
||||
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_, TaggedProto(nullptr)));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape emptyDeclEnvShape(cx);
|
||||
emptyDeclEnvShape = EmptyShape::getInitialShape(cx, &class_, TaggedProto(nullptr),
|
||||
FINALIZE_KIND, BaseShape::DELEGATE);
|
||||
if (!emptyDeclEnvShape)
|
||||
return nullptr;
|
||||
|
||||
RootedNativeObject obj(cx, MaybeNativeObject(JSObject::create(cx, FINALIZE_KIND, heap,
|
||||
emptyDeclEnvShape, group)));
|
||||
Rooted<DeclEnvObject*> obj(cx);
|
||||
obj = NewObjectWithNullTaggedProto<DeclEnvObject>(cx, newKind, BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -356,13 +344,13 @@ DeclEnvObject::createTemplateObject(JSContext* cx, HandleFunction fun, gc::Initi
|
||||
return nullptr;
|
||||
|
||||
MOZ_ASSERT(!obj->hasDynamicSlots());
|
||||
return &obj->as<DeclEnvObject>();
|
||||
return obj;
|
||||
}
|
||||
|
||||
DeclEnvObject*
|
||||
DeclEnvObject::create(JSContext* cx, HandleObject enclosing, HandleFunction callee)
|
||||
{
|
||||
Rooted<DeclEnvObject*> obj(cx, createTemplateObject(cx, callee, gc::DefaultHeap));
|
||||
Rooted<DeclEnvObject*> obj(cx, createTemplateObject(cx, callee, GenericObject));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -400,20 +388,7 @@ js::XDRStaticWithObject(XDRState<XDR_DECODE>*, HandleObject, MutableHandle<Stati
|
||||
StaticWithObject*
|
||||
StaticWithObject::create(ExclusiveContext* cx)
|
||||
{
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_, TaggedProto(nullptr)));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &class_, TaggedProto(nullptr),
|
||||
FINALIZE_KIND));
|
||||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
RootedObject obj(cx, JSObject::create(cx, FINALIZE_KIND, gc::TenuredHeap, shape, group));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
return &obj->as<StaticWithObject>();
|
||||
return NewObjectWithNullTaggedProto<StaticWithObject>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
@ -433,18 +408,11 @@ DynamicWithObject::create(JSContext* cx, HandleObject object, HandleObject enclo
|
||||
HandleObject staticWith, WithKind kind)
|
||||
{
|
||||
MOZ_ASSERT(staticWith->is<StaticWithObject>());
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_,
|
||||
TaggedProto(staticWith.get())));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &class_, TaggedProto(staticWith),
|
||||
FINALIZE_KIND));
|
||||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
RootedNativeObject obj(cx, MaybeNativeObject(JSObject::create(cx, FINALIZE_KIND,
|
||||
gc::DefaultHeap, shape, group)));
|
||||
Rooted<TaggedProto> proto(cx, TaggedProto(staticWith));
|
||||
Rooted<DynamicWithObject*> obj(cx);
|
||||
obj = NewObjectWithGivenTaggedProto<DynamicWithObject>(cx, proto, GenericObject,
|
||||
BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -457,7 +425,7 @@ DynamicWithObject::create(JSContext* cx, HandleObject object, HandleObject enclo
|
||||
obj->setFixedSlot(THIS_SLOT, ObjectValue(*thisp));
|
||||
obj->setFixedSlot(KIND_SLOT, Int32Value(kind));
|
||||
|
||||
return &obj->as<DynamicWithObject>();
|
||||
return obj;
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -567,23 +535,14 @@ const Class DynamicWithObject::class_ = {
|
||||
/* static */ StaticEvalObject*
|
||||
StaticEvalObject::create(JSContext* cx, HandleObject enclosing)
|
||||
{
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_, TaggedProto(nullptr)));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &class_, TaggedProto(nullptr),
|
||||
FINALIZE_KIND, BaseShape::DELEGATE));
|
||||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
RootedNativeObject obj(cx, MaybeNativeObject(JSObject::create(cx, FINALIZE_KIND,
|
||||
gc::TenuredHeap, shape, group)));
|
||||
StaticEvalObject* obj =
|
||||
NewObjectWithNullTaggedProto<StaticEvalObject>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
obj->setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(enclosing));
|
||||
obj->setReservedSlot(STRICT_SLOT, BooleanValue(false));
|
||||
return &obj->as<StaticEvalObject>();
|
||||
return obj;
|
||||
}
|
||||
|
||||
const Class StaticEvalObject::class_ = {
|
||||
@ -606,7 +565,10 @@ ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockObject*> block, Handl
|
||||
|
||||
RootedShape shape(cx, block->lastProperty());
|
||||
|
||||
RootedNativeObject obj(cx, MaybeNativeObject(JSObject::create(cx, FINALIZE_KIND,
|
||||
gc::AllocKind allocKind = gc::GetGCObjectKind(&BlockObject::class_);
|
||||
if (CanBeFinalizedInBackground(allocKind, &BlockObject::class_))
|
||||
allocKind = GetBackgroundAllocKind(allocKind);
|
||||
RootedNativeObject obj(cx, MaybeNativeObject(JSObject::create(cx, allocKind,
|
||||
gc::TenuredHeap, shape, group)));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
@ -680,22 +642,7 @@ ClonedBlockObject::clone(JSContext* cx, Handle<ClonedBlockObject*> clonedBlock)
|
||||
StaticBlockObject*
|
||||
StaticBlockObject::create(ExclusiveContext* cx)
|
||||
{
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &BlockObject::class_,
|
||||
TaggedProto(nullptr)));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape emptyBlockShape(cx);
|
||||
emptyBlockShape = EmptyShape::getInitialShape(cx, &BlockObject::class_, TaggedProto(nullptr),
|
||||
FINALIZE_KIND, BaseShape::DELEGATE);
|
||||
if (!emptyBlockShape)
|
||||
return nullptr;
|
||||
|
||||
JSObject* obj = JSObject::create(cx, FINALIZE_KIND, gc::TenuredHeap, emptyBlockShape, group);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
return &obj->as<StaticBlockObject>();
|
||||
return NewObjectWithNullTaggedProto<StaticBlockObject>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
}
|
||||
|
||||
/* static */ Shape*
|
||||
@ -893,22 +840,13 @@ js::CloneNestedScopeObject(JSContext* cx, HandleObject enclosingScope, Handle<Ne
|
||||
/* static */ UninitializedLexicalObject*
|
||||
UninitializedLexicalObject::create(JSContext* cx, HandleObject enclosing)
|
||||
{
|
||||
RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_, TaggedProto(nullptr)));
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &class_, TaggedProto(nullptr),
|
||||
FINALIZE_KIND));
|
||||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
RootedObject obj(cx, JSObject::create(cx, FINALIZE_KIND, gc::DefaultHeap, shape, group));
|
||||
UninitializedLexicalObject* obj =
|
||||
NewObjectWithNullTaggedProto<UninitializedLexicalObject>(cx, GenericObject,
|
||||
BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
obj->as<ScopeObject>().setEnclosingScope(enclosing);
|
||||
|
||||
return &obj->as<UninitializedLexicalObject>();
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -340,12 +340,10 @@ class DeclEnvObject : public ScopeObject
|
||||
|
||||
public:
|
||||
static const uint32_t RESERVED_SLOTS = 2;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
static DeclEnvObject*
|
||||
createTemplateObject(JSContext* cx, HandleFunction fun, gc::InitialHeap heap);
|
||||
createTemplateObject(JSContext* cx, HandleFunction fun, NewObjectKind newKind);
|
||||
|
||||
static DeclEnvObject* create(JSContext* cx, HandleObject enclosing, HandleFunction callee);
|
||||
|
||||
@ -362,8 +360,6 @@ class StaticEvalObject : public ScopeObject
|
||||
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 2;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
static StaticEvalObject* create(JSContext* cx, HandleObject enclosing);
|
||||
@ -436,8 +432,6 @@ class StaticWithObject : public NestedScopeObject
|
||||
{
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 1;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
static StaticWithObject* create(ExclusiveContext* cx);
|
||||
@ -452,8 +446,6 @@ class DynamicWithObject : public NestedScopeObject
|
||||
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 4;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
enum WithKind {
|
||||
@ -505,8 +497,6 @@ class BlockObject : public NestedScopeObject
|
||||
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 2;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
/* Return the abstract stack depth right before entering this nested scope. */
|
||||
@ -593,7 +583,7 @@ class StaticBlockObject : public BlockObject
|
||||
* variable of the block isAliased.
|
||||
*/
|
||||
bool needsClone() {
|
||||
return !getFixedSlot(RESERVED_SLOTS).isFalse();
|
||||
return numVariables() > 0 && !getSlot(RESERVED_SLOTS).isFalse();
|
||||
}
|
||||
|
||||
/* Frontend-only functions ***********************************************/
|
||||
@ -697,8 +687,6 @@ class UninitializedLexicalObject : public ScopeObject
|
||||
{
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 1;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||
|
||||
static const Class class_;
|
||||
|
||||
static UninitializedLexicalObject* create(JSContext* cx, HandleObject enclosing);
|
||||
|
Loading…
Reference in New Issue
Block a user