OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arm64/lithium-codegen-arm64.h" | 7 #include "src/arm64/lithium-codegen-arm64.h" |
8 #include "src/arm64/lithium-gap-resolver-arm64.h" | 8 #include "src/arm64/lithium-gap-resolver-arm64.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/stub-cache.h" | 10 #include "src/stub-cache.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 BranchOnCondition(LCodeGen* codegen, Condition cond) | 49 BranchOnCondition(LCodeGen* codegen, Condition cond) |
50 : BranchGenerator(codegen), | 50 : BranchGenerator(codegen), |
51 cond_(cond) { } | 51 cond_(cond) { } |
52 | 52 |
53 virtual void Emit(Label* label) const { | 53 virtual void Emit(Label* label) const { |
54 __ B(cond_, label); | 54 __ B(cond_, label); |
55 } | 55 } |
56 | 56 |
57 virtual void EmitInverted(Label* label) const { | 57 virtual void EmitInverted(Label* label) const { |
58 if (cond_ != al) { | 58 if (cond_ != al) { |
59 __ B(InvertCondition(cond_), label); | 59 __ B(NegateCondition(cond_), label); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 Condition cond_; | 64 Condition cond_; |
65 }; | 65 }; |
66 | 66 |
67 | 67 |
68 // Emit code to compare lhs and rhs and branch if the condition holds. | 68 // Emit code to compare lhs and rhs and branch if the condition holds. |
69 // This uses MacroAssembler's CompareAndBranch function so it will handle | 69 // This uses MacroAssembler's CompareAndBranch function so it will handle |
70 // converting the comparison to Cbz/Cbnz if the right-hand side is 0. | 70 // converting the comparison to Cbz/Cbnz if the right-hand side is 0. |
71 // | 71 // |
72 // EmitInverted still compares the two operands but inverts the condition. | 72 // EmitInverted still compares the two operands but inverts the condition. |
73 class CompareAndBranch : public BranchGenerator { | 73 class CompareAndBranch : public BranchGenerator { |
74 public: | 74 public: |
75 CompareAndBranch(LCodeGen* codegen, | 75 CompareAndBranch(LCodeGen* codegen, |
76 Condition cond, | 76 Condition cond, |
77 const Register& lhs, | 77 const Register& lhs, |
78 const Operand& rhs) | 78 const Operand& rhs) |
79 : BranchGenerator(codegen), | 79 : BranchGenerator(codegen), |
80 cond_(cond), | 80 cond_(cond), |
81 lhs_(lhs), | 81 lhs_(lhs), |
82 rhs_(rhs) { } | 82 rhs_(rhs) { } |
83 | 83 |
84 virtual void Emit(Label* label) const { | 84 virtual void Emit(Label* label) const { |
85 __ CompareAndBranch(lhs_, rhs_, cond_, label); | 85 __ CompareAndBranch(lhs_, rhs_, cond_, label); |
86 } | 86 } |
87 | 87 |
88 virtual void EmitInverted(Label* label) const { | 88 virtual void EmitInverted(Label* label) const { |
89 __ CompareAndBranch(lhs_, rhs_, InvertCondition(cond_), label); | 89 __ CompareAndBranch(lhs_, rhs_, NegateCondition(cond_), label); |
90 } | 90 } |
91 | 91 |
92 private: | 92 private: |
93 Condition cond_; | 93 Condition cond_; |
94 const Register& lhs_; | 94 const Register& lhs_; |
95 const Operand& rhs_; | 95 const Operand& rhs_; |
96 }; | 96 }; |
97 | 97 |
98 | 98 |
99 // Test the input with the given mask and branch if the condition holds. | 99 // Test the input with the given mask and branch if the condition holds. |
(...skipping 29 matching lines...) Expand all Loading... |
129 // The inverse of "all clear" is "any set" and vice versa. | 129 // The inverse of "all clear" is "any set" and vice versa. |
130 switch (cond_) { | 130 switch (cond_) { |
131 case eq: | 131 case eq: |
132 __ TestAndBranchIfAnySet(value_, mask_, label); | 132 __ TestAndBranchIfAnySet(value_, mask_, label); |
133 break; | 133 break; |
134 case ne: | 134 case ne: |
135 __ TestAndBranchIfAllClear(value_, mask_, label); | 135 __ TestAndBranchIfAllClear(value_, mask_, label); |
136 break; | 136 break; |
137 default: | 137 default: |
138 __ Tst(value_, mask_); | 138 __ Tst(value_, mask_); |
139 __ B(InvertCondition(cond_), label); | 139 __ B(NegateCondition(cond_), label); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 private: | 143 private: |
144 Condition cond_; | 144 Condition cond_; |
145 const Register& value_; | 145 const Register& value_; |
146 uint64_t mask_; | 146 uint64_t mask_; |
147 }; | 147 }; |
148 | 148 |
149 | 149 |
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1841 |
1842 | 1842 |
1843 void LCodeGen::DoBoundsCheck(LBoundsCheck *instr) { | 1843 void LCodeGen::DoBoundsCheck(LBoundsCheck *instr) { |
1844 Condition cond = instr->hydrogen()->allow_equality() ? hi : hs; | 1844 Condition cond = instr->hydrogen()->allow_equality() ? hi : hs; |
1845 ASSERT(instr->hydrogen()->index()->representation().IsInteger32()); | 1845 ASSERT(instr->hydrogen()->index()->representation().IsInteger32()); |
1846 ASSERT(instr->hydrogen()->length()->representation().IsInteger32()); | 1846 ASSERT(instr->hydrogen()->length()->representation().IsInteger32()); |
1847 if (instr->index()->IsConstantOperand()) { | 1847 if (instr->index()->IsConstantOperand()) { |
1848 Operand index = ToOperand32I(instr->index()); | 1848 Operand index = ToOperand32I(instr->index()); |
1849 Register length = ToRegister32(instr->length()); | 1849 Register length = ToRegister32(instr->length()); |
1850 __ Cmp(length, index); | 1850 __ Cmp(length, index); |
1851 cond = ReverseConditionForCmp(cond); | 1851 cond = ReverseCondition(cond); |
1852 } else { | 1852 } else { |
1853 Register index = ToRegister32(instr->index()); | 1853 Register index = ToRegister32(instr->index()); |
1854 Operand length = ToOperand32I(instr->length()); | 1854 Operand length = ToOperand32I(instr->length()); |
1855 __ Cmp(index, length); | 1855 __ Cmp(index, length); |
1856 } | 1856 } |
1857 if (FLAG_debug_code && instr->hydrogen()->skip_check()) { | 1857 if (FLAG_debug_code && instr->hydrogen()->skip_check()) { |
1858 __ Assert(InvertCondition(cond), kEliminatedBoundsCheckFailed); | 1858 __ Assert(NegateCondition(cond), kEliminatedBoundsCheckFailed); |
1859 } else { | 1859 } else { |
1860 DeoptimizeIf(cond, instr->environment()); | 1860 DeoptimizeIf(cond, instr->environment()); |
1861 } | 1861 } |
1862 } | 1862 } |
1863 | 1863 |
1864 | 1864 |
1865 void LCodeGen::DoBranch(LBranch* instr) { | 1865 void LCodeGen::DoBranch(LBranch* instr) { |
1866 Representation r = instr->hydrogen()->value()->representation(); | 1866 Representation r = instr->hydrogen()->value()->representation(); |
1867 Label* true_label = instr->TrueLabel(chunk_); | 1867 Label* true_label = instr->TrueLabel(chunk_); |
1868 Label* false_label = instr->FalseLabel(chunk_); | 1868 Label* false_label = instr->FalseLabel(chunk_); |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 EmitGoto(next_block); | 2482 EmitGoto(next_block); |
2483 } else { | 2483 } else { |
2484 if (instr->is_double()) { | 2484 if (instr->is_double()) { |
2485 if (right->IsConstantOperand()) { | 2485 if (right->IsConstantOperand()) { |
2486 __ Fcmp(ToDoubleRegister(left), | 2486 __ Fcmp(ToDoubleRegister(left), |
2487 ToDouble(LConstantOperand::cast(right))); | 2487 ToDouble(LConstantOperand::cast(right))); |
2488 } else if (left->IsConstantOperand()) { | 2488 } else if (left->IsConstantOperand()) { |
2489 // Transpose the operands and reverse the condition. | 2489 // Transpose the operands and reverse the condition. |
2490 __ Fcmp(ToDoubleRegister(right), | 2490 __ Fcmp(ToDoubleRegister(right), |
2491 ToDouble(LConstantOperand::cast(left))); | 2491 ToDouble(LConstantOperand::cast(left))); |
2492 cond = ReverseConditionForCmp(cond); | 2492 cond = ReverseCondition(cond); |
2493 } else { | 2493 } else { |
2494 __ Fcmp(ToDoubleRegister(left), ToDoubleRegister(right)); | 2494 __ Fcmp(ToDoubleRegister(left), ToDoubleRegister(right)); |
2495 } | 2495 } |
2496 | 2496 |
2497 // If a NaN is involved, i.e. the result is unordered (V set), | 2497 // If a NaN is involved, i.e. the result is unordered (V set), |
2498 // jump to false block label. | 2498 // jump to false block label. |
2499 __ B(vs, instr->FalseLabel(chunk_)); | 2499 __ B(vs, instr->FalseLabel(chunk_)); |
2500 EmitBranch(instr, cond); | 2500 EmitBranch(instr, cond); |
2501 } else { | 2501 } else { |
2502 if (instr->hydrogen_value()->representation().IsInteger32()) { | 2502 if (instr->hydrogen_value()->representation().IsInteger32()) { |
2503 if (right->IsConstantOperand()) { | 2503 if (right->IsConstantOperand()) { |
2504 EmitCompareAndBranch(instr, | 2504 EmitCompareAndBranch(instr, |
2505 cond, | 2505 cond, |
2506 ToRegister32(left), | 2506 ToRegister32(left), |
2507 ToOperand32I(right)); | 2507 ToOperand32I(right)); |
2508 } else { | 2508 } else { |
2509 // Transpose the operands and reverse the condition. | 2509 // Transpose the operands and reverse the condition. |
2510 EmitCompareAndBranch(instr, | 2510 EmitCompareAndBranch(instr, |
2511 ReverseConditionForCmp(cond), | 2511 ReverseCondition(cond), |
2512 ToRegister32(right), | 2512 ToRegister32(right), |
2513 ToOperand32I(left)); | 2513 ToOperand32I(left)); |
2514 } | 2514 } |
2515 } else { | 2515 } else { |
2516 ASSERT(instr->hydrogen_value()->representation().IsSmi()); | 2516 ASSERT(instr->hydrogen_value()->representation().IsSmi()); |
2517 if (right->IsConstantOperand()) { | 2517 if (right->IsConstantOperand()) { |
2518 int32_t value = ToInteger32(LConstantOperand::cast(right)); | 2518 int32_t value = ToInteger32(LConstantOperand::cast(right)); |
2519 EmitCompareAndBranch(instr, | 2519 EmitCompareAndBranch(instr, |
2520 cond, | 2520 cond, |
2521 ToRegister(left), | 2521 ToRegister(left), |
2522 Operand(Smi::FromInt(value))); | 2522 Operand(Smi::FromInt(value))); |
2523 } else if (left->IsConstantOperand()) { | 2523 } else if (left->IsConstantOperand()) { |
2524 // Transpose the operands and reverse the condition. | 2524 // Transpose the operands and reverse the condition. |
2525 int32_t value = ToInteger32(LConstantOperand::cast(left)); | 2525 int32_t value = ToInteger32(LConstantOperand::cast(left)); |
2526 EmitCompareAndBranch(instr, | 2526 EmitCompareAndBranch(instr, |
2527 ReverseConditionForCmp(cond), | 2527 ReverseCondition(cond), |
2528 ToRegister(right), | 2528 ToRegister(right), |
2529 Operand(Smi::FromInt(value))); | 2529 Operand(Smi::FromInt(value))); |
2530 } else { | 2530 } else { |
2531 EmitCompareAndBranch(instr, | 2531 EmitCompareAndBranch(instr, |
2532 cond, | 2532 cond, |
2533 ToRegister(left), | 2533 ToRegister(left), |
2534 ToRegister(right)); | 2534 ToRegister(right)); |
2535 } | 2535 } |
2536 } | 2536 } |
2537 } | 2537 } |
(...skipping 3495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6033 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 6033 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
6034 // Index is equal to negated out of object property index plus 1. | 6034 // Index is equal to negated out of object property index plus 1. |
6035 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 6035 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
6036 __ Ldr(result, FieldMemOperand(result, | 6036 __ Ldr(result, FieldMemOperand(result, |
6037 FixedArray::kHeaderSize - kPointerSize)); | 6037 FixedArray::kHeaderSize - kPointerSize)); |
6038 __ Bind(deferred->exit()); | 6038 __ Bind(deferred->exit()); |
6039 __ Bind(&done); | 6039 __ Bind(&done); |
6040 } | 6040 } |
6041 | 6041 |
6042 } } // namespace v8::internal | 6042 } } // namespace v8::internal |
OLD | NEW |