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

Side by Side Diff: runtime/vm/intermediate_language_mips.cc

Issue 346823003: VM: Optimized context allocation on all platforms. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 } 1987 }
1988 1988
1989 1989
1990 // Inlines array allocation for known constant values. 1990 // Inlines array allocation for known constant values.
1991 static void InlineArrayAllocation(FlowGraphCompiler* compiler, 1991 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
1992 intptr_t num_elements, 1992 intptr_t num_elements,
1993 Label* slow_path, 1993 Label* slow_path,
1994 Label* done) { 1994 Label* done) {
1995 const Register kLengthReg = A1; 1995 const Register kLengthReg = A1;
1996 const Register kElemTypeReg = A0; 1996 const Register kElemTypeReg = A0;
1997 const intptr_t kArraySize = Array::InstanceSize(num_elements); 1997 const intptr_t instance_size = Array::InstanceSize(num_elements);
1998 1998
1999 Isolate* isolate = Isolate::Current(); 1999 __ TryAllocateArray(kArrayCid, instance_size, slow_path,
2000 Heap* heap = isolate->heap(); 2000 V0, // instance
2001 2001 T1, // end address
2002 __ LoadImmediate(T3, heap->TopAddress()); 2002 T2,
2003 __ lw(V0, Address(T3, 0)); // Potential new object start. 2003 T3);
2004 // Potential next object start.
2005 __ AddImmediateDetectOverflow(T1, V0, kArraySize, CMPRES1);
2006 __ bltz(CMPRES1, slow_path); // CMPRES1 < 0 on overflow.
2007
2008 // Check if the allocation fits into the remaining space.
2009 // V0: potential new object start.
2010 // T1: potential next object start.
2011 __ LoadImmediate(T4, heap->EndAddress());
2012 __ lw(T4, Address(T4, 0));
2013 __ BranchUnsignedGreaterEqual(T1, T4, slow_path);
2014
2015
2016 // Successfully allocated the object(s), now update top to point to
2017 // next object start and initialize the object.
2018 __ sw(T1, Address(T3, 0));
2019 __ addiu(V0, V0, Immediate(kHeapObjectTag));
2020 __ LoadImmediate(T2, kArraySize);
2021 __ UpdateAllocationStatsWithSize(kArrayCid, T2, T4);
2022
2023 // Initialize the tags.
2024 // V0: new object start as a tagged pointer.
2025 {
2026 uword tags = 0;
2027 tags = RawObject::ClassIdTag::update(kArrayCid, tags);
2028 tags = RawObject::SizeTag::update(kArraySize, tags);
2029 __ LoadImmediate(T2, tags);
2030 __ sw(T2, FieldAddress(V0, Array::tags_offset())); // Store tags.
2031 }
2032 // V0: new object start as a tagged pointer. 2004 // V0: new object start as a tagged pointer.
2033 // T1: new object end address. 2005 // T1: new object end address.
2034 2006
2035 // Store the type argument field. 2007 // Store the type argument field.
2036 __ StoreIntoObjectNoBarrier(V0, 2008 __ StoreIntoObjectNoBarrier(V0,
2037 FieldAddress(V0, Array::type_arguments_offset()), 2009 FieldAddress(V0, Array::type_arguments_offset()),
2038 kElemTypeReg); 2010 kElemTypeReg);
2039 2011
2040 // Set the length field. 2012 // Set the length field.
2041 __ StoreIntoObjectNoBarrier(V0, 2013 __ StoreIntoObjectNoBarrier(V0,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 2, 2273 2,
2302 locs()); 2274 locs());
2303 // Pop instantiated type arguments. 2275 // Pop instantiated type arguments.
2304 __ lw(result_reg, Address(SP, 2 * kWordSize)); 2276 __ lw(result_reg, Address(SP, 2 * kWordSize));
2305 // Drop instantiator and uninstantiated type arguments. 2277 // Drop instantiator and uninstantiated type arguments.
2306 __ addiu(SP, SP, Immediate(3 * kWordSize)); 2278 __ addiu(SP, SP, Immediate(3 * kWordSize));
2307 __ Bind(&type_arguments_instantiated); 2279 __ Bind(&type_arguments_instantiated);
2308 } 2280 }
2309 2281
2310 2282
2283 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary(
2284 Isolate* isolate,
2285 bool opt) const {
2286 ASSERT(opt);
2287 const intptr_t kNumInputs = 0;
2288 const intptr_t kNumTemps = 3;
2289 LocationSummary* locs = new(isolate) LocationSummary(
2290 isolate, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
2291 locs->set_temp(0, Location::RegisterLocation(T1));
2292 locs->set_temp(1, Location::RegisterLocation(T2));
2293 locs->set_temp(2, Location::RegisterLocation(T3));
2294 locs->set_out(0, Location::RegisterLocation(V0));
2295 return locs;
2296 }
2297
2298
2299 class AllocateContextSlowPath : public SlowPathCode {
2300 public:
2301 explicit AllocateContextSlowPath(
2302 AllocateUninitializedContextInstr* instruction)
2303 : instruction_(instruction) { }
2304
2305 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2306 __ Comment("AllocateContextSlowPath");
2307 __ Bind(entry_label());
2308
2309 LocationSummary* locs = instruction_->locs();
2310 locs->live_registers()->Remove(locs->out(0));
2311
2312 compiler->SaveLiveRegisters(locs);
2313
2314 __ LoadImmediate(T1, instruction_->num_context_variables());
2315 StubCode* stub_code = compiler->isolate()->stub_code();
2316 const ExternalLabel label(stub_code->AllocateContextEntryPoint());
2317 compiler->GenerateCall(instruction_->token_pos(),
2318 &label,
2319 RawPcDescriptors::kOther,
2320 locs);
2321 ASSERT(instruction_->locs()->out(0).reg() == R0);
2322 compiler->RestoreLiveRegisters(instruction_->locs());
2323 __ b(exit_label());
2324 }
2325
2326 private:
2327 AllocateUninitializedContextInstr* instruction_;
2328 };
2329
2330
2331 void AllocateUninitializedContextInstr::EmitNativeCode(
2332 FlowGraphCompiler* compiler) {
2333 Register temp0 = locs()->temp(0).reg();
2334 Register temp1 = locs()->temp(1).reg();
2335 Register temp2 = locs()->temp(2).reg();
2336 Register result = locs()->out(0).reg();
2337 // Try allocate the object.
2338 AllocateContextSlowPath* slow_path = new AllocateContextSlowPath(this);
2339 compiler->AddSlowPathCode(slow_path);
2340 intptr_t instance_size = Context::InstanceSize(num_context_variables());
2341
2342 __ TryAllocateArray(kContextCid, instance_size, slow_path->entry_label(),
2343 result, // instance
2344 temp0,
2345 temp1,
2346 temp2);
2347
2348 // Setup up number of context variables field.
2349 __ LoadImmediate(temp0, num_context_variables());
2350 __ sw(temp0, FieldAddress(result, Context::num_variables_offset()));
2351
2352 // Setup isolate field.
2353 __ lw(temp0, FieldAddress(CTX, Context::isolate_offset()));
2354 __ sw(temp0, FieldAddress(result, Context::isolate_offset()));
2355
2356 __ Bind(slow_path->exit_label());
2357 }
2358
2359
2311 LocationSummary* AllocateContextInstr::MakeLocationSummary(Isolate* isolate, 2360 LocationSummary* AllocateContextInstr::MakeLocationSummary(Isolate* isolate,
2312 bool opt) const { 2361 bool opt) const {
2313 const intptr_t kNumInputs = 0; 2362 const intptr_t kNumInputs = 0;
2314 const intptr_t kNumTemps = 1; 2363 const intptr_t kNumTemps = 1;
2315 LocationSummary* locs = new(isolate) LocationSummary( 2364 LocationSummary* locs = new(isolate) LocationSummary(
2316 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); 2365 isolate, kNumInputs, kNumTemps, LocationSummary::kCall);
2317 locs->set_temp(0, Location::RegisterLocation(T1)); 2366 locs->set_temp(0, Location::RegisterLocation(T1));
2318 locs->set_out(0, Location::RegisterLocation(V0)); 2367 locs->set_out(0, Location::RegisterLocation(V0));
2319 return locs; 2368 return locs;
2320 } 2369 }
2321 2370
2322 2371
2323 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2372 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2324 Register temp = T1; 2373 ASSERT(locs()->temp(0).reg() == T1);
2325 ASSERT(locs()->temp(0).reg() == temp);
2326 ASSERT(locs()->out(0).reg() == V0); 2374 ASSERT(locs()->out(0).reg() == V0);
2327 2375
2328 __ TraceSimMsg("AllocateContextInstr"); 2376 __ TraceSimMsg("AllocateContextInstr");
2329 __ LoadImmediate(temp, num_context_variables()); 2377 __ LoadImmediate(T1, num_context_variables());
2330 StubCode* stub_code = compiler->isolate()->stub_code(); 2378 StubCode* stub_code = compiler->isolate()->stub_code();
2331 const ExternalLabel label(stub_code->AllocateContextEntryPoint()); 2379 const ExternalLabel label(stub_code->AllocateContextEntryPoint());
2332 compiler->GenerateCall(token_pos(), 2380 compiler->GenerateCall(token_pos(),
2333 &label, 2381 &label,
2334 RawPcDescriptors::kOther, 2382 RawPcDescriptors::kOther,
2335 locs()); 2383 locs());
2336 } 2384 }
2337 2385
2338 2386
2339 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate, 2387 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate,
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 4823 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
4776 #if defined(DEBUG) 4824 #if defined(DEBUG)
4777 __ LoadImmediate(S4, kInvalidObjectPointer); 4825 __ LoadImmediate(S4, kInvalidObjectPointer);
4778 __ LoadImmediate(S5, kInvalidObjectPointer); 4826 __ LoadImmediate(S5, kInvalidObjectPointer);
4779 #endif 4827 #endif
4780 } 4828 }
4781 4829
4782 } // namespace dart 4830 } // namespace dart
4783 4831
4784 #endif // defined TARGET_ARCH_MIPS 4832 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698