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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 __ asm_instr(i.InputRegister(0), right); \ | 768 __ asm_instr(i.InputRegister(0), right); \ |
769 } else { \ | 769 } else { \ |
770 if (HasImmediateInput(instr, 1)) { \ | 770 if (HasImmediateInput(instr, 1)) { \ |
771 __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ | 771 __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ |
772 } else { \ | 772 } else { \ |
773 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ | 773 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
774 } \ | 774 } \ |
775 } \ | 775 } \ |
776 } while (0) | 776 } while (0) |
777 | 777 |
778 #define ASSEMBLE_ATOMIC_BINOP(bin_inst, mov_inst, cmpxchg_inst) \ | |
779 do { \ | |
780 Label binop; \ | |
781 __ bind(&binop); \ | |
782 __ mov_inst(eax, i.MemoryOperand(1)); \ | |
783 __ mov_inst(i.TempRegister(0), Operand(eax)); \ | |
784 __ bin_inst(i.TempRegister(0), i.InputRegister(0)); \ | |
785 __ lock(); \ | |
786 __ cmpxchg_inst(i.MemoryOperand(1), i.TempRegister(0)); \ | |
787 __ j(negative, &binop); \ | |
binji
2017/04/06 19:04:50
should be j(not_equal, &binop) I think
aseemgarg
2017/04/06 21:03:56
Done.
| |
788 } while (false) | |
789 | |
778 void CodeGenerator::AssembleDeconstructFrame() { | 790 void CodeGenerator::AssembleDeconstructFrame() { |
779 __ mov(esp, ebp); | 791 __ mov(esp, ebp); |
780 __ pop(ebp); | 792 __ pop(ebp); |
781 } | 793 } |
782 | 794 |
783 void CodeGenerator::AssemblePrepareTailCall() { | 795 void CodeGenerator::AssemblePrepareTailCall() { |
784 if (frame_access_state()->has_frame()) { | 796 if (frame_access_state()->has_frame()) { |
785 __ mov(ebp, MemOperand(ebp, 0)); | 797 __ mov(ebp, MemOperand(ebp, 0)); |
786 } | 798 } |
787 frame_access_state()->SetFrameAccessToSP(); | 799 frame_access_state()->SetFrameAccessToSP(); |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 __ lock(); | 2021 __ lock(); |
2010 __ cmpxchg_w(i.MemoryOperand(2), i.InputRegister(1)); | 2022 __ cmpxchg_w(i.MemoryOperand(2), i.InputRegister(1)); |
2011 __ movzx_w(eax, eax); | 2023 __ movzx_w(eax, eax); |
2012 break; | 2024 break; |
2013 } | 2025 } |
2014 case kAtomicCompareExchangeWord32: { | 2026 case kAtomicCompareExchangeWord32: { |
2015 __ lock(); | 2027 __ lock(); |
2016 __ cmpxchg(i.MemoryOperand(2), i.InputRegister(1)); | 2028 __ cmpxchg(i.MemoryOperand(2), i.InputRegister(1)); |
2017 break; | 2029 break; |
2018 } | 2030 } |
2031 #define ATOMIC_BINOP_CASE(op, inst) \ | |
2032 case kAtomic##op##Int8: { \ | |
2033 ASSEMBLE_ATOMIC_BINOP(inst, mov_b, cmpxchg_b); \ | |
2034 __ movsx_b(eax, eax); \ | |
2035 break; \ | |
2036 } \ | |
2037 case kAtomic##op##Uint8: { \ | |
2038 ASSEMBLE_ATOMIC_BINOP(inst, mov_b, cmpxchg_b); \ | |
2039 __ movzx_b(eax, eax); \ | |
2040 break; \ | |
2041 } \ | |
2042 case kAtomic##op##Int16: { \ | |
2043 ASSEMBLE_ATOMIC_BINOP(inst, mov_w, cmpxchg_w); \ | |
2044 __ movsx_w(eax, eax); \ | |
2045 break; \ | |
2046 } \ | |
2047 case kAtomic##op##Uint16: { \ | |
2048 ASSEMBLE_ATOMIC_BINOP(inst, mov_w, cmpxchg_w); \ | |
2049 __ movzx_w(eax, eax); \ | |
2050 break; \ | |
2051 } \ | |
2052 case kAtomic##op##Word32: { \ | |
2053 ASSEMBLE_ATOMIC_BINOP(inst, mov, cmpxchg); \ | |
2054 break; \ | |
2055 } | |
2056 ATOMIC_BINOP_CASE(Add, add) | |
2057 ATOMIC_BINOP_CASE(Sub, sub) | |
2058 ATOMIC_BINOP_CASE(And, and_) | |
2059 ATOMIC_BINOP_CASE(Or, or_) | |
2060 ATOMIC_BINOP_CASE(Xor, xor_) | |
2061 #undef ATOMIC_BINOP_CASE | |
2019 case kAtomicLoadInt8: | 2062 case kAtomicLoadInt8: |
2020 case kAtomicLoadUint8: | 2063 case kAtomicLoadUint8: |
2021 case kAtomicLoadInt16: | 2064 case kAtomicLoadInt16: |
2022 case kAtomicLoadUint16: | 2065 case kAtomicLoadUint16: |
2023 case kAtomicLoadWord32: | 2066 case kAtomicLoadWord32: |
2024 case kAtomicStoreWord8: | 2067 case kAtomicStoreWord8: |
2025 case kAtomicStoreWord16: | 2068 case kAtomicStoreWord16: |
2026 case kAtomicStoreWord32: | 2069 case kAtomicStoreWord32: |
2027 UNREACHABLE(); // Won't be generated by instruction selector. | 2070 UNREACHABLE(); // Won't be generated by instruction selector. |
2028 break; | 2071 break; |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2733 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2776 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2734 __ Nop(padding_size); | 2777 __ Nop(padding_size); |
2735 } | 2778 } |
2736 } | 2779 } |
2737 | 2780 |
2738 #undef __ | 2781 #undef __ |
2739 | 2782 |
2740 } // namespace compiler | 2783 } // namespace compiler |
2741 } // namespace internal | 2784 } // namespace internal |
2742 } // namespace v8 | 2785 } // namespace v8 |
OLD | NEW |