OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/assembler-arm64-inl.h" | 7 #include "src/arm64/assembler-arm64-inl.h" |
8 #include "src/arm64/frames-arm64.h" | 8 #include "src/arm64/frames-arm64.h" |
9 #include "src/arm64/macro-assembler-arm64-inl.h" | 9 #include "src/arm64/macro-assembler-arm64-inl.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 Operand InputOperand64(size_t index) { return InputOperand(index); } | 94 Operand InputOperand64(size_t index) { return InputOperand(index); } |
95 | 95 |
96 Operand InputOperand32(size_t index) { | 96 Operand InputOperand32(size_t index) { |
97 return ToOperand32(instr_->InputAt(index)); | 97 return ToOperand32(instr_->InputAt(index)); |
98 } | 98 } |
99 | 99 |
100 Register OutputRegister64() { return OutputRegister(); } | 100 Register OutputRegister64() { return OutputRegister(); } |
101 | 101 |
102 Register OutputRegister32() { return ToRegister(instr_->Output()).W(); } | 102 Register OutputRegister32() { return ToRegister(instr_->Output()).W(); } |
103 | 103 |
104 Register TempRegister32() { return ToRegister(instr_->TempAt(0)).W(); } | 104 Register TempRegister32(size_t index) { |
105 return ToRegister(instr_->TempAt(index)).W(); | |
106 } | |
105 | 107 |
106 Operand InputOperand2_32(size_t index) { | 108 Operand InputOperand2_32(size_t index) { |
107 switch (AddressingModeField::decode(instr_->opcode())) { | 109 switch (AddressingModeField::decode(instr_->opcode())) { |
108 case kMode_None: | 110 case kMode_None: |
109 return InputOperand32(index); | 111 return InputOperand32(index); |
110 case kMode_Operand2_R_LSL_I: | 112 case kMode_Operand2_R_LSL_I: |
111 return Operand(InputRegister32(index), LSL, InputInt5(index + 1)); | 113 return Operand(InputRegister32(index), LSL, InputInt5(index + 1)); |
112 case kMode_Operand2_R_LSR_I: | 114 case kMode_Operand2_R_LSR_I: |
113 return Operand(InputRegister32(index), LSR, InputInt5(index + 1)); | 115 return Operand(InputRegister32(index), LSR, InputInt5(index + 1)); |
114 case kMode_Operand2_R_ASR_I: | 116 case kMode_Operand2_R_ASR_I: |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 MemOperand(i.InputRegister(0), i.InputRegister(1))); \ | 532 MemOperand(i.InputRegister(0), i.InputRegister(1))); \ |
531 __ Dmb(InnerShareable, BarrierAll); \ | 533 __ Dmb(InnerShareable, BarrierAll); \ |
532 } while (0) | 534 } while (0) |
533 | 535 |
534 #define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \ | 536 #define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \ |
535 do { \ | 537 do { \ |
536 Label exchange; \ | 538 Label exchange; \ |
537 __ bind(&exchange); \ | 539 __ bind(&exchange); \ |
538 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ | 540 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ |
539 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ | 541 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ |
540 __ store_instr(i.TempRegister32(), i.InputRegister32(2), \ | 542 __ store_instr(i.TempRegister32(0), i.InputRegister32(2), \ |
541 i.TempRegister(0)); \ | 543 i.TempRegister(0)); \ |
542 __ cbnz(i.TempRegister32(), &exchange); \ | 544 __ cbnz(i.TempRegister32(0), &exchange); \ |
545 } while (0) | |
546 | |
547 #define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_instr, store_instr) \ | |
aseemgarg
2017/03/16 22:26:57
Landing this for now with ldaxr and stlxr use. Wil
| |
548 do { \ | |
549 Label compareExchange; \ | |
550 Label exit; \ | |
551 __ bind(&compareExchange); \ | |
552 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ | |
553 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ | |
554 __ cmp(i.TempRegister32(1), i.OutputRegister32()); \ | |
555 __ B(ne, &exit); \ | |
556 __ store_instr(i.TempRegister32(0), i.InputRegister32(3), \ | |
557 i.TempRegister(0)); \ | |
558 __ cbnz(i.TempRegister32(0), &compareExchange); \ | |
559 __ bind(&exit); \ | |
543 } while (0) | 560 } while (0) |
544 | 561 |
545 #define ASSEMBLE_IEEE754_BINOP(name) \ | 562 #define ASSEMBLE_IEEE754_BINOP(name) \ |
546 do { \ | 563 do { \ |
547 FrameScope scope(masm(), StackFrame::MANUAL); \ | 564 FrameScope scope(masm(), StackFrame::MANUAL); \ |
548 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 565 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
549 0, 2); \ | 566 0, 2); \ |
550 } while (0) | 567 } while (0) |
551 | 568 |
552 #define ASSEMBLE_IEEE754_UNOP(name) \ | 569 #define ASSEMBLE_IEEE754_UNOP(name) \ |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 case kAtomicExchangeInt16: | 1673 case kAtomicExchangeInt16: |
1657 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); | 1674 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); |
1658 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); | 1675 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); |
1659 break; | 1676 break; |
1660 case kAtomicExchangeUint16: | 1677 case kAtomicExchangeUint16: |
1661 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); | 1678 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); |
1662 break; | 1679 break; |
1663 case kAtomicExchangeWord32: | 1680 case kAtomicExchangeWord32: |
1664 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr); | 1681 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr); |
1665 break; | 1682 break; |
1683 case kAtomicCompareExchangeInt8: | |
1684 __ Uxtb(i.TempRegister(1), i.InputRegister(2)); | |
1685 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb); | |
1686 __ Sxtb(i.OutputRegister(0), i.OutputRegister(0)); | |
1687 break; | |
1688 case kAtomicCompareExchangeUint8: | |
1689 __ Uxtb(i.TempRegister(1), i.InputRegister(2)); | |
1690 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb); | |
1691 break; | |
1692 case kAtomicCompareExchangeInt16: | |
1693 __ Uxth(i.TempRegister(1), i.InputRegister(2)); | |
1694 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh); | |
1695 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); | |
1696 break; | |
1697 case kAtomicCompareExchangeUint16: | |
1698 __ Uxth(i.TempRegister(1), i.InputRegister(2)); | |
1699 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh); | |
1700 break; | |
1701 case kAtomicCompareExchangeWord32: | |
1702 __ mov(i.TempRegister(1), i.InputRegister(2)); | |
1703 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxr, stlxr); | |
1704 break; | |
1666 } | 1705 } |
1667 return kSuccess; | 1706 return kSuccess; |
1668 } // NOLINT(readability/fn_size) | 1707 } // NOLINT(readability/fn_size) |
1669 | 1708 |
1670 | 1709 |
1671 // Assemble branches after this instruction. | 1710 // Assemble branches after this instruction. |
1672 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1711 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1673 Arm64OperandConverter i(this, instr); | 1712 Arm64OperandConverter i(this, instr); |
1674 Label* tlabel = branch->true_label; | 1713 Label* tlabel = branch->true_label; |
1675 Label* flabel = branch->false_label; | 1714 Label* flabel = branch->false_label; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2209 padding_size -= kInstructionSize; | 2248 padding_size -= kInstructionSize; |
2210 } | 2249 } |
2211 } | 2250 } |
2212 } | 2251 } |
2213 | 2252 |
2214 #undef __ | 2253 #undef __ |
2215 | 2254 |
2216 } // namespace compiler | 2255 } // namespace compiler |
2217 } // namespace internal | 2256 } // namespace internal |
2218 } // namespace v8 | 2257 } // namespace v8 |
OLD | NEW |