Bug 902720 - Clean up GetTopIonJSScript to use ThreadSafeContext. (r=jandem)
authorShu-yu Guo <shu@rfrn.org>
Fri, 09 Aug 2013 17:07:50 -0700
changeset 142142 ab48e2538553a1cb08a4c3acbd5fb6d9839900a8
parent 142141 1bdd3f639d69f139ed670ae424f322c8f00298e5
child 142143 f5d38a9eb834e378958e845395adc7111b59eb11
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjandem
bugs902720
milestone26.0a1
Bug 902720 - Clean up GetTopIonJSScript to use ThreadSafeContext. (r=jandem)
js/src/jit/IonCaches.cpp
js/src/jit/IonFrames.h
--- a/js/src/jit/IonCaches.cpp
+++ b/js/src/jit/IonCaches.cpp
@@ -1655,23 +1655,18 @@ GetPropertyParIC::attachTypedArrayLength
     return linkAndAttachStub(cx, masm, attacher, ion, "parallel typed array length");
 }
 
 ParallelResult
 GetPropertyParIC::update(ForkJoinSlice *slice, size_t cacheIndex,
                          HandleObject obj, MutableHandleValue vp)
 {
     AutoFlushCache afc("GetPropertyParCache");
-    PerThreadData *pt = slice->perThreadData;
-
-    const SafepointIndex *safepointIndex;
-    void *returnAddr;
-    RootedScript topScript(pt, GetTopIonJSScript(pt, &safepointIndex, &returnAddr));
-    IonScript *ion = topScript->parallelIonScript();
-
+
+    IonScript *ion = GetTopIonJSScript(slice)->parallelIonScript();
     GetPropertyParIC &cache = ion->getCache(cacheIndex).toGetPropertyPar();
 
     // Grab the property early, as the pure path is fast anyways and doesn't
     // need a lock. If we can't do it purely, bail out of parallel execution.
     if (!GetPropertyPure(slice, obj, NameToId(cache.name()), vp.address()))
         return TP_RETRY_SEQUENTIALLY;
 
     // Avoid unnecessary locking if cannot attach stubs.
@@ -2793,23 +2788,18 @@ GetElementParIC::attachTypedArrayElement
     return linkAndAttachStub(cx, masm, attacher, ion, "parallel typed array");
 }
 
 ParallelResult
 GetElementParIC::update(ForkJoinSlice *slice, size_t cacheIndex, HandleObject obj,
                         HandleValue idval, MutableHandleValue vp)
 {
     AutoFlushCache afc("GetElementParCache");
-    PerThreadData *pt = slice->perThreadData;
-
-    const SafepointIndex *safepointIndex;
-    void *returnAddr;
-    RootedScript topScript(pt, GetTopIonJSScript(pt, &safepointIndex, &returnAddr));
-    IonScript *ion = topScript->parallelIonScript();
-
+
+    IonScript *ion = GetTopIonJSScript(slice)->parallelIonScript();
     GetElementParIC &cache = ion->getCache(cacheIndex).toGetElementPar();
 
     // Try to get the element early, as the pure path doesn't need a lock. If
     // we can't do it purely, bail out of parallel execution.
     if (!GetObjectElementOperationPure(slice, obj, idval, vp.address()))
         return TP_RETRY_SEQUENTIALLY;
 
     // Avoid unnecessary locking if cannot attach stubs.
--- a/js/src/jit/IonFrames.h
+++ b/js/src/jit/IonFrames.h
@@ -312,40 +312,36 @@ GetTopIonJSScript(PerThreadData *pt, con
         JS_ASSERT(iter.isBaselineJS());
     }
 
     JS_ASSERT(iter.isScripted());
     return iter.script();
 }
 
 inline JSScript *
-GetTopIonJSScript(JSContext *cx, const SafepointIndex **safepointIndexOut, void **returnAddrOut)
+GetTopIonJSScript(ThreadSafeContext *cx, const SafepointIndex **safepointIndexOut = NULL,
+                  void **returnAddrOut = NULL)
 {
-    return GetTopIonJSScript(&cx->mainThread(), safepointIndexOut, returnAddrOut);
+    return GetTopIonJSScript(cx->perThreadData, safepointIndexOut, returnAddrOut);
 }
 
 } // namespace ion
 } // namespace js
 
 #if defined(JS_CPU_X86) || defined (JS_CPU_X64)
 # include "jit/shared/IonFrames-x86-shared.h"
 #elif defined (JS_CPU_ARM)
 # include "jit/arm/IonFrames-arm.h"
 #else
 # error "unsupported architecture"
 #endif
 
 namespace js {
 namespace ion {
 
-JSScript *
-GetTopIonJSScript(JSContext *cx,
-                  const SafepointIndex **safepointIndexOut = NULL,
-                  void **returnAddrOut = NULL);
-
 void
 GetPcScript(JSContext *cx, JSScript **scriptRes, jsbytecode **pcRes);
 
 // Given a slot index, returns the offset, in bytes, of that slot from an
 // IonJSFrameLayout. Slot distances are uniform across architectures, however,
 // the distance does depend on the size of the frame header.
 static inline int32_t
 OffsetOfFrameSlot(int32_t slot)