Bug 1248503 - Improve log output for MSimdBox and MSimdUnbox. r=nbp draft
authorJakob Stoklund Olesen <jolesen@mozilla.com>
Wed, 17 Feb 2016 10:17:49 -0800
changeset 331633 b72d256b0623c662db460481ecea8786f818aed4
parent 331632 5039eb1fa76cc1872f7c1372b5d8569188d36998
child 331634 f130b356de408bbaeecf3ff1070266e0223d4aaa
push id11020
push userjolesen@mozilla.com
push dateWed, 17 Feb 2016 18:16:38 +0000
reviewersnbp
bugs1248503
milestone47.0a1
Bug 1248503 - Improve log output for MSimdBox and MSimdUnbox. r=nbp Add a function SimdTypeToString used for logging purposes only. Include the exact SimdType and initial heap when logging MSimdBox and MSimdUnbox instructions. MozReview-Commit-ID: 1WbwaQgMLqm
js/src/builtin/SIMD.cpp
js/src/builtin/SIMD.h
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -90,16 +90,28 @@ js::IsVectorObject(HandleValue v)
   macro(Bool32x4)            \
   macro(Bool64x2)
 
 #define InstantiateIsVectorObject_(T) \
     template bool js::IsVectorObject<T>(HandleValue v);
 FOR_EACH_SIMD(InstantiateIsVectorObject_)
 #undef InstantiateIsVectorObject_
 
+const char*
+js::SimdTypeToString(SimdType type)
+{
+    switch (type) {
+#define RETSTR_(TYPE) case SimdType::TYPE: return #TYPE;
+      FOR_EACH_SIMD(RETSTR_)
+#undef RETSTR_
+      case SimdType::Count: break;
+    }
+    return "<bad SimdType>";
+}
+
 static inline bool
 ErrorBadArgs(JSContext* cx)
 {
     JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS);
     return false;
 }
 
 static inline bool
--- a/js/src/builtin/SIMD.h
+++ b/js/src/builtin/SIMD.h
@@ -1114,16 +1114,18 @@ struct Bool64x2 {
     }
     static Value ToValue(Elem value) {
         return BooleanValue(value);
     }
 };
 
 PropertyName* SimdTypeToName(JSContext* cx, SimdType type);
 
+const char* SimdTypeToString(SimdType type);
+
 template<typename V>
 JSObject* CreateSimd(JSContext* cx, const typename V::Elem* data);
 
 template<typename V>
 bool IsVectorObject(HandleValue v);
 
 template<typename V>
 bool ToSimdConstant(JSContext* cx, HandleValue v, jit::SimdConstant* out);
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -1339,16 +1339,31 @@ MSimdShift::printOpcode(GenericPrinter& 
 
 void
 MSimdInsertElement::printOpcode(GenericPrinter& out) const
 {
     MDefinition::printOpcode(out);
     out.printf(" (%s)", MSimdInsertElement::LaneName(lane()));
 }
 
+void
+MSimdBox::printOpcode(GenericPrinter& out) const
+{
+    MDefinition::printOpcode(out);
+    out.printf(" (%s%s)", SimdTypeToString(simdType()),
+               initialHeap() == gc::TenuredHeap ? ", tenured" : "");
+}
+
+void
+MSimdUnbox::printOpcode(GenericPrinter& out) const
+{
+    MDefinition::printOpcode(out);
+    out.printf(" (%s)", SimdTypeToString(simdType()));
+}
+
 MCloneLiteral*
 MCloneLiteral::New(TempAllocator& alloc, MDefinition* obj)
 {
     return new(alloc) MCloneLiteral(obj);
 }
 
 void
 MControlInstruction::printOpcode(GenericPrinter& out) const
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -3484,16 +3484,17 @@ class MSimdBox
         MOZ_ASSERT(box->initialHeap() == initialHeap());
         return true;
     }
 
     AliasSet getAliasSet() const override {
         return AliasSet::None();
     }
 
+    void printOpcode(GenericPrinter& out) const override;
     bool writeRecoverData(CompactBufferWriter& writer) const override;
     bool canRecoverOnBailout() const override {
         return true;
     }
 };
 
 class MSimdUnbox
   : public MUnaryInstruction,
@@ -3529,16 +3530,18 @@ class MSimdUnbox
         if (!congruentIfOperandsEqual(ins))
             return false;
         return ins->toSimdUnbox()->simdType() == simdType();
     }
 
     AliasSet getAliasSet() const override {
         return AliasSet::None();
     }
+
+    void printOpcode(GenericPrinter& out) const override;
 };
 
 // Creates a new derived type object. At runtime, this is just a call
 // to `BinaryBlock::createDerived()`. That is, the MIR itself does not
 // compile to particularly optimized code. However, using a distinct
 // MIR for creating derived type objects allows the compiler to
 // optimize ephemeral typed objects as would be created for a
 // reference like `a.b.c` -- here, the `a.b` will create an ephemeral