Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 8513a68fa915fa98ad69f5b544941287e4446c38..19764855cddd2a4e07c4af2da4feb348e219e231 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -3758,6 +3758,7 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
Register scratch, |
Label* gc_required, |
AllocationFlags flags) { |
+ ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); |
if (!FLAG_inline_new) { |
if (emit_debug_code()) { |
// Trash the registers to simulate an allocation failure. |
@@ -3777,6 +3778,16 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
// Load address of new object into result. |
LoadAllocationTopHelper(result, scratch, flags); |
+ // Align the next allocation. Storing the filler map without checking top is |
+ // always safe because the limit of the heap is always aligned. |
+ if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { |
+ Label aligned; |
Yang
2012/12/28 10:03:48
You can use MacroAssembler::Check for this.
danno
2012/12/28 15:44:55
Done.
|
+ testq(result, Immediate(kDoubleAlignmentMask)); |
+ j(zero, &aligned, Label::kNear); |
+ Abort("Allocation is not double aligned"); |
+ bind(&aligned); |
+ } |
+ |
// Calculate new top and bail out if new space is exhausted. |
ExternalReference new_space_allocation_limit = |
ExternalReference::new_space_allocation_limit_address(isolate()); |
@@ -3795,15 +3806,17 @@ void MacroAssembler::AllocateInNewSpace(int object_size, |
// Update allocation top. |
UpdateAllocationTopHelper(top_reg, scratch); |
+ bool tag_result = (flags & TAG_OBJECT) != 0; |
if (top_reg.is(result)) { |
- if ((flags & TAG_OBJECT) != 0) { |
+ if (tag_result) { |
subq(result, Immediate(object_size - kHeapObjectTag)); |
} else { |
subq(result, Immediate(object_size)); |
} |
- } else if ((flags & TAG_OBJECT) != 0) { |
+ } else if (tag_result) { |
// Tag the result if requested. |
- addq(result, Immediate(kHeapObjectTag)); |
+ ASSERT(kHeapObjectTag == 1); |
+ incq(result); |
} |
} |
@@ -3816,6 +3829,7 @@ void MacroAssembler::AllocateInNewSpace(int header_size, |
Register scratch, |
Label* gc_required, |
AllocationFlags flags) { |
+ ASSERT((flags & SIZE_IN_WORDS) == 0); |
if (!FLAG_inline_new) { |
if (emit_debug_code()) { |
// Trash the registers to simulate an allocation failure. |
@@ -3834,6 +3848,16 @@ void MacroAssembler::AllocateInNewSpace(int header_size, |
// Load address of new object into result. |
LoadAllocationTopHelper(result, scratch, flags); |
+ // Align the next allocation. Storing the filler map without checking top is |
+ // always safe because the limit of the heap is always aligned. |
+ if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { |
+ Label aligned; |
Yang
2012/12/28 10:03:48
Ditto.
danno
2012/12/28 15:44:55
Done.
|
+ testq(result, Immediate(kDoubleAlignmentMask)); |
+ j(zero, &aligned, Label::kNear); |
+ Abort("Allocation is not double aligned"); |
+ bind(&aligned); |
+ } |
+ |
// Calculate new top and bail out if new space is exhausted. |
ExternalReference new_space_allocation_limit = |
ExternalReference::new_space_allocation_limit_address(isolate()); |
@@ -3852,7 +3876,8 @@ void MacroAssembler::AllocateInNewSpace(int header_size, |
// Tag the result if requested. |
if ((flags & TAG_OBJECT) != 0) { |
- addq(result, Immediate(kHeapObjectTag)); |
+ ASSERT(kHeapObjectTag == 1); |
+ incq(result); |
} |
} |
@@ -3863,6 +3888,8 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, |
Register scratch, |
Label* gc_required, |
AllocationFlags flags) { |
+ ASSERT((flags & (DOUBLE_ALIGNMENT | RESULT_CONTAINS_TOP | |
+ SIZE_IN_WORDS)) == 0); |
if (!FLAG_inline_new) { |
if (emit_debug_code()) { |
// Trash the registers to simulate an allocation failure. |