Bug 1096023 - Fix code generation for ClassHook caches when the SPS profiler is active, r=jandem.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 13 Nov 2014 09:30:28 -0700
changeset 215526 657e8b81c02dd70dd04cce286edffa35a7b1bf01
parent 215525 58f75321e4c18b78276b561531b65b19fb8ab579
child 215527 e2be5d0449c5eea1f4395c737c53baf3f4e4780a
push id27818
push userryanvm@gmail.com
push dateThu, 13 Nov 2014 20:19:09 +0000
treeherdermozilla-central@292ed84594c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1096023
milestone36.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 1096023 - Fix code generation for ClassHook caches when the SPS profiler is active, r=jandem.
js/src/jit-test/tests/TypedObject/bug1096023.js
js/src/jit/BaselineIC.cpp
js/src/jit/BaselineIC.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/TypedObject/bug1096023.js
@@ -0,0 +1,20 @@
+if (!this.hasOwnProperty("TypedObject"))
+  quit();
+
+enableSPSProfiling();
+var T = TypedObject;
+function check(results, ctor) {
+  for (var i = 0; i < results.length; i++)
+  var S = new T.StructType({f: ctor});
+  for (var i = 0; i < results.length; i++) {
+    var s = new S({f: results[i][1]});
+  }
+}
+var int8results = [
+  [22, 22],
+  [-128, 128],
+  [-1, 255],
+  [0x75, 0x7575],
+  [-123, 0x7585]
+];
+check(int8results, T.int8);
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -8683,17 +8683,18 @@ TryAttachCallStub(JSContext *cx, ICCall_
             if (op != JSOP_FUNAPPLY && !isSpread && !useNewType) {
                 RootedObject templateObject(cx);
                 CallArgs args = CallArgsFromVp(argc, vp);
                 if (!GetTemplateObjectForClassHook(cx, hook, args, &templateObject))
                     return false;
 
                 JitSpew(JitSpew_BaselineIC, "  Generating Call_ClassHook stub");
                 ICCall_ClassHook::Compiler compiler(cx, stub->fallbackMonitorStub()->firstMonitorStub(),
-                                                    obj->getClass(), hook, templateObject, constructing);
+                                                    obj->getClass(), hook, templateObject,
+                                                    script->pcToOffset(pc), constructing);
                 ICStub *newStub = compiler.getStub(compiler.getStubSpace(script));
                 if (!newStub)
                     return false;
 
                 stub->addNewStub(newStub);
                 return true;
             }
         }
@@ -9937,17 +9938,17 @@ ICCall_ClassHook::Compiler::generateStub
 
     EmitCreateStubFrameDescriptor(masm, scratch);
     masm.push(scratch);
     masm.push(BaselineTailCallReg);
     masm.enterFakeExitFrame(IonNativeExitFrameLayout::Token());
 
     // If needed, update SPS Profiler frame entry.  At this point, BaselineTailCallReg
     // and scratch can be clobbered.
-    emitProfilingUpdate(masm, BaselineTailCallReg, scratch, ICCall_Native::offsetOfPCOffset());
+    emitProfilingUpdate(masm, BaselineTailCallReg, scratch, ICCall_ClassHook::offsetOfPCOffset());
 
     // Execute call.
     masm.setupUnalignedABICall(3, scratch);
     masm.loadJSContext(scratch);
     masm.passABIArg(scratch);
     masm.passABIArg(argcReg);
     masm.passABIArg(vpReg);
     masm.callWithABI(Address(BaselineStubReg, ICCall_ClassHook::offsetOfNative()));
@@ -11311,37 +11312,39 @@ ICCall_Native::Clone(JSContext *cx, ICSt
 {
     RootedFunction callee(cx, other.callee_);
     RootedNativeObject templateObject(cx, other.templateObject_);
     return New(space, other.jitCode(), firstMonitorStub, callee, templateObject,
                other.pcOffset_);
 }
 
 ICCall_ClassHook::ICCall_ClassHook(JitCode *stubCode, ICStub *firstMonitorStub,
-                                   const Class *clasp, Native native, HandleObject templateObject)
+                                   const Class *clasp, Native native,
+                                   HandleObject templateObject, uint32_t pcOffset)
   : ICMonitoredStub(ICStub::Call_ClassHook, stubCode, firstMonitorStub),
     clasp_(clasp),
     native_(JS_FUNC_TO_DATA_PTR(void *, native)),
-    templateObject_(templateObject)
+    templateObject_(templateObject),
+    pcOffset_(pcOffset)
 {
 #if defined(JS_ARM_SIMULATOR) || defined(JS_MIPS_SIMULATOR)
     // The simulator requires VM calls to be redirected to a special swi
     // instruction to handle them. To make this work, we store the redirected
     // pointer in the stub.
     native_ = Simulator::RedirectNativeFunction(native_, Args_General3);
 #endif
 }
 
 /* static */ ICCall_ClassHook *
 ICCall_ClassHook::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
                         ICCall_ClassHook &other)
 {
     RootedObject templateObject(cx, other.templateObject_);
     ICCall_ClassHook *res = New(space, other.jitCode(), firstMonitorStub,
-                                other.clasp(), nullptr, templateObject);
+                                other.clasp(), nullptr, templateObject, other.pcOffset_);
     if (res)
         res->native_ = other.native();
     return res;
 }
 
 /* static */ ICCall_ScriptedApplyArray *
 ICCall_ScriptedApplyArray::Clone(JSContext *, ICStubSpace *space, ICStub *firstMonitorStub,
                                  ICCall_ScriptedApplyArray &other)
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -5902,30 +5902,33 @@ class ICCall_Native : public ICMonitored
 class ICCall_ClassHook : public ICMonitoredStub
 {
     friend class ICStubSpace;
 
   protected:
     const Class *clasp_;
     void *native_;
     HeapPtrObject templateObject_;
+    uint32_t pcOffset_;
 
     ICCall_ClassHook(JitCode *stubCode, ICStub *firstMonitorStub,
-                     const Class *clasp, Native native, HandleObject templateObject);
+                     const Class *clasp, Native native, HandleObject templateObject,
+                     uint32_t pcOffset);
 
   public:
     static inline ICCall_ClassHook *New(ICStubSpace *space,
                                         JitCode *code, ICStub *firstMonitorStub,
                                         const Class *clasp, Native native,
-                                        HandleObject templateObject)
+                                        HandleObject templateObject,
+                                        uint32_t pcOffset)
     {
         if (!code)
             return nullptr;
         return space->allocate<ICCall_ClassHook>(code, firstMonitorStub,
-                                                 clasp, native, templateObject);
+                                                 clasp, native, templateObject, pcOffset);
     }
 
     static ICCall_ClassHook *Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorStub,
                                    ICCall_ClassHook &other);
 
     const Class *clasp() {
         return clasp_;
     }
@@ -5937,46 +5940,52 @@ class ICCall_ClassHook : public ICMonito
     }
 
     static size_t offsetOfClass() {
         return offsetof(ICCall_ClassHook, clasp_);
     }
     static size_t offsetOfNative() {
         return offsetof(ICCall_ClassHook, native_);
     }
+    static size_t offsetOfPCOffset() {
+        return offsetof(ICCall_ClassHook, pcOffset_);
+    }
 
     // Compiler for this stub kind.
     class Compiler : public ICCallStubCompiler {
       protected:
         ICStub *firstMonitorStub_;
         bool isConstructing_;
         const Class *clasp_;
         Native native_;
         RootedObject templateObject_;
+        uint32_t pcOffset_;
         bool generateStubCode(MacroAssembler &masm);
 
         virtual int32_t getKey() const {
             return static_cast<int32_t>(kind) | (static_cast<int32_t>(isConstructing_) << 16);
         }
 
       public:
         Compiler(JSContext *cx, ICStub *firstMonitorStub,
-                 const Class *clasp, Native native, HandleObject templateObject,
+                 const Class *clasp, Native native,
+                 HandleObject templateObject, uint32_t pcOffset,
                  bool isConstructing)
           : ICCallStubCompiler(cx, ICStub::Call_ClassHook),
             firstMonitorStub_(firstMonitorStub),
             isConstructing_(isConstructing),
             clasp_(clasp),
             native_(native),
-            templateObject_(cx, templateObject)
+            templateObject_(cx, templateObject),
+            pcOffset_(pcOffset)
         { }
 
         ICStub *getStub(ICStubSpace *space) {
             return ICCall_ClassHook::New(space, getStubCode(), firstMonitorStub_,
-                                         clasp_, native_, templateObject_);
+                                         clasp_, native_, templateObject_, pcOffset_);
         }
     };
 };
 
 class ICCall_ScriptedApplyArray : public ICMonitoredStub
 {
     friend class ICStubSpace;
   public: