Chromium Code Reviews| 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 4798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4809 } | 4809 } |
| 4810 } | 4810 } |
| 4811 | 4811 |
| 4812 | 4812 |
| 4813 void MacroAssembler::MakeSureDoubleAlignedHelper(Register result, | 4813 void MacroAssembler::MakeSureDoubleAlignedHelper(Register result, |
| 4814 Register scratch, | 4814 Register scratch, |
| 4815 Label* gc_required, | 4815 Label* gc_required, |
| 4816 AllocationFlags flags) { | 4816 AllocationFlags flags) { |
| 4817 if (kPointerSize == kDoubleSize) { | 4817 if (kPointerSize == kDoubleSize) { |
| 4818 if (FLAG_debug_code) { | 4818 if (FLAG_debug_code) { |
| 4819 testl(result, Immediate(kDoubleAlignmentMask)); | 4819 testl(result, Immediate(kDoubleAlignmentMask - kHeapObjectTag)); |
|
Michael Lippautz
2016/04/28 16:58:08
Don't really like this one (and below) but also do
Hannes Payer (out of office)
2016/04/29 14:13:31
I think that is fine. Maybe have a constant for th
| |
| 4820 Check(zero, kAllocationIsNotDoubleAligned); | 4820 Check(zero, kAllocationIsNotDoubleAligned); |
| 4821 } | 4821 } |
| 4822 } else { | 4822 } else { |
| 4823 // Align the next allocation. Storing the filler map without checking top | 4823 // Align the next allocation. Storing the filler map without checking top |
| 4824 // is safe in new-space because the limit of the heap is aligned there. | 4824 // is safe in new-space because the limit of the heap is aligned there. |
| 4825 DCHECK(kPointerSize * 2 == kDoubleSize); | 4825 DCHECK(kPointerSize * 2 == kDoubleSize); |
| 4826 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); | 4826 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); |
| 4827 // Make sure scratch is not clobbered by this function as it might be | 4827 // Make sure scratch is not clobbered by this function as it might be |
| 4828 // used in UpdateAllocationTopHelper later. | 4828 // used in UpdateAllocationTopHelper later. |
| 4829 DCHECK(!scratch.is(kScratchRegister)); | 4829 DCHECK(!scratch.is(kScratchRegister)); |
| 4830 Label aligned; | 4830 Label aligned; |
| 4831 testl(result, Immediate(kDoubleAlignmentMask)); | 4831 testl(result, Immediate(kDoubleAlignmentMask - kHeapObjectTag)); |
| 4832 j(zero, &aligned, Label::kNear); | 4832 j(zero, &aligned, Label::kNear); |
| 4833 if ((flags & PRETENURE) != 0) { | 4833 if ((flags & PRETENURE) != 0) { |
| 4834 ExternalReference allocation_limit = | 4834 ExternalReference allocation_limit = |
| 4835 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 4835 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4836 cmpp(result, ExternalOperand(allocation_limit)); | 4836 cmpp(result, ExternalOperand(allocation_limit)); |
| 4837 j(above_equal, gc_required); | 4837 j(above_equal, gc_required); |
| 4838 } | 4838 } |
| 4839 LoadRoot(kScratchRegister, Heap::kOnePointerFillerMapRootIndex); | 4839 LoadRoot(kScratchRegister, Heap::kOnePointerFillerMapRootIndex); |
| 4840 movp(Operand(result, 0), kScratchRegister); | 4840 movp(Operand(result, 0), kScratchRegister); |
| 4841 addp(result, Immediate(kDoubleSize / 2)); | 4841 addp(result, Immediate(kDoubleSize / 2)); |
| 4842 bind(&aligned); | 4842 bind(&aligned); |
| 4843 } | 4843 } |
| 4844 } | 4844 } |
| 4845 | 4845 |
| 4846 | 4846 |
| 4847 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, | 4847 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
| 4848 Register scratch, | 4848 Register scratch, |
| 4849 AllocationFlags flags) { | 4849 AllocationFlags flags) { |
| 4850 if (emit_debug_code()) { | 4850 if (emit_debug_code()) { |
| 4851 testp(result_end, Immediate(kObjectAlignmentMask)); | 4851 testp(result_end, Immediate(kObjectAlignmentMask)); |
| 4852 Check(zero, kUnalignedAllocationInNewSpace); | 4852 Check(not_zero, kUnalignedAllocationInNewSpace); |
| 4853 } | 4853 } |
| 4854 | 4854 |
| 4855 ExternalReference allocation_top = | 4855 ExternalReference allocation_top = |
| 4856 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 4856 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| 4857 | 4857 |
| 4858 // Update new top. | 4858 // Update new top. |
| 4859 if (scratch.is_valid()) { | 4859 if (scratch.is_valid()) { |
| 4860 // Scratch already contains address of allocation top. | 4860 // Scratch already contains address of allocation top. |
| 4861 movp(Operand(scratch, 0), result_end); | 4861 movp(Operand(scratch, 0), result_end); |
| 4862 } else { | 4862 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4906 movp(top_reg, result); | 4906 movp(top_reg, result); |
| 4907 } | 4907 } |
| 4908 addp(top_reg, Immediate(object_size)); | 4908 addp(top_reg, Immediate(object_size)); |
| 4909 Operand limit_operand = ExternalOperand(allocation_limit); | 4909 Operand limit_operand = ExternalOperand(allocation_limit); |
| 4910 cmpp(top_reg, limit_operand); | 4910 cmpp(top_reg, limit_operand); |
| 4911 j(above, gc_required); | 4911 j(above, gc_required); |
| 4912 | 4912 |
| 4913 // Update allocation top. | 4913 // Update allocation top. |
| 4914 UpdateAllocationTopHelper(top_reg, scratch, flags); | 4914 UpdateAllocationTopHelper(top_reg, scratch, flags); |
| 4915 | 4915 |
| 4916 // Untag result_end. | |
| 4917 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4918 decp(result_end); | |
|
Benedikt Meurer
2016/05/01 17:30:03
Hm, who needs this result_end anyways? Shouldn't t
| |
| 4919 | |
| 4916 if (top_reg.is(result)) { | 4920 if (top_reg.is(result)) { |
| 4917 subp(result, Immediate(object_size - kHeapObjectTag)); | 4921 subp(result, Immediate(object_size)); |
| 4918 } else { | |
| 4919 // Tag the result. | |
| 4920 DCHECK(kHeapObjectTag == 1); | |
| 4921 incp(result); | |
| 4922 } | 4922 } |
| 4923 } | 4923 } |
| 4924 | 4924 |
| 4925 | 4925 |
| 4926 void MacroAssembler::Allocate(int header_size, | 4926 void MacroAssembler::Allocate(int header_size, |
| 4927 ScaleFactor element_size, | 4927 ScaleFactor element_size, |
| 4928 Register element_count, | 4928 Register element_count, |
| 4929 Register result, | 4929 Register result, |
| 4930 Register result_end, | 4930 Register result_end, |
| 4931 Register scratch, | 4931 Register scratch, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4974 } | 4974 } |
| 4975 addp(result_end, result); | 4975 addp(result_end, result); |
| 4976 j(carry, gc_required); | 4976 j(carry, gc_required); |
| 4977 Operand limit_operand = ExternalOperand(allocation_limit); | 4977 Operand limit_operand = ExternalOperand(allocation_limit); |
| 4978 cmpp(result_end, limit_operand); | 4978 cmpp(result_end, limit_operand); |
| 4979 j(above, gc_required); | 4979 j(above, gc_required); |
| 4980 | 4980 |
| 4981 // Update allocation top. | 4981 // Update allocation top. |
| 4982 UpdateAllocationTopHelper(result_end, scratch, flags); | 4982 UpdateAllocationTopHelper(result_end, scratch, flags); |
| 4983 | 4983 |
| 4984 // Tag the result. | 4984 // Untag result_end. |
| 4985 addp(result, Immediate(kHeapObjectTag)); | 4985 STATIC_ASSERT(kHeapObjectTag == 1); |
| 4986 decp(result_end); | |
| 4986 } | 4987 } |
| 4987 | 4988 |
| 4988 | 4989 |
| 4989 void MacroAssembler::AllocateHeapNumber(Register result, | 4990 void MacroAssembler::AllocateHeapNumber(Register result, |
| 4990 Register scratch, | 4991 Register scratch, |
| 4991 Label* gc_required, | 4992 Label* gc_required, |
| 4992 MutableMode mode) { | 4993 MutableMode mode) { |
| 4993 // Allocate heap number in new space. | 4994 // Allocate heap number in new space. |
| 4994 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, | 4995 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, |
| 4995 NO_ALLOCATION_FLAGS); | 4996 NO_ALLOCATION_FLAGS); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5682 movl(rax, dividend); | 5683 movl(rax, dividend); |
| 5683 shrl(rax, Immediate(31)); | 5684 shrl(rax, Immediate(31)); |
| 5684 addl(rdx, rax); | 5685 addl(rdx, rax); |
| 5685 } | 5686 } |
| 5686 | 5687 |
| 5687 | 5688 |
| 5688 } // namespace internal | 5689 } // namespace internal |
| 5689 } // namespace v8 | 5690 } // namespace v8 |
| 5690 | 5691 |
| 5691 #endif // V8_TARGET_ARCH_X64 | 5692 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |