Bug 935228 - Toggle debug traps only in debug mode. (r=jandem)
authorShu-yu Guo <shu@rfrn.org>
Tue, 19 Nov 2013 14:17:13 -0800
changeset 171116 de3dd3c48114149af5c7efcab0219749a5299ca9
parent 171115 00644e4b067d981d77fcffef244a09bbc0896016
child 171117 4983f1debf4ca46bac2ef72d20929f9f1d5f4a4d
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs935228
milestone28.0a1
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 935228 - Toggle debug traps only in debug mode. (r=jandem)
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineJIT.cpp
js/src/jit/BaselineJIT.h
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -246,16 +246,19 @@ BaselineCompiler::compile()
 
         JS_ASSERT(added == script->nTypeSets);
 
         // The last entry in the last index found, and is used to avoid binary
         // searches for the sought entry when queries are in linear order.
         bytecodeMap[script->nTypeSets] = 0;
     }
 
+    if (script->compartment()->debugMode())
+        baselineScript->setDebugMode();
+
     return Method_Compiled;
 }
 
 bool
 BaselineCompiler::emitPrologue()
 {
     masm.push(BaselineFrameReg);
     masm.mov(BaselineStackReg, BaselineFrameReg);
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -741,16 +741,20 @@ BaselineScript::pcForReturnAddress(JSScr
     return pcForReturnOffset(script, uint32_t(nativeAddress - method_->raw()));
 }
 
 void
 BaselineScript::toggleDebugTraps(JSScript *script, jsbytecode *pc)
 {
     JS_ASSERT(script->baselineScript() == this);
 
+    // Only scripts compiled for debug mode have toggled calls.
+    if (!debugMode())
+        return;
+
     SrcNoteLineScanner scanner(script->notes(), script->lineno);
 
     JSRuntime *rt = script->runtimeFromMainThread();
     IonContext ictx(CompileRuntime::get(rt),
                     CompileCompartment::get(script->compartment()),
                     nullptr);
     AutoFlushCache afc("DebugTraps", rt->jitRuntime());
 
--- a/js/src/jit/BaselineJIT.h
+++ b/js/src/jit/BaselineJIT.h
@@ -127,17 +127,21 @@ struct BaselineScript
         NEEDS_ARGS_OBJ = 1 << 0,
 
         // Flag set when discarding JIT code, to indicate this script is
         // on the stack and should not be discarded.
         ACTIVE = 1 << 1,
 
         // Flag set when the script contains any writes to its on-stack
         // (rather than call object stored) arguments.
-        MODIFIES_ARGUMENTS = 1 << 2
+        MODIFIES_ARGUMENTS = 1 << 2,
+
+        // Flag set when compiled for use for debug mode. Handles various
+        // Debugger hooks and compiles toggled calls for traps.
+        DEBUG_MODE = 1 << 3
     };
 
   private:
     uint32_t flags_;
 
   private:
     void trace(JSTracer *trc);
 
@@ -196,16 +200,23 @@ struct BaselineScript
 
     void setModifiesArguments() {
         flags_ |= MODIFIES_ARGUMENTS;
     }
     bool modifiesArguments() {
         return flags_ & MODIFIES_ARGUMENTS;
     }
 
+    void setDebugMode() {
+        flags_ |= DEBUG_MODE;
+    }
+    bool debugMode() const {
+        return flags_ & DEBUG_MODE;
+    }
+
     uint32_t prologueOffset() const {
         return prologueOffset_;
     }
     uint8_t *prologueEntryAddr() const {
         return method_->raw() + prologueOffset_;
     }
 
     ICEntry *icEntryList() {