Bug 1244254 - Move SimdTypeToMIRType into the header. r=nbp

Provide two versions of this function:

- MaybeSimdTypeToMIRType returns false for unsupported SimdTypes.
- SimdTypeToMIRType asserts that the type is supported.

The conditional one is used in IonBuilder::inlineConstructSimdObject() to
provide a 'SimdTypeNotOptimized' outcome for JIT coach.
This commit is contained in:
Jakob Stoklund Olesen 2016-02-09 08:45:59 -08:00
parent 720d026727
commit 138ad03336
2 changed files with 31 additions and 13 deletions

View File

@ -3267,18 +3267,6 @@ IonBuilder::convertToBooleanSimdLane(MDefinition* scalar)
return result;
}
static inline
bool SimdTypeToMIRType(SimdType type, MIRType* mirType)
{
switch (type) {
case SimdType::Int32x4:
case SimdType::Uint32x4: *mirType = MIRType_Int32x4; return true;
case SimdType::Float32x4: *mirType = MIRType_Float32x4; return true;
case SimdType::Bool32x4: *mirType = MIRType_Bool32x4; return true;
default: return false;
}
}
IonBuilder::InliningStatus
IonBuilder::inlineConstructSimdObject(CallInfo& callInfo, SimdTypeDescr* descr)
{
@ -3289,8 +3277,10 @@ IonBuilder::inlineConstructSimdObject(CallInfo& callInfo, SimdTypeDescr* descr)
// Generic constructor of SIMD valuesX4.
MIRType simdType;
if (!SimdTypeToMIRType(descr->type(), &simdType))
if (!MaybeSimdTypeToMIRType(descr->type(), &simdType)) {
trackOptimizationOutcome(TrackedOutcome::SimdTypeNotOptimized);
return InliningStatus_NotInlined;
}
// Take the templateObject out of Baseline ICs, such that we can box
// SIMD value type in the same kind of objects.

View File

@ -67,6 +67,34 @@ MIRType MIRTypeFromValue(const js::Value& vp)
return MIRTypeFromValueType(vp.extractNonDoubleType());
}
// If simdType is one of the SIMD types suported by Ion, set mirType to the
// corresponding MIRType, and return true.
//
// If simdType is not suported by Ion, return false.
static inline
bool MaybeSimdTypeToMIRType(SimdType type, MIRType* mirType)
{
switch (type) {
case SimdType::Uint32x4:
case SimdType::Int32x4: *mirType = MIRType_Int32x4; return true;
case SimdType::Float32x4: *mirType = MIRType_Float32x4; return true;
case SimdType::Bool32x4: *mirType = MIRType_Bool32x4; return true;
default: return false;
}
}
// Convert a SimdType to the corresponding MIRType, or crash.
//
// Note that this is not an injective mapping: SimdType has signed and unsigned
// integer types that map to the same MIRType.
static inline
MIRType SimdTypeToMIRType(SimdType type)
{
MIRType ret = MIRType_None;
JS_ALWAYS_TRUE(MaybeSimdTypeToMIRType(type, &ret));
return ret;
}
static inline
SimdType MIRTypeToSimdType(MIRType type)
{