Index: src/arm/macro-assembler-arm.cc |
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc |
index b39404e7f91a560ee896097853523a4523b95fc1..b34a1015480306821fe40f7ed84074723d5e2716 100644 |
--- a/src/arm/macro-assembler-arm.cc |
+++ b/src/arm/macro-assembler-arm.cc |
@@ -196,7 +196,7 @@ void MacroAssembler::SmiJumpTable(Register index, Vector<Label*> targets) { |
void MacroAssembler::LoadRoot(Register destination, |
Heap::RootListIndex index, |
Condition cond) { |
- ldr(destination, MemOperand(r10, index << kPointerSizeLog2), cond); |
+ ldr(destination, MemOperand(roots, index << kPointerSizeLog2), cond); |
} |
@@ -940,6 +940,75 @@ void MacroAssembler::UndoAllocationInNewSpace(Register object, |
} |
+void MacroAssembler::AllocateTwoByteString(Register result, |
+ Register length, |
+ Register scratch1, |
+ Register scratch2, |
+ Register scratch3, |
+ Label* gc_required) { |
+ // Calculate the number of bytes needed for the characters in the string while |
+ // observing object alignment. |
+ ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
+ mov(scratch1, Operand(length, LSL, 1)); // Length in bytes, not chars. |
+ add(scratch1, scratch1, |
+ Operand(kObjectAlignmentMask + SeqTwoByteString::kHeaderSize)); |
+ // AllocateInNewSpace expects the size in words, so we can round down |
+ // to kObjectAlignment and divide by kPointerSize in the same shift. |
+ ASSERT_EQ(kPointerSize, kObjectAlignmentMask + 1); |
+ mov(scratch1, Operand(scratch1, ASR, kPointerSizeLog2)); |
+ |
+ // Allocate two-byte string in new space. |
+ AllocateInNewSpace(scratch1, |
+ result, |
+ scratch2, |
+ scratch3, |
+ gc_required, |
+ TAG_OBJECT); |
+ |
+ // Set the map, length and hash field. |
+ LoadRoot(scratch1, Heap::kStringMapRootIndex); |
+ str(length, FieldMemOperand(result, String::kLengthOffset)); |
+ str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset)); |
+ mov(scratch2, Operand(String::kEmptyHashField)); |
+ str(scratch2, FieldMemOperand(result, String::kHashFieldOffset)); |
+} |
+ |
+ |
+void MacroAssembler::AllocateAsciiString(Register result, |
+ Register length, |
+ Register scratch1, |
+ Register scratch2, |
+ Register scratch3, |
+ Label* gc_required) { |
+ // Calculate the number of bytes needed for the characters in the string while |
+ // observing object alignment. |
+ ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0); |
+ ASSERT(kCharSize == 1); |
+ add(scratch1, length, |
+ Operand(kObjectAlignmentMask + SeqAsciiString::kHeaderSize)); |
+ // AllocateInNewSpace expects the size in words, so we can round down |
+ // to kObjectAlignment and divide by kPointerSize in the same shift. |
+ ASSERT_EQ(kPointerSize, kObjectAlignmentMask + 1); |
+ mov(scratch1, Operand(scratch1, ASR, kPointerSizeLog2)); |
+ |
+ // Allocate ASCII string in new space. |
+ AllocateInNewSpace(scratch1, |
+ result, |
+ scratch2, |
+ scratch3, |
+ gc_required, |
+ TAG_OBJECT); |
+ |
+ // Set the map, length and hash field. |
+ LoadRoot(scratch1, Heap::kAsciiStringMapRootIndex); |
+ mov(scratch1, Operand(Factory::ascii_string_map())); |
+ str(length, FieldMemOperand(result, String::kLengthOffset)); |
+ str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset)); |
+ mov(scratch2, Operand(String::kEmptyHashField)); |
+ str(scratch2, FieldMemOperand(result, String::kHashFieldOffset)); |
+} |
+ |
+ |
void MacroAssembler::CompareObjectType(Register function, |
Register map, |
Register type_reg, |