From a1733785cfd5f328fb8506e2768a89932c57c7da Mon Sep 17 00:00:00 2001 From: mbrandy Date: Wed, 26 Aug 2015 12:50:31 -0700 Subject: [PATCH] PPC: [simd.js] Single SIMD128_VALUE_TYPE for all Simd128Values. Port f4c079d450a5990639b295d40a3d1663d70412d6 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} --- src/full-codegen/ppc/full-codegen-ppc.cc | 47 ++++++++---------------------- src/ppc/code-stubs-ppc.cc | 16 +++-------- src/ppc/lithium-codegen-ppc.cc | 49 +++++++------------------------- 3 files changed, 27 insertions(+), 85 deletions(-) diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc index ae6a2bd..6bca4a6 100644 --- a/src/full-codegen/ppc/full-codegen-ppc.cc +++ b/src/full-codegen/ppc/full-codegen-ppc.cc @@ -3399,14 +3399,9 @@ void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) { &if_false, &fall_through); __ JumpIfSmi(r3, if_false); - Register map = r4; - 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)); + __ CompareObjectType(r3, r4, r4, SIMD128_VALUE_TYPE); 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); } @@ -4998,34 +4993,6 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, __ JumpIfSmi(r3, if_false); __ CompareObjectType(r3, r3, r4, SYMBOL_TYPE); 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())) { __ CompareRoot(r3, Heap::kTrueValueRootIndex); __ beq(if_true); @@ -5061,6 +5028,16 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, __ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset)); __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); 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 { if (if_false != fall_through) __ b(if_false); } diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc index 8edef61..14b95e7 100644 --- a/src/ppc/code-stubs-ppc.cc +++ b/src/ppc/code-stubs-ppc.cc @@ -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 // Smis. If it's not a heap number, then return equal. if (cond == lt || cond == gt) { - Label not_simd; // Call runtime on identical JSObjects. __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); __ bge(slow); @@ -266,11 +265,8 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, __ cmpi(r7, Operand(SYMBOL_TYPE)); __ beq(slow); // Call runtime on identical SIMD values since we must throw a TypeError. - __ cmpi(r7, Operand(FIRST_SIMD_VALUE_TYPE)); - __ blt(¬_simd); - __ cmpi(r7, Operand(LAST_SIMD_VALUE_TYPE)); - __ ble(slow); - __ bind(¬_simd); + __ cmpi(r7, Operand(SIMD128_VALUE_TYPE)); + __ beq(slow); if (is_strong(strength)) { // Call the runtime on anything that is converted in the semantics, since // 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); // Comparing JS objects with <=, >= is complicated. if (cond != eq) { - Label not_simd; __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); __ bge(slow); // Call runtime on identical symbols since we need to throw a TypeError. __ cmpi(r7, Operand(SYMBOL_TYPE)); __ beq(slow); // Call runtime on identical SIMD values since we must throw a TypeError. - __ cmpi(r7, Operand(FIRST_SIMD_VALUE_TYPE)); - __ blt(¬_simd); - __ cmpi(r7, Operand(LAST_SIMD_VALUE_TYPE)); - __ ble(slow); - __ bind(¬_simd); + __ cmpi(r7, Operand(SIMD128_VALUE_TYPE)); + __ beq(slow); if (is_strong(strength)) { // Call the runtime on anything that is converted in the semantics, // since we need to throw a TypeError. Smis and heap numbers have diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc index 1e28f66..1883184 100644 --- a/src/ppc/lithium-codegen-ppc.cc +++ b/src/ppc/lithium-codegen-ppc.cc @@ -2306,11 +2306,8 @@ void LCodeGen::DoBranch(LBranch* instr) { if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { // SIMD value -> true. Label not_simd; - __ CompareInstanceType(map, ip, FIRST_SIMD_VALUE_TYPE); - __ blt(¬_simd); - __ CompareInstanceType(map, ip, LAST_SIMD_VALUE_TYPE); - __ ble(instr->TrueLabel(chunk_)); - __ bind(¬_simd); + __ CompareInstanceType(map, ip, SIMD128_VALUE_TYPE); + __ beq(instr->TrueLabel(chunk_)); } if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { @@ -5949,40 +5946,16 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label, Label* false_label, __ cmpi(r0, Operand::Zero()); final_branch_condition = eq; - } else if (String::Equals(type_name, factory->float32x4_string())) { - __ JumpIfSmi(input, false_label); - __ CompareObjectType(input, scratch, no_reg, FLOAT32X4_TYPE); - final_branch_condition = eq; - - } else if (String::Equals(type_name, factory->int32x4_string())) { - __ 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); +// clang-format off +#define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ + } else if (String::Equals(type_name, factory->type##_string())) { \ + __ JumpIfSmi(input, false_label); \ + __ LoadP(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); \ + __ CompareRoot(scratch, Heap::k##Type##MapRootIndex); \ final_branch_condition = eq; + SIMD128_TYPES(SIMD128_TYPE) +#undef SIMD128_TYPE + // clang-format on } else { __ b(false_label); -- 2.7.4