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

Unified Diff: runtime/vm/stub_code_arm64.cc

Issue 284013002: Improve performance of stubcode based array allocation moving stub to isolate specific area. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months 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
Index: runtime/vm/stub_code_arm64.cc
===================================================================
--- runtime/vm/stub_code_arm64.cc (revision 36194)
+++ runtime/vm/stub_code_arm64.cc (working copy)
@@ -612,111 +612,109 @@
// The newly allocated object is returned in R0.
void StubCode::GenerateAllocateArrayStub(Assembler* assembler) {
Label slow_case;
- if (FLAG_inline_alloc) {
- // Compute the size to be allocated, it is based on the array length
- // and is computed as:
- // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
- // Assert that length is a Smi.
- __ tsti(R2, kSmiTagMask);
- if (FLAG_use_slow_path) {
- __ b(&slow_case);
- } else {
- __ b(&slow_case, NE);
- }
- __ cmp(R2, Operand(0));
- __ b(&slow_case, LT);
- __ LoadFieldFromOffset(R8, CTX, Context::isolate_offset(), kNoPP);
- __ LoadFromOffset(R8, R8, Isolate::heap_offset(), kNoPP);
- __ LoadFromOffset(R8, R8, Heap::new_space_offset(), kNoPP);
+ // Compute the size to be allocated, it is based on the array length
+ // and is computed as:
+ // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
+ // Assert that length is a Smi.
+ __ tsti(R2, kSmiTagMask);
+ if (FLAG_use_slow_path) {
+ __ b(&slow_case);
+ } else {
+ __ b(&slow_case, NE);
+ }
+ __ cmp(R2, Operand(0));
+ __ b(&slow_case, LT);
+ __ LoadFieldFromOffset(R8, CTX, Context::isolate_offset(), kNoPP);
+ __ LoadFromOffset(R8, R8, Isolate::heap_offset(), kNoPP);
+ __ LoadFromOffset(R8, R8, Heap::new_space_offset(), kNoPP);
- // Calculate and align allocation size.
- // Load new object start and calculate next object start.
- // R1: array element type.
- // R2: array length as Smi.
- // R8: points to new space object.
- __ LoadFromOffset(R0, R8, Scavenger::top_offset(), kNoPP);
- intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
- __ LoadImmediate(R3, fixed_size, kNoPP);
- __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi.
- ASSERT(kSmiTagShift == 1);
- __ andi(R3, R3, ~(kObjectAlignment - 1));
- __ adds(R7, R3, Operand(R0));
- __ b(&slow_case, VS);
+ // Calculate and align allocation size.
+ // Load new object start and calculate next object start.
+ // R1: array element type.
+ // R2: array length as Smi.
+ // R8: points to new space object.
+ __ LoadFromOffset(R0, R8, Scavenger::top_offset(), kNoPP);
+ intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
+ __ LoadImmediate(R3, fixed_size, kNoPP);
+ __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi.
+ ASSERT(kSmiTagShift == 1);
+ __ andi(R3, R3, ~(kObjectAlignment - 1));
+ __ adds(R7, R3, Operand(R0));
+ __ b(&slow_case, VS);
- // Check if the allocation fits into the remaining space.
- // R0: potential new object start.
- // R1: array element type.
- // R2: array length as Smi.
- // R3: array size.
- // R7: potential next object start.
- // R8: points to new space object.
- __ LoadFromOffset(TMP, R8, Scavenger::end_offset(), kNoPP);
- __ CompareRegisters(R7, TMP);
- __ b(&slow_case, CS); // Branch if unsigned higher or equal.
+ // Check if the allocation fits into the remaining space.
+ // R0: potential new object start.
+ // R1: array element type.
+ // R2: array length as Smi.
+ // R3: array size.
+ // R7: potential next object start.
+ // R8: points to new space object.
+ __ LoadFromOffset(TMP, R8, Scavenger::end_offset(), kNoPP);
+ __ CompareRegisters(R7, TMP);
+ __ b(&slow_case, CS); // Branch if unsigned higher or equal.
- // Successfully allocated the object(s), now update top to point to
- // next object start and initialize the object.
- // R0: potential new object start.
- // R3: array size.
- // R7: potential next object start.
- // R8: Points to new space object.
- __ StoreToOffset(R7, R8, Scavenger::top_offset(), kNoPP);
- __ add(R0, R0, Operand(kHeapObjectTag));
- __ UpdateAllocationStatsWithSize(kArrayCid, R3, R8, kNoPP);
+ // Successfully allocated the object(s), now update top to point to
+ // next object start and initialize the object.
+ // R0: potential new object start.
+ // R3: array size.
+ // R7: potential next object start.
+ // R8: Points to new space object.
+ __ StoreToOffset(R7, R8, Scavenger::top_offset(), kNoPP);
+ __ add(R0, R0, Operand(kHeapObjectTag));
+ __ UpdateAllocationStatsWithSize(kArrayCid, R3, R8, kNoPP);
- // R0: new object start as a tagged pointer.
- // R1: array element type.
- // R2: array length as Smi.
- // R3: array size.
- // R7: new object end address.
+ // R0: new object start as a tagged pointer.
+ // R1: array element type.
+ // R2: array length as Smi.
+ // R3: array size.
+ // R7: new object end address.
- // Store the type argument field.
- __ StoreIntoObjectOffsetNoBarrier(
- R0, Array::type_arguments_offset(), R1, PP);
+ // Store the type argument field.
+ __ StoreIntoObjectOffsetNoBarrier(
+ R0, Array::type_arguments_offset(), R1, PP);
- // Set the length field.
- __ StoreIntoObjectOffsetNoBarrier(R0, Array::length_offset(), R2, PP);
+ // Set the length field.
+ __ StoreIntoObjectOffsetNoBarrier(R0, Array::length_offset(), R2, PP);
- // Calculate the size tag.
- // R0: new object start as a tagged pointer.
- // R2: array length as Smi.
- // R3: array size.
- // R7: new object end address.
- const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
- __ CompareImmediate(R3, RawObject::SizeTag::kMaxSizeTag, kNoPP);
- // If no size tag overflow, shift R1 left, else set R1 to zero.
- __ Lsl(TMP, R3, shift);
- __ csel(R1, TMP, R1, LS);
- __ csel(R1, ZR, R1, HI);
+ // Calculate the size tag.
+ // R0: new object start as a tagged pointer.
+ // R2: array length as Smi.
+ // R3: array size.
+ // R7: new object end address.
+ const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
+ __ CompareImmediate(R3, RawObject::SizeTag::kMaxSizeTag, kNoPP);
+ // If no size tag overflow, shift R1 left, else set R1 to zero.
+ __ Lsl(TMP, R3, shift);
+ __ csel(R1, TMP, R1, LS);
+ __ csel(R1, ZR, R1, HI);
- // Get the class index and insert it into the tags.
- __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(kArrayCid), kNoPP);
- __ orr(R1, R1, Operand(TMP));
- __ StoreFieldToOffset(R1, R0, Array::tags_offset(), kNoPP);
+ // Get the class index and insert it into the tags.
+ __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(kArrayCid), kNoPP);
+ __ orr(R1, R1, Operand(TMP));
+ __ StoreFieldToOffset(R1, R0, Array::tags_offset(), kNoPP);
- // Initialize all array elements to raw_null.
- // R0: new object start as a tagged pointer.
- // R7: new object end address.
- // R2: array length as Smi.
- __ AddImmediate(R1, R0, Array::data_offset() - kHeapObjectTag, kNoPP);
- // R1: iterator which initially points to the start of the variable
- // data area to be initialized.
- __ LoadObject(TMP, Object::null_object(), PP);
- Label loop, done;
- __ Bind(&loop);
- // TODO(cshapiro): StoreIntoObjectNoBarrier
- __ CompareRegisters(R1, R7);
- __ b(&done, CS);
- __ str(TMP, Address(R1)); // Store if unsigned lower.
- __ AddImmediate(R1, R1, kWordSize, kNoPP);
- __ b(&loop); // Loop until R1 == R7.
- __ Bind(&done);
+ // Initialize all array elements to raw_null.
+ // R0: new object start as a tagged pointer.
+ // R7: new object end address.
+ // R2: array length as Smi.
+ __ AddImmediate(R1, R0, Array::data_offset() - kHeapObjectTag, kNoPP);
+ // R1: iterator which initially points to the start of the variable
+ // data area to be initialized.
+ __ LoadObject(TMP, Object::null_object(), PP);
+ Label loop, done;
+ __ Bind(&loop);
+ // TODO(cshapiro): StoreIntoObjectNoBarrier
+ __ CompareRegisters(R1, R7);
+ __ b(&done, CS);
+ __ str(TMP, Address(R1)); // Store if unsigned lower.
+ __ AddImmediate(R1, R1, kWordSize, kNoPP);
+ __ b(&loop); // Loop until R1 == R7.
+ __ Bind(&done);
- // Done allocating and initializing the array.
- // R0: new object.
- // R2: array length as Smi (preserved for the caller.)
- __ ret();
- }
+ // Done allocating and initializing the array.
+ // R0: new object.
+ // R2: array length as Smi (preserved for the caller.)
+ __ ret();
// Unable to allocate the array using the fast inline code, just call
// into the runtime.

Powered by Google App Engine
This is Rietveld 408576698