Bug 747543 - Convert JIT registration API to use JITChunks nearly everywhere in place of JITScripts. r=bhackett
authorSteve Fink <sfink@mozilla.com>
Mon, 30 Jan 2012 16:13:24 -0800
changeset 92361 01252613250ce0652135c2aa6b2cf20e891433e4
parent 92360 311b9a384ba94174c6c914ecd4dc0ca8e7d6ca01
child 92362 931678f97b3a01af8d47d8bfd42a662c76eeb032
push id22529
push usereakhgari@mozilla.com
push dateWed, 25 Apr 2012 14:06:19 +0000
treeherdermozilla-central@83ef3c9a64b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs747543
milestone14.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 747543 - Convert JIT registration API to use JITChunks nearly everywhere in place of JITScripts. r=bhackett
js/src/jsprobes.cpp
js/src/jsprobes.h
js/src/methodjit/BaseCompiler.h
js/src/methodjit/Compiler.cpp
js/src/methodjit/MethodJIT.cpp
--- a/js/src/jsprobes.cpp
+++ b/js/src/jsprobes.cpp
@@ -212,43 +212,43 @@ Probes::JITWatcher::CollectNativeRegions
     // All of the stub code comes immediately after the main code
     for (NativeRegion *iter = regions.begin(); iter != regions.end(); ++iter)
         iter->stubOffset += outerFrame->mainCodeEnd;
 
     return true;
 }
 
 void
-Probes::registerMJITCode(JSContext *cx, js::mjit::JITScript *jscr,
+Probes::registerMJITCode(JSContext *cx, js::mjit::JITChunk *chunk,
                          js::mjit::JSActiveFrame *outerFrame,
                          js::mjit::JSActiveFrame **inlineFrames,
                          void *mainCodeAddress, size_t mainCodeSize,
                          void *stubCodeAddress, size_t stubCodeSize)
 {
     for (JITWatcher **p = jitWatchers.begin(); p != jitWatchers.end(); ++p)
-        (*p)->registerMJITCode(cx, jscr, outerFrame,
+        (*p)->registerMJITCode(cx, chunk, outerFrame,
                                inlineFrames,
                                mainCodeAddress, mainCodeSize,
                                stubCodeAddress, stubCodeSize);
 }
 
 void
-Probes::discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, JSScript *script, void* address)
+Probes::discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, mjit::JITChunk *chunk, void* address)
 {
     for (JITWatcher **p = jitWatchers.begin(); p != jitWatchers.end(); ++p)
-        (*p)->discardMJITCode(fop, jscr, script, address);
+        (*p)->discardMJITCode(fop, jscr, chunk, address);
 }
 
 void
 Probes::registerICCode(JSContext *cx,
-                       mjit::JITScript *jscr, JSScript *script, jsbytecode* pc,
+                       mjit::JITChunk *chunk, JSScript *script, jsbytecode* pc,
                        void *start, size_t size)
 {
     for (JITWatcher **p = jitWatchers.begin(); p != jitWatchers.end(); ++p)
-        (*p)->registerICCode(cx, jscr, script, pc, start, size);
+        (*p)->registerICCode(cx, chunk, script, pc, start, size);
 }
 #endif
 
 /* ICs are unregistered in a batch */
 void
 Probes::discardExecutableRegion(void *start, size_t size)
 {
     for (JITWatcher **p = jitWatchers.begin(); p != jitWatchers.end(); ++p)
--- a/js/src/jsprobes.h
+++ b/js/src/jsprobes.h
@@ -253,27 +253,27 @@ public:
 
 #ifdef JS_METHODJIT
     static bool CollectNativeRegions(RegionVector &regions,
                                      JSRuntime *rt,
                                      mjit::JITChunk *jit,
                                      mjit::JSActiveFrame *outerFrame,
                                      mjit::JSActiveFrame **inlineFrames);
 
-    virtual void registerMJITCode(JSContext *cx, js::mjit::JITScript *jscr,
+    virtual void registerMJITCode(JSContext *cx, js::mjit::JITChunk *chunk,
                                   mjit::JSActiveFrame *outerFrame,
                                   mjit::JSActiveFrame **inlineFrames,
                                   void *mainCodeAddress, size_t mainCodeSize,
                                   void *stubCodeAddress, size_t stubCodeSize) = 0;
 
-    virtual void discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, JSScript *script,
+    virtual void discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, mjit::JITChunk *chunk,
                                  void* address) = 0;
 
     virtual void registerICCode(JSContext *cx,
-                                js::mjit::JITScript *jscr, JSScript *script, jsbytecode* pc,
+                                js::mjit::JITChunk *chunk, JSScript *script, jsbytecode* pc,
                                 void *start, size_t size) = 0;
 #endif
 
     virtual void discardExecutableRegion(void *start, size_t size) = 0;
 };
 
 /*
  * Register a JITWatcher subclass to be informed of JIT code
@@ -301,34 +301,34 @@ removeAllJITWatchers(JSRuntime *rt);
 JITReportGranularity
 JITGranularityRequested();
 
 #ifdef JS_METHODJIT
 /*
  * New method JIT code has been created
  */
 void
