Sisyphus - merge commits for bug 422942

This commit is contained in:
Bob Clary 2008-06-25 17:57:24 -04:00
commit ccc0f6f7b7
3 changed files with 11 additions and 9 deletions

View File

@ -912,8 +912,8 @@ array_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
case JSENUMERATE_INIT:
JS_ASSERT(OBJ_IS_DENSE_ARRAY(cx, obj));
length = ARRAY_DENSE_LENGTH(obj);
if (idp && !IndexToId(cx, length, idp))
return JS_FALSE;
if (idp)
*idp = INT_TO_JSVAL(obj->fslots[JSSLOT_ARRAY_COUNT]);
ii = NULL;
for (i = 0; i != length; ++i) {
if (obj->dslots[i] == JSVAL_HOLE) {

View File

@ -61,10 +61,12 @@ JS_BEGIN_EXTERN_C
/*
* js_GetSrcNote cache to avoid O(n^2) growth in finding a source note for a
* given pc in a script.
* given pc in a script. We use the script->code pointer to tag the cache,
* instead of the script address itself, so that source notes are always found
* by offset from the bytecode with which they were generated.
*/
typedef struct JSGSNCache {
JSScript *script;
jsbytecode *code;
JSDHashTable table;
#ifdef JS_GSNMETER
uint32 hits;
@ -79,7 +81,7 @@ typedef struct JSGSNCache {
#define GSN_CACHE_CLEAR(cache) \
JS_BEGIN_MACRO \
(cache)->script = NULL; \
(cache)->code = NULL; \
if ((cache)->table.ops) { \
JS_DHashTableFinish(&(cache)->table); \
(cache)->table.ops = NULL; \

View File

@ -1532,7 +1532,7 @@ js_DestroyScript(JSContext *cx, JSScript *script)
if (script->principals)
JSPRINCIPALS_DROP(cx, script->principals);
if (JS_GSN_CACHE(cx).script == script)
if (JS_GSN_CACHE(cx).code == script->code)
JS_CLEAR_GSN_CACHE(cx);
/*
@ -1638,7 +1638,7 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
if ((uint32)target >= script->length)
return NULL;
if (JS_GSN_CACHE(cx).script == script) {
if (JS_GSN_CACHE(cx).code == script->code) {
JS_METER_GSN_CACHE(cx, hits);
entry = (GSNCacheEntry *)
JS_DHashTableOperate(&JS_GSN_CACHE(cx).table, pc,
@ -1660,7 +1660,7 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
}
}
if (JS_GSN_CACHE(cx).script != script &&
if (JS_GSN_CACHE(cx).code != script->code &&
script->length >= GSN_CACHE_THRESHOLD) {
JS_CLEAR_GSN_CACHE(cx);
nsrcnotes = 0;
@ -1686,7 +1686,7 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
entry->sn = sn;
}
}
JS_GSN_CACHE(cx).script = script;
JS_GSN_CACHE(cx).code = script->code;
JS_METER_GSN_CACHE(cx, fills);
}
}