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 4878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4889 } | 4889 } |
4890 DCHECK(!result.is(result_end)); | 4890 DCHECK(!result.is(result_end)); |
4891 | 4891 |
4892 // Load address of new object into result. | 4892 // Load address of new object into result. |
4893 LoadAllocationTopHelper(result, scratch, flags); | 4893 LoadAllocationTopHelper(result, scratch, flags); |
4894 | 4894 |
4895 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 4895 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
4896 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); | 4896 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); |
4897 } | 4897 } |
4898 | 4898 |
4899 // Calculate new top and bail out if new space is exhausted. | |
4900 ExternalReference allocation_limit = | |
4901 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
4902 | |
4903 Register top_reg = result_end.is_valid() ? result_end : result; | 4899 Register top_reg = result_end.is_valid() ? result_end : result; |
4904 | 4900 |
4905 if (!top_reg.is(result)) { | 4901 if (!top_reg.is(result)) { |
Benedikt Meurer
2016/04/19 07:25:39
We can fuse this movp and the addp into a single l
Hannes Payer (out of office)
2016/04/19 11:03:56
Done.
| |
4906 movp(top_reg, result); | 4902 movp(top_reg, result); |
4907 } | 4903 } |
4908 addp(top_reg, Immediate(object_size)); | 4904 addp(top_reg, Immediate(object_size)); |
4909 j(carry, gc_required); | |
4910 Operand limit_operand = ExternalOperand(allocation_limit); | |
4911 cmpp(top_reg, limit_operand); | |
4912 j(above, gc_required); | |
4913 | 4905 |
4914 // Update allocation top. | 4906 if ((flags & ALLOCATION_FOLDING_DOMINATED) == 0) { |
4915 UpdateAllocationTopHelper(top_reg, scratch, flags); | 4907 j(carry, gc_required); |
4908 // Calculate new top and bail out if new space is exhausted. | |
Benedikt Meurer
2016/04/19 07:25:39
This comment is wrong here, as the calculation hap
Hannes Payer (out of office)
2016/04/19 11:03:56
Done.
| |
4909 ExternalReference allocation_limit = | |
4910 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
4911 Operand limit_operand = ExternalOperand(allocation_limit); | |
4912 cmpp(top_reg, limit_operand); | |
4913 j(above, gc_required); | |
4914 } | |
4915 | |
4916 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | |
4917 // Update allocation top. | |
4918 UpdateAllocationTopHelper(top_reg, scratch, flags); | |
4919 } | |
4916 | 4920 |
4917 bool tag_result = (flags & TAG_OBJECT) != 0; | 4921 bool tag_result = (flags & TAG_OBJECT) != 0; |
4918 if (top_reg.is(result)) { | 4922 if (top_reg.is(result)) { |
4919 if (tag_result) { | 4923 if (tag_result) { |
4920 subp(result, Immediate(object_size - kHeapObjectTag)); | 4924 subp(result, Immediate(object_size - kHeapObjectTag)); |
4921 } else { | 4925 } else { |
4922 subp(result, Immediate(object_size)); | 4926 subp(result, Immediate(object_size)); |
4923 } | 4927 } |
4924 } else if (tag_result) { | 4928 } else if (tag_result) { |
4925 // Tag the result if requested. | 4929 // Tag the result if requested. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4965 } | 4969 } |
4966 DCHECK(!result.is(result_end)); | 4970 DCHECK(!result.is(result_end)); |
4967 | 4971 |
4968 // Load address of new object into result. | 4972 // Load address of new object into result. |
4969 LoadAllocationTopHelper(result, scratch, flags); | 4973 LoadAllocationTopHelper(result, scratch, flags); |
4970 | 4974 |
4971 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 4975 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
4972 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); | 4976 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); |
4973 } | 4977 } |
4974 | 4978 |
4975 // Calculate new top and bail out if new space is exhausted. | |
4976 ExternalReference allocation_limit = | |
4977 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
4978 if (!object_size.is(result_end)) { | 4979 if (!object_size.is(result_end)) { |
Benedikt Meurer
2016/04/19 07:25:38
Same here, see comment above.
Hannes Payer (out of office)
2016/04/19 11:03:56
Done.
| |
4979 movp(result_end, object_size); | 4980 movp(result_end, object_size); |
4980 } | 4981 } |
4981 addp(result_end, result); | 4982 addp(result_end, result); |
4982 j(carry, gc_required); | |
4983 Operand limit_operand = ExternalOperand(allocation_limit); | |
4984 cmpp(result_end, limit_operand); | |
4985 j(above, gc_required); | |
4986 | 4983 |
4987 // Update allocation top. | 4984 if ((flags & ALLOCATION_FOLDING_DOMINATED) == 0) { |
4988 UpdateAllocationTopHelper(result_end, scratch, flags); | 4985 j(carry, gc_required); |
4986 // Calculate new top and bail out if new space is exhausted. | |
Benedikt Meurer
2016/04/19 07:25:38
Same here, see comment above.
Hannes Payer (out of office)
2016/04/19 11:03:56
Done.
| |
4987 ExternalReference allocation_limit = | |
4988 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
4989 Operand limit_operand = ExternalOperand(allocation_limit); | |
4990 cmpp(result_end, limit_operand); | |
4991 j(above, gc_required); | |
4992 } | |
4993 | |
4994 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | |
4995 // Update allocation top. | |
4996 UpdateAllocationTopHelper(result_end, scratch, flags); | |
4997 } | |
4989 | 4998 |
4990 // Tag the result if requested. | 4999 // Tag the result if requested. |
4991 if ((flags & TAG_OBJECT) != 0) { | 5000 if ((flags & TAG_OBJECT) != 0) { |
4992 addp(result, Immediate(kHeapObjectTag)); | 5001 addp(result, Immediate(kHeapObjectTag)); |
4993 } | 5002 } |
4994 } | 5003 } |
4995 | 5004 |
5005 void MacroAssembler::SetTop(Register value, AllocationFlags flags) { | |
5006 ExternalReference allocation_top = | |
5007 AllocationUtils::GetAllocationTopReference(isolate(), flags); | |
5008 | |
5009 subp(value, Immediate(kHeapObjectTag)); | |
Benedikt Meurer
2016/04/19 07:25:39
How about this one instead?
// TODO(hpayer): Chan
Hannes Payer (out of office)
2016/04/19 11:03:56
Store already uses the scratch register.
| |
5010 Store(allocation_top, value); | |
5011 addp(value, Immediate(kHeapObjectTag)); | |
5012 } | |
4996 | 5013 |
4997 void MacroAssembler::AllocateHeapNumber(Register result, | 5014 void MacroAssembler::AllocateHeapNumber(Register result, |
4998 Register scratch, | 5015 Register scratch, |
4999 Label* gc_required, | 5016 Label* gc_required, |
5000 MutableMode mode) { | 5017 MutableMode mode) { |
5001 // Allocate heap number in new space. | 5018 // Allocate heap number in new space. |
5002 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, TAG_OBJECT); | 5019 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, TAG_OBJECT); |
5003 | 5020 |
5004 Heap::RootListIndex map_index = mode == MUTABLE | 5021 Heap::RootListIndex map_index = mode == MUTABLE |
5005 ? Heap::kMutableHeapNumberMapRootIndex | 5022 ? Heap::kMutableHeapNumberMapRootIndex |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5704 movl(rax, dividend); | 5721 movl(rax, dividend); |
5705 shrl(rax, Immediate(31)); | 5722 shrl(rax, Immediate(31)); |
5706 addl(rdx, rax); | 5723 addl(rdx, rax); |
5707 } | 5724 } |
5708 | 5725 |
5709 | 5726 |
5710 } // namespace internal | 5727 } // namespace internal |
5711 } // namespace v8 | 5728 } // namespace v8 |
5712 | 5729 |
5713 #endif // V8_TARGET_ARCH_X64 | 5730 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |