Bug 662132: Better coordination of GC and ICs, r=dvander, a=clegnitto
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 23 Jun 2011 18:19:57 -0700
changeset 70564 a7367773bb010c74f21b5c83eb05492a6fe8b509
parent 70563 4a1e595c3a96a477492f9b55abea609acd284d48
child 70565 5f3522e3e4ae9e2608b37198dbe1fcd66a7fb864
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersdvander, clegnitto
bugs662132
milestone6.0
Bug 662132: Better coordination of GC and ICs, r=dvander, a=clegnitto
js/src/methodjit/PolyIC.cpp
--- a/js/src/methodjit/PolyIC.cpp
+++ b/js/src/methodjit/PolyIC.cpp
@@ -141,20 +141,22 @@ class PICLinker : public LinkerHelper
 class PICStubCompiler : public BaseCompiler
 {
   protected:
     const char *type;
     VMFrame &f;
     JSScript *script;
     ic::PICInfo &pic;
     void *stub;
+    uint32 gcNumber;
 
   public:
     PICStubCompiler(const char *type, VMFrame &f, JSScript *script, ic::PICInfo &pic, void *stub)
-      : BaseCompiler(f.cx), type(type), f(f), script(script), pic(pic), stub(stub)
+      : BaseCompiler(f.cx), type(type), f(f), script(script), pic(pic), stub(stub),
+        gcNumber(f.cx->runtime->gcNumber)
     { }
 
     bool isCallOp() const {
         if (pic.kind == ic::PICInfo::CALL)
             return true;
         return !!(js_CodeSpec[pic.op].format & JOF_CALLOP);
     }
 
@@ -170,16 +172,20 @@ class PICStubCompiler : public BaseCompi
     LookupStatus disable(const char *reason) {
         return disable(f.cx, reason);
     }
 
     LookupStatus disable(JSContext *cx, const char *reason) {
         return pic.disable(cx, reason, stub);
     }
 
+    bool hadGC() {
+        return gcNumber != f.cx->runtime->gcNumber;
+    }
+
   protected:
     void spew(const char *event, const char *op) {
 #ifdef JS_METHODJIT_SPEW
         JaegerSpew(JSpew_PICs, "%s %s: %s (%s: %d)\n",
                    type, event, op, script->filename,
                    js_FramePCToLineNumber(cx, f.fp()));
 #endif
     }
@@ -269,16 +275,19 @@ class SetPropCompiler : public PICStubCo
             repatcher.relink(pic.setPropLabels().getInlineShapeJump(shapeGuard), cs);
         }
         if (int secondGuardOffset = getLastStubSecondShapeGuard())
             repatcher.relink(label.jumpAtOffset(secondGuardOffset), cs);
     }
 
     LookupStatus generateStub(uint32 initialShape, const Shape *shape, bool adding, bool inlineSlot)
     {
+        if (hadGC())
+            return Lookup_Uncacheable;
+
         /* Exits to the slow path. */
         Vector<Jump, 8> slowExits(cx);
         Vector<Jump, 8> otherGuards(cx);
 
         Assembler masm;
 
         // Shape guard.
         if (pic.shapeNeedsRemat()) {
@@ -892,16 +901,18 @@ class GetPropCompiler : public PICStubCo
             return disable("String.prototype without compile-and-go");
 
         GetPropertyHelper<GetPropCompiler> getprop(cx, obj, atom, *this);
         LookupStatus status = getprop.lookupAndTest();
         if (status != Lookup_Cacheable)
             return status;
         if (getprop.obj != getprop.holder)
             return disable("proto walk on String.prototype");
+        if (hadGC())
+            return Lookup_Uncacheable;
 
         Assembler masm;
 
         /* Only strings are allowed. */
         Jump notString = masm.branchPtr(Assembler::NotEqual, pic.typeReg(),
                                         ImmType(JSVAL_TYPE_STRING));
 
         /*
@@ -1145,16 +1156,18 @@ class GetPropCompiler : public PICStubCo
     LookupStatus update()
     {
         JS_ASSERT(pic.hit);
 
         GetPropertyHelper<GetPropCompiler> getprop(cx, obj, atom, *this);
         LookupStatus status = getprop.lookupAndTest();
         if (status != Lookup_Cacheable)
             return status;
+        if (hadGC())
+            return Lookup_Uncacheable;
 
         if (obj == getprop.holder && !pic.inlinePathPatched)
             return patchInline(getprop.holder, getprop.shape);
 
         return generateStub(getprop.holder, getprop.shape);
     }
 };