зеркало из https://github.com/mozilla/pjs.git
Fixed generation-number-optimized hash revalidation (415721, r=igor).
This commit is contained in:
Родитель
f975099f55
Коммит
ec3aa4dded
|
@ -364,7 +364,6 @@ js_InitAtomState(JSRuntime *rt)
|
||||||
*/
|
*/
|
||||||
JS_ASSERT(!state->stringAtoms.ops);
|
JS_ASSERT(!state->stringAtoms.ops);
|
||||||
JS_ASSERT(!state->doubleAtoms.ops);
|
JS_ASSERT(!state->doubleAtoms.ops);
|
||||||
JS_ASSERT(state->tablegen == 0);
|
|
||||||
|
|
||||||
if (!JS_DHashTableInit(&state->stringAtoms, &StringHashOps,
|
if (!JS_DHashTableInit(&state->stringAtoms, &StringHashOps,
|
||||||
NULL, sizeof(JSAtomHashEntry),
|
NULL, sizeof(JSAtomHashEntry),
|
||||||
|
@ -559,10 +558,11 @@ js_SweepAtomState(JSContext *cx)
|
||||||
JS_DHashTableEnumerate(&state->stringAtoms, js_atom_sweeper, cx);
|
JS_DHashTableEnumerate(&state->stringAtoms, js_atom_sweeper, cx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optimize for simplicity and mutate tablegen even if the sweeper has not
|
* Optimize for simplicity and mutate table generation numbers even if the
|
||||||
* removed any entries.
|
* sweeper has not removed any entries.
|
||||||
*/
|
*/
|
||||||
state->tablegen++;
|
state->doubleAtoms.generation++;
|
||||||
|
state->stringAtoms.generation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSAtom *
|
JSAtom *
|
||||||
|
@ -583,7 +583,7 @@ js_AtomizeDouble(JSContext *cx, jsdouble d)
|
||||||
if (!entry)
|
if (!entry)
|
||||||
goto failed_hash_add;
|
goto failed_hash_add;
|
||||||
if (entry->keyAndFlags == 0) {
|
if (entry->keyAndFlags == 0) {
|
||||||
gen = ++state->tablegen;
|
gen = ++table->generation;
|
||||||
JS_UNLOCK(&state->lock, cx);
|
JS_UNLOCK(&state->lock, cx);
|
||||||
|
|
||||||
key = js_NewDouble(cx, d, 0);
|
key = js_NewDouble(cx, d, 0);
|
||||||
|
@ -591,7 +591,7 @@ js_AtomizeDouble(JSContext *cx, jsdouble d)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
JS_LOCK(&state->lock, cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
if (state->tablegen == gen) {
|
if (table->generation == gen) {
|
||||||
JS_ASSERT(entry->keyAndFlags == 0);
|
JS_ASSERT(entry->keyAndFlags == 0);
|
||||||
} else {
|
} else {
|
||||||
entry = TO_ATOM_ENTRY(JS_DHashTableOperate(table, key,
|
entry = TO_ATOM_ENTRY(JS_DHashTableOperate(table, key,
|
||||||
|
@ -600,7 +600,7 @@ js_AtomizeDouble(JSContext *cx, jsdouble d)
|
||||||
goto failed_hash_add;
|
goto failed_hash_add;
|
||||||
if (entry->keyAndFlags != 0)
|
if (entry->keyAndFlags != 0)
|
||||||
goto finish;
|
goto finish;
|
||||||
++state->tablegen;
|
++table->generation;
|
||||||
}
|
}
|
||||||
INIT_ATOM_ENTRY(entry, key);
|
INIT_ATOM_ENTRY(entry, key);
|
||||||
}
|
}
|
||||||
|
@ -647,12 +647,12 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||||
* string construction is a complex operation. For example, it can
|
* string construction is a complex operation. For example, it can
|
||||||
* trigger GC which may rehash the table and make the entry invalid.
|
* trigger GC which may rehash the table and make the entry invalid.
|
||||||
*/
|
*/
|
||||||
++state->tablegen;
|
++table->generation;
|
||||||
if (!(flags & ATOM_TMPSTR) && JSSTRING_IS_FLAT(str)) {
|
if (!(flags & ATOM_TMPSTR) && JSSTRING_IS_FLAT(str)) {
|
||||||
JSFLATSTR_CLEAR_MUTABLE(str);
|
JSFLATSTR_CLEAR_MUTABLE(str);
|
||||||
key = str;
|
key = str;
|
||||||
} else {
|
} else {
|
||||||
gen = state->tablegen;
|
gen = table->generation;
|
||||||
JS_UNLOCK(&state->lock, cx);
|
JS_UNLOCK(&state->lock, cx);
|
||||||
|
|
||||||
if (flags & ATOM_TMPSTR) {
|
if (flags & ATOM_TMPSTR) {
|
||||||
|
@ -678,7 +678,7 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_LOCK(&state->lock, cx);
|
JS_LOCK(&state->lock, cx);
|
||||||
if (state->tablegen == gen) {
|
if (table->generation == gen) {
|
||||||
JS_ASSERT(entry->keyAndFlags == 0);
|
JS_ASSERT(entry->keyAndFlags == 0);
|
||||||
} else {
|
} else {
|
||||||
entry = TO_ATOM_ENTRY(JS_DHashTableOperate(table, key,
|
entry = TO_ATOM_ENTRY(JS_DHashTableOperate(table, key,
|
||||||
|
@ -689,7 +689,7 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||||
key = (JSString *)ATOM_ENTRY_KEY(entry);
|
key = (JSString *)ATOM_ENTRY_KEY(entry);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
++state->tablegen;
|
++table->generation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
INIT_ATOM_ENTRY(entry, key);
|
INIT_ATOM_ENTRY(entry, key);
|
||||||
|
|
|
@ -147,8 +147,6 @@ struct JSAtomMap {
|
||||||
struct JSAtomState {
|
struct JSAtomState {
|
||||||
JSDHashTable stringAtoms; /* hash table with shared strings */
|
JSDHashTable stringAtoms; /* hash table with shared strings */
|
||||||
JSDHashTable doubleAtoms; /* hash table with shared doubles */
|
JSDHashTable doubleAtoms; /* hash table with shared doubles */
|
||||||
uint32 tablegen; /* number of atoms mutations to
|
|
||||||
optimize hashing */
|
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
JSThinLock lock;
|
JSThinLock lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче