Bug 1542740: Convert GetNameIRGenerator to use AttachDecision r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Fri, 26 Apr 2019 14:28:16 +0000
changeset 471522 3169b44fe327b503594fbbf6cce6f4500c703a2e
parent 471521 f3c7978228c0c13793704a6e1b9bab1387c003eb
child 471523 b9871f6c9a35abaf847e01d4b902bb57b87ac3a4
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 GetNameIRGenerator to use AttachDecision r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D27299
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
@@ -2681,19 +2681,19 @@ bool DoGetNameFallback(JSContext* cx, Ba
   jsbytecode* pc = stub->icEntry()->pc(script);
   mozilla::DebugOnly<JSOp> op = JSOp(*pc);
   FallbackICSpew(cx, stub, "GetName(%s)", CodeName[JSOp(*pc)]);
 
   MOZ_ASSERT(op == JSOP_GETNAME || op == JSOP_GETGNAME);
 
   RootedPropertyName name(cx, script->getName(pc));
 
-  TryAttachStubOld<GetNameIRGenerator>("GetName", cx, frame, stub,
-                                       BaselineCacheIRStubKind::Monitored,
-                                       envChain, name);
+  TryAttachStub<GetNameIRGenerator>("GetName", cx, frame, stub,
+                                    BaselineCacheIRStubKind::Monitored,
+                                    envChain, name);
 
   static_assert(JSOP_GETGNAME_LENGTH == JSOP_GETNAME_LENGTH,
                 "Otherwise our check for JSOP_TYPEOF isn't ok");
   if (JSOp(pc[JSOP_GETGNAME_LENGTH]) == JSOP_TYPEOF) {
     if (!GetEnvironmentName<GetNameMode::TypeOf>(cx, envChain, name, res)) {
       return false;
     }
   } else {
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -2364,36 +2364,30 @@ void SetPropIRGenerator::maybeEmitIdGuar
 GetNameIRGenerator::GetNameIRGenerator(JSContext* cx, HandleScript script,
                                        jsbytecode* pc, ICState::Mode mode,
                                        HandleObject env,
                                        HandlePropertyName name)
     : IRGenerator(cx, script, pc, CacheKind::GetName, mode),
       env_(env),
       name_(name) {}
 
-bool GetNameIRGenerator::tryAttachStub() {
+AttachDecision GetNameIRGenerator::tryAttachStub() {
   MOZ_ASSERT(cacheKind_ == CacheKind::GetName);
 
   AutoAssertNoPendingException aanpe(cx_);
 
   ObjOperandId envId(writer.setInputOperandId(0));
   RootedId id(cx_, NameToId(name_));
 
-  if (tryAttachGlobalNameValue(envId, id)) {
-    return true;
-  }
-  if (tryAttachGlobalNameGetter(envId, id)) {
-    return true;
-  }
-  if (tryAttachEnvironmentName(envId, id)) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachGlobalNameValue(envId, id));
+  TRY_ATTACH(tryAttachGlobalNameGetter(envId, id));
+  TRY_ATTACH(tryAttachEnvironmentName(envId, id));
 
   trackAttached(IRGenerator::NotAttached);
-  return false;
+  return AttachDecision::NoAction;
 }
 
 bool CanAttachGlobalName(JSContext* cx,
                          Handle<LexicalEnvironmentObject*> globalLexical,
                          HandleId id, MutableHandleNativeObject holder,
                          MutableHandleShape shape) {
   // The property must be found, and it must be found as a normal data property.
   RootedNativeObject current(cx, globalLexical);
@@ -2419,40 +2413,40 @@ bool CanAttachGlobalName(JSContext* cx,
       current = &proto->as<NativeObject>();
     }
   }
 
   holder.set(current);
   return true;
 }
 
-bool GetNameIRGenerator::tryAttachGlobalNameValue(ObjOperandId objId,
-                                                  HandleId id) {
+AttachDecision GetNameIRGenerator::tryAttachGlobalNameValue(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());
 
   RootedNativeObject holder(cx_);
   RootedShape shape(cx_);
   if (!CanAttachGlobalName(cx_, globalLexical, id, &holder, &shape)) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // The property must be found, and it must be found as a normal data property.
   if (!shape->isDataProperty()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // This might still be an uninitialized lexical.
   if (holder->getSlot(shape->slot()).isMagic()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Instantiate this global property, for use during Ion compilation.
   if (IsIonEnabled(cx_)) {
     EnsureTrackPropertyTypes(cx_, holder, id);
   }
 
   if (holder == globalLexical) {
@@ -2463,17 +2457,17 @@ bool GetNameIRGenerator::tryAttachGlobal
     writer.loadDynamicSlotResult(objId, dynamicSlotOffset);
   } else {
     // Check the prototype chain from the global to the holder
     // prototype. Ignore the global lexical scope as it doesn't figure
     // into the prototype chain. We guard on the global lexical
     // scope's shape independently.
     if (!IsCacheableGetPropReadSlot(&globalLexical->global(), holder,
                                     PropertyResult(shape))) {
-      return false;
+      return AttachDecision::NoAction;
     }
 
     // Shape guard for global lexical.
     writer.guardShape(objId, globalLexical->lastProperty());
 
     // Guard on the shape of the GlobalObject.
     ObjOperandId globalId = writer.loadEnclosingEnvironment(objId);
     writer.guardShape(globalId, globalLexical->global().lastProperty());
@@ -2486,41 +2480,41 @@ bool GetNameIRGenerator::tryAttachGlobal
     }
 
     EmitLoadSlotResult(writer, holderId, holder, shape);
   }
 
   writer.typeMonitorResult();
 
   trackAttached("GlobalNameValue");
-  return true;
-}
-
-bool GetNameIRGenerator::tryAttachGlobalNameGetter(ObjOperandId objId,
-                                                   HandleId id) {
+  return AttachDecision::Attach;
+}
+
+AttachDecision GetNameIRGenerator::tryAttachGlobalNameGetter(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());
 
   RootedNativeObject holder(cx_);
   RootedShape shape(cx_);
   if (!CanAttachGlobalName(cx_, globalLexical, id, &holder, &shape)) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (holder == globalLexical) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (!IsCacheableGetPropCallNative(&globalLexical->global(), holder, shape)) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (IsIonEnabled(cx_)) {
     EnsureTrackPropertyTypes(cx_, holder, id);
   }
 
   // Shape guard for global lexical.
   writer.guardShape(objId, globalLexical->lastProperty());
@@ -2534,17 +2528,17 @@ bool GetNameIRGenerator::tryAttachGlobal
     ObjOperandId holderId = writer.loadObject(holder);
     writer.guardShape(holderId, holder->lastProperty());
   }
 
   EmitCallGetterResultNoGuards(writer, &globalLexical->global(), holder, shape,
                                globalId);
 
   trackAttached("GlobalNameGetter");
-  return true;
+  return AttachDecision::Attach;
 }
 
 static bool NeedEnvironmentShapeGuard(JSObject* envObj) {
   if (!envObj->is<CallObject>()) {
     return true;
   }
 
   // We can skip a guard on the call object if the script's bindings are
@@ -2555,37 +2549,37 @@ static bool NeedEnvironmentShapeGuard(JS
   JSFunction* fun = &callObj->callee();
   if (!fun->hasScript() || fun->nonLazyScript()->funHasExtensibleScope()) {
     return true;
   }
 
   return false;
 }
 
-bool GetNameIRGenerator::tryAttachEnvironmentName(ObjOperandId objId,
-                                                  HandleId id) {
+AttachDecision GetNameIRGenerator::tryAttachEnvironmentName(ObjOperandId objId,
+                                                            HandleId id) {
   if (IsGlobalOp(JSOp(*pc_)) || script_->hasNonSyntacticScope()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   RootedObject env(cx_, env_);
   RootedShape shape(cx_);
   RootedNativeObject holder(cx_);
 
   while (env) {
     if (env->is<GlobalObject>()) {
       shape = env->as<GlobalObject>().lookup(cx_, id);
       if (shape) {
         break;
       }
-      return false;
+      return AttachDecision::NoAction;
     }
 
     if (!env->is<EnvironmentObject>() || env->is<WithEnvironmentObject>()) {
-      return false;
+      return AttachDecision::NoAction;
     }
 
     MOZ_ASSERT(!env->hasUncacheableProto());
 
     // Check for an 'own' property on the env. There is no need to
     // check the prototype as non-with scopes do not inherit properties
     // from any prototype.
     shape = env->as<NativeObject>().lookup(cx_, id);
@@ -2593,20 +2587,20 @@ bool GetNameIRGenerator::tryAttachEnviro
       break;
     }
 
     env = env->enclosingEnvironment();
   }
 
   holder = &env->as<NativeObject>();
   if (!IsCacheableGetPropReadSlot(holder, holder, PropertyResult(shape))) {
-    return false;
+    return AttachDecision::NoAction;
   }
   if (holder->getSlot(shape->slot()).isMagic()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ObjOperandId lastObjId = objId;
   env = env_;
   while (env) {
     if (NeedEnvironmentShapeGuard(env)) {
       writer.guardShape(lastObjId, env->shape());
     }
@@ -2625,17 +2619,17 @@ bool GetNameIRGenerator::tryAttachEnviro
   } else {
     size_t dynamicSlotOffset =
         holder->dynamicSlotIndex(shape->slot()) * sizeof(Value);
     writer.loadEnvironmentDynamicSlotResult(lastObjId, dynamicSlotOffset);
   }
   writer.typeMonitorResult();
 
   trackAttached("EnvironmentName");
-  return true;
+  return AttachDecision::Attach;
 }
 
 void GetNameIRGenerator::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
@@ -2082,28 +2082,28 @@ class MOZ_RAII GetPropIRGenerator : publ
   }
 };
 
 // GetNameIRGenerator generates CacheIR for a GetName IC.
 class MOZ_RAII GetNameIRGenerator : public IRGenerator {
   HandleObject env_;
   HandlePropertyName name_;
 
-  bool tryAttachGlobalNameValue(ObjOperandId objId, HandleId id);
-  bool tryAttachGlobalNameGetter(ObjOperandId objId, HandleId id);
-  bool tryAttachEnvironmentName(ObjOperandId objId, HandleId id);
+  AttachDecision tryAttachGlobalNameValue(ObjOperandId objId, HandleId id);
+  AttachDecision tryAttachGlobalNameGetter(ObjOperandId objId, HandleId id);
+  AttachDecision tryAttachEnvironmentName(ObjOperandId objId, HandleId id);
 
   void trackAttached(const char* name);
 
  public:
   GetNameIRGenerator(JSContext* cx, HandleScript script, jsbytecode* pc,
                      ICState::Mode mode, HandleObject env,
                      HandlePropertyName name);
 
-  bool tryAttachStub();
+  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);
--- a/js/src/jit/IonIC.cpp
+++ b/js/src/jit/IonIC.cpp
@@ -404,18 +404,18 @@ bool IonSetPropertyIC::update(JSContext*
 /* static */
 bool IonGetNameIC::update(JSContext* cx, HandleScript outerScript,
                           IonGetNameIC* ic, HandleObject envChain,
                           MutableHandleValue res) {
   IonScript* ionScript = outerScript->ionScript();
   jsbytecode* pc = ic->pc();
   RootedPropertyName name(cx, ic->script()->getName(pc));
 
-  TryAttachIonStubOld<GetNameIRGenerator, IonGetNameIC>(cx, ic, ionScript,
-                                                        envChain, name);
+  TryAttachIonStub<GetNameIRGenerator, IonGetNameIC>(cx, ic, ionScript,
+                                                     envChain, name);
 
   RootedObject obj(cx);
   RootedObject holder(cx);
   Rooted<PropertyResult> prop(cx);
   if (!LookupName(cx, name, envChain, &obj, &holder, &prop)) {
     return false;
   }