| Index: runtime/vm/intrinsifier_arm.cc
|
| ===================================================================
|
| --- runtime/vm/intrinsifier_arm.cc (revision 39452)
|
| +++ runtime/vm/intrinsifier_arm.cc (working copy)
|
| @@ -22,6 +22,116 @@
|
| #define __ assembler->
|
|
|
|
|
| +void Intrinsifier::ObjectArrayAllocate(Assembler* assembler) {
|
| + Label fall_through;
|
| + const intptr_t kTypeArgumentsOffset = 1 * kWordSize;
|
| + const intptr_t kLengthOffset = 0 * kWordSize;
|
| +
|
| + __ ldr(R1, Address(SP, kTypeArgumentsOffset));
|
| + __ ldr(R2, Address(SP, kLengthOffset));
|
| +
|
| + // Compute the size to be allocated, it is based on the array length
|
| + // and is computed as:
|
| + // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
|
| + __ MoveRegister(R3, R2); // Array length.
|
| +
|
| + // Check that length is a positive Smi.
|
| + __ tst(R3, Operand(kSmiTagMask));
|
| + __ b(&fall_through, NE);
|
| + __ cmp(R3, Operand(0));
|
| + __ b(&fall_through, LT);
|
| +
|
| + // Check for maximum allowed length.
|
| + const intptr_t max_len =
|
| + reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements));
|
| + __ CompareImmediate(R3, max_len);
|
| + __ b(&fall_through, GT);
|
| +
|
| + const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
|
| + __ LoadImmediate(R8, fixed_size);
|
| + __ add(R8, R8, Operand(R3, LSL, 1)); // R3 is a Smi.
|
| + ASSERT(kSmiTagShift == 1);
|
| + __ bic(R8, R8, Operand(kObjectAlignment - 1));
|
| +
|
| + // R8: Allocation size.
|
| +
|
| + Isolate* isolate = Isolate::Current();
|
| + Heap* heap = isolate->heap();
|
| +
|
| + __ LoadImmediate(R6, heap->TopAddress());
|
| + __ ldr(R0, Address(R6, 0)); // Potential new object start.
|
| + __ adds(R7, R0, Operand(R8)); // Potential next object start.
|
| + __ b(&fall_through, VS);
|
| +
|
| + // Check if the allocation fits into the remaining space.
|
| + // R0: potential new object start.
|
| + // R7: potential next object start.
|
| + // R8: allocation size.
|
| + __ LoadImmediate(R3, heap->EndAddress());
|
| + __ ldr(R3, Address(R3, 0));
|
| + __ cmp(R7, Operand(R3));
|
| + __ b(&fall_through, CS);
|
| +
|
| + // Successfully allocated the object(s), now update top to point to
|
| + // next object start and initialize the object.
|
| + __ str(R7, Address(R6, 0));
|
| + __ add(R0, R0, Operand(kHeapObjectTag));
|
| + __ UpdateAllocationStatsWithSize(kArrayCid, R8, R4);
|
| +
|
| + // Initialize the tags.
|
| + // R0: new object start as a tagged pointer.
|
| + // R7: new object end address.
|
| + // R8: allocation size.
|
| + {
|
| + const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
|
| + const Class& cls = Class::Handle(isolate->object_store()->array_class());
|
| +
|
| + __ CompareImmediate(R8, RawObject::SizeTag::kMaxSizeTag);
|
| + __ mov(R8, Operand(R8, LSL, shift), LS);
|
| + __ mov(R8, Operand(0), HI);
|
| +
|
| + // Get the class index and insert it into the tags.
|
| + // R8: size and bit tags.
|
| + __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cls.id()));
|
| + __ orr(R8, R8, Operand(TMP));
|
| + __ str(R8, FieldAddress(R0, Array::tags_offset())); // Store tags.
|
| + }
|
| +
|
| + // R0: new object start as a tagged pointer.
|
| + // R7: new object end address.
|
| + // Store the type argument field.
|
| + __ StoreIntoObjectNoBarrier(R0,
|
| + FieldAddress(R0, Array::type_arguments_offset()),
|
| + R1);
|
| +
|
| + // Set the length field.
|
| + __ StoreIntoObjectNoBarrier(R0,
|
| + FieldAddress(R0, Array::length_offset()),
|
| + R2);
|
| +
|
| + // Initialize all array elements to raw_null.
|
| + // R0: new object start as a tagged pointer.
|
| + // 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()));
|
| + __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag);
|
| +
|
| + Label init_loop;
|
| + __ Bind(&init_loop);
|
| + __ cmp(R8, Operand(R7));
|
| + __ str(R3, Address(R8, 0), CC);
|
| + __ AddImmediate(R8, kWordSize, CC);
|
| + __ b(&init_loop, CC);
|
| +
|
| + __ Ret(); // Returns the newly allocated object in R0.
|
| + // Unable to allocate the array using the fast inline code, just call
|
| + // into the runtime.
|
| + __ Bind(&fall_through);
|
| +}
|
| +
|
| +
|
| void Intrinsifier::ObjectArrayLength(Assembler* assembler) {
|
| __ ldr(R0, Address(SP, 0 * kWordSize));
|
| __ ldr(R0, FieldAddress(R0, Array::length_offset()));
|
| @@ -1411,6 +1521,49 @@
|
| }
|
|
|
|
|
| +void Intrinsifier::StringBase_charAt(Assembler* assembler) {
|
| + Label fall_through, try_two_byte_string;
|
| +
|
| + __ ldr(R1, Address(SP, 0 * kWordSize)); // Index.
|
| + __ ldr(R0, Address(SP, 1 * kWordSize)); // String.
|
| + __ tst(R1, Operand(kSmiTagMask));
|
| + __ b(&fall_through, NE); // Index is not a Smi.
|
| + // Range check.
|
| + __ ldr(R2, FieldAddress(R0, String::length_offset()));
|
| + __ cmp(R1, Operand(R2));
|
| + __ b(&fall_through, CS); // Runtime throws exception.
|
| +
|
| + __ CompareClassId(R0, kOneByteStringCid, R3);
|
| + __ b(&try_two_byte_string, NE);
|
| + __ SmiUntag(R1);
|
| + __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag);
|
| + __ ldrb(R1, Address(R0, R1));
|
| + __ CompareImmediate(R1, Symbols::kNumberOfOneCharCodeSymbols);
|
| + __ b(&fall_through, GE);
|
| + __ LoadImmediate(R0,
|
| + reinterpret_cast<uword>(Symbols::PredefinedAddress()));
|
| + __ AddImmediate(R0, Symbols::kNullCharCodeSymbolOffset * kWordSize);
|
| + __ ldr(R0, Address(R0, R1, LSL, 2));
|
| + __ Ret();
|
| +
|
| + __ Bind(&try_two_byte_string);
|
| + __ CompareClassId(R0, kTwoByteStringCid, R3);
|
| + __ b(&fall_through, NE);
|
| + ASSERT(kSmiTagShift == 1);
|
| + __ AddImmediate(R0, TwoByteString::data_offset() - kHeapObjectTag);
|
| + __ ldrh(R1, Address(R0, R1));
|
| + __ CompareImmediate(R1, Symbols::kNumberOfOneCharCodeSymbols);
|
| + __ b(&fall_through, GE);
|
| + __ LoadImmediate(R0,
|
| + reinterpret_cast<uword>(Symbols::PredefinedAddress()));
|
| + __ AddImmediate(R0, Symbols::kNullCharCodeSymbolOffset * kWordSize);
|
| + __ ldr(R0, Address(R0, R1, LSL, 2));
|
| + __ Ret();
|
| +
|
| + __ Bind(&fall_through);
|
| +}
|
| +
|
| +
|
| void Intrinsifier::StringBaseIsEmpty(Assembler* assembler) {
|
| __ ldr(R0, Address(SP, 0 * kWordSize));
|
| __ ldr(R0, FieldAddress(R0, String::length_offset()));
|
|
|