Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: src/arm/macro-assembler-arm.cc

Issue 5512004: Improve code generated for AllocInNewSpace (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/macro-assembler-arm.cc
===================================================================
--- src/arm/macro-assembler-arm.cc (revision 5914)
+++ src/arm/macro-assembler-arm.cc (working copy)
@@ -920,6 +920,7 @@
}
ASSERT(!result.is(scratch1));
+ ASSERT(!result.is(scratch2));
ASSERT(!scratch1.is(scratch2));
// Make object size into bytes.
@@ -928,38 +929,55 @@
}
ASSERT_EQ(0, object_size & kObjectAlignmentMask);
- // Load address of new object into result and allocation top address into
- // scratch1.
+ // Check relative positions of allocation top and limit addresses.
+ // The values must be adjacent in memory to allow the use of LDM.
+ // Also, assert that the registers are numbered such that the values
+ // are loaded in the correct order.
ExternalReference new_space_allocation_top =
ExternalReference::new_space_allocation_top_address();
- mov(scratch1, Operand(new_space_allocation_top));
+ ExternalReference new_space_allocation_limit =
+ ExternalReference::new_space_allocation_limit_address();
+ uint32_t top =
+ reinterpret_cast<uint32_t>(new_space_allocation_top.address());
+ uint32_t limit =
+ reinterpret_cast<uint32_t>(new_space_allocation_limit.address());
+ ASSERT((limit - top) == 4);
Erik Corry 2010/12/06 09:40:06 Prefer kPointerSize to 4 since it tells the reader
+ ASSERT(result.code() < ip.code());
+
+ // Set up allocation top address and object size registers.
+ Register topaddr = scratch1;
+ Register obj_size_reg = scratch2;
+ mov(topaddr, Operand(new_space_allocation_top));
+ mov(obj_size_reg, Operand(object_size));
+
+ // This code stores a temporary value in ip. This is OK, as the code below
+ // does not need ip for implicit literal generation.
if ((flags & RESULT_CONTAINS_TOP) == 0) {
- ldr(result, MemOperand(scratch1));
- } else if (FLAG_debug_code) {
- // Assert that result actually contains top on entry. scratch2 is used
- // immediately below so this use of scratch2 does not cause difference with
- // respect to register content between debug and release mode.
- ldr(scratch2, MemOperand(scratch1));
- cmp(result, scratch2);
- Check(eq, "Unexpected allocation top");
+ // Load allocation top into result and allocation limit into ip.
+ ldm(ia, topaddr, result.bit() | ip.bit());
+ } else {
+ if (FLAG_debug_code) {
+ // Assert that result actually contains top on entry. ip is used
+ // immediately below so this use of ip does not cause difference with
+ // respect to register content between debug and release mode.
+ ldr(ip, MemOperand(topaddr));
+ cmp(result, ip);
+ Check(eq, "Unexpected allocation top");
+ }
+ // Load allocation limit into ip. Result already contains allocation top.
+ ldr(ip, MemOperand(topaddr, limit - top));
}
// Calculate new top and bail out if new space is exhausted. Use result
// to calculate the new top.
- ExternalReference new_space_allocation_limit =
- ExternalReference::new_space_allocation_limit_address();
- mov(scratch2, Operand(new_space_allocation_limit));
- ldr(scratch2, MemOperand(scratch2));
- add(result, result, Operand(object_size));
- cmp(result, Operand(scratch2));
+ add(scratch2, result, Operand(obj_size_reg));
+ cmp(scratch2, Operand(ip));
b(hi, gc_required);
- str(result, MemOperand(scratch1));
+ str(scratch2, MemOperand(topaddr));
- // Tag and adjust back to start of new object.
+ // Tag object if requested.
if ((flags & TAG_OBJECT) != 0) {
- sub(result, result, Operand(object_size - kHeapObjectTag));
- } else {
- sub(result, result, Operand(object_size));
+ add(result, result, Operand(kHeapObjectTag));
}
}
@@ -982,53 +1000,64 @@
}
ASSERT(!result.is(scratch1));
+ ASSERT(!result.is(scratch2));
ASSERT(!scratch1.is(scratch2));
- // Load address of new object into result and allocation top address into
- // scratch1.
+ // Check relative positions of allocation top and limit addresses.
+ // The values must be adjacent in memory to allow the use of LDM.
+ // Also, assert that the registers are numbered such that the values
+ // are loaded in the correct order.
ExternalReference new_space_allocation_top =
ExternalReference::new_space_allocation_top_address();
- mov(scratch1, Operand(new_space_allocation_top));
+ ExternalReference new_space_allocation_limit =
+ ExternalReference::new_space_allocation_limit_address();
+ uint32_t top =
+ reinterpret_cast<uint32_t>(new_space_allocation_top.address());
+ uint32_t limit =
+ reinterpret_cast<uint32_t>(new_space_allocation_limit.address());
+ ASSERT((limit - top) == 4);
+ ASSERT(result.code() < ip.code());
+
+ // Set up allocation top address.
+ Register topaddr = scratch1;
+ mov(topaddr, Operand(new_space_allocation_top));
+
+ // This code stores a temporary value in ip. This is OK, as the code below
+ // does not need ip for implicit literal generation.
if ((flags & RESULT_CONTAINS_TOP) == 0) {
- ldr(result, MemOperand(scratch1));
- } else if (FLAG_debug_code) {
- // Assert that result actually contains top on entry. scratch2 is used
- // immediately below so this use of scratch2 does not cause difference with
- // respect to register content between debug and release mode.
- ldr(scratch2, MemOperand(scratch1));
- cmp(result, scratch2);
- Check(eq, "Unexpected allocation top");
+ // Load allocation top into result and allocation limit into ip.
+ ldm(ia, topaddr, result.bit() | ip.bit());
+ } else {
+ if (FLAG_debug_code) {
+ // Assert that result actually contains top on entry. ip is used
+ // immediately below so this use of ip does not cause difference with
+ // respect to register content between debug and release mode.
+ ldr(ip, MemOperand(topaddr));
+ cmp(result, ip);
+ Check(eq, "Unexpected allocation top");
+ }
+ // Load allocation limit into ip. Result already contains allocation top.
+ ldr(ip, MemOperand(topaddr, limit - top));
}
// Calculate new top and bail out if new space is exhausted. Use result
- // to calculate the new top. Object size is in words so a shift is required to
- // get the number of bytes
- ExternalReference new_space_allocation_limit =
- ExternalReference::new_space_allocation_limit_address();
- mov(scratch2, Operand(new_space_allocation_limit));
- ldr(scratch2, MemOperand(scratch2));
+ // to calculate the new top. Object size may be in words so a shift is
+ // required to get the number of bytes.
if ((flags & SIZE_IN_WORDS) != 0) {
- add(result, result, Operand(object_size, LSL, kPointerSizeLog2));
+ add(scratch2, result, Operand(object_size, LSL, kPointerSizeLog2));
} else {
- add(result, result, Operand(object_size));
+ add(scratch2, result, Operand(object_size));
}
- cmp(result, Operand(scratch2));
+ cmp(scratch2, Operand(ip));
b(hi, gc_required);
// Update allocation top. result temporarily holds the new top.
if (FLAG_debug_code) {
- tst(result, Operand(kObjectAlignmentMask));
+ tst(scratch2, Operand(kObjectAlignmentMask));
Check(eq, "Unaligned allocation in new space");
}
- str(result, MemOperand(scratch1));
+ str(scratch2, MemOperand(topaddr));
- // Adjust back to start of new object.
- if ((flags & SIZE_IN_WORDS) != 0) {
- sub(result, result, Operand(object_size, LSL, kPointerSizeLog2));
- } else {
- sub(result, result, Operand(object_size));
- }
-
// Tag object if requested.
if ((flags & TAG_OBJECT) != 0) {
add(result, result, Operand(kHeapObjectTag));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698