Bug 1542740: Convert BindNameIRGenerator to use AttachDecision r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Fri, 26 Apr 2019 14:28:23 +0000
changeset 471523 b9871f6c9a35abaf847e01d4b902bb57b87ac3a4
parent 471522 3169b44fe327b503594fbbf6cce6f4500c703a2e
child 471524 448eb3cd7fdf864db3a331fc1dd405ba19d3f316
push id84143
push useriireland@mozilla.com
push dateFri, 26 Apr 2019 15:09:46 +0000
treeherderautoland@85d43344501f [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 BindNameIRGenerator to use AttachDecision r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D27300
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
@@ -2739,19 +2739,19 @@ bool DoBindNameFallback(JSContext* cx, B
   jsbytecode* pc = stub->icEntry()->pc(frame->script());
   mozilla::DebugOnly<JSOp> op = JSOp(*pc);
   FallbackICSpew(cx, stub, "BindName(%s)", CodeName[JSOp(*pc)]);
 
   MOZ_ASSERT(op == JSOP_BINDNAME || op == JSOP_BINDGNAME);
 
   RootedPropertyName name(cx, frame->script()->getName(pc));
 
-  TryAttachStubOld<BindNameIRGenerator>("BindName", cx, frame, stub,
-                                        BaselineCacheIRStubKind::Regular,
-                                        envChain, name);
+  TryAttachStub<BindNameIRGenerator>("BindName", cx, frame, stub,
+                                     BaselineCacheIRStubKind::Regular, envChain,
+                                     name);
 
   RootedObject scope(cx);
   if (!LookupNameUnqualified(cx, name, envChain, &scope)) {
     return false;
   }
 
   res.setObject(*scope);
   return true;
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -2639,50 +2639,47 @@ void GetNameIRGenerator::trackAttached(c
 BindNameIRGenerator::BindNameIRGenerator(JSContext* cx, HandleScript script,
                                          jsbytecode* pc, ICState::Mode mode,
                                          HandleObject env,
                                          HandlePropertyName name)
     : IRGenerator(cx, script, pc, CacheKind::BindName, mode),
       env_(env),
       name_(name) {}
 
-bool BindNameIRGenerator::tryAttachStub() {
+AttachDecision BindNameIRGenerator::tryAttachStub() {
   MOZ_ASSERT(cacheKind_ == CacheKind::BindName);
 
   AutoAssertNoPendingException aanpe(cx_);
 
   ObjOperandId envId(writer.setInputOperandId(0));
   RootedId id(cx_, NameToId(name_));
 
-  if (tryAttachGlobalName(envId, id)) {
-    return true;
-  }
-  if (tryAttachEnvironmentName(envId, id)) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachGlobalName(envId, id));
+  TRY_ATTACH(tryAttachEnvironmentName(envId, id));
 
   trackAttached(IRGenerator::NotAttached);
-  return false;
-}
-
-bool BindNameIRGenerator::tryAttachGlobalName(ObjOperandId objId, HandleId id) {
+  return AttachDecision::NoAction;
+}
+
+AttachDecision BindNameIRGenerator::tryAttachGlobalName(ObjOperandId objId,
+                                                        HandleId id) {
   if (!IsGlobalOp(JSOp(*pc_)) || script_->hasNonSyntacticScope()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   Handle<LexicalEnvironmentObject*> globalLexical =
       env_.as<LexicalEnvironmentObject>();
   MOZ_ASSERT(globalLexical->isGlobal());
 
   JSObject* result = nullptr;
   if (Shape* shape = globalLexical->lookup(cx_, id)) {
     // If this is an uninitialized lexical or a const, we need to return a
     // RuntimeLexicalErrorObject.
     if (globalLexical->getSlot(shape->slot()).isMagic() || !shape->writable()) {
-      return false;
+      return AttachDecision::NoAction;
     }
     result = globalLexical;
   } else {
     result = &globalLexical->global();
   }
 
   if (result == globalLexical) {
     // Lexical bindings are non-configurable so we can just return the
@@ -2697,33 +2694,33 @@ bool BindNameIRGenerator::tryAttachGloba
       writer.guardShape(objId, globalLexical->lastProperty());
     }
     ObjOperandId globalId = writer.loadEnclosingEnvironment(objId);
     writer.loadObjectResult(globalId);
   }
   writer.returnFromIC();
 
   trackAttached("GlobalName");
-  return true;
-}
-
-bool BindNameIRGenerator::tryAttachEnvironmentName(ObjOperandId objId,
-                                                   HandleId id) {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BindNameIRGenerator::tryAttachEnvironmentName(ObjOperandId objId,
+                                                             HandleId id) {
   if (IsGlobalOp(JSOp(*pc_)) || script_->hasNonSyntacticScope()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   RootedObject env(cx_, env_);
   RootedShape shape(cx_);
   while (true) {
     if (!env->is<GlobalObject>() && !env->is<EnvironmentObject>()) {
-      return false;
+      return AttachDecision::NoAction;
     }
     if (env->is<WithEnvironmentObject>()) {
-      return false;
+      return AttachDecision::NoAction;
     }
 
     MOZ_ASSERT(!env->hasUncacheableProto());
 
     // When we reach an unqualified variables object (like the global) we
     // have to stop looking and return that object.
     if (env->isUnqualifiedVarObj()) {
       break;
@@ -2740,17 +2737,17 @@ bool BindNameIRGenerator::tryAttachEnvir
     env = env->enclosingEnvironment();
   }
 
   // If this is an uninitialized lexical or a const, we need to return a
   // RuntimeLexicalErrorObject.
   RootedNativeObject holder(cx_, &env->as<NativeObject>());
   if (shape && holder->is<EnvironmentObject>() &&
       (holder->getSlot(shape->slot()).isMagic() || !shape->writable())) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ObjOperandId lastObjId = objId;
   env = env_;
   while (env) {
     if (NeedEnvironmentShapeGuard(env) && !env->is<GlobalObject>()) {
       writer.guardShape(lastObjId, env->shape());
     }
@@ -2761,17 +2758,17 @@ bool BindNameIRGenerator::tryAttachEnvir
 
     lastObjId = writer.loadEnclosingEnvironment(lastObjId);
     env = env->enclosingEnvironment();
   }
   writer.loadObjectResult(lastObjId);
   writer.returnFromIC();
 
   trackAttached("EnvironmentName");
-  return true;
+  return AttachDecision::Attach;
 }
 
 void BindNameIRGenerator::trackAttached(const char* name) {
 #ifdef JS_CACHEIR_SPEW
   if (const CacheIRSpewer::Guard& sp = CacheIRSpewer::Guard(*this, name)) {
     sp.valueProperty("base", ObjectValue(*env_));
     sp.valueProperty("property", StringValue(name_));
   }
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -2101,27 +2101,27 @@ class MOZ_RAII GetNameIRGenerator : publ
   AttachDecision tryAttachStub();
 };
 
 // BindNameIRGenerator generates CacheIR for a BindName IC.
 class MOZ_RAII BindNameIRGenerator : public IRGenerator {
   HandleObject env_;
   HandlePropertyName name_;
 
-  bool tryAttachGlobalName(ObjOperandId objId, HandleId id);
-  bool tryAttachEnvironmentName(ObjOperandId objId, HandleId id);
+  AttachDecision tryAttachGlobalName(ObjOperandId objId, HandleId id);
+  AttachDecision tryAttachEnvironmentName(ObjOperandId objId, HandleId id);
 
   void trackAttached(const char* name);
 
  public:
   BindNameIRGenerator(JSContext* cx, HandleScript script, jsbytecode* pc,
                       ICState::Mode mode, HandleObject env,
                       HandlePropertyName name);
 
-  bool tryAttachStub();
+  AttachDecision tryAttachStub();
 };
 
 // Information used by SetProp/SetElem stubs to check/update property types.
 class MOZ_RAII PropertyTypeCheckInfo {
   RootedObjectGroup group_;
   RootedId id_;
   bool needsTypeBarrier_;
 
--- a/js/src/jit/IonIC.cpp
+++ b/js/src/jit/IonIC.cpp
@@ -437,18 +437,18 @@ bool IonGetNameIC::update(JSContext* cx,
 
 /* static */
 JSObject* IonBindNameIC::update(JSContext* cx, HandleScript outerScript,
                                 IonBindNameIC* ic, HandleObject envChain) {
   IonScript* ionScript = outerScript->ionScript();
   jsbytecode* pc = ic->pc();
   RootedPropertyName name(cx, ic->script()->getName(pc));
 
-  TryAttachIonStubOld<BindNameIRGenerator, IonBindNameIC>(cx, ic, ionScript,
-                                                          envChain, name);
+  TryAttachIonStub<BindNameIRGenerator, IonBindNameIC>(cx, ic, ionScript,
+                                                       envChain, name);
 
   RootedObject holder(cx);
   if (!LookupNameUnqualified(cx, name, envChain, &holder)) {
     return nullptr;
   }
 
   return holder;
 }