Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 807e90dbec86555ee90921dc3e1349204897e398..351bc80c29a617ce18886a2dd716618cd7690ae7 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -3688,11 +3688,31 @@ void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
} |
+ExternalReference MacroAssembler::GetTopAddress(AllocationTarget target) { |
danno
2013/03/05 12:18:18
Do these belong in the macro assembler at all? Els
Hannes Payer (out of office)
2013/03/11 17:16:31
Done. I removed these helper functions.
|
+ if (target == NEW_SPACE) { |
+ return ExternalReference::new_space_allocation_top_address(isolate()); |
+ } else { |
+ return ExternalReference::old_pointer_space_allocation_top_address( |
+ isolate()); |
+ } |
+} |
+ |
+ |
+ExternalReference MacroAssembler::GetLimitAddress(AllocationTarget target) { |
+ if (target == NEW_SPACE) { |
+ return ExternalReference::new_space_allocation_limit_address(isolate()); |
+ } else { |
+ return ExternalReference::old_pointer_space_allocation_limit_address( |
+ isolate()); |
+ } |
+} |
+ |
+ |
void MacroAssembler::LoadAllocationTopHelper(Register result, |
Register scratch, |
- AllocationFlags flags) { |
- ExternalReference new_space_allocation_top = |
- ExternalReference::new_space_allocation_top_address(isolate()); |
+ AllocationFlags flags, |
+ AllocationTarget target) { |
+ ExternalReference allocation_top = GetTopAddress(target); |
// Just return if allocation top is already known. |
if ((flags & RESULT_CONTAINS_TOP) != 0) { |
@@ -3700,7 +3720,7 @@ void MacroAssembler::LoadAllocationTopHelper(Register result, |
ASSERT(!scratch.is_valid()); |
#ifdef DEBUG |
// Assert that result actually contains top on entry. |
- Operand top_operand = ExternalOperand(new_space_allocation_top); |
+ Operand top_operand = ExternalOperand(allocation_top); |
cmpq(result, top_operand); |
Check(equal, "Unexpected allocation top"); |
#endif |
@@ -3710,40 +3730,41 @@ void MacroAssembler::LoadAllocationTopHelper(Register result, |
// Move address of new object to result. Use scratch register if available, |
// and keep address in scratch until call to UpdateAllocationTopHelper. |
if (scratch.is_valid()) { |
- LoadAddress(scratch, new_space_allocation_top); |
+ LoadAddress(scratch, allocation_top); |
movq(result, Operand(scratch, 0)); |
} else { |
- Load(result, new_space_allocation_top); |
+ Load(result, allocation_top); |
} |
} |
void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
- Register scratch) { |
+ Register scratch, |
+ AllocationTarget target) { |
if (emit_debug_code()) { |
testq(result_end, Immediate(kObjectAlignmentMask)); |
Check(zero, "Unaligned allocation in new space"); |
} |
- ExternalReference new_space_allocation_top = |
- ExternalReference::new_space_allocation_top_address(isolate()); |
+ ExternalReference allocation_top = GetTopAddress(target); |
// Update new top. |
if (scratch.is_valid()) { |
// Scratch already contains address of allocation top. |
movq(Operand(scratch, 0), result_end); |
} else { |
- Store(new_space_allocation_top, result_end); |
+ Store(allocation_top, result_end); |
} |
} |
-void MacroAssembler::AllocateInNewSpace(int object_size, |
- Register result, |
- Register result_end, |
- Register scratch, |
- Label* gc_required, |
- AllocationFlags flags) { |
+void MacroAssembler::Allocate(int object_size, |
+ Register result, |
+ Register result_end, |
+ Register scratch, |
+ Label* gc_required, |
+ AllocationFlags flags, |
+ AllocationTarget target) { |
ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); |
if (!FLAG_inline_new) { |
if (emit_debug_code()) { |
@@ -3762,7 +3783,7 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
ASSERT(!result.is(result_end)); |
// Load address of new object into result. |
- LoadAllocationTopHelper(result, scratch, flags); |
+ LoadAllocationTopHelper(result, scratch, flags, target); |
// Align the next allocation. Storing the filler map without checking top is |
// always safe because the limit of the heap is always aligned. |
@@ -3772,8 +3793,7 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
} |
// Calculate new top and bail out if new space is exhausted. |
- ExternalReference new_space_allocation_limit = |
- ExternalReference::new_space_allocation_limit_address(isolate()); |
+ ExternalReference allocation_limit = GetLimitAddress(target); |
Register top_reg = result_end.is_valid() ? result_end : result; |
@@ -3782,12 +3802,12 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
} |
addq(top_reg, Immediate(object_size)); |
j(carry, gc_required); |
- Operand limit_operand = ExternalOperand(new_space_allocation_limit); |
+ Operand limit_operand = ExternalOperand(allocation_limit); |
cmpq(top_reg, limit_operand); |
j(above, gc_required); |
// Update allocation top. |
- UpdateAllocationTopHelper(top_reg, scratch); |
+ UpdateAllocationTopHelper(top_reg, scratch, target); |
bool tag_result = (flags & TAG_OBJECT) != 0; |
if (top_reg.is(result)) { |
@@ -3829,7 +3849,7 @@ void MacroAssembler::AllocateInNewSpace(int header_size, |
ASSERT(!result.is(result_end)); |
// Load address of new object into result. |
- LoadAllocationTopHelper(result, scratch, flags); |
+ LoadAllocationTopHelper(result, scratch, flags, NEW_SPACE); |
// Align the next allocation. Storing the filler map without checking top is |
// always safe because the limit of the heap is always aligned. |
@@ -3852,7 +3872,7 @@ void MacroAssembler::AllocateInNewSpace(int header_size, |
j(above, gc_required); |
// Update allocation top. |
- UpdateAllocationTopHelper(result_end, scratch); |
+ UpdateAllocationTopHelper(result_end, scratch, NEW_SPACE); |
// Tag the result if requested. |
if ((flags & TAG_OBJECT) != 0) { |
@@ -3885,7 +3905,7 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, |
ASSERT(!result.is(result_end)); |
// Load address of new object into result. |
- LoadAllocationTopHelper(result, scratch, flags); |
+ LoadAllocationTopHelper(result, scratch, flags, NEW_SPACE); |
// Calculate new top and bail out if new space is exhausted. |
ExternalReference new_space_allocation_limit = |
@@ -3900,7 +3920,7 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, |
j(above, gc_required); |
// Update allocation top. |
- UpdateAllocationTopHelper(result_end, scratch); |
+ UpdateAllocationTopHelper(result_end, scratch, NEW_SPACE); |
// Align the next allocation. Storing the filler map without checking top is |
// always safe because the limit of the heap is always aligned. |
@@ -3935,12 +3955,8 @@ void MacroAssembler::AllocateHeapNumber(Register result, |
Register scratch, |
Label* gc_required) { |
// Allocate heap number in new space. |
- AllocateInNewSpace(HeapNumber::kSize, |
- result, |
- scratch, |
- no_reg, |
- gc_required, |
- TAG_OBJECT); |
+ Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, TAG_OBJECT, |
+ NEW_SPACE); |
// Set the map. |
LoadRoot(kScratchRegister, Heap::kHeapNumberMapRootIndex); |
@@ -4030,12 +4046,8 @@ void MacroAssembler::AllocateTwoByteConsString(Register result, |
Register scratch2, |
Label* gc_required) { |
// Allocate heap number in new space. |
- AllocateInNewSpace(ConsString::kSize, |
- result, |
- scratch1, |
- scratch2, |
- gc_required, |
- TAG_OBJECT); |
+ Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, |
+ TAG_OBJECT, NEW_SPACE); |
// Set the map. The other fields are left uninitialized. |
LoadRoot(kScratchRegister, Heap::kConsStringMapRootIndex); |
@@ -4048,12 +4060,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, |
Register scratch2, |
Label* gc_required) { |
// Allocate heap number in new space. |
- AllocateInNewSpace(ConsString::kSize, |
- result, |
- scratch1, |
- scratch2, |
- gc_required, |
- TAG_OBJECT); |
+ Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, |
+ TAG_OBJECT, NEW_SPACE); |
// Set the map. The other fields are left uninitialized. |
LoadRoot(kScratchRegister, Heap::kConsAsciiStringMapRootIndex); |
@@ -4066,12 +4074,8 @@ void MacroAssembler::AllocateTwoByteSlicedString(Register result, |
Register scratch2, |
Label* gc_required) { |
// Allocate heap number in new space. |
- AllocateInNewSpace(SlicedString::kSize, |
- result, |
- scratch1, |
- scratch2, |
- gc_required, |
- TAG_OBJECT); |
+ Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
+ TAG_OBJECT, NEW_SPACE); |
// Set the map. The other fields are left uninitialized. |
LoadRoot(kScratchRegister, Heap::kSlicedStringMapRootIndex); |
@@ -4084,12 +4088,8 @@ void MacroAssembler::AllocateAsciiSlicedString(Register result, |
Register scratch2, |
Label* gc_required) { |
// Allocate heap number in new space. |
- AllocateInNewSpace(SlicedString::kSize, |
- result, |
- scratch1, |
- scratch2, |
- gc_required, |
- TAG_OBJECT); |
+ Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
+ TAG_OBJECT, NEW_SPACE); |
// Set the map. The other fields are left uninitialized. |
LoadRoot(kScratchRegister, Heap::kSlicedAsciiStringMapRootIndex); |