Commit eabf5c89 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Add alignment check to object allocated in generated code for x64 and ARM

Review URL: http://codereview.chromium.org/460068

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3418 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cbce986f
...@@ -794,15 +794,13 @@ void MacroAssembler::AllocateInNewSpace(int object_size, ...@@ -794,15 +794,13 @@ void MacroAssembler::AllocateInNewSpace(int object_size,
mov(scratch1, Operand(new_space_allocation_top)); mov(scratch1, Operand(new_space_allocation_top));
if ((flags & RESULT_CONTAINS_TOP) == 0) { if ((flags & RESULT_CONTAINS_TOP) == 0) {
ldr(result, MemOperand(scratch1)); ldr(result, MemOperand(scratch1));
} else { } else if (FLAG_debug_code) {
#ifdef DEBUG
// Assert that result actually contains top on entry. scratch2 is used // Assert that result actually contains top on entry. scratch2 is used
// immediately below so this use of scratch2 does not cause difference with // immediately below so this use of scratch2 does not cause difference with
// respect to register content between debug and release mode. // respect to register content between debug and release mode.
ldr(scratch2, MemOperand(scratch1)); ldr(scratch2, MemOperand(scratch1));
cmp(result, scratch2); cmp(result, scratch2);
Check(eq, "Unexpected allocation top"); Check(eq, "Unexpected allocation top");
#endif
} }
// Calculate new top and bail out if new space is exhausted. Use result // Calculate new top and bail out if new space is exhausted. Use result
...@@ -815,7 +813,11 @@ void MacroAssembler::AllocateInNewSpace(int object_size, ...@@ -815,7 +813,11 @@ void MacroAssembler::AllocateInNewSpace(int object_size,
cmp(result, Operand(scratch2)); cmp(result, Operand(scratch2));
b(hi, gc_required); b(hi, gc_required);
// Update allocation top. result temporarily holds the new top, // Update allocation top. result temporarily holds the new top.
if (FLAG_debug_code) {
tst(result, Operand(kObjectAlignmentMask));
Check(eq, "Unaligned allocation in new space");
}
str(result, MemOperand(scratch1)); str(result, MemOperand(scratch1));
// Tag and adjust back to start of new object. // Tag and adjust back to start of new object.
...@@ -844,15 +846,13 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, ...@@ -844,15 +846,13 @@ void MacroAssembler::AllocateInNewSpace(Register object_size,
mov(scratch1, Operand(new_space_allocation_top)); mov(scratch1, Operand(new_space_allocation_top));
if ((flags & RESULT_CONTAINS_TOP) == 0) { if ((flags & RESULT_CONTAINS_TOP) == 0) {
ldr(result, MemOperand(scratch1)); ldr(result, MemOperand(scratch1));
} else { } else if (FLAG_debug_code) {
#ifdef DEBUG
// Assert that result actually contains top on entry. scratch2 is used // Assert that result actually contains top on entry. scratch2 is used
// immediately below so this use of scratch2 does not cause difference with // immediately below so this use of scratch2 does not cause difference with
// respect to register content between debug and release mode. // respect to register content between debug and release mode.
ldr(scratch2, MemOperand(scratch1)); ldr(scratch2, MemOperand(scratch1));
cmp(result, scratch2); cmp(result, scratch2);
Check(eq, "Unexpected allocation top"); Check(eq, "Unexpected allocation top");
#endif
} }
// Calculate new top and bail out if new space is exhausted. Use result // Calculate new top and bail out if new space is exhausted. Use result
...@@ -866,7 +866,11 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, ...@@ -866,7 +866,11 @@ void MacroAssembler::AllocateInNewSpace(Register object_size,
cmp(result, Operand(scratch2)); cmp(result, Operand(scratch2));
b(hi, gc_required); b(hi, gc_required);
// Update allocation top. result temporarily holds the new top, // Update allocation top. result temporarily holds the new top.
if (FLAG_debug_code) {
tst(result, Operand(kObjectAlignmentMask));
Check(eq, "Unaligned allocation in new space");
}
str(result, MemOperand(scratch1)); str(result, MemOperand(scratch1));
// Adjust back to start of new object. // Adjust back to start of new object.
...@@ -1162,6 +1166,9 @@ void MacroAssembler::Abort(const char* msg) { ...@@ -1162,6 +1166,9 @@ void MacroAssembler::Abort(const char* msg) {
RecordComment(msg); RecordComment(msg);
} }
#endif #endif
// Disable stub call restrictions to always allow calls to abort.
set_allow_stub_calls(true);
mov(r0, Operand(p0)); mov(r0, Operand(p0));
push(r0); push(r0);
mov(r0, Operand(Smi::FromInt(p1 - p0))); mov(r0, Operand(Smi::FromInt(p1 - p0)));
......
...@@ -1393,7 +1393,7 @@ void MacroAssembler::Abort(const char* msg) { ...@@ -1393,7 +1393,7 @@ void MacroAssembler::Abort(const char* msg) {
RecordComment(msg); RecordComment(msg);
} }
#endif #endif
// Disable stub call restrictions to always allow cals to abort. // Disable stub call restrictions to always allow calls to abort.
set_allow_stub_calls(true); set_allow_stub_calls(true);
push(eax); push(eax);
......
...@@ -288,6 +288,9 @@ void MacroAssembler::Abort(const char* msg) { ...@@ -288,6 +288,9 @@ void MacroAssembler::Abort(const char* msg) {
RecordComment(msg); RecordComment(msg);
} }
#endif #endif
// Disable stub call restrictions to always allow calls to abort.
set_allow_stub_calls(true);
push(rax); push(rax);
movq(kScratchRegister, p0, RelocInfo::NONE); movq(kScratchRegister, p0, RelocInfo::NONE);
push(kScratchRegister); push(kScratchRegister);
...@@ -297,6 +300,7 @@ void MacroAssembler::Abort(const char* msg) { ...@@ -297,6 +300,7 @@ void MacroAssembler::Abort(const char* msg) {
push(kScratchRegister); push(kScratchRegister);
CallRuntime(Runtime::kAbort, 2); CallRuntime(Runtime::kAbort, 2);
// will not return here // will not return here
int3();
} }
...@@ -2094,6 +2098,11 @@ void MacroAssembler::LoadAllocationTopHelper(Register result, ...@@ -2094,6 +2098,11 @@ void MacroAssembler::LoadAllocationTopHelper(Register result,
void MacroAssembler::UpdateAllocationTopHelper(Register result_end, void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
Register scratch) { Register scratch) {
if (FLAG_debug_code) {
testq(result_end, Immediate(kObjectAlignmentMask));
Check(zero, "Unaligned allocation in new space");
}
ExternalReference new_space_allocation_top = ExternalReference new_space_allocation_top =
ExternalReference::new_space_allocation_top_address(); ExternalReference::new_space_allocation_top_address();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment