Sisyphus - merge commits for bug 422942
authorBob Clary <bclary@bclary.com>
Wed, 25 Jun 2008 17:57:24 -0400
changeset 15534 f012f9e140d9b8200eae9ed197dede839334ac64
parent 15533 5f932c24feea20b7aa52d9a00ceeae64bb9e6775 (current diff)
parent 15532 f171c57e016ecaa2e2d6b14f1a645c44cf4e6898 (diff)
child 15535 9c6b4d06e7cd708da68d00eebdebd7a8b5c144fd
child 15536 a47d251b7cf933f4bb008541bbf7ab8ebdc81d48
push id292
push userbclary@mozilla.com
push dateWed, 25 Jun 2008 21:59:25 +0000
treeherdermozilla-central@f012f9e140d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs422942
milestone1.9.1a1pre
Sisyphus - merge commits for bug 422942
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -907,18 +907,18 @@ array_enumerate(JSContext *cx, JSObject 
 {
     uint32 length, i;
     JSIndexIterState *ii;
 
     switch (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) {
                 if (!ii) {
                     ii = (JSIndexIterState *)
                          JS_malloc(cx, offsetof(JSIndexIterState, holes) +
                                    JS_BITMAP_SIZE(length));
                     if (!ii)
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -56,35 +56,37 @@
 #include "jspubtd.h"
 #include "jsregexp.h"
 #include "jsutil.h"
 
 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;
     uint32          misses;
     uint32          fills;
     uint32          clears;
 # define GSN_CACHE_METER(cache,cnt) (++(cache)->cnt)
 #else
 # define GSN_CACHE_METER(cache,cnt) /* nothing */
 #endif
 } 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;                                        \
         }                                                                     \
         GSN_CACHE_METER(cache, clears);                                       \
     JS_END_MACRO
 
 /* These helper macros take a cx as parameter and operate on its GSN cache. */
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1527,17 +1527,17 @@ void
 js_DestroyScript(JSContext *cx, JSScript *script)
 {
     js_CallDestroyScriptHook(cx, script);
     JS_ClearScriptTraps(cx, 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);
 
     /*
      * The GC flushes all property caches, so no need to purge just the
      * entries for this script.
      *
      * JS_THREADSAFE note: js_FlushPropertyCacheForScript flushes only the
      * current thread's property cache, so a script not owned by a function
@@ -1633,17 +1633,17 @@ js_GetSrcNoteCached(JSContext *cx, JSScr
     jssrcnote *sn, *result;
     uintN nsrcnotes;
 
 
     target = PTRDIFF(pc, script->code, jsbytecode);
     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,
                                      JS_DHASH_LOOKUP);
         return entry->sn;
     }
 
     JS_METER_GSN_CACHE(cx, misses);
@@ -1655,17 +1655,17 @@ js_GetSrcNoteCached(JSContext *cx, JSScr
         }
         offset += SN_DELTA(sn);
         if (offset == target && SN_IS_GETTABLE(sn)) {
             result = sn;
             break;
         }
     }
 
-    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;
         for (sn = SCRIPT_NOTES(script); !SN_IS_TERMINATOR(sn);
              sn = SN_NEXT(sn)) {
             if (SN_IS_GETTABLE(sn))
                 ++nsrcnotes;
         }
@@ -1681,17 +1681,17 @@ js_GetSrcNoteCached(JSContext *cx, JSScr
                 if (SN_IS_GETTABLE(sn)) {
                     entry = (GSNCacheEntry *)
                             JS_DHashTableOperate(&JS_GSN_CACHE(cx).table, pc,
                                                  JS_DHASH_ADD);
                     entry->pc = pc;
                     entry->sn = sn;
                 }
             }
-            JS_GSN_CACHE(cx).script = script;
+            JS_GSN_CACHE(cx).code = script->code;
             JS_METER_GSN_CACHE(cx, fills);
         }
     }
 
     return result;
 }
 
 uintN