| Index: runtime/vm/intermediate_language_mips.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_mips.cc (revision 38897)
|
| +++ runtime/vm/intermediate_language_mips.cc (working copy)
|
| @@ -1994,42 +1994,14 @@
|
| Label* done) {
|
| const Register kLengthReg = A1;
|
| const Register kElemTypeReg = A0;
|
| - const intptr_t kArraySize = Array::InstanceSize(num_elements);
|
| + const intptr_t instance_size = Array::InstanceSize(num_elements);
|
|
|
| - Isolate* isolate = Isolate::Current();
|
| - Heap* heap = isolate->heap();
|
| -
|
| - __ LoadImmediate(T3, heap->TopAddress());
|
| - __ lw(V0, Address(T3, 0)); // Potential new object start.
|
| - // Potential next object start.
|
| - __ AddImmediateDetectOverflow(T1, V0, kArraySize, CMPRES1);
|
| - __ bltz(CMPRES1, slow_path); // CMPRES1 < 0 on overflow.
|
| -
|
| - // Check if the allocation fits into the remaining space.
|
| - // V0: potential new object start.
|
| - // T1: potential next object start.
|
| - __ LoadImmediate(T4, heap->EndAddress());
|
| - __ lw(T4, Address(T4, 0));
|
| - __ BranchUnsignedGreaterEqual(T1, T4, slow_path);
|
| -
|
| -
|
| - // Successfully allocated the object(s), now update top to point to
|
| - // next object start and initialize the object.
|
| - __ sw(T1, Address(T3, 0));
|
| - __ addiu(V0, V0, Immediate(kHeapObjectTag));
|
| - __ LoadImmediate(T2, kArraySize);
|
| - __ UpdateAllocationStatsWithSize(kArrayCid, T2, T4);
|
| -
|
| - // Initialize the tags.
|
| + __ TryAllocateArray(kArrayCid, instance_size, slow_path,
|
| + V0, // instance
|
| + T1, // end address
|
| + T2,
|
| + T3);
|
| // V0: new object start as a tagged pointer.
|
| - {
|
| - uword tags = 0;
|
| - tags = RawObject::ClassIdTag::update(kArrayCid, tags);
|
| - tags = RawObject::SizeTag::update(kArraySize, tags);
|
| - __ LoadImmediate(T2, tags);
|
| - __ sw(T2, FieldAddress(V0, Array::tags_offset())); // Store tags.
|
| - }
|
| - // V0: new object start as a tagged pointer.
|
| // T1: new object end address.
|
|
|
| // Store the type argument field.
|
| @@ -2308,6 +2280,83 @@
|
| }
|
|
|
|
|
| +LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary(
|
| + Isolate* isolate,
|
| + bool opt) const {
|
| + ASSERT(opt);
|
| + const intptr_t kNumInputs = 0;
|
| + const intptr_t kNumTemps = 3;
|
| + LocationSummary* locs = new(isolate) LocationSummary(
|
| + isolate, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
|
| + locs->set_temp(0, Location::RegisterLocation(T1));
|
| + locs->set_temp(1, Location::RegisterLocation(T2));
|
| + locs->set_temp(2, Location::RegisterLocation(T3));
|
| + locs->set_out(0, Location::RegisterLocation(V0));
|
| + return locs;
|
| +}
|
| +
|
| +
|
| +class AllocateContextSlowPath : public SlowPathCode {
|
| + public:
|
| + explicit AllocateContextSlowPath(
|
| + AllocateUninitializedContextInstr* instruction)
|
| + : instruction_(instruction) { }
|
| +
|
| + virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
|
| + __ Comment("AllocateContextSlowPath");
|
| + __ Bind(entry_label());
|
| +
|
| + LocationSummary* locs = instruction_->locs();
|
| + locs->live_registers()->Remove(locs->out(0));
|
| +
|
| + compiler->SaveLiveRegisters(locs);
|
| +
|
| + __ LoadImmediate(T1, instruction_->num_context_variables());
|
| + StubCode* stub_code = compiler->isolate()->stub_code();
|
| + const ExternalLabel label(stub_code->AllocateContextEntryPoint());
|
| + compiler->GenerateCall(instruction_->token_pos(),
|
| + &label,
|
| + RawPcDescriptors::kOther,
|
| + locs);
|
| + ASSERT(instruction_->locs()->out(0).reg() == R0);
|
| + compiler->RestoreLiveRegisters(instruction_->locs());
|
| + __ b(exit_label());
|
| + }
|
| +
|
| + private:
|
| + AllocateUninitializedContextInstr* instruction_;
|
| +};
|
| +
|
| +
|
| +void AllocateUninitializedContextInstr::EmitNativeCode(
|
| + FlowGraphCompiler* compiler) {
|
| + Register temp0 = locs()->temp(0).reg();
|
| + Register temp1 = locs()->temp(1).reg();
|
| + Register temp2 = locs()->temp(2).reg();
|
| + Register result = locs()->out(0).reg();
|
| + // Try allocate the object.
|
| + AllocateContextSlowPath* slow_path = new AllocateContextSlowPath(this);
|
| + compiler->AddSlowPathCode(slow_path);
|
| + intptr_t instance_size = Context::InstanceSize(num_context_variables());
|
| +
|
| + __ TryAllocateArray(kContextCid, instance_size, slow_path->entry_label(),
|
| + result, // instance
|
| + temp0,
|
| + temp1,
|
| + temp2);
|
| +
|
| + // Setup up number of context variables field.
|
| + __ LoadImmediate(temp0, num_context_variables());
|
| + __ sw(temp0, FieldAddress(result, Context::num_variables_offset()));
|
| +
|
| + // Setup isolate field.
|
| + __ lw(temp0, FieldAddress(CTX, Context::isolate_offset()));
|
| + __ sw(temp0, FieldAddress(result, Context::isolate_offset()));
|
| +
|
| + __ Bind(slow_path->exit_label());
|
| +}
|
| +
|
| +
|
| LocationSummary* AllocateContextInstr::MakeLocationSummary(Isolate* isolate,
|
| bool opt) const {
|
| const intptr_t kNumInputs = 0;
|
| @@ -2321,12 +2370,11 @@
|
|
|
|
|
| void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| - Register temp = T1;
|
| - ASSERT(locs()->temp(0).reg() == temp);
|
| + ASSERT(locs()->temp(0).reg() == T1);
|
| ASSERT(locs()->out(0).reg() == V0);
|
|
|
| __ TraceSimMsg("AllocateContextInstr");
|
| - __ LoadImmediate(temp, num_context_variables());
|
| + __ LoadImmediate(T1, num_context_variables());
|
| StubCode* stub_code = compiler->isolate()->stub_code();
|
| const ExternalLabel label(stub_code->AllocateContextEntryPoint());
|
| compiler->GenerateCall(token_pos(),
|
|
|