Bug 604756 first try: restrict ropes optimization to main-thread content JS, r=lw, a=b7-blocker
☠☠ backed out by ab7354a933de ☠ ☠
authorDavid Mandelin <dmandelin@mozilla.com>
Mon, 25 Oct 2010 17:28:18 -0700
changeset 56476 8dd996c91f406f9e3b58686cfec681fb7f05bc6f
parent 56475 eaf6f9566f2eb59e647f03630a21a056b75899b8
child 56477 c668ad69aaed1ac527a49e9ba0042574345ae548
child 56611 ab7354a933de1e774545483a055cb271bb45e980
push id16568
push userdmandelin@mozilla.com
push dateTue, 26 Oct 2010 00:28:42 +0000
treeherdermozilla-central@8dd996c91f40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslw, b7-blocker
bugs604756
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 604756 first try: restrict ropes optimization to main-thread content JS, r=lw, a=b7-blocker
dom/base/nsJSEnvironment.cpp
js/src/jsapi.h
js/src/jsstr.cpp
js/src/shell/js.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1227,16 +1227,19 @@ nsJSContext::JSOptionChangedCallback(con
     PRBool safeMode = PR_FALSE;
     xr->GetInSafeMode(&safeMode);
     if (safeMode) {
       useTraceJIT = PR_FALSE;
       useMethodJIT = PR_FALSE;
     }
   }    
 
+  if (!chromeWindow)
+    newDefaultJSOptions |= JSOPTION_ROPES;
+
   if (useTraceJIT)
     newDefaultJSOptions |= JSOPTION_JIT;
   else
     newDefaultJSOptions &= ~JSOPTION_JIT;
 
   if (useMethodJIT)
     newDefaultJSOptions |= JSOPTION_METHODJIT;
   else
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -910,16 +910,18 @@ JS_StringToVersion(const char *string);
                                                    to JS_ExecuteScript. */
 #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13)     /* The GC will not root the
                                                    contexts' global objects
                                                    (see JS_GetGlobalObject),
                                                    leaving that up to the
                                                    embedding. */
 
 #define JSOPTION_METHODJIT      JS_BIT(14)      /* Whole-method JIT. */
+#define JSOPTION_ROPES          JS_BIT(16)      /* Enable rope optimization for
+                                                 * string concat. */
 
 extern JS_PUBLIC_API(uint32)
 JS_GetOptions(JSContext *cx);
 
 extern JS_PUBLIC_API(uint32)
 JS_SetOptions(JSContext *cx, uint32 options);
 
 extern JS_PUBLIC_API(uint32)
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -263,16 +263,18 @@ FinishConcat(JSContext *cx, bool usingLe
         cx->free(buf);
         return NULL;
     }
     res->initTopNode(left, right, length, buf);
     if (usingLeft)
         left->convertToInteriorNode(res);
     if (usingRight)
         right->convertToInteriorNode(res);
+    if (!JS_HAS_OPTION(cx, JSOPTION_ROPES))
+        res->flatten();
     return res;
 }
 
 JSString * JS_FASTCALL
 js_ConcatStrings(JSContext *cx, JSString *left, JSString *right)
 {
     size_t length, leftLen, rightLen;
     bool leftRopeTop, rightRopeTop;
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -5381,17 +5381,17 @@ main(int argc, char **argv, char **envp)
 
     if (!InitWatchdog(rt))
         return 1;
 
     cx = NewContext(rt);
     if (!cx)
         return 1;
 
-    JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_ANONFUNFIX);
+    JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_ANONFUNFIX | JSOPTION_ROPES);
     JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 16 * 1024 * 1024);
 
     result = Shell(cx, argc, argv, envp);
 
     DestroyContext(cx, true);
 
     KillWatchdog();