Bug 1542740: Convert TypeOfIRGenerator to use AttachDecision r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Fri, 26 Apr 2019 14:28:56 +0000
changeset 471526 f96d9bb8699791a332ab8e68af1137de39c38ff3
parent 471525 1e1017253de570f2440de2dc2ccbfe2b6646ae60
child 471527 ec38ecf241e2974a594e4ed362632dc3ccde03ac
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 TypeOfIRGenerator to use AttachDecision r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D27303
js/src/jit/BaselineIC.cpp
js/src/jit/CacheIR.cpp
js/src/jit/CacheIR.h
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -5508,18 +5508,18 @@ bool FallbackICCodeCompiler::emit_Instan
 //
 
 bool DoTypeOfFallback(JSContext* cx, BaselineFrame* frame,
                       ICTypeOf_Fallback* stub, HandleValue val,
                       MutableHandleValue res) {
   stub->incrementEnteredCount();
   FallbackICSpew(cx, stub, "TypeOf");
 
-  TryAttachStubOld<TypeOfIRGenerator>("TypeOf", cx, frame, stub,
-                                      BaselineCacheIRStubKind::Regular, val);
+  TryAttachStub<TypeOfIRGenerator>("TypeOf", cx, frame, stub,
+                                   BaselineCacheIRStubKind::Regular, val);
 
   JSType type = js::TypeOfValue(val);
   RootedString string(cx, TypeName(type, cx->names()));
   res.setString(string);
   return true;
 }
 
 bool FallbackICCodeCompiler::emit_TypeOf() {
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -4485,58 +4485,57 @@ TypeOfIRGenerator::TypeOfIRGenerator(JSC
 void TypeOfIRGenerator::trackAttached(const char* name) {
 #ifdef JS_CACHEIR_SPEW
   if (const CacheIRSpewer::Guard& sp = CacheIRSpewer::Guard(*this, name)) {
     sp.valueProperty("val", val_);
   }
 #endif
 }
 
-bool TypeOfIRGenerator::tryAttachStub() {
+AttachDecision TypeOfIRGenerator::tryAttachStub() {
   MOZ_ASSERT(cacheKind_ == CacheKind::TypeOf);
 
   AutoAssertNoPendingException aanpe(cx_);
 
   ValOperandId valId(writer.setInputOperandId(0));
 
-  if (tryAttachPrimitive(valId)) {
-    return true;
-  }
-
-  MOZ_ALWAYS_TRUE(tryAttachObject(valId));
-  return true;
-}
-
-bool TypeOfIRGenerator::tryAttachPrimitive(ValOperandId valId) {
+  TRY_ATTACH(tryAttachPrimitive(valId));
+  TRY_ATTACH(tryAttachObject(valId));
+
+  MOZ_ASSERT_UNREACHABLE("Failed to attach TypeOf");
+  return AttachDecision::NoAction;
+}
+
+AttachDecision TypeOfIRGenerator::tryAttachPrimitive(ValOperandId valId) {
   if (!val_.isPrimitive()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (val_.isNumber()) {
     writer.guardIsNumber(valId);
   } else {
     writer.guardType(valId, val_.type());
   }
 
   writer.loadStringResult(TypeName(js::TypeOfValue(val_), cx_->names()));
   writer.returnFromIC();
   trackAttached("Primitive");
-  return true;
-}
-
-bool TypeOfIRGenerator::tryAttachObject(ValOperandId valId) {
+  return AttachDecision::Attach;
+}
+
+AttachDecision TypeOfIRGenerator::tryAttachObject(ValOperandId valId) {
   if (!val_.isObject()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ObjOperandId objId = writer.guardIsObject(valId);
   writer.loadTypeOfObjectResult(objId);
   writer.returnFromIC();
   trackAttached("Object");
-  return true;
+  return AttachDecision::Attach;
 }
 
 GetIteratorIRGenerator::GetIteratorIRGenerator(JSContext* cx,
                                                HandleScript script,
                                                jsbytecode* pc,
                                                ICState::Mode mode,
                                                HandleValue value)
     : IRGenerator(cx, script, pc, CacheKind::GetIterator, mode), val_(value) {}
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -2310,25 +2310,25 @@ class MOZ_RAII InstanceOfIRGenerator : p
                         HandleValue, HandleObject);
 
   AttachDecision tryAttachStub();
 };
 
 class MOZ_RAII TypeOfIRGenerator : public IRGenerator {
   HandleValue val_;
 
-  bool tryAttachPrimitive(ValOperandId valId);
-  bool tryAttachObject(ValOperandId valId);
+  AttachDecision tryAttachPrimitive(ValOperandId valId);
+  AttachDecision tryAttachObject(ValOperandId valId);
   void trackAttached(const char* name);
 
  public:
   TypeOfIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,
                     ICState::Mode mode, HandleValue value);
 
-  bool tryAttachStub();
+  AttachDecision tryAttachStub();
 };
 
 class MOZ_RAII GetIteratorIRGenerator : public IRGenerator {
   HandleValue val_;
 
   bool tryAttachNativeIterator(ObjOperandId objId, HandleObject obj);
 
  public: