Bug 1055758 - rm Ion CompilerRoot infrastructure. r=bhackett

--HG--
extra : rebase_source : 73d4b369b240436d0c2cc95a9f40cac783c6adb5
This commit is contained in:
Jan de Mooij 2014-08-20 12:18:49 +02:00
Родитель 8f9c39edf4
Коммит 69fca6313c
9 изменённых файлов: 80 добавлений и 176 удалений

Просмотреть файл

@ -1236,23 +1236,6 @@ class JS_PUBLIC_API(ObjectPtr)
} /* namespace JS */
namespace js {
/* Base class for automatic read-only object rooting during compilation. */
class CompilerRootNode
{
protected:
explicit CompilerRootNode(js::gc::Cell *ptr) : next(nullptr), ptr_(ptr) {}
public:
void **address() { return (void **)&ptr_; }
public:
CompilerRootNode *next;
protected:
js::gc::Cell *ptr_;
};
namespace gc {
template <typename T, typename TraceCallbacks>

Просмотреть файл

@ -540,11 +540,6 @@ AutoGCRooter::trace(JSTracer *trc)
return;
}
case IONALLOC: {
static_cast<js::jit::AutoTempAllocatorRooter *>(this)->trace(trc);
return;
}
case WRAPPER: {
/*
* We need to use MarkValueUnbarriered here because we mark wrapper

Просмотреть файл

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jit_CompilerRoot_h
#define jit_CompilerRoot_h
#include "jscntxt.h"
#include "jit/Ion.h"
#include "jit/IonAllocPolicy.h"
#include "js/RootingAPI.h"
namespace js {
namespace jit {
// Roots a read-only GCThing for the lifetime of a single compilation.
// Each root is maintained in a linked list that is walked over during tracing.
// The CompilerRoot must be heap-allocated and may not go out of scope.
template <typename T>
class CompilerRoot : public CompilerRootNode
{
public:
explicit CompilerRoot(T ptr)
: CompilerRootNode(nullptr)
{
if (ptr) {
JS_ASSERT(!GetIonContext()->runtime->isInsideNursery(ptr));
setRoot(ptr);
}
}
public:
// Sets the pointer and inserts into root list. The pointer becomes read-only.
void setRoot(T root) {
CompilerRootNode *&rootList = GetIonContext()->temp->rootList();
JS_ASSERT(!ptr_);
ptr_ = root;
next = rootList;
rootList = this;
}
public:
operator T () const { return static_cast<T>(ptr_); }
T operator ->() const { return static_cast<T>(ptr_); }
private:
CompilerRoot() MOZ_DELETE;
CompilerRoot(const CompilerRoot<T> &) MOZ_DELETE;
CompilerRoot<T> &operator =(const CompilerRoot<T> &) MOZ_DELETE;
};
typedef CompilerRoot<JSObject*> CompilerRootObject;
typedef CompilerRoot<JSFunction*> CompilerRootFunction;
typedef CompilerRoot<JSScript*> CompilerRootScript;
typedef CompilerRoot<PropertyName*> CompilerRootPropertyName;
typedef CompilerRoot<Shape*> CompilerRootShape;
typedef CompilerRoot<Value> CompilerRootValue;
} // namespace jit
} // namespace js
#endif /* jit_CompilerRoot_h */

Просмотреть файл

@ -1789,8 +1789,6 @@ AttachFinishedCompilations(JSContext *cx)
bool success;
{
// Release the helper thread lock and root the compiler for GC.
AutoTempAllocatorRooter root(cx, &builder->alloc());
AutoUnlockHelperThreadState unlock;
success = codegen->link(cx, builder->constraints());
}
@ -1926,7 +1924,6 @@ IonCompile(JSContext *cx, JSScript *script,
return AbortReason_Alloc;
}
AutoTempAllocatorRooter root(cx, temp);
types::CompilerConstraintList *constraints = types::NewCompilerConstraintList(*temp);
if (!constraints)
return AbortReason_Alloc;

Просмотреть файл

@ -23,13 +23,9 @@ class TempAllocator
{
LifoAllocScope lifoScope_;
// Linked list of GCThings rooted by this allocator.
CompilerRootNode *rootList_;
public:
explicit TempAllocator(LifoAlloc *lifoAlloc)
: lifoScope_(lifoAlloc),
rootList_(nullptr)
: lifoScope_(lifoAlloc)
{ }
void *allocateInfallible(size_t bytes)
@ -61,11 +57,6 @@ class TempAllocator
return &lifoScope_.alloc();
}
CompilerRootNode *&rootList()
{
return rootList_;
}
bool ensureBallast() {
// Most infallible Ion allocations are small, so we use a ballast of
// ~16K for now.
@ -73,25 +64,6 @@ class TempAllocator
}
};
// Stack allocated rooter for all roots associated with a TempAllocator
class AutoTempAllocatorRooter : private JS::AutoGCRooter
{
public:
explicit AutoTempAllocatorRooter(JSContext *cx, TempAllocator *temp
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: JS::AutoGCRooter(cx, IONALLOC), temp(temp)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
friend void JS::AutoGCRooter::trace(JSTracer *trc);
void trace(JSTracer *trc);
private:
TempAllocator *temp;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class IonAllocPolicy
{
TempAllocator &alloc_;

Просмотреть файл

@ -2773,8 +2773,6 @@ jit::AnalyzeNewScriptProperties(JSContext *cx, JSFunction *fun,
script->needsArgsObj(),
inlineScriptTree);
AutoTempAllocatorRooter root(cx, &temp);
const OptimizationInfo *optimizationInfo = js_IonOptimizations.get(Optimization_Normal);
types::CompilerConstraintList *constraints = types::NewCompilerConstraintList(temp);
@ -3004,8 +3002,6 @@ jit::AnalyzeArgumentsUsage(JSContext *cx, JSScript *scriptArg)
/* needsArgsObj = */ true,
inlineScriptTree);
AutoTempAllocatorRooter root(cx, &temp);
const OptimizationInfo *optimizationInfo = js_IonOptimizations.get(Optimization_Normal);
types::CompilerConstraintList *constraints = types::NewCompilerConstraintList(temp);

Просмотреть файл

@ -1357,13 +1357,6 @@ void UpdateJitActivationsForMinorGC<gc::ForkJoinNursery>(PerThreadData *ptd, JST
#endif
void
AutoTempAllocatorRooter::trace(JSTracer *trc)
{
for (CompilerRootNode *root = temp->rootList(); root != nullptr; root = root->next)
gc::MarkGCThingRoot(trc, root->address(), "ion-compiler-root");
}
void
GetPcScript(JSContext *cx, JSScript **scriptRes, jsbytecode **pcRes)
{

Просмотреть файл

@ -15,7 +15,6 @@
#include "mozilla/Array.h"
#include "mozilla/DebugOnly.h"
#include "jit/CompilerRoot.h"
#include "jit/FixedList.h"
#include "jit/InlineList.h"
#include "jit/IonAllocPolicy.h"
@ -1848,6 +1847,42 @@ bool
MergeTypes(MIRType *ptype, types::TemporaryTypeSet **ptypeSet,
MIRType newType, types::TemporaryTypeSet *newTypeSet);
// Helper class to assert all GC pointers embedded in MIR instructions are
// tenured. Off-thread Ion compilation and nursery GCs can happen in parallel,
// so it's invalid to store pointers to nursery things. There's no need to root
// these pointers, as GC is suppressed during compilation and off-thread
// compilations are canceled on every major GC.
template <typename T>
class AlwaysTenured
{
js::gc::Cell *ptr_;
public:
explicit AlwaysTenured(T ptr)
: ptr_(ptr)
{
#ifdef DEBUG
MOZ_ASSERT(!IsInsideNursery(ptr_));
PerThreadData *pt = TlsPerThreadData.get();
MOZ_ASSERT_IF(pt->runtimeIfOnOwnerThread(), pt->suppressGC);
#endif
}
operator T() const { return static_cast<T>(ptr_); }
T operator->() const { return static_cast<T>(ptr_); }
private:
AlwaysTenured() MOZ_DELETE;
AlwaysTenured(const AlwaysTenured<T> &) MOZ_DELETE;
AlwaysTenured<T> &operator=(const AlwaysTenured<T> &) MOZ_DELETE;
};
typedef AlwaysTenured<JSObject*> AlwaysTenuredObject;
typedef AlwaysTenured<JSFunction*> AlwaysTenuredFunction;
typedef AlwaysTenured<JSScript*> AlwaysTenuredScript;
typedef AlwaysTenured<PropertyName*> AlwaysTenuredPropertyName;
typedef AlwaysTenured<Shape*> AlwaysTenuredShape;
class MNewArray : public MUnaryInstruction
{
public:
@ -1928,7 +1963,7 @@ class MNewArray : public MUnaryInstruction
class MNewArrayCopyOnWrite : public MNullaryInstruction
{
CompilerRootObject templateObject_;
AlwaysTenuredObject templateObject_;
gc::InitialHeap initialHeap_;
MNewArrayCopyOnWrite(types::CompilerConstraintList *constraints, JSObject *templateObject,
@ -2028,7 +2063,7 @@ class MNewObject : public MUnaryInstruction
// Could be allocating either a new array or a new object.
class MNewPar : public MUnaryInstruction
{
CompilerRootObject templateObject_;
AlwaysTenuredObject templateObject_;
MNewPar(MDefinition *cx, JSObject *templateObject)
: MUnaryInstruction(cx),
@ -2346,7 +2381,7 @@ class MInitProp
public MixPolicy<ObjectPolicy<0>, BoxPolicy<1> >
{
public:
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
protected:
MInitProp(MDefinition *obj, PropertyName *name, MDefinition *value)
@ -2388,7 +2423,7 @@ class MInitPropGetterSetter
: public MBinaryInstruction,
public MixPolicy<ObjectPolicy<0>, ObjectPolicy<1> >
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
MInitPropGetterSetter(MDefinition *obj, PropertyName *name, MDefinition *value)
: MBinaryInstruction(obj, value),
@ -2499,7 +2534,7 @@ class MCall
protected:
// Monomorphic cache of single target from TI, or nullptr.
CompilerRootFunction target_;
AlwaysTenuredFunction target_;
// Original value of argc from the bytecode.
uint32_t numActualArgs_;
@ -2682,7 +2717,7 @@ class MApplyArgs
{
protected:
// Monomorphic cache of single target from TI, or nullptr.
CompilerRootFunction target_;
AlwaysTenuredFunction target_;
MApplyArgs(JSFunction *target, MDefinition *fun, MDefinition *argc, MDefinition *self)
: target_(target)
@ -3336,7 +3371,7 @@ class MCreateThisWithTemplate
: public MNullaryInstruction
{
// Template for |this|, provided by TI
CompilerRootObject templateObject_;
AlwaysTenuredObject templateObject_;
gc::InitialHeap initialHeap_;
MCreateThisWithTemplate(types::CompilerConstraintList *constraints, JSObject *templateObject,
@ -5895,7 +5930,7 @@ class MAsmJSInterruptCheck : public MNullaryInstruction
// If not defined, set a global variable to |undefined|.
class MDefVar : public MUnaryInstruction
{
CompilerRootPropertyName name_; // Target name to be defined.
AlwaysTenuredPropertyName name_; // Target name to be defined.
unsigned attrs_; // Attributes to be set.
private:
@ -5931,7 +5966,7 @@ class MDefVar : public MUnaryInstruction
class MDefFun : public MUnaryInstruction
{
CompilerRootFunction fun_;
AlwaysTenuredFunction fun_;
private:
MDefFun(JSFunction *fun, MDefinition *scopeChain)
@ -5959,7 +5994,7 @@ class MDefFun : public MUnaryInstruction
class MRegExp : public MNullaryInstruction
{
CompilerRoot<RegExpObject *> source_;
AlwaysTenured<RegExpObject *> source_;
bool mustClone_;
MRegExp(types::CompilerConstraintList *constraints, RegExpObject *source, bool mustClone)
@ -6167,7 +6202,7 @@ struct LambdaFunctionInfo
// The functions used in lambdas are the canonical original function in
// the script, and are immutable except for delazification. Record this
// information while still on the main thread to avoid races.
CompilerRootFunction fun;
AlwaysTenuredFunction fun;
uint16_t flags;
gc::Cell *scriptOrLazyScript;
bool singletonType;
@ -7373,7 +7408,7 @@ class MArrayConcat
: public MBinaryInstruction,
public MixPolicy<ObjectPolicy<0>, ObjectPolicy<1> >
{
CompilerRootObject templateObj_;
AlwaysTenuredObject templateObj_;
gc::InitialHeap initialHeap_;
MArrayConcat(types::CompilerConstraintList *constraints, MDefinition *lhs, MDefinition *rhs,
@ -7587,7 +7622,7 @@ class MLoadTypedArrayElementStatic
setResultType(MIRType_Int32);
}
CompilerRoot<TypedArrayObject*> typedArray_;
AlwaysTenured<TypedArrayObject*> typedArray_;
bool fallible_;
public:
@ -7776,7 +7811,7 @@ class MStoreTypedArrayElementStatic :
: MBinaryInstruction(ptr, v), typedArray_(typedArray)
{}
CompilerRoot<TypedArrayObject*> typedArray_;
AlwaysTenured<TypedArrayObject*> typedArray_;
public:
INSTRUCTION_HEADER(StoreTypedArrayElementStatic);
@ -7999,8 +8034,8 @@ typedef Vector<bool, 4, IonAllocPolicy> BoolVector;
class InlinePropertyTable : public TempObject
{
struct Entry : public TempObject {
CompilerRoot<types::TypeObject *> typeObj;
CompilerRootFunction func;
AlwaysTenured<types::TypeObject *> typeObj;
AlwaysTenuredFunction func;
Entry(types::TypeObject *typeObj, JSFunction *func)
: typeObj(typeObj), func(func)
@ -8073,7 +8108,7 @@ class MGetPropertyCache
: public MUnaryInstruction,
public SingleObjectPolicy
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
bool idempotent_;
bool monitoredResult_;
@ -8178,7 +8213,7 @@ class MGetPropertyPolymorphic
};
Vector<Entry, 4, IonAllocPolicy> shapes_;
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
MGetPropertyPolymorphic(TempAllocator &alloc, MDefinition *obj, PropertyName *name)
: MUnaryInstruction(obj),
@ -8502,8 +8537,8 @@ class MBindNameCache
: public MUnaryInstruction,
public SingleObjectPolicy
{
CompilerRootPropertyName name_;
CompilerRootScript script_;
AlwaysTenuredPropertyName name_;
AlwaysTenuredScript script_;
jsbytecode *pc_;
MBindNameCache(MDefinition *scopeChain, PropertyName *name, JSScript *script, jsbytecode *pc)
@ -8543,7 +8578,7 @@ class MGuardShape
: public MUnaryInstruction,
public SingleObjectPolicy
{
CompilerRootShape shape_;
AlwaysTenuredShape shape_;
BailoutKind bailoutKind_;
MGuardShape(MDefinition *obj, Shape *shape, BailoutKind bailoutKind)
@ -8642,7 +8677,7 @@ class MGuardObjectType
: public MUnaryInstruction,
public SingleObjectPolicy
{
CompilerRoot<types::TypeObject *> typeObject_;
AlwaysTenured<types::TypeObject *> typeObject_;
bool bailOnEquality_;
MGuardObjectType(MDefinition *obj, types::TypeObject *typeObject, bool bailOnEquality)
@ -8694,7 +8729,7 @@ class MGuardObjectIdentity
: public MUnaryInstruction,
public SingleObjectPolicy
{
CompilerRoot<JSObject *> singleObject_;
AlwaysTenured<JSObject *> singleObject_;
bool bailOnEquality_;
MGuardObjectIdentity(MDefinition *obj, JSObject *singleObject, bool bailOnEquality)
@ -9003,7 +9038,7 @@ class MGetNameCache
};
private:
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
AccessKind kind_;
MGetNameCache(MDefinition *obj, PropertyName *name, AccessKind kind)
@ -9038,7 +9073,7 @@ class MGetNameCache
class MCallGetIntrinsicValue : public MNullaryInstruction
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
explicit MCallGetIntrinsicValue(PropertyName *name)
: name_(name)
@ -9100,7 +9135,7 @@ class MCallsiteCloneCache
class MSetPropertyInstruction : public MBinaryInstruction
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
bool strict_;
bool needsBarrier_;
@ -9157,7 +9192,7 @@ class MDeleteProperty
: public MUnaryInstruction,
public BoxInputsPolicy
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
protected:
MDeleteProperty(MDefinition *val, PropertyName *name)
@ -9312,7 +9347,7 @@ class MCallGetProperty
: public MUnaryInstruction,
public BoxInputsPolicy
{
CompilerRootPropertyName name_;
AlwaysTenuredPropertyName name_;
bool idempotent_;
bool callprop_;
@ -10010,7 +10045,7 @@ class MInstanceOf
: public MUnaryInstruction,
public InstanceOfPolicy
{
CompilerRootObject protoObj_;
AlwaysTenuredObject protoObj_;
MInstanceOf(MDefinition *obj, JSObject *proto)
: MUnaryInstruction(obj),
@ -10174,7 +10209,7 @@ class MSetFrameArgument
class MRestCommon
{
unsigned numFormals_;
CompilerRootObject templateObject_;
AlwaysTenuredObject templateObject_;
protected:
MRestCommon(unsigned numFormals, JSObject *templateObject)
@ -10498,7 +10533,7 @@ class MPostWriteBarrier : public MBinaryInstruction, public ObjectPolicy<0>
class MNewDeclEnvObject : public MNullaryInstruction
{
CompilerRootObject templateObj_;
AlwaysTenuredObject templateObj_;
explicit MNewDeclEnvObject(JSObject *templateObj)
: MNullaryInstruction(),
@ -10524,7 +10559,7 @@ class MNewDeclEnvObject : public MNullaryInstruction
class MNewCallObjectBase : public MNullaryInstruction
{
CompilerRootObject templateObj_;
AlwaysTenuredObject templateObj_;
protected:
explicit MNewCallObjectBase(JSObject *templateObj)
@ -10577,7 +10612,7 @@ class MNewRunOnceCallObject : public MNewCallObjectBase
class MNewCallObjectPar : public MUnaryInstruction
{
CompilerRootObject templateObj_;
AlwaysTenuredObject templateObj_;
MNewCallObjectPar(MDefinition *cx, JSObject *templateObj)
: MUnaryInstruction(cx),
@ -10610,7 +10645,7 @@ class MNewStringObject :
public MUnaryInstruction,
public ConvertToStringPolicy<0>
{
CompilerRootObject templateObj_;
AlwaysTenuredObject templateObj_;
MNewStringObject(MDefinition *input, JSObject *templateObj)
: MUnaryInstruction(input),
@ -10700,7 +10735,7 @@ class MEnclosingScope : public MLoadFixedSlot
// Note: the template object should be an *empty* dense array!
class MNewDenseArrayPar : public MBinaryInstruction
{
CompilerRootObject templateObject_;
AlwaysTenuredObject templateObject_;
MNewDenseArrayPar(MDefinition *cx, MDefinition *length, JSObject *templateObject)
: MBinaryInstruction(cx, length),

Просмотреть файл

@ -302,15 +302,14 @@ class JS_PUBLIC_API(AutoGCRooter)
NAMEVECTOR = -17, /* js::AutoNameVector */
HASHABLEVALUE=-18, /* js::HashableValue */
IONMASM = -19, /* js::jit::MacroAssembler */
IONALLOC = -20, /* js::jit::AutoTempAllocatorRooter */
WRAPVECTOR = -21, /* js::AutoWrapperVector */
WRAPPER = -22, /* js::AutoWrapperRooter */
OBJOBJHASHMAP=-23, /* js::AutoObjectObjectHashMap */
OBJU32HASHMAP=-24, /* js::AutoObjectUnsigned32HashMap */
OBJHASHSET = -25, /* js::AutoObjectHashSet */
JSONPARSER = -26, /* js::JSONParser */
CUSTOM = -27, /* js::CustomAutoRooter */
FUNVECTOR = -28 /* js::AutoFunctionVector */
WRAPVECTOR = -20, /* js::AutoWrapperVector */
WRAPPER = -21, /* js::AutoWrapperRooter */
OBJOBJHASHMAP=-22, /* js::AutoObjectObjectHashMap */
OBJU32HASHMAP=-23, /* js::AutoObjectUnsigned32HashMap */
OBJHASHSET = -24, /* js::AutoObjectHashSet */
JSONPARSER = -25, /* js::JSONParser */
CUSTOM = -26, /* js::CustomAutoRooter */
FUNVECTOR = -27 /* js::AutoFunctionVector */
};
private: