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

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

Issue 1125623003: Move megamorphic lookup code to stub instead of inlining. Preformance loss < 5%, instruction size r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/stub_code_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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 const Register temp1 = T2; 2248 const Register temp1 = T2;
2249 const Register temp2 = T3; 2249 const Register temp2 = T3;
2250 const Register left = T1; 2250 const Register left = T1;
2251 const Register right = T0; 2251 const Register right = T0;
2252 __ lw(left, Address(SP, 1 * kWordSize)); 2252 __ lw(left, Address(SP, 1 * kWordSize));
2253 __ lw(right, Address(SP, 0 * kWordSize)); 2253 __ lw(right, Address(SP, 0 * kWordSize));
2254 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2); 2254 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2);
2255 __ Ret(); 2255 __ Ret();
2256 } 2256 }
2257 2257
2258
2259 void StubCode::EmitMegamorphicLookup(
2260 Assembler* assembler, Register receiver, Register cache, Register target) {
2261 ASSERT((cache != T0) && (cache != T2));
2262 __ LoadTaggedClassIdMayBeSmi(T0, receiver);
2263 // T0: class ID of the receiver (smi).
2264 __ lw(T2, FieldAddress(cache, MegamorphicCache::buckets_offset()));
2265 __ lw(T1, FieldAddress(cache, MegamorphicCache::mask_offset()));
2266 // T2: cache buckets array.
2267 // T1: mask.
2268 __ mov(T3, T0);
2269
2270 Label loop, update, call_target_function;
2271 __ b(&loop);
2272
2273 __ Bind(&update);
2274 __ addiu(T3, T3, Immediate(Smi::RawValue(1)));
2275 __ Bind(&loop);
2276 __ and_(T3, T3, T1);
2277 const intptr_t base = Array::data_offset();
2278 // T3 is smi tagged, but table entries are two words, so LSL 2.
2279 __ sll(TMP, T3, 2);
2280 __ addu(TMP, T2, TMP);
2281 __ lw(T4, FieldAddress(TMP, base));
2282
2283 ASSERT(kIllegalCid == 0);
2284 __ beq(T4, ZR, &call_target_function);
2285 __ bne(T4, T0, &update);
2286
2287 __ Bind(&call_target_function);
2288 // Call the target found in the cache. For a class id match, this is a
2289 // proper target for the given name and arguments descriptor. If the
2290 // illegal class id was found, the target is a cache miss handler that can
2291 // be invoked as a normal Dart function.
2292 __ sll(T1, T3, 2);
2293 __ addu(T1, T2, T1);
2294 __ lw(T0, FieldAddress(T1, base + kWordSize));
2295
2296 __ lw(target, FieldAddress(T0, Function::instructions_offset()));
2297 // TODO(srdjan): Evaluate performance impact of moving the instruction below
2298 // to the call site, instead of having it here.
2299 __ AddImmediate(target, Instructions::HeaderSize() - kHeapObjectTag);
2300 }
2301
2302
2303 // Called from megamorphic calls.
2304 // T0: receiver.
2305 // T1: lookup cache.
2306 // Result:
2307 // T1: entry point.
2308 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2309 EmitMegamorphicLookup(assembler, T0, T1, T1);
2310 __ Ret();
2311 }
2312
2258 } // namespace dart 2313 } // namespace dart
2259 2314
2260 #endif // defined TARGET_ARCH_MIPS 2315 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698