-registerMJITCode(JSContext *cx, js::mjit::JITScript *jscr,
+registerMJITCode(JSContext *cx, js::mjit::JITChunk *chunk,
                  mjit::JSActiveFrame *outerFrame,
                  mjit::JSActiveFrame **inlineFrames,
                  void *mainCodeAddress, size_t mainCodeSize,
                  void *stubCodeAddress, size_t stubCodeSize);
 
 /*
  * Method JIT code is about to be discarded
  */
 void
-discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, JSScript *script, void* address);
+discardMJITCode(FreeOp *fop, mjit::JITScript *jscr, mjit::JITChunk *chunk, void* address);
 
 /*
- * IC code has been allocated within the given JITScript
+ * IC code has been allocated within the given JITChunk
  */
 void
 registerICCode(JSContext *cx,
-               mjit::JITScript *jscr, JSScript *script, jsbytecode* pc,
+               mjit::JITChunk *chunk, JSScript *script, jsbytecode* pc,
                void *start, size_t size);
 #endif /* JS_METHODJIT */
 
 /*
  * A whole region of code has been deallocated, containing any number of ICs.
  * (ICs are unregistered in a batch, so individual ICs are not registered.)
  */
 void
--- a/js/src/methodjit/BaseCompiler.h
+++ b/js/src/methodjit/BaseCompiler.h
@@ -166,17 +166,17 @@ class LinkerHelper : public JSC::LinkBuf
         }
         m_size = masm.size();   // must come after call to executableAllocAndCopy()!
         return pool;
     }
 
     JSC::CodeLocationLabel finalize(VMFrame &f) {
         masm.finalize(*this);
         JSC::CodeLocationLabel label = finalizeCodeAddendum();
-        Probes::registerICCode(f.cx, f.jit(), f.script(), f.pc(),
+        Probes::registerICCode(f.cx, f.chunk(), f.script(), f.pc(),
                                label.executableAddress(), masm.size());
         return label;
     }
 
     void maybeLink(MaybeJump jump, JSC::CodeLocationLabel label) {
         if (!jump.isSet())
             return;
         link(jump.get(), label);
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -1769,17 +1769,17 @@ mjit::Compiler::finishThisUp()
 
     /* Patch all outgoing calls. */
     masm.finalize(fullCode, inlineDoubles);
     stubcc.masm.finalize(stubCode, oolDoubles);
 
     JSC::ExecutableAllocator::makeExecutable(result, masm.size() + stubcc.size());
     JSC::ExecutableAllocator::cacheFlush(result, masm.size() + stubcc.size());
 
-    Probes::registerMJITCode(cx, jit,
+    Probes::registerMJITCode(cx, chunk,
                              a,
                              (JSActiveFrame**) inlineFrames.begin(),
                              result, masm.size(),
                              result + masm.size(), stubcc.size());
 
     outerChunkRef().chunk = chunk;
 
     /* Patch all incoming and outgoing cross-chunk jumps. */
--- a/js/src/methodjit/MethodJIT.cpp
+++ b/js/src/methodjit/MethodJIT.cpp
@@ -1323,17 +1323,17 @@ JITScript::destroy(FreeOp *fop)
 }
 
 void
 JITScript::destroyChunk(FreeOp *fop, unsigned chunkIndex, bool resetUses)
 {
     ChunkDescriptor &desc = chunkDescriptor(chunkIndex);
 
     if (desc.chunk) {
-        Probes::discardMJITCode(fop, this, script, desc.chunk->code.m_code.executableAddress());
+        Probes::discardMJITCode(fop, this, desc.chunk, desc.chunk->code.m_code.executableAddress());
         fop->delete_(desc.chunk);
         desc.chunk = NULL;
 
         CrossChunkEdge *edges = this->edges();
         for (unsigned i = 0; i < nedges; i++) {
             CrossChunkEdge &edge = edges[i];
             if (edge.source >= desc.begin && edge.source < desc.end) {
                 edge.sourceJump1 = edge.sourceJump2 = NULL;
@@ -1479,16 +1479,18 @@ JITScript::findCodeChunk(void *addr)
 }
 
 jsbytecode *
 JITScript::nativeToPC(void *returnAddress, CallSite **pinline)
 {
     JITChunk *chunk = findCodeChunk(returnAddress);
     JS_ASSERT(chunk);
 
+    JS_ASSERT(chunk->isValidCode(returnAddress));
+
     size_t low = 0;
     size_t high = chunk->nCallICs;
     js::mjit::ic::CallICInfo *callICs_ = chunk->callICs();
     while (high > low + 1) {
         /* Could overflow here on a script with 2 billion calls. Oh well. */
         size_t mid = (high + low) / 2;
         void *entry = callICs_[mid].funGuard.executableAddress();