| Index: runtime/vm/stub_code_arm.cc
|
| ===================================================================
|
| --- runtime/vm/stub_code_arm.cc (revision 40840)
|
| +++ runtime/vm/stub_code_arm.cc (working copy)
|
| @@ -697,26 +697,27 @@
|
|
|
| // Successfully allocated the object(s), now update top to point to
|
| // next object start and initialize the object.
|
| + __ LoadAllocationStatsAddress(R3, cid, space);
|
| __ str(R7, Address(R6, 0));
|
| __ add(R0, R0, Operand(kHeapObjectTag));
|
| - __ UpdateAllocationStatsWithSize(cid, R8, R4, space);
|
|
|
| // Initialize the tags.
|
| // R0: new object start as a tagged pointer.
|
| + // R3: allocation stats address.
|
| // R7: new object end address.
|
| // R8: allocation size.
|
| {
|
| const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
|
|
|
| __ CompareImmediate(R8, RawObject::SizeTag::kMaxSizeTag);
|
| - __ mov(R8, Operand(R8, LSL, shift), LS);
|
| - __ mov(R8, Operand(0), HI);
|
| + __ mov(R6, Operand(R8, LSL, shift), LS);
|
| + __ mov(R6, Operand(0), HI);
|
|
|
| // Get the class index and insert it into the tags.
|
| - // R8: size and bit tags.
|
| + // R6: size and bit tags.
|
| __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cid));
|
| - __ orr(R8, R8, Operand(TMP));
|
| - __ str(R8, FieldAddress(R0, Array::tags_offset())); // Store tags.
|
| + __ orr(R6, R6, Operand(TMP));
|
| + __ str(R6, FieldAddress(R0, Array::tags_offset())); // Store tags.
|
| }
|
|
|
| // R0: new object start as a tagged pointer.
|
| @@ -733,20 +734,24 @@
|
|
|
| // Initialize all array elements to raw_null.
|
| // R0: new object start as a tagged pointer.
|
| + // R3: allocation stats address.
|
| // R7: new object end address.
|
| // R8: iterator which initially points to the start of the variable
|
| // data area to be initialized.
|
| - // R3: null
|
| - __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null()));
|
| + // R4, R5: null
|
| + __ LoadImmediate(R4, reinterpret_cast<intptr_t>(Object::null()));
|
| + __ mov(R5, Operand(R4));
|
| __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag);
|
|
|
| Label init_loop;
|
| __ Bind(&init_loop);
|
| + __ AddImmediate(R8, 2 * kWordSize);
|
| __ cmp(R8, Operand(R7));
|
| - __ str(R3, Address(R8, 0), CC);
|
| - __ AddImmediate(R8, kWordSize, CC);
|
| + __ strd(R4, Address(R8, -2 * kWordSize), LS);
|
| __ b(&init_loop, CC);
|
| + __ str(R4, Address(R8, -2 * kWordSize), HI);
|
|
|
| + __ IncrementAllocationStatsWithSize(R3, R8, cid, space);
|
| __ Ret(); // Returns the newly allocated object in R0.
|
| // Unable to allocate the array using the fast inline code, just call
|
| // into the runtime.
|
| @@ -938,6 +943,7 @@
|
| // R1: number of context variables.
|
| // R2: object size.
|
| // R3: potential next object start.
|
| + // R5: top address.
|
| __ LoadImmediate(IP, heap->EndAddress(space));
|
| __ ldr(IP, Address(IP, 0));
|
| __ cmp(R3, Operand(IP));
|
| @@ -953,56 +959,68 @@
|
| // R1: number of context variables.
|
| // R2: object size.
|
| // R3: next object start.
|
| + // R5: top address.
|
| + __ LoadAllocationStatsAddress(R4, cid, space);
|
| __ str(R3, Address(R5, 0));
|
| __ add(R0, R0, Operand(kHeapObjectTag));
|
| - __ UpdateAllocationStatsWithSize(cid, R2, R5, space);
|
|
|
| // Calculate the size tag.
|
| // R0: new object.
|
| // R1: number of context variables.
|
| // R2: object size.
|
| + // R4: allocation stats address.
|
| const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
|
| __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag);
|
| // If no size tag overflow, shift R2 left, else set R2 to zero.
|
| - __ mov(R2, Operand(R2, LSL, shift), LS);
|
| - __ mov(R2, Operand(0), HI);
|
| + __ mov(R3, Operand(R2, LSL, shift), LS);
|
| + __ mov(R3, Operand(0), HI);
|
|
|
| // Get the class index and insert it into the tags.
|
| - // R2: size and bit tags.
|
| + // R3: size and bit tags.
|
| __ LoadImmediate(IP, RawObject::ClassIdTag::encode(cid));
|
| - __ orr(R2, R2, Operand(IP));
|
| - __ str(R2, FieldAddress(R0, Context::tags_offset()));
|
| + __ orr(R3, R3, Operand(IP));
|
| + __ str(R3, FieldAddress(R0, Context::tags_offset()));
|
|
|
| // Setup up number of context variables field.
|
| // R0: new object.
|
| // R1: number of context variables as integer value (not object).
|
| + // R2: object size.
|
| + // R4: allocation stats address.
|
| __ str(R1, FieldAddress(R0, Context::num_variables_offset()));
|
|
|
| // Setup isolate field.
|
| - // Load Isolate pointer into R2.
|
| + // Load Isolate pointer into R3.
|
| // R0: new object.
|
| // R1: number of context variables.
|
| - __ LoadIsolate(R2);
|
| - // R2: isolate, not an object.
|
| - __ str(R2, FieldAddress(R0, Context::isolate_offset()));
|
| + // R2: object size.
|
| + // R4: allocation stats address.
|
| + __ LoadIsolate(R3);
|
| + // R3: isolate, not an object.
|
| + __ str(R3, FieldAddress(R0, Context::isolate_offset()));
|
|
|
| // Setup the parent field.
|
| // R0: new object.
|
| // R1: number of context variables.
|
| - __ LoadImmediate(R2, reinterpret_cast<intptr_t>(Object::null()));
|
| - __ str(R2, FieldAddress(R0, Context::parent_offset()));
|
| + // R2: object size.
|
| + // R4: allocation stats address.
|
| + __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null()));
|
| + __ str(R3, FieldAddress(R0, Context::parent_offset()));
|
|
|
| // Initialize the context variables.
|
| // R0: new object.
|
| // R1: number of context variables.
|
| - // R2: raw null.
|
| + // R2: object size.
|
| + // R3: raw null.
|
| + // R4: allocation stats address.
|
| Label loop;
|
| - __ AddImmediate(R3, R0, Context::variable_offset(0) - kHeapObjectTag);
|
| + __ AddImmediate(R5, R0, Context::variable_offset(0) - kHeapObjectTag);
|
| __ Bind(&loop);
|
| __ subs(R1, R1, Operand(1));
|
| - __ str(R2, Address(R3, R1, LSL, 2), PL); // Store if R1 positive or zero.
|
| + __ str(R3, Address(R5, R1, LSL, 2), PL); // Store if R1 positive or zero.
|
| __ b(&loop, NE); // Loop if R1 not zero.
|
|
|
| + __ IncrementAllocationStatsWithSize(R4, R2, cid, space);
|
| +
|
| // Done allocating and initializing the context.
|
| // R0: new object.
|
| __ Ret();
|
| @@ -1108,15 +1126,10 @@
|
| const int kInlineInstanceSize = 12;
|
| const intptr_t instance_size = cls.instance_size();
|
| ASSERT(instance_size > 0);
|
| - if (is_cls_parameterized) {
|
| - __ ldr(R1, Address(SP, 0));
|
| - // R1: instantiated type arguments.
|
| - }
|
| if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) {
|
| Label slow_case;
|
| // Allocate the object and update top to point to
|
| // next object start and initialize the allocated object.
|
| - // R1: instantiated type arguments (if is_cls_parameterized).
|
| Heap* heap = Isolate::Current()->heap();
|
| Heap::Space space = heap->SpaceForAllocation(cls.id());
|
| __ LoadImmediate(R5, heap->TopAddress(space));
|
| @@ -1134,11 +1147,14 @@
|
| __ b(&slow_case, CS); // Unsigned higher or equal.
|
| }
|
| __ str(R3, Address(R5, 0));
|
| - __ UpdateAllocationStats(cls.id(), R5, space);
|
|
|
| + // Load the address of the allocation stats table. We split up the load
|
| + // and the increment so that the dependent load is not too nearby.
|
| + __ LoadAllocationStatsAddress(R5, cls.id(), space);
|
| +
|
| // R2: new object start.
|
| // R3: next object start.
|
| - // R1: new object type arguments (if is_cls_parameterized).
|
| + // R5: allocation stats table.
|
| // Set the tags.
|
| uword tags = 0;
|
| tags = RawObject::SizeTag::update(instance_size, tags);
|
| @@ -1153,49 +1169,69 @@
|
| // R0: raw null.
|
| // R2: new object start.
|
| // R3: next object start.
|
| - // R1: new object type arguments (if is_cls_parameterized).
|
| + // R5: allocation stats table.
|
| // First try inlining the initialization without a loop.
|
| if (instance_size < (kInlineInstanceSize * kWordSize)) {
|
| // Check if the object contains any non-header fields.
|
| // Small objects are initialized using a consecutive set of writes.
|
| - for (intptr_t current_offset = Instance::NextFieldOffset();
|
| - current_offset < instance_size;
|
| - current_offset += kWordSize) {
|
| + intptr_t current_offset = Instance::NextFieldOffset();
|
| + // Write two nulls at a time.
|
| + if (instance_size >= 2 * kWordSize) {
|
| + __ mov(R1, Operand(R0));
|
| + while (current_offset + kWordSize < instance_size) {
|
| + __ StoreToOffset(kWordPair, R0, R2, current_offset);
|
| + current_offset += 2 * kWordSize;
|
| + }
|
| + }
|
| + // Write remainder.
|
| + while (current_offset < instance_size) {
|
| __ StoreToOffset(kWord, R0, R2, current_offset);
|
| + current_offset += kWordSize;
|
| }
|
| } else {
|
| + // There are more than kInlineInstanceSize(12) fields
|
| __ add(R4, R2, Operand(Instance::NextFieldOffset()));
|
| + __ mov(R1, Operand(R0));
|
| // Loop until the whole object is initialized.
|
| // R0: raw null.
|
| + // R1: raw null.
|
| // R2: new object.
|
| // R3: next object start.
|
| // R4: next word to be initialized.
|
| - // R1: new object type arguments (if is_cls_parameterized).
|
| + // R5: allocation stats table.
|
| Label init_loop;
|
| - Label done;
|
| __ Bind(&init_loop);
|
| + __ AddImmediate(R4, 2 * kWordSize);
|
| __ cmp(R4, Operand(R3));
|
| - __ b(&done, CS);
|
| - __ str(R0, Address(R4, 0));
|
| - __ AddImmediate(R4, kWordSize);
|
| - __ b(&init_loop);
|
| - __ Bind(&done);
|
| + __ strd(R0, Address(R4, -2 * kWordSize), LS);
|
| + __ b(&init_loop, CC);
|
| + __ str(R0, Address(R4, -2 * kWordSize), HI);
|
| }
|
| if (is_cls_parameterized) {
|
| - // R1: new object type arguments.
|
| // Set the type arguments in the new object.
|
| - __ StoreToOffset(kWord, R1, R2, cls.type_arguments_field_offset());
|
| + __ ldr(R4, Address(SP, 0));
|
| + __ StoreToOffset(kWord, R4, R2, cls.type_arguments_field_offset());
|
| }
|
| +
|
| // Done allocating and initializing the instance.
|
| // R2: new object still missing its heap tag.
|
| + // R5: allocation stats table.
|
| __ add(R0, R2, Operand(kHeapObjectTag));
|
| +
|
| + // Update allocation stats.
|
| + __ IncrementAllocationStats(R5, cls.id(), space);
|
| +
|
| // R0: new object.
|
| __ Ret();
|
|
|
| __ Bind(&slow_case);
|
| }
|
| + if (is_cls_parameterized) {
|
| + // Load the type arguments.
|
| + __ ldr(R4, Address(SP, 0));
|
| + }
|
| // If is_cls_parameterized:
|
| - // R1: new object type arguments.
|
| + // R4: new object type arguments.
|
| // Create a stub frame as we are pushing some objects on the stack before
|
| // calling into the runtime.
|
| __ EnterStubFrame(true); // Uses pool pointer to pass cls to runtime.
|
| @@ -1204,7 +1240,7 @@
|
| __ PushObject(cls); // Push class of object to be allocated.
|
| if (is_cls_parameterized) {
|
| // Push type arguments.
|
| - __ Push(R1);
|
| + __ Push(R4);
|
| } else {
|
| // Push null type arguments.
|
| __ Push(R2);
|
|
|