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
--- 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