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 <limits> | 7 #include <limits> |
8 | 8 |
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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 2); \ | 703 2); \ |
704 } while (false) | 704 } while (false) |
705 | 705 |
706 #define ASSEMBLE_IEEE754_UNOP(name) \ | 706 #define ASSEMBLE_IEEE754_UNOP(name) \ |
707 do { \ | 707 do { \ |
708 __ PrepareCallCFunction(1); \ | 708 __ PrepareCallCFunction(1); \ |
709 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 709 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
710 1); \ | 710 1); \ |
711 } while (false) | 711 } while (false) |
712 | 712 |
| 713 #define ASSEMBLE_ATOMIC_BINOP(bin_inst, mov_inst, cmpxchg_inst) \ |
| 714 do { \ |
| 715 Label binop; \ |
| 716 __ bind(&binop); \ |
| 717 __ mov_inst(rax, i.MemoryOperand(1)); \ |
| 718 __ movl(i.TempRegister(0), rax); \ |
| 719 __ bin_inst(i.TempRegister(0), i.InputRegister(0)); \ |
| 720 __ lock(); \ |
| 721 __ cmpxchg_inst(i.MemoryOperand(1), i.TempRegister(0)); \ |
| 722 __ j(not_equal, &binop); \ |
| 723 } while (false) |
| 724 |
713 void CodeGenerator::AssembleDeconstructFrame() { | 725 void CodeGenerator::AssembleDeconstructFrame() { |
714 unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset()); | 726 unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset()); |
715 __ movq(rsp, rbp); | 727 __ movq(rsp, rbp); |
716 __ popq(rbp); | 728 __ popq(rbp); |
717 } | 729 } |
718 | 730 |
719 void CodeGenerator::AssemblePrepareTailCall() { | 731 void CodeGenerator::AssemblePrepareTailCall() { |
720 if (frame_access_state()->has_frame()) { | 732 if (frame_access_state()->has_frame()) { |
721 __ movq(rbp, MemOperand(rbp, 0)); | 733 __ movq(rbp, MemOperand(rbp, 0)); |
722 } | 734 } |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 __ lock(); | 2335 __ lock(); |
2324 __ cmpxchgw(i.MemoryOperand(2), i.InputRegister(1)); | 2336 __ cmpxchgw(i.MemoryOperand(2), i.InputRegister(1)); |
2325 __ movzxwl(rax, rax); | 2337 __ movzxwl(rax, rax); |
2326 break; | 2338 break; |
2327 } | 2339 } |
2328 case kAtomicCompareExchangeWord32: { | 2340 case kAtomicCompareExchangeWord32: { |
2329 __ lock(); | 2341 __ lock(); |
2330 __ cmpxchgl(i.MemoryOperand(2), i.InputRegister(1)); | 2342 __ cmpxchgl(i.MemoryOperand(2), i.InputRegister(1)); |
2331 break; | 2343 break; |
2332 } | 2344 } |
| 2345 #define ATOMIC_BINOP_CASE(op, inst) \ |
| 2346 case kAtomic##op##Int8: \ |
| 2347 ASSEMBLE_ATOMIC_BINOP(inst, movb, cmpxchgb); \ |
| 2348 __ movsxbl(rax, rax); \ |
| 2349 break; \ |
| 2350 case kAtomic##op##Uint8: \ |
| 2351 ASSEMBLE_ATOMIC_BINOP(inst, movb, cmpxchgb); \ |
| 2352 __ movzxbl(rax, rax); \ |
| 2353 break; \ |
| 2354 case kAtomic##op##Int16: \ |
| 2355 ASSEMBLE_ATOMIC_BINOP(inst, movw, cmpxchgw); \ |
| 2356 __ movsxwl(rax, rax); \ |
| 2357 break; \ |
| 2358 case kAtomic##op##Uint16: \ |
| 2359 ASSEMBLE_ATOMIC_BINOP(inst, movw, cmpxchgw); \ |
| 2360 __ movzxwl(rax, rax); \ |
| 2361 break; \ |
| 2362 case kAtomic##op##Word32: \ |
| 2363 ASSEMBLE_ATOMIC_BINOP(inst, movl, cmpxchgl); \ |
| 2364 break; |
| 2365 ATOMIC_BINOP_CASE(Add, addl) |
| 2366 ATOMIC_BINOP_CASE(Sub, subl) |
| 2367 ATOMIC_BINOP_CASE(And, andl) |
| 2368 ATOMIC_BINOP_CASE(Or, orl) |
| 2369 ATOMIC_BINOP_CASE(Xor, xorl) |
| 2370 #undef ATOMIC_BINOP_CASE |
2333 case kAtomicLoadInt8: | 2371 case kAtomicLoadInt8: |
2334 case kAtomicLoadUint8: | 2372 case kAtomicLoadUint8: |
2335 case kAtomicLoadInt16: | 2373 case kAtomicLoadInt16: |
2336 case kAtomicLoadUint16: | 2374 case kAtomicLoadUint16: |
2337 case kAtomicLoadWord32: | 2375 case kAtomicLoadWord32: |
2338 case kAtomicStoreWord8: | 2376 case kAtomicStoreWord8: |
2339 case kAtomicStoreWord16: | 2377 case kAtomicStoreWord16: |
2340 case kAtomicStoreWord32: | 2378 case kAtomicStoreWord32: |
2341 UNREACHABLE(); // Won't be generated by instruction selector. | 2379 UNREACHABLE(); // Won't be generated by instruction selector. |
2342 break; | 2380 break; |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 3001 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2964 __ Nop(padding_size); | 3002 __ Nop(padding_size); |
2965 } | 3003 } |
2966 } | 3004 } |
2967 | 3005 |
2968 #undef __ | 3006 #undef __ |
2969 | 3007 |
2970 } // namespace compiler | 3008 } // namespace compiler |
2971 } // namespace internal | 3009 } // namespace internal |
2972 } // namespace v8 | 3010 } // namespace v8 |
OLD | NEW |