| Index: src/arm/lithium-codegen-arm.cc
|
| diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
|
| index b5ed662ff198067304e4cdd5eedbb140d2d24019..431bb38188b83272d4b2d1e8495bcf6a7a1a4be5 100644
|
| --- a/src/arm/lithium-codegen-arm.cc
|
| +++ b/src/arm/lithium-codegen-arm.cc
|
| @@ -2159,11 +2159,12 @@ int LCodeGen::GetNextEmittedBlock() const {
|
| return -1;
|
| }
|
|
|
| +template<class InstrType>
|
| +void LCodeGen::EmitBranch(InstrType instr, Condition cc) {
|
| + int right_block = instr->FalseDestination(chunk_);
|
| + int left_block = instr->TrueDestination(chunk_);
|
|
|
| -void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
|
| int next_block = GetNextEmittedBlock();
|
| - right_block = chunk_->LookupDestination(right_block);
|
| - left_block = chunk_->LookupDestination(left_block);
|
|
|
| if (right_block == left_block) {
|
| EmitGoto(left_block);
|
| @@ -2184,22 +2185,19 @@ void LCodeGen::DoDebugBreak(LDebugBreak* instr) {
|
|
|
|
|
| void LCodeGen::DoBranch(LBranch* instr) {
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| Representation r = instr->hydrogen()->value()->representation();
|
| if (r.IsInteger32() || r.IsSmi()) {
|
| ASSERT(!info()->IsStub());
|
| Register reg = ToRegister(instr->value());
|
| __ cmp(reg, Operand::Zero());
|
| - EmitBranch(true_block, false_block, ne);
|
| + EmitBranch(instr, ne);
|
| } else if (r.IsDouble()) {
|
| ASSERT(!info()->IsStub());
|
| DwVfpRegister reg = ToDoubleRegister(instr->value());
|
| // Test the double value. Zero and NaN are false.
|
| __ VFPCompareAndSetFlags(reg, 0.0);
|
| __ cmp(r0, r0, vs); // If NaN, set the Z flag.
|
| - EmitBranch(true_block, false_block, ne);
|
| + EmitBranch(instr, ne);
|
| } else {
|
| ASSERT(r.IsTagged());
|
| Register reg = ToRegister(instr->value());
|
| @@ -2207,15 +2205,12 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| if (type.IsBoolean()) {
|
| ASSERT(!info()->IsStub());
|
| __ CompareRoot(reg, Heap::kTrueValueRootIndex);
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| } else if (type.IsSmi()) {
|
| ASSERT(!info()->IsStub());
|
| __ cmp(reg, Operand::Zero());
|
| - EmitBranch(true_block, false_block, ne);
|
| + EmitBranch(instr, ne);
|
| } else {
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types();
|
| // Avoid deopts in the case where we've never executed this path before.
|
| if (expected.IsEmpty()) expected = ToBooleanStub::all_types();
|
| @@ -2223,26 +2218,26 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| if (expected.Contains(ToBooleanStub::UNDEFINED)) {
|
| // undefined -> false.
|
| __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
|
| - __ b(eq, false_label);
|
| + __ b(eq, instr->FalseLabel(chunk_));
|
| }
|
| if (expected.Contains(ToBooleanStub::BOOLEAN)) {
|
| // Boolean -> its value.
|
| __ CompareRoot(reg, Heap::kTrueValueRootIndex);
|
| - __ b(eq, true_label);
|
| + __ b(eq, instr->TrueLabel(chunk_));
|
| __ CompareRoot(reg, Heap::kFalseValueRootIndex);
|
| - __ b(eq, false_label);
|
| + __ b(eq, instr->FalseLabel(chunk_));
|
| }
|
| if (expected.Contains(ToBooleanStub::NULL_TYPE)) {
|
| // 'null' -> false.
|
| __ CompareRoot(reg, Heap::kNullValueRootIndex);
|
| - __ b(eq, false_label);
|
| + __ b(eq, instr->FalseLabel(chunk_));
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::SMI)) {
|
| // Smis: 0 -> false, all other -> true.
|
| __ cmp(reg, Operand::Zero());
|
| - __ b(eq, false_label);
|
| - __ JumpIfSmi(reg, true_label);
|
| + __ b(eq, instr->FalseLabel(chunk_));
|
| + __ JumpIfSmi(reg, instr->TrueLabel(chunk_));
|
| } else if (expected.NeedsMap()) {
|
| // If we need a map later and have a Smi -> deopt.
|
| __ SmiTst(reg);
|
| @@ -2257,14 +2252,14 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| // Undetectable -> false.
|
| __ ldrb(ip, FieldMemOperand(map, Map::kBitFieldOffset));
|
| __ tst(ip, Operand(1 << Map::kIsUndetectable));
|
| - __ b(ne, false_label);
|
| + __ b(ne, instr->FalseLabel(chunk_));
|
| }
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) {
|
| // spec object -> true.
|
| __ CompareInstanceType(map, ip, FIRST_SPEC_OBJECT_TYPE);
|
| - __ b(ge, true_label);
|
| + __ b(ge, instr->TrueLabel(chunk_));
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::STRING)) {
|
| @@ -2274,15 +2269,15 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| __ b(ge, ¬_string);
|
| __ ldr(ip, FieldMemOperand(reg, String::kLengthOffset));
|
| __ cmp(ip, Operand::Zero());
|
| - __ b(ne, true_label);
|
| - __ b(false_label);
|
| + __ b(ne, instr->TrueLabel(chunk_));
|
| + __ b(instr->FalseLabel(chunk_));
|
| __ bind(¬_string);
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::SYMBOL)) {
|
| // Symbol value -> true.
|
| __ CompareInstanceType(map, ip, SYMBOL_TYPE);
|
| - __ b(eq, true_label);
|
| + __ b(eq, instr->TrueLabel(chunk_));
|
| }
|
|
|
| if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) {
|
| @@ -2294,8 +2289,8 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
| __ vldr(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset));
|
| __ VFPCompareAndSetFlags(dbl_scratch, 0.0);
|
| __ cmp(r0, r0, vs); // NaN -> false.
|
| - __ b(eq, false_label); // +0, -0 -> false.
|
| - __ b(true_label);
|
| + __ b(eq, instr->FalseLabel(chunk_)); // +0, -0 -> false.
|
| + __ b(instr->TrueLabel(chunk_));
|
| __ bind(¬_heap_number);
|
| }
|
|
|
| @@ -2308,7 +2303,7 @@ void LCodeGen::DoBranch(LBranch* instr) {
|
|
|
| void LCodeGen::EmitGoto(int block) {
|
| if (!IsNextEmittedBlock(block)) {
|
| - __ jmp(chunk_->GetAssemblyLabel(chunk_->LookupDestination(block)));
|
| + __ jmp(chunk_->GetAssemblyLabel(LookupDestination(block)));
|
| }
|
| }
|
|
|
| @@ -2349,17 +2344,14 @@ Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
|
| void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| LOperand* left = instr->left();
|
| LOperand* right = instr->right();
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| Condition cond = TokenToCondition(instr->op(), false);
|
|
|
| if (left->IsConstantOperand() && right->IsConstantOperand()) {
|
| // We can statically evaluate the comparison.
|
| double left_val = ToDouble(LConstantOperand::cast(left));
|
| double right_val = ToDouble(LConstantOperand::cast(right));
|
| - int next_block =
|
| - EvalComparison(instr->op(), left_val, right_val) ? true_block
|
| - : false_block;
|
| + int next_block = EvalComparison(instr->op(), left_val, right_val) ?
|
| + instr->TrueDestination(chunk_) : instr->FalseDestination(chunk_);
|
| EmitGoto(next_block);
|
| } else {
|
| if (instr->is_double()) {
|
| @@ -2368,7 +2360,7 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right));
|
| // If a NaN is involved, i.e. the result is unordered (V set),
|
| // jump to false block label.
|
| - __ b(vs, chunk_->GetAssemblyLabel(false_block));
|
| + __ b(vs, instr->FalseLabel(chunk_));
|
| } else {
|
| if (right->IsConstantOperand()) {
|
| int32_t value = ToInteger32(LConstantOperand::cast(right));
|
| @@ -2390,7 +2382,7 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| __ cmp(ToRegister(left), ToRegister(right));
|
| }
|
| }
|
| - EmitBranch(true_block, false_block, cond);
|
| + EmitBranch(instr, cond);
|
| }
|
| }
|
|
|
| @@ -2398,21 +2390,17 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
|
| void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
|
| Register left = ToRegister(instr->left());
|
| Register right = ToRegister(instr->right());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
|
|
| __ cmp(left, Operand(right));
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) {
|
| Register left = ToRegister(instr->left());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| __ cmp(left, Operand(instr->hydrogen()->right()));
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| @@ -2447,15 +2435,11 @@ void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
| Register temp1 = ToRegister(instr->temp());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| Condition true_cond =
|
| - EmitIsObject(reg, temp1, false_label, true_label);
|
| + EmitIsObject(reg, temp1,
|
| + instr->FalseLabel(chunk_), instr->TrueLabel(chunk_));
|
|
|
| - EmitBranch(true_block, false_block, true_cond);
|
| + EmitBranch(instr, true_cond);
|
| }
|
|
|
|
|
| @@ -2473,24 +2457,17 @@ void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
| Register temp1 = ToRegister(instr->temp());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| Condition true_cond =
|
| - EmitIsString(reg, temp1, false_label);
|
| + EmitIsString(reg, temp1, instr->FalseLabel(chunk_));
|
|
|
| - EmitBranch(true_block, false_block, true_cond);
|
| + EmitBranch(instr, true_cond);
|
| }
|
|
|
|
|
| void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| Register input_reg = EmitLoadRegister(instr->value(), ip);
|
| __ SmiTst(input_reg);
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| @@ -2498,14 +2475,11 @@ void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
| Register temp = ToRegister(instr->temp());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block));
|
| + __ JumpIfSmi(input, instr->FalseLabel(chunk_));
|
| __ ldr(temp, FieldMemOperand(input, HeapObject::kMapOffset));
|
| __ ldrb(temp, FieldMemOperand(temp, Map::kBitFieldOffset));
|
| __ tst(temp, Operand(1 << Map::kIsUndetectable));
|
| - EmitBranch(true_block, false_block, ne);
|
| + EmitBranch(instr, ne);
|
| }
|
|
|
|
|
| @@ -2531,8 +2505,6 @@ static Condition ComputeCompareCondition(Token::Value op) {
|
|
|
| void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
|
| Token::Value op = instr->op();
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op);
|
| CallCode(ic, RelocInfo::CODE_TARGET, instr);
|
| @@ -2541,7 +2513,7 @@ void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
|
|
|
| Condition condition = ComputeCompareCondition(op);
|
|
|
| - EmitBranch(true_block, false_block, condition);
|
| + EmitBranch(instr, condition);
|
| }
|
|
|
|
|
| @@ -2569,15 +2541,10 @@ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
|
| Register scratch = scratch0();
|
| Register input = ToRegister(instr->value());
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| - __ JumpIfSmi(input, false_label);
|
| + __ JumpIfSmi(input, instr->FalseLabel(chunk_));
|
|
|
| __ CompareObjectType(input, scratch, scratch, TestType(instr->hydrogen()));
|
| - EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
|
| + EmitBranch(instr, BranchCondition(instr->hydrogen()));
|
| }
|
|
|
|
|
| @@ -2597,13 +2564,10 @@ void LCodeGen::DoHasCachedArrayIndexAndBranch(
|
| Register input = ToRegister(instr->value());
|
| Register scratch = scratch0();
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| __ ldr(scratch,
|
| FieldMemOperand(input, String::kHashFieldOffset));
|
| __ tst(scratch, Operand(String::kContainsCachedArrayIndexMask));
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| @@ -2680,27 +2644,20 @@ void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
|
| Register temp2 = ToRegister(instr->temp());
|
| Handle<String> class_name = instr->hydrogen()->class_name();
|
|
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| -
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
| -
|
| - EmitClassOfTest(true_label, false_label, class_name, input, temp, temp2);
|
| + EmitClassOfTest(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_),
|
| + class_name, input, temp, temp2);
|
|
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) {
|
| Register reg = ToRegister(instr->value());
|
| Register temp = ToRegister(instr->temp());
|
| - int true_block = instr->true_block_id();
|
| - int false_block = instr->false_block_id();
|
|
|
| __ ldr(temp, FieldMemOperand(reg, HeapObject::kMapOffset));
|
| __ cmp(temp, Operand(instr->map()));
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
| @@ -5597,17 +5554,13 @@ void LCodeGen::DoTypeof(LTypeof* instr) {
|
|
|
| void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
|
| Register input = ToRegister(instr->value());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
| - Label* true_label = chunk_->GetAssemblyLabel(true_block);
|
| - Label* false_label = chunk_->GetAssemblyLabel(false_block);
|
|
|
| - Condition final_branch_condition = EmitTypeofIs(true_label,
|
| - false_label,
|
| + Condition final_branch_condition = EmitTypeofIs(instr->TrueLabel(chunk_),
|
| + instr->FalseLabel(chunk_),
|
| input,
|
| instr->type_literal());
|
| if (final_branch_condition != kNoCondition) {
|
| - EmitBranch(true_block, false_block, final_branch_condition);
|
| + EmitBranch(instr, final_branch_condition);
|
| }
|
| }
|
|
|
| @@ -5692,11 +5645,9 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label,
|
|
|
| void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) {
|
| Register temp1 = ToRegister(instr->temp());
|
| - int true_block = chunk_->LookupDestination(instr->true_block_id());
|
| - int false_block = chunk_->LookupDestination(instr->false_block_id());
|
|
|
| EmitIsConstructCall(temp1, scratch0());
|
| - EmitBranch(true_block, false_block, eq);
|
| + EmitBranch(instr, eq);
|
| }
|
|
|
|
|
|
|