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