зеркало из https://github.com/mozilla/pjs.git
Bug 720853 - Add read barrier for atom table (r=luke)
This commit is contained in:
Родитель
145c2a2ac3
Коммит
d5bf8fee3b
|
@ -774,44 +774,6 @@ class HashTable : private AllocPolicy
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
template <typename T>
|
||||
class TaggedPointerEntry
|
||||
{
|
||||
uintptr_t bits;
|
||||
|
||||
typedef TaggedPointerEntry<T> ThisT;
|
||||
|
||||
static const uintptr_t NO_TAG_MASK = uintptr_t(-1) - 1;
|
||||
|
||||
public:
|
||||
TaggedPointerEntry() : bits(0) {}
|
||||
TaggedPointerEntry(const TaggedPointerEntry &other) : bits(other.bits) {}
|
||||
TaggedPointerEntry(T *ptr, bool tagged)
|
||||
: bits(uintptr_t(ptr) | uintptr_t(tagged))
|
||||
{
|
||||
JS_ASSERT((uintptr_t(ptr) & 0x1) == 0);
|
||||
}
|
||||
|
||||
bool isTagged() const {
|
||||
return bits & 0x1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-branching code sequence. Note that the const_cast is safe because
|
||||
* the hash function doesn't consider the tag to be a portion of the key.
|
||||
*/
|
||||
void setTagged(bool enabled) const {
|
||||
const_cast<ThisT *>(this)->bits |= uintptr_t(enabled);
|
||||
}
|
||||
|
||||
T *asPtr() const {
|
||||
JS_ASSERT(bits != 0);
|
||||
return reinterpret_cast<T *>(bits & NO_TAG_MASK);
|
||||
}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Hash policy
|
||||
*
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
#include "frontend/Parser.h"
|
||||
#include "frontend/ParseMaps.h"
|
||||
|
||||
#include "jsatominlines.h"
|
||||
|
||||
namespace js {
|
||||
|
||||
/*
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
#include "jsxml.h"
|
||||
#endif
|
||||
|
||||
#include "jsatominlines.h"
|
||||
|
||||
#include "vm/String-inl.h"
|
||||
|
||||
using namespace js;
|
||||
|
||||
static ParseNode *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
@ -180,7 +180,35 @@ HashChars(const jschar *chars, size_t length)
|
|||
return h;
|
||||
}
|
||||
|
||||
typedef TaggedPointerEntry<JSAtom> AtomStateEntry;
|
||||
class AtomStateEntry
|
||||
{
|
||||
uintptr_t bits;
|
||||
|
||||
static const uintptr_t NO_TAG_MASK = uintptr_t(-1) - 1;
|
||||
|
||||
public:
|
||||
AtomStateEntry() : bits(0) {}
|
||||
AtomStateEntry(const AtomStateEntry &other) : bits(other.bits) {}
|
||||
AtomStateEntry(JSAtom *ptr, bool tagged)
|
||||
: bits(uintptr_t(ptr) | uintptr_t(tagged))
|
||||
{
|
||||
JS_ASSERT((uintptr_t(ptr) & 0x1) == 0);
|
||||
}
|
||||
|
||||
bool isTagged() const {
|
||||
return bits & 0x1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-branching code sequence. Note that the const_cast is safe because
|
||||
* the hash function doesn't consider the tag to be a portion of the key.
|
||||
*/
|
||||
void setTagged(bool enabled) const {
|
||||
const_cast<AtomStateEntry *>(this)->bits |= uintptr_t(enabled);
|
||||
}
|
||||
|
||||
JSAtom *asPtr() const;
|
||||
};
|
||||
|
||||
struct AtomHasher
|
||||
{
|
||||
|
|
|
@ -47,6 +47,15 @@
|
|||
#include "jsobj.h"
|
||||
#include "jsstr.h"
|
||||
|
||||
inline JSAtom *
|
||||
js::AtomStateEntry::asPtr() const
|
||||
{
|
||||
JS_ASSERT(bits != 0);
|
||||
JSAtom *atom = reinterpret_cast<JSAtom *>(bits & NO_TAG_MASK);
|
||||
JSString::readBarrier(atom);
|
||||
return atom;
|
||||
}
|
||||
|
||||
inline bool
|
||||
js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp)
|
||||
{
|
||||
|
|
|
@ -76,6 +76,16 @@ JSString::needWriteBarrierPre(JSCompartment *comp)
|
|||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
JSString::readBarrier(JSString *str)
|
||||
{
|
||||
#ifdef JSGC_INCREMENTAL
|
||||
JSCompartment *comp = str->compartment();
|
||||
if (comp->needsBarrier())
|
||||
MarkStringUnbarriered(comp->barrierTracer(), str, "read barrier");
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE bool
|
||||
JSString::validateLength(JSContext *cx, size_t length)
|
||||
{
|
||||
|
|
|
@ -422,6 +422,7 @@ class JSString : public js::gc::Cell
|
|||
static inline void writeBarrierPre(JSString *str);
|
||||
static inline void writeBarrierPost(JSString *str, void *addr);
|
||||
static inline bool needWriteBarrierPre(JSCompartment *comp);
|
||||
static inline void readBarrier(JSString *str);
|
||||
|
||||
static inline js::ThingRootKind rootKind() { return js::THING_ROOT_STRING; }
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче