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

Side by Side Diff: runtime/vm/stub_code_arm.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.h ('k') | runtime/vm/stub_code_arm64.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_ARM) 6 #if defined(TARGET_ARCH_ARM)
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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 Assembler* assembler) { 2052 Assembler* assembler) {
2053 const Register temp = R2; 2053 const Register temp = R2;
2054 const Register left = R1; 2054 const Register left = R1;
2055 const Register right = R0; 2055 const Register right = R0;
2056 __ ldr(left, Address(SP, 1 * kWordSize)); 2056 __ ldr(left, Address(SP, 1 * kWordSize));
2057 __ ldr(right, Address(SP, 0 * kWordSize)); 2057 __ ldr(right, Address(SP, 0 * kWordSize));
2058 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2058 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2059 __ Ret(); 2059 __ Ret();
2060 } 2060 }
2061 2061
2062
2063 void StubCode::EmitMegamorphicLookup(
2064 Assembler* assembler, Register receiver, Register cache, Register target) {
2065 ASSERT((cache != R0) && (cache != R2));
2066 __ LoadTaggedClassIdMayBeSmi(R0, receiver);
2067 // R0: class ID of the receiver (smi).
2068 __ ldr(R2, FieldAddress(cache, MegamorphicCache::buckets_offset()));
2069 __ ldr(R1, FieldAddress(R1, MegamorphicCache::mask_offset()));
2070 // R2: cache buckets array.
2071 // R1: mask.
2072 __ mov(R3, Operand(R0));
2073
2074 Label loop, update, call_target_function;
2075 __ b(&loop);
2076
2077 __ Bind(&update);
2078 __ add(R3, R3, Operand(Smi::RawValue(1)));
2079 __ Bind(&loop);
2080 __ and_(R3, R3, Operand(R1));
2081 const intptr_t base = Array::data_offset();
2082 // R3 is smi tagged, but table entries are two words, so LSL 2.
2083 __ add(IP, R2, Operand(R3, LSL, 2));
2084 __ ldr(R4, FieldAddress(IP, base));
2085
2086 ASSERT(kIllegalCid == 0);
2087 __ tst(R4, Operand(R4));
2088 __ b(&call_target_function, EQ);
2089 __ cmp(R4, Operand(R0));
2090 __ b(&update, NE);
2091
2092 __ Bind(&call_target_function);
2093 // Call the target found in the cache. For a class id match, this is a
2094 // proper target for the given name and arguments descriptor. If the
2095 // illegal class id was found, the target is a cache miss handler that can
2096 // be invoked as a normal Dart function.
2097 __ add(IP, R2, Operand(R3, LSL, 2));
2098 __ ldr(R0, FieldAddress(IP, base + kWordSize));
2099 __ ldr(target, FieldAddress(R0, Function::instructions_offset()));
2100 // TODO(srdjan): Evaluate performance impact of moving the instruction below
2101 // to the call site, instead of having it here.
2102 __ AddImmediate(target, Instructions::HeaderSize() - kHeapObjectTag);
2103 }
2104
2105
2106 // Called from megamorphic calls.
2107 // R0: receiver.
2108 // R1: lookup cache.
2109 // Result:
2110 // R1: entry point.
2111 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2112 EmitMegamorphicLookup(assembler, R0, R1, R1);
2113 __ Ret();
2114 }
2115
2062 } // namespace dart 2116 } // namespace dart
2063 2117
2064 #endif // defined TARGET_ARCH_ARM 2118 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698