PPC: [simd.js] Single SIMD128_VALUE_TYPE for all Simd128Values.

Port f4c079d450

Original commit message:
    There's no need to have one InstanceType per SIMD primitive type (this
    will not scale long-term).  Also reduce the amount of code duplication
    and make it more robust wrt adding new SIMD types.

R=bmeurer@chromium.org, jyan@ca.ibm.com, dstence@us.ibm.com, joransiu@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1312513004

Cr-Commit-Position: refs/heads/master@{#30392}
This commit is contained in:
mbrandy 2015-08-26 12:50:31 -07:00 committed by Commit bot
parent 7aecd51209
commit a1733785cf
3 changed files with 27 additions and 85 deletions

View File

@ -3399,14 +3399,9 @@ void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) {
&if_false, &fall_through); &if_false, &fall_through);
__ JumpIfSmi(r3, if_false); __ JumpIfSmi(r3, if_false);
Register map = r4; __ CompareObjectType(r3, r4, r4, SIMD128_VALUE_TYPE);
Register type_reg = r5;
__ LoadP(map, FieldMemOperand(r3, HeapObject::kMapOffset));
__ lbz(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
__ subi(type_reg, type_reg, Operand(FIRST_SIMD_VALUE_TYPE));
__ cmpli(type_reg, Operand(LAST_SIMD_VALUE_TYPE - FIRST_SIMD_VALUE_TYPE));
PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
Split(le, if_true, if_false, fall_through); Split(eq, if_true, if_false, fall_through);
context()->Plug(if_true, if_false); context()->Plug(if_true, if_false);
} }
@ -4998,34 +4993,6 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
__ JumpIfSmi(r3, if_false); __ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, SYMBOL_TYPE); __ CompareObjectType(r3, r3, r4, SYMBOL_TYPE);
Split(eq, if_true, if_false, fall_through); Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->float32x4_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, FLOAT32X4_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->int32x4_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, INT32X4_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->bool32x4_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, BOOL32X4_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->int16x8_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, INT16X8_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->bool16x8_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, BOOL16X8_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->int8x16_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, INT8X16_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->bool8x16_string())) {
__ JumpIfSmi(r3, if_false);
__ CompareObjectType(r3, r3, r4, BOOL8X16_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->boolean_string())) { } else if (String::Equals(check, factory->boolean_string())) {
__ CompareRoot(r3, Heap::kTrueValueRootIndex); __ CompareRoot(r3, Heap::kTrueValueRootIndex);
__ beq(if_true); __ beq(if_true);
@ -5061,6 +5028,16 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
__ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset)); __ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset));
__ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); __ andi(r0, r4, Operand(1 << Map::kIsUndetectable));
Split(eq, if_true, if_false, fall_through, cr0); Split(eq, if_true, if_false, fall_through, cr0);
// clang-format off
#define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
} else if (String::Equals(check, factory->type##_string())) { \
__ JumpIfSmi(r3, if_false); \
__ LoadP(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); \
__ CompareRoot(r3, Heap::k##Type##MapRootIndex); \
Split(eq, if_true, if_false, fall_through);
SIMD128_TYPES(SIMD128_TYPE)
#undef SIMD128_TYPE
// clang-format on
} else { } else {
if (if_false != fall_through) __ b(if_false); if (if_false != fall_through) __ b(if_false);
} }

View File

@ -258,7 +258,6 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
// They are both equal and they are not both Smis so both of them are not // They are both equal and they are not both Smis so both of them are not
// Smis. If it's not a heap number, then return equal. // Smis. If it's not a heap number, then return equal.
if (cond == lt || cond == gt) { if (cond == lt || cond == gt) {
Label not_simd;
// Call runtime on identical JSObjects. // Call runtime on identical JSObjects.
__ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE);
__ bge(slow); __ bge(slow);
@ -266,11 +265,8 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
__ cmpi(r7, Operand(SYMBOL_TYPE)); __ cmpi(r7, Operand(SYMBOL_TYPE));
__ beq(slow); __ beq(slow);
// Call runtime on identical SIMD values since we must throw a TypeError. // Call runtime on identical SIMD values since we must throw a TypeError.
__ cmpi(r7, Operand(FIRST_SIMD_VALUE_TYPE)); __ cmpi(r7, Operand(SIMD128_VALUE_TYPE));
__ blt(&not_simd); __ beq(slow);
__ cmpi(r7, Operand(LAST_SIMD_VALUE_TYPE));
__ ble(slow);
__ bind(&not_simd);
if (is_strong(strength)) { if (is_strong(strength)) {
// Call the runtime on anything that is converted in the semantics, since // Call the runtime on anything that is converted in the semantics, since
// we need to throw a TypeError. Smis have already been ruled out. // we need to throw a TypeError. Smis have already been ruled out.
@ -284,18 +280,14 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
__ beq(&heap_number); __ beq(&heap_number);
// Comparing JS objects with <=, >= is complicated. // Comparing JS objects with <=, >= is complicated.
if (cond != eq) { if (cond != eq) {
Label not_simd;
__ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE));
__ bge(slow); __ bge(slow);
// Call runtime on identical symbols since we need to throw a TypeError. // Call runtime on identical symbols since we need to throw a TypeError.
__ cmpi(r7, Operand(SYMBOL_TYPE)); __ cmpi(r7, Operand(SYMBOL_TYPE));
__ beq(slow); __ beq(slow);
// Call runtime on identical SIMD values since we must throw a TypeError. // Call runtime on identical SIMD values since we must throw a TypeError.
__ cmpi(r7, Operand(FIRST_SIMD_VALUE_TYPE)); __ cmpi(r7, Operand(SIMD128_VALUE_TYPE));
__ blt(&not_simd); __ beq(slow);
__ cmpi(r7, Operand(LAST_SIMD_VALUE_TYPE));
__ ble(slow);
__ bind(&not_simd);
if (is_strong(strength)) { if (is_strong(strength)) {
// Call the runtime on anything that is converted in the semantics, // Call the runtime on anything that is converted in the semantics,
// since we need to throw a TypeError. Smis and heap numbers have // since we need to throw a TypeError. Smis and heap numbers have

View File

@ -2306,11 +2306,8 @@ void LCodeGen::DoBranch(LBranch* instr) {
if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { if (expected.Contains(ToBooleanStub::SIMD_VALUE)) {
// SIMD value -> true. // SIMD value -> true.
Label not_simd; Label not_simd;
__ CompareInstanceType(map, ip, FIRST_SIMD_VALUE_TYPE); __ CompareInstanceType(map, ip, SIMD128_VALUE_TYPE);
__ blt(&not_simd); __ beq(instr->TrueLabel(chunk_));
__ CompareInstanceType(map, ip, LAST_SIMD_VALUE_TYPE);
__ ble(instr->TrueLabel(chunk_));
__ bind(&not_simd);
} }
if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) {
@ -5949,40 +5946,16 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label, Label* false_label,
__ cmpi(r0, Operand::Zero()); __ cmpi(r0, Operand::Zero());
final_branch_condition = eq; final_branch_condition = eq;
} else if (String::Equals(type_name, factory->float32x4_string())) { // clang-format off
__ JumpIfSmi(input, false_label); #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
__ CompareObjectType(input, scratch, no_reg, FLOAT32X4_TYPE); } else if (String::Equals(type_name, factory->type##_string())) { \
final_branch_condition = eq; __ JumpIfSmi(input, false_label); \
__ LoadP(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); \
} else if (String::Equals(type_name, factory->int32x4_string())) { __ CompareRoot(scratch, Heap::k##Type##MapRootIndex); \
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, INT32X4_TYPE);
final_branch_condition = eq;
} else if (String::Equals(type_name, factory->bool32x4_string())) {
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, BOOL32X4_TYPE);
final_branch_condition = eq;
} else if (String::Equals(type_name, factory->int16x8_string())) {
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, INT16X8_TYPE);
final_branch_condition = eq;
} else if (String::Equals(type_name, factory->bool16x8_string())) {
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, BOOL16X8_TYPE);
final_branch_condition = eq;
} else if (String::Equals(type_name, factory->int8x16_string())) {
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, INT8X16_TYPE);
final_branch_condition = eq;
} else if (String::Equals(type_name, factory->bool8x16_string())) {
__ JumpIfSmi(input, false_label);
__ CompareObjectType(input, scratch, no_reg, BOOL8X16_TYPE);
final_branch_condition = eq; final_branch_condition = eq;
SIMD128_TYPES(SIMD128_TYPE)
#undef SIMD128_TYPE
// clang-format on
} else { } else {
__ b(false_label); __ b(false_label);