Bug 1542740: Convert NewObjectIRGenerator to use AttachDecision r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Fri, 26 Apr 2019 14:30:15 +0000
changeset 471518 7a8e62330019d4596274635543d36c0b01a559bd
parent 471517 c9e126b6fe3d2383bed37ff0a355f5a31600ac09
child 471519 85d43344501fbdca980332154e3d4e5d4bfcdb84
push id35920
push useraiakab@mozilla.com
push dateFri, 26 Apr 2019 22:02:33 +0000
treeherdermozilla-central@b13f2b24ae62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1542740
milestone68.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 1542740: Convert NewObjectIRGenerator to use AttachDecision r=mgaudet This was the last consumer of the old implementation of TryAttachStub/TryAttachIonStub. This patch removes the transitional version. Differential Revision: https://phabricator.services.mozilla.com/D27310
js/src/jit/BaselineIC.cpp
js/src/jit/CacheIR.cpp
js/src/jit/CacheIR.h
js/src/jit/IonIC.cpp
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -720,47 +720,16 @@ void ICStub::trace(JSTracer* trc) {
     default:
       break;
   }
 }
 
 // This helper handles ICState updates/transitions while attaching CacheIR
 // stubs.
 template <typename IRGenerator, typename... Args>
-static void TryAttachStubOld(const char* name, JSContext* cx,
-                             BaselineFrame* frame, ICFallbackStub* stub,
-                             BaselineCacheIRStubKind kind, Args&&... args) {
-  if (stub->state().maybeTransition()) {
-    stub->discardStubs(cx);
-  }
-
-  if (stub->state().canAttachStub()) {
-    RootedScript script(cx, frame->script());
-    jsbytecode* pc = stub->icEntry()->pc(script);
-
-    bool attached = false;
-    IRGenerator gen(cx, script, pc, stub->state().mode(),
-                    std::forward<Args>(args)...);
-    if (gen.tryAttachStub()) {
-      ICStub* newStub = AttachBaselineCacheIRStub(
-          cx, gen.writerRef(), gen.cacheKind(), kind, script, stub, &attached);
-      if (newStub) {
-        JitSpew(JitSpew_BaselineIC, "  %s %s CacheIR stub",
-                attached ? "Attached" : "Failed to attach", name);
-      }
-    }
-    if (!attached) {
-      stub->state().trackNotAttached();
-    }
-  }
-}
-
-// This helper handles ICState updates/transitions while attaching CacheIR
-// stubs.
-template <typename IRGenerator, typename... Args>
 static void TryAttachStub(const char* name, JSContext* cx, BaselineFrame* frame,
                           ICFallbackStub* stub, BaselineCacheIRStubKind kind,
                           Args&&... args) {
   if (stub->state().maybeTransition()) {
     stub->discardStubs(cx);
   }
 
   if (stub->state().canAttachStub()) {
@@ -5994,19 +5963,19 @@ bool DoNewObjectFallback(JSContext* cx, 
 
     if (obj && !obj->isSingleton() &&
         !obj->group()->maybePreliminaryObjectsDontCheckGeneration()) {
       templateObject = NewObjectOperation(cx, script, pc, TenuredObject);
       if (!templateObject) {
         return false;
       }
 
-      TryAttachStubOld<NewObjectIRGenerator>("NewObject", cx, frame, stub,
-                                             BaselineCacheIRStubKind::Regular,
-                                             JSOp(*pc), templateObject);
+      TryAttachStub<NewObjectIRGenerator>("NewObject", cx, frame, stub,
+                                          BaselineCacheIRStubKind::Regular,
+                                          JSOp(*pc), templateObject);
 
       stub->setTemplateObject(templateObject);
     }
   }
 
   if (!obj) {
     return false;
   }
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -6602,43 +6602,43 @@ NewObjectIRGenerator::NewObjectIRGenerat
 void NewObjectIRGenerator::trackAttached(const char* name) {
 #ifdef JS_CACHEIR_SPEW
   if (const CacheIRSpewer::Guard& sp = CacheIRSpewer::Guard(*this, name)) {
     sp.opcodeProperty("op", op_);
   }
 #endif
 }
 
-bool NewObjectIRGenerator::tryAttachStub() {
+AttachDecision NewObjectIRGenerator::tryAttachStub() {
   AutoAssertNoPendingException aanpe(cx_);
   if (templateObject_->as<PlainObject>().hasDynamicSlots()) {
     trackAttached(IRGenerator::NotAttached);
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Don't attach stub if group is pretenured, as the stub
   // won't succeed.
   AutoSweepObjectGroup sweep(templateObject_->group());
   if (templateObject_->group()->shouldPreTenure(sweep)) {
     trackAttached(IRGenerator::NotAttached);
-    return false;
+    return AttachDecision::NoAction;
   }
   // Stub doesn't support metadata builder
   if (cx_->realm()->hasAllocationMetadataBuilder()) {
     trackAttached(IRGenerator::NotAttached);
-    return false;
+    return AttachDecision::NoAction;
   }
 
   writer.guardNoAllocationMetadataBuilder();
   writer.guardObjectGroupNotPretenured(templateObject_->group());
   writer.loadNewObjectFromTemplateResult(templateObject_);
   writer.returnFromIC();
 
   trackAttached("NewObjectWithTemplate");
-  return true;
+  return AttachDecision::Attach;
 }
 
 #ifdef JS_SIMULATOR
 bool js::jit::CallAnyNative(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   RootedObject calleeObj(cx, &args.callee());
 
   MOZ_ASSERT(calleeObj->is<JSFunction>());
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -2504,17 +2504,17 @@ class MOZ_RAII NewObjectIRGenerator : pu
   HandleObject templateObject_;
 
   void trackAttached(const char* name);
 
  public:
   NewObjectIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,
                        ICState::Mode, JSOp op, HandleObject templateObj);
 
-  bool tryAttachStub();
+  AttachDecision tryAttachStub();
 };
 
 static inline uint32_t SimpleTypeDescrKey(SimpleTypeDescr* descr) {
   if (descr->is<ScalarTypeDescr>()) {
     return uint32_t(descr->as<ScalarTypeDescr>().type()) << 1;
   }
   return (uint32_t(descr->as<ReferenceTypeDescr>().type()) << 1) | 1;
 }
--- a/js/src/jit/IonIC.cpp
+++ b/js/src/jit/IonIC.cpp
@@ -113,40 +113,16 @@ void IonIC::trace(JSTracer* trc) {
   }
 
   MOZ_ASSERT(nextCodeRaw == fallbackLabel_.raw());
 }
 
 // This helper handles ICState updates/transitions while attaching CacheIR
 // stubs.
 template <typename IRGenerator, typename IC, typename... Args>
-static void TryAttachIonStubOld(JSContext* cx, IC* ic, IonScript* ionScript,
-                                Args&&... args) {
-  if (ic->state().maybeTransition()) {
-    ic->discardStubs(cx->zone());
-  }
-
-  if (ic->state().canAttachStub()) {
-    RootedScript script(cx, ic->script());
-    bool attached = false;
-    IRGenerator gen(cx, script, ic->pc(), ic->state().mode(),
-                    std::forward<Args>(args)...);
-    if (gen.tryAttachStub()) {
-      ic->attachCacheIRStub(cx, gen.writerRef(), gen.cacheKind(), ionScript,
-                            &attached);
-    }
-    if (!attached) {
-      ic->state().trackNotAttached();
-    }
-  }
-}
-
-// This helper handles ICState updates/transitions while attaching CacheIR
-// stubs.
-template <typename IRGenerator, typename IC, typename... Args>
 static void TryAttachIonStub(JSContext* cx, IC* ic, IonScript* ionScript,
                              Args&&... args) {
   if (ic->state().maybeTransition()) {
     ic->discardStubs(cx->zone());
   }
 
   if (ic->state().canAttachStub()) {
     RootedScript script(cx, ic->script());