mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 549683 - Remove final JSDHashTable users from SpiderMonkey; r=?
This does not build jsdhash.cpp for SpiderMonkey, but does keep it in tree for the remaining users in xpconnect. --HG-- extra : rebase_source : 5780e1e024a247d619a548541ad84cbeeba6c75b
This commit is contained in:
parent
99955b0700
commit
196698e430
@ -245,9 +245,11 @@ struct JSCountHeapNode {
|
||||
JSCountHeapNode *next;
|
||||
};
|
||||
|
||||
typedef HashSet<void *, PointerHasher<void *, 3>, SystemAllocPolicy> VisitedSet;
|
||||
|
||||
typedef struct JSCountHeapTracer {
|
||||
JSTracer base;
|
||||
JSDHashTable visited;
|
||||
VisitedSet visited;
|
||||
bool ok;
|
||||
JSCountHeapNode *traceList;
|
||||
JSCountHeapNode *recycleList;
|
||||
@ -256,27 +258,24 @@ typedef struct JSCountHeapTracer {
|
||||
static void
|
||||
CountHeapNotify(JSTracer *trc, void **thingp, JSGCTraceKind kind)
|
||||
{
|
||||
JSCountHeapTracer *countTracer;
|
||||
JSDHashEntryStub *entry;
|
||||
JSCountHeapNode *node;
|
||||
JS_ASSERT(trc->callback == CountHeapNotify);
|
||||
|
||||
JSCountHeapTracer *countTracer = (JSCountHeapTracer *)trc;
|
||||
void *thing = *thingp;
|
||||
|
||||
JS_ASSERT(trc->callback == CountHeapNotify);
|
||||
countTracer = (JSCountHeapTracer *)trc;
|
||||
if (!countTracer->ok)
|
||||
return;
|
||||
|
||||
entry = (JSDHashEntryStub *)
|
||||
JS_DHashTableOperate(&countTracer->visited, thing, JS_DHASH_ADD);
|
||||
if (!entry) {
|
||||
VisitedSet::AddPtr p = countTracer->visited.lookupForAdd(thing);
|
||||
if (p)
|
||||
return;
|
||||
|
||||
if (!countTracer->visited.add(p, thing)) {
|
||||
countTracer->ok = false;
|
||||
return;
|
||||
}
|
||||
if (entry->key)
|
||||
return;
|
||||
entry->key = thing;
|
||||
|
||||
node = countTracer->recycleList;
|
||||
JSCountHeapNode *node = countTracer->recycleList;
|
||||
if (node) {
|
||||
countTracer->recycleList = node->next;
|
||||
} else {
|
||||
@ -354,9 +353,7 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
JS_TracerInit(&countTracer.base, JS_GetRuntime(cx), CountHeapNotify);
|
||||
if (!JS_DHashTableInit(&countTracer.visited, JS_DHashGetStubOps(),
|
||||
NULL, sizeof(JSDHashEntryStub),
|
||||
JS_DHASH_DEFAULT_CAPACITY(100))) {
|
||||
if (!countTracer.visited.init()) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -384,7 +381,6 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
countTracer.recycleList = node->next;
|
||||
js_free(node);
|
||||
}
|
||||
JS_DHashTableFinish(&countTracer.visited);
|
||||
if (!countTracer.ok) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
|
@ -86,10 +86,6 @@
|
||||
#include "jsxml.h"
|
||||
#endif
|
||||
|
||||
#if JS_HAS_DESTRUCTURING
|
||||
#include "jsdhash.h"
|
||||
#endif
|
||||
|
||||
#include "jsatominlines.h"
|
||||
#include "jsscriptinlines.h"
|
||||
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h"
|
||||
#include "jsclist.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
@ -2608,9 +2607,11 @@ struct JSHeapDumpNode {
|
||||
into thing */
|
||||
};
|
||||
|
||||
typedef HashSet<void *, PointerHasher<void *, 3>, SystemAllocPolicy> VisitedSet;
|
||||
|
||||
typedef struct JSDumpingTracer {
|
||||
JSTracer base;
|
||||
JSDHashTable visited;
|
||||
VisitedSet visited;
|
||||
bool ok;
|
||||
void *startThing;
|
||||
void *thingToFind;
|
||||
@ -2623,12 +2624,10 @@ typedef struct JSDumpingTracer {
|
||||
static void
|
||||
DumpNotify(JSTracer *trc, void **thingp, JSGCTraceKind kind)
|
||||
{
|
||||
void *thing = *thingp;
|
||||
JSDumpingTracer *dtrc;
|
||||
JSDHashEntryStub *entry;
|
||||
|
||||
JS_ASSERT(trc->callback == DumpNotify);
|
||||
dtrc = (JSDumpingTracer *)trc;
|
||||
|
||||
JSDumpingTracer *dtrc = (JSDumpingTracer *)trc;
|
||||
void *thing = *thingp;
|
||||
|
||||
if (!dtrc->ok || thing == dtrc->thingToIgnore)
|
||||
return;
|
||||
@ -2650,15 +2649,13 @@ DumpNotify(JSTracer *trc, void **thingp, JSGCTraceKind kind)
|
||||
*/
|
||||
if (thing == dtrc->startThing)
|
||||
return;
|
||||
entry = (JSDHashEntryStub *)
|
||||
JS_DHashTableOperate(&dtrc->visited, thing, JS_DHASH_ADD);
|
||||
if (!entry) {
|
||||
VisitedSet::AddPtr p = dtrc->visited.lookupForAdd(thing);
|
||||
if (p)
|
||||
return;
|
||||
if (!dtrc->visited.add(p, thing)) {
|
||||
dtrc->ok = false;
|
||||
return;
|
||||
}
|
||||
if (entry->key)
|
||||
return;
|
||||
entry->key = thing;
|
||||
}
|
||||
|
||||
const char *edgeName = JS_GetTraceEdgeName(&dtrc->base, dtrc->buffer, sizeof(dtrc->buffer));
|
||||
@ -2750,26 +2747,20 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind startKind,
|
||||
void *thingToFind, size_t maxDepth, void *thingToIgnore)
|
||||
{
|
||||
JSDumpingTracer dtrc;
|
||||
JSHeapDumpNode *node, *children, *next, *parent;
|
||||
size_t depth;
|
||||
JSBool thingToFindWasTraced;
|
||||
|
||||
if (maxDepth == 0)
|
||||
return JS_TRUE;
|
||||
return true;
|
||||
|
||||
JS_TracerInit(&dtrc.base, rt, DumpNotify);
|
||||
if (!JS_DHashTableInit(&dtrc.visited, JS_DHashGetStubOps(),
|
||||
NULL, sizeof(JSDHashEntryStub),
|
||||
JS_DHASH_DEFAULT_CAPACITY(100))) {
|
||||
JSDumpingTracer dtrc;
|
||||
if (!dtrc.visited.init()) {
|
||||
return false;
|
||||
}
|
||||
JS_TracerInit(&dtrc.base, rt, DumpNotify);
|
||||
dtrc.ok = JS_TRUE;
|
||||
dtrc.startThing = startThing;
|
||||
dtrc.thingToFind = thingToFind;
|
||||
dtrc.thingToIgnore = thingToIgnore;
|
||||
dtrc.parentNode = NULL;
|
||||
node = NULL;
|
||||
JSHeapDumpNode *node = NULL;
|
||||
dtrc.lastNodep = &node;
|
||||
if (!startThing) {
|
||||
JS_ASSERT(startKind == JSTRACE_OBJECT);
|
||||
@ -2778,11 +2769,12 @@ JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind startKind,
|
||||
JS_TraceChildren(&dtrc.base, startThing, startKind);
|
||||
}
|
||||
|
||||
depth = 1;
|
||||
size_t depth = 1;
|
||||
if (!node)
|
||||
goto dump_out;
|
||||
return dtrc.ok;
|
||||
|
||||
thingToFindWasTraced = thingToFind && thingToFind == startThing;
|
||||
JSHeapDumpNode *children, *next, *parent;
|
||||
bool thingToFindWasTraced = thingToFind && thingToFind == startThing;
|
||||
for (;;) {
|
||||
/*
|
||||
* Loop must continue even when !dtrc.ok to free all nodes allocated
|
||||
@ -2819,16 +2811,14 @@ JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind startKind,
|
||||
if (node)
|
||||
break;
|
||||
if (!parent)
|
||||
goto dump_out;
|
||||
return dtrc.ok;
|
||||
JS_ASSERT(depth > 1);
|
||||
--depth;
|
||||
node = parent;
|
||||
}
|
||||
}
|
||||
|
||||
dump_out:
|
||||
JS_ASSERT(depth == 1);
|
||||
JS_DHashTableFinish(&dtrc.visited);
|
||||
return dtrc.ok;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "jsprvtd.h"
|
||||
#include "jsatom.h"
|
||||
#include "jsclist.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jsgc.h"
|
||||
#include "jspropertycache.h"
|
||||
#include "jspropertytree.h"
|
||||
|
@ -968,7 +968,7 @@ GetAtomTotalSize(JSContext *cx, JSAtom *atom)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
nbytes = sizeof(JSAtom *) + sizeof(JSDHashEntryStub);
|
||||
nbytes = sizeof(AtomStateEntry) + sizeof(HashNumber);
|
||||
nbytes += sizeof(JSString);
|
||||
nbytes += (atom->length() + 1) * sizeof(jschar);
|
||||
return nbytes;
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "jstypes.h"
|
||||
#include "jsprvtd.h"
|
||||
#include "jspubtd.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jslock.h"
|
||||
#include "jsutil.h"
|
||||
#include "jsversion.h"
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h"
|
||||
#include "jshash.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#include "jsclist.h"
|
||||
#include "jsdhash.h"
|
||||
#include "jsutil.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
@ -89,7 +88,7 @@ PropertyTable::init(JSRuntime *rt, Shape *lastProp)
|
||||
if (!entries)
|
||||
return false;
|
||||
|
||||
hashShift = JS_DHASH_BITS - sizeLog2;
|
||||
hashShift = HASH_BITS - sizeLog2;
|
||||
for (Shape::Range r = lastProp->all(); !r.empty(); r.popFront()) {
|
||||
const Shape &shape = r.front();
|
||||
Shape **spp = search(shape.propid(), true);
|
||||
@ -202,7 +201,7 @@ PropertyTable::search(jsid id, bool adding)
|
||||
return spp;
|
||||
|
||||
/* Collision: double hash. */
|
||||
sizeLog2 = JS_DHASH_BITS - hashShift;
|
||||
sizeLog2 = HASH_BITS - hashShift;
|
||||
hash2 = HASH2(hash0, sizeLog2, hashShift);
|
||||
sizeMask = JS_BITMASK(sizeLog2);
|
||||
|
||||
@ -261,7 +260,7 @@ PropertyTable::change(int log2Delta, JSContext *cx)
|
||||
/*
|
||||
* Grow, shrink, or compress by changing this->entries.
|
||||
*/
|
||||
int oldlog2 = JS_DHASH_BITS - hashShift;
|
||||
int oldlog2 = HASH_BITS - hashShift;
|
||||
int newlog2 = oldlog2 + log2Delta;
|
||||
uint32_t oldsize = JS_BIT(oldlog2);
|
||||
uint32_t newsize = JS_BIT(newlog2);
|
||||
@ -270,7 +269,7 @@ PropertyTable::change(int log2Delta, JSContext *cx)
|
||||
return false;
|
||||
|
||||
/* Now that we have newTable allocated, update members. */
|
||||
hashShift = JS_DHASH_BITS - newlog2;
|
||||
hashShift = HASH_BITS - newlog2;
|
||||
removedCount = 0;
|
||||
Shape **oldTable = entries;
|
||||
entries = newTable;
|
||||
@ -1151,7 +1150,7 @@ Shape::setObjectFlag(JSContext *cx, BaseShape::Flag flag, JSObject *proto, Shape
|
||||
/* static */ inline HashNumber
|
||||
StackBaseShape::hash(const StackBaseShape *base)
|
||||
{
|
||||
JSDHashNumber hash = base->flags;
|
||||
HashNumber hash = base->flags;
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(base->clasp) >> 3);
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(base->parent) >> 3);
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ uintptr_t(base->rawGetter);
|
||||
@ -1288,7 +1287,7 @@ Bindings::setParent(JSContext *cx, JSObject *obj)
|
||||
/* static */ inline HashNumber
|
||||
InitialShapeEntry::hash(const Lookup &lookup)
|
||||
{
|
||||
JSDHashNumber hash = uintptr_t(lookup.clasp) >> 3;
|
||||
HashNumber hash = uintptr_t(lookup.clasp) >> 3;
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(lookup.proto) >> 3);
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(lookup.parent) >> 3);
|
||||
return hash + lookup.nfixed;
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "jsdhash.h"
|
||||
#include "jsobj.h"
|
||||
#include "jspropertytree.h"
|
||||
#include "jstypes.h"
|
||||
@ -136,10 +135,11 @@ static const uint32_t SHAPE_INVALID_SLOT = JS_BIT(24) - 1;
|
||||
static const uint32_t SHAPE_MAXIMUM_SLOT = JS_BIT(24) - 2;
|
||||
|
||||
/*
|
||||
* Shapes use multiplicative hashing, _a la_ jsdhash.[ch], but specialized to
|
||||
* Shapes use multiplicative hashing, but specialized to
|
||||
* minimize footprint.
|
||||
*/
|
||||
struct PropertyTable {
|
||||
static const uint32_t HASH_BITS = tl::BitSize<HashNumber>::result;
|
||||
static const uint32_t MIN_ENTRIES = 7;
|
||||
static const uint32_t MIN_SIZE_LOG2 = 4;
|
||||
static const uint32_t MIN_SIZE = JS_BIT(MIN_SIZE_LOG2);
|
||||
@ -154,7 +154,7 @@ struct PropertyTable {
|
||||
js::Shape **entries; /* table of ptrs to shared tree nodes */
|
||||
|
||||
PropertyTable(uint32_t nentries)
|
||||
: hashShift(JS_DHASH_BITS - MIN_SIZE_LOG2),
|
||||
: hashShift(HASH_BITS - MIN_SIZE_LOG2),
|
||||
entryCount(nentries),
|
||||
removedCount(0),
|
||||
freelist(SHAPE_INVALID_SLOT)
|
||||
@ -166,8 +166,8 @@ struct PropertyTable {
|
||||
js::UnwantedForeground::free_(entries);
|
||||
}
|
||||
|
||||
/* By definition, hashShift = JS_DHASH_BITS - log2(capacity). */
|
||||
uint32_t capacity() const { return JS_BIT(JS_DHASH_BITS - hashShift); }
|
||||
/* By definition, hashShift = HASH_BITS - log2(capacity). */
|
||||
uint32_t capacity() const { return JS_BIT(HASH_BITS - hashShift); }
|
||||
|
||||
/* Computes the size of the entries array for a given capacity. */
|
||||
static size_t sizeOfEntries(size_t cap) { return cap * sizeof(Shape *); }
|
||||
@ -999,7 +999,7 @@ struct StackShape
|
||||
slot_ = slot;
|
||||
}
|
||||
|
||||
inline JSDHashNumber hash() const;
|
||||
inline HashNumber hash() const;
|
||||
};
|
||||
|
||||
/* Rooter for stack allocated shapes. */
|
||||
|
@ -236,10 +236,10 @@ Shape::Shape(UnownedBaseShape *base, uint32_t nfixed)
|
||||
kids.setNull();
|
||||
}
|
||||
|
||||
inline JSDHashNumber
|
||||
inline HashNumber
|
||||
StackShape::hash() const
|
||||
{
|
||||
JSDHashNumber hash = uintptr_t(base);
|
||||
HashNumber hash = uintptr_t(base);
|
||||
|
||||
/* Accumulate from least to most random so the low bits are most random. */
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ (flags & Shape::PUBLIC_FLAGS);
|
||||
|
Loading…
Reference in New Issue
Block a user