mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989414 - Convert FixedHeapPtr to take a T* as template parameter instead of T; r=jonco
--HG-- extra : rebase_source : 1b71b0bdf3437e9f02dbb89b5db1186040d94872
This commit is contained in:
parent
c3b59a5d99
commit
2bdc771587
@ -545,9 +545,9 @@ class HeapPtr : public BarrieredPtr<T>
|
||||
};
|
||||
|
||||
/*
|
||||
* FixedHeapPtr is designed for one very narrow case: replacing immutable raw
|
||||
* pointers to GC-managed things, implicitly converting to a handle type for
|
||||
* ease of use. Pointers encapsulated by this type must:
|
||||
* ImmutableTenuredPtr is designed for one very narrow case: replacing
|
||||
* immutable raw pointers to GC-managed things, implicitly converting to a
|
||||
* handle type for ease of use. Pointers encapsulated by this type must:
|
||||
*
|
||||
* be immutable (no incremental write barriers),
|
||||
* never point into the nursery (no generational write barriers), and
|
||||
@ -556,20 +556,21 @@ class HeapPtr : public BarrieredPtr<T>
|
||||
* In short: you *really* need to know what you're doing before you use this
|
||||
* class!
|
||||
*/
|
||||
template <class T>
|
||||
class FixedHeapPtr
|
||||
template <typename T>
|
||||
class ImmutableTenuredPtr
|
||||
{
|
||||
T *value;
|
||||
T value;
|
||||
|
||||
public:
|
||||
operator T*() const { return value; }
|
||||
T * operator->() const { return value; }
|
||||
operator T() const { return value; }
|
||||
T operator->() const { return value; }
|
||||
|
||||
operator Handle<T*>() const {
|
||||
return Handle<T*>::fromMarkedLocation(&value);
|
||||
operator Handle<T>() const {
|
||||
return Handle<T>::fromMarkedLocation(&value);
|
||||
}
|
||||
|
||||
void init(T *ptr) {
|
||||
void init(T ptr) {
|
||||
JS_ASSERT(ptr->isTenured());
|
||||
value = ptr;
|
||||
}
|
||||
};
|
||||
@ -728,6 +729,8 @@ typedef EncapsulatedPtr<jsid> EncapsulatedId;
|
||||
typedef RelocatablePtr<jsid> RelocatableId;
|
||||
typedef HeapPtr<jsid> HeapId;
|
||||
|
||||
typedef ImmutableTenuredPtr<PropertyName*> ImmutablePropertyNamePtr;
|
||||
|
||||
/* Useful for hashtables with a HeapPtr as key. */
|
||||
template <class T>
|
||||
struct HeapPtrHasher
|
||||
|
@ -149,7 +149,7 @@ JSRuntime::initializeAtoms(JSContext *cx)
|
||||
if (!commonNames)
|
||||
return false;
|
||||
|
||||
FixedHeapPtr<PropertyName> *names = reinterpret_cast<FixedHeapPtr<PropertyName> *>(commonNames);
|
||||
ImmutablePropertyNamePtr *names = reinterpret_cast<ImmutablePropertyNamePtr *>(commonNames);
|
||||
for (size_t i = 0; i < ArrayLength(cachedNames); i++, names++) {
|
||||
JSAtom *atom = Atomize(cx, cachedNames[i].str, cachedNames[i].length, InternAtom);
|
||||
if (!atom)
|
||||
|
@ -158,7 +158,7 @@ TypeName(JSType type, const JSAtomState &names)
|
||||
{
|
||||
JS_ASSERT(type < JSTYPE_LIMIT);
|
||||
JS_STATIC_ASSERT(offsetof(JSAtomState, undefined) +
|
||||
JSTYPE_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
|
||||
JSTYPE_LIMIT * sizeof(ImmutablePropertyNamePtr) <=
|
||||
sizeof(JSAtomState));
|
||||
JS_STATIC_ASSERT(JSTYPE_VOID == 0);
|
||||
return (&names.undefined)[type];
|
||||
@ -169,7 +169,7 @@ ClassName(JSProtoKey key, JSAtomState &atomState)
|
||||
{
|
||||
JS_ASSERT(key < JSProto_LIMIT);
|
||||
JS_STATIC_ASSERT(offsetof(JSAtomState, Null) +
|
||||
JSProto_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
|
||||
JSProto_LIMIT * sizeof(ImmutablePropertyNamePtr) <=
|
||||
sizeof(JSAtomState));
|
||||
JS_STATIC_ASSERT(JSProto_Null == 0);
|
||||
return (&atomState.Null)[key];
|
||||
|
@ -452,10 +452,10 @@ struct RuntimeSizes;
|
||||
/* Various built-in or commonly-used names pinned on first context. */
|
||||
struct JSAtomState
|
||||
{
|
||||
#define PROPERTYNAME_FIELD(idpart, id, text) js::FixedHeapPtr<js::PropertyName> id;
|
||||
#define PROPERTYNAME_FIELD(idpart, id, text) js::ImmutablePropertyNamePtr id;
|
||||
FOR_EACH_COMMON_PROPERTYNAME(PROPERTYNAME_FIELD)
|
||||
#undef PROPERTYNAME_FIELD
|
||||
#define PROPERTYNAME_FIELD(name, code, init, clasp) js::FixedHeapPtr<js::PropertyName> name;
|
||||
#define PROPERTYNAME_FIELD(name, code, init, clasp) js::ImmutablePropertyNamePtr name;
|
||||
JS_FOR_EACH_PROTOTYPE(PROPERTYNAME_FIELD)
|
||||
#undef PROPERTYNAME_FIELD
|
||||
};
|
||||
@ -467,7 +467,7 @@ namespace js {
|
||||
inline HandlePropertyName
|
||||
AtomStateOffsetToName(const JSAtomState &atomState, size_t offset)
|
||||
{
|
||||
return *(js::FixedHeapPtr<js::PropertyName>*)((char*)&atomState + offset);
|
||||
return *reinterpret_cast<js::ImmutablePropertyNamePtr *>((char*)&atomState + offset);
|
||||
}
|
||||
|
||||
// There are several coarse locks in the enum below. These may be either
|
||||
|
Loading…
Reference in New Issue
Block a user