OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 AllowDeferredHandleDereference smi_check; | 2736 AllowDeferredHandleDereference smi_check; |
2737 if (source->IsSmi()) { | 2737 if (source->IsSmi()) { |
2738 Move(dst, Smi::cast(*source)); | 2738 Move(dst, Smi::cast(*source)); |
2739 } else { | 2739 } else { |
2740 MoveHeapObject(kScratchRegister, source); | 2740 MoveHeapObject(kScratchRegister, source); |
2741 movp(dst, kScratchRegister); | 2741 movp(dst, kScratchRegister); |
2742 } | 2742 } |
2743 } | 2743 } |
2744 | 2744 |
2745 | 2745 |
| 2746 void MacroAssembler::Move(XMMRegister dst, uint32_t src) { |
| 2747 if (src == 0) { |
| 2748 xorps(dst, dst); |
| 2749 } else { |
| 2750 unsigned cnt = base::bits::CountPopulation32(src); |
| 2751 unsigned nlz = base::bits::CountLeadingZeros32(src); |
| 2752 unsigned ntz = base::bits::CountTrailingZeros32(src); |
| 2753 if (nlz + cnt + ntz == 32) { |
| 2754 pcmpeqd(dst, dst); |
| 2755 if (ntz == 0) { |
| 2756 psrld(dst, 32 - cnt); |
| 2757 } else { |
| 2758 pslld(dst, 32 - cnt); |
| 2759 if (nlz != 0) psrld(dst, nlz); |
| 2760 } |
| 2761 } else { |
| 2762 movl(kScratchRegister, Immediate(src)); |
| 2763 movq(dst, kScratchRegister); |
| 2764 } |
| 2765 } |
| 2766 } |
| 2767 |
| 2768 |
| 2769 void MacroAssembler::Move(XMMRegister dst, uint64_t src) { |
| 2770 uint32_t lower = static_cast<uint32_t>(src); |
| 2771 uint32_t upper = static_cast<uint32_t>(src >> 32); |
| 2772 if (upper == 0) { |
| 2773 Move(dst, lower); |
| 2774 } else { |
| 2775 unsigned cnt = base::bits::CountPopulation64(src); |
| 2776 unsigned nlz = base::bits::CountLeadingZeros64(src); |
| 2777 unsigned ntz = base::bits::CountTrailingZeros64(src); |
| 2778 if (nlz + cnt + ntz == 64) { |
| 2779 pcmpeqd(dst, dst); |
| 2780 if (ntz == 0) { |
| 2781 psrlq(dst, 64 - cnt); |
| 2782 } else { |
| 2783 psllq(dst, 64 - cnt); |
| 2784 if (nlz != 0) psrlq(dst, nlz); |
| 2785 } |
| 2786 } else if (lower == 0) { |
| 2787 Move(dst, upper); |
| 2788 psllq(dst, 32); |
| 2789 } else { |
| 2790 movq(kScratchRegister, src); |
| 2791 movq(dst, kScratchRegister); |
| 2792 } |
| 2793 } |
| 2794 } |
| 2795 |
| 2796 |
2746 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { | 2797 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { |
2747 AllowDeferredHandleDereference smi_check; | 2798 AllowDeferredHandleDereference smi_check; |
2748 if (source->IsSmi()) { | 2799 if (source->IsSmi()) { |
2749 Cmp(dst, Smi::cast(*source)); | 2800 Cmp(dst, Smi::cast(*source)); |
2750 } else { | 2801 } else { |
2751 MoveHeapObject(kScratchRegister, source); | 2802 MoveHeapObject(kScratchRegister, source); |
2752 cmpp(dst, kScratchRegister); | 2803 cmpp(dst, kScratchRegister); |
2753 } | 2804 } |
2754 } | 2805 } |
2755 | 2806 |
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5342 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); | 5393 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); |
5343 movl(rax, dividend); | 5394 movl(rax, dividend); |
5344 shrl(rax, Immediate(31)); | 5395 shrl(rax, Immediate(31)); |
5345 addl(rdx, rax); | 5396 addl(rdx, rax); |
5346 } | 5397 } |
5347 | 5398 |
5348 | 5399 |
5349 } } // namespace v8::internal | 5400 } } // namespace v8::internal |
5350 | 5401 |
5351 #endif // V8_TARGET_ARCH_X64 | 5402 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |