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

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

Issue 2226893002: Optimize AOT's switchable calls for the monomorphic case. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 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
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 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 2147
2148 2148
2149 // Called from megamorphic calls. 2149 // Called from megamorphic calls.
2150 // T0: receiver 2150 // T0: receiver
2151 // S5: MegamorphicCache (preserved) 2151 // S5: MegamorphicCache (preserved)
2152 // Result: 2152 // Result:
2153 // T1: target entry point 2153 // T1: target entry point
2154 // CODE_REG: target Code 2154 // CODE_REG: target Code
2155 // S4: arguments descriptor 2155 // S4: arguments descriptor
2156 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2156 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2157 __ NoMonomorphicCheckedEntry();
2158
2157 __ LoadTaggedClassIdMayBeSmi(T0, T0); 2159 __ LoadTaggedClassIdMayBeSmi(T0, T0);
2158 // T0: class ID of the receiver (smi). 2160 // T0: class ID of the receiver (smi).
2159 __ lw(S4, FieldAddress(S5, MegamorphicCache::arguments_descriptor_offset())); 2161 __ lw(S4, FieldAddress(S5, MegamorphicCache::arguments_descriptor_offset()));
2160 __ lw(T2, FieldAddress(S5, MegamorphicCache::buckets_offset())); 2162 __ lw(T2, FieldAddress(S5, MegamorphicCache::buckets_offset()));
2161 __ lw(T1, FieldAddress(S5, MegamorphicCache::mask_offset())); 2163 __ lw(T1, FieldAddress(S5, MegamorphicCache::mask_offset()));
2162 // T2: cache buckets array. 2164 // T2: cache buckets array.
2163 // T1: mask. 2165 // T1: mask.
2164 __ LoadImmediate(TMP, MegamorphicCache::kSpreadFactor); 2166 __ LoadImmediate(TMP, MegamorphicCache::kSpreadFactor);
2165 __ mult(TMP, T0); 2167 __ mult(TMP, T0);
2166 __ mflo(T3); 2168 __ mflo(T3);
(...skipping 20 matching lines...) Expand all
2187 // Call the target found in the cache. For a class id match, this is a 2189 // Call the target found in the cache. For a class id match, this is a
2188 // proper target for the given name and arguments descriptor. If the 2190 // proper target for the given name and arguments descriptor. If the
2189 // illegal class id was found, the target is a cache miss handler that can 2191 // illegal class id was found, the target is a cache miss handler that can
2190 // be invoked as a normal Dart function. 2192 // be invoked as a normal Dart function.
2191 __ sll(T1, T3, 2); 2193 __ sll(T1, T3, 2);
2192 __ addu(T1, T2, T1); 2194 __ addu(T1, T2, T1);
2193 __ lw(T0, FieldAddress(T1, base + kWordSize)); 2195 __ lw(T0, FieldAddress(T1, base + kWordSize));
2194 2196
2195 __ lw(T1, FieldAddress(T0, Function::entry_point_offset())); 2197 __ lw(T1, FieldAddress(T0, Function::entry_point_offset()));
2196 __ lw(CODE_REG, FieldAddress(T0, Function::code_offset())); 2198 __ lw(CODE_REG, FieldAddress(T0, Function::code_offset()));
2197 __ Ret(); 2199 __ jr(T1);
2198 } 2200 }
2199 2201
2200 2202
2201 // Called from switchable IC calls. 2203 // Called from switchable IC calls.
2202 // T0: receiver 2204 // T0: receiver
2203 // S5: ICData (preserved) 2205 // S5: ICData (preserved)
2204 // Result: 2206 // Result:
2205 // T1: target entry point 2207 // T1: target entry point
2206 // CODE_REG: target Code object 2208 // CODE_REG: target Code object
2207 // S4: arguments descriptor 2209 // S4: arguments descriptor
2208 void StubCode::GenerateICLookupThroughFunctionStub(Assembler* assembler) { 2210 void StubCode::GenerateICLookupThroughFunctionStub(Assembler* assembler) {
2211 __ NoMonomorphicCheckedEntry();
2212
2209 Label loop, found, miss; 2213 Label loop, found, miss;
2210 __ lw(T6, FieldAddress(S5, ICData::ic_data_offset())); 2214 __ lw(T6, FieldAddress(S5, ICData::ic_data_offset()));
2211 __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset())); 2215 __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset()));
2212 __ AddImmediate(T6, T6, Array::data_offset() - kHeapObjectTag); 2216 __ AddImmediate(T6, T6, Array::data_offset() - kHeapObjectTag);
2213 // T6: first IC entry. 2217 // T6: first IC entry.
2214 __ LoadTaggedClassIdMayBeSmi(T1, T0); 2218 __ LoadTaggedClassIdMayBeSmi(T1, T0);
2215 // T1: receiver cid as Smi 2219 // T1: receiver cid as Smi
2216 2220
2217 __ Bind(&loop); 2221 __ Bind(&loop);
2218 __ lw(T2, Address(T6, 0)); 2222 __ lw(T2, Address(T6, 0));
2219 __ beq(T1, T2, &found); 2223 __ beq(T1, T2, &found);
2220 ASSERT(Smi::RawValue(kIllegalCid) == 0); 2224 ASSERT(Smi::RawValue(kIllegalCid) == 0);
2221 __ beq(T2, ZR, &miss); 2225 __ beq(T2, ZR, &miss);
2222 2226
2223 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; 2227 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize;
2224 __ AddImmediate(T6, entry_length); // Next entry. 2228 __ AddImmediate(T6, entry_length); // Next entry.
2225 __ b(&loop); 2229 __ b(&loop);
2226 2230
2227 __ Bind(&found); 2231 __ Bind(&found);
2228 const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize; 2232 const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize;
2229 __ lw(T0, Address(T6, target_offset)); 2233 __ lw(T0, Address(T6, target_offset));
2230 __ lw(T1, FieldAddress(T0, Function::entry_point_offset())); 2234 __ lw(T1, FieldAddress(T0, Function::entry_point_offset()));
2231 __ lw(CODE_REG, FieldAddress(T0, Function::code_offset())); 2235 __ lw(CODE_REG, FieldAddress(T0, Function::code_offset()));
2232 __ Ret(); 2236 __ jr(T1);
2233 2237
2234 __ Bind(&miss); 2238 __ Bind(&miss);
2235 __ LoadIsolate(T2); 2239 __ LoadIsolate(T2);
2236 __ lw(CODE_REG, Address(T2, Isolate::ic_miss_code_offset())); 2240 __ lw(CODE_REG, Address(T2, Isolate::ic_miss_code_offset()));
2237 __ lw(T1, FieldAddress(CODE_REG, Code::entry_point_offset())); 2241 __ lw(T1, FieldAddress(CODE_REG, Code::entry_point_offset()));
2238 __ Ret(); 2242 __ jr(T1);
2239 } 2243 }
2240 2244
2241 2245
2242 void StubCode::GenerateICLookupThroughCodeStub(Assembler* assembler) { 2246 void StubCode::GenerateICLookupThroughCodeStub(Assembler* assembler) {
2247 __ NoMonomorphicCheckedEntry();
2248
2243 Label loop, found, miss; 2249 Label loop, found, miss;
2244 __ lw(T6, FieldAddress(S5, ICData::ic_data_offset())); 2250 __ lw(T6, FieldAddress(S5, ICData::ic_data_offset()));
2245 __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset())); 2251 __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset()));
2246 __ AddImmediate(T6, T6, Array::data_offset() - kHeapObjectTag); 2252 __ AddImmediate(T6, T6, Array::data_offset() - kHeapObjectTag);
2247 // T6: first IC entry. 2253 // T6: first IC entry.
2248 __ LoadTaggedClassIdMayBeSmi(T1, T0); 2254 __ LoadTaggedClassIdMayBeSmi(T1, T0);
2249 // T1: receiver cid as Smi 2255 // T1: receiver cid as Smi
2250 2256
2251 __ Bind(&loop); 2257 __ Bind(&loop);
2252 __ lw(T2, Address(T6, 0)); 2258 __ lw(T2, Address(T6, 0));
2253 __ beq(T1, T2, &found); 2259 __ beq(T1, T2, &found);
2254 ASSERT(Smi::RawValue(kIllegalCid) == 0); 2260 ASSERT(Smi::RawValue(kIllegalCid) == 0);
2255 __ beq(T2, ZR, &miss); 2261 __ beq(T2, ZR, &miss);
2256 2262
2257 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; 2263 const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize;
2258 __ AddImmediate(T6, entry_length); // Next entry. 2264 __ AddImmediate(T6, entry_length); // Next entry.
2259 __ b(&loop); 2265 __ b(&loop);
2260 2266
2261 __ Bind(&found); 2267 __ Bind(&found);
2262 const intptr_t code_offset = ICData::CodeIndexFor(1) * kWordSize; 2268 const intptr_t code_offset = ICData::CodeIndexFor(1) * kWordSize;
2263 const intptr_t entry_offset = ICData::EntryPointIndexFor(1) * kWordSize; 2269 const intptr_t entry_offset = ICData::EntryPointIndexFor(1) * kWordSize;
2264 __ lw(T1, Address(T6, entry_offset)); 2270 __ lw(T1, Address(T6, entry_offset));
2265 __ lw(CODE_REG, Address(T6, code_offset)); 2271 __ lw(CODE_REG, Address(T6, code_offset));
2266 __ Ret(); 2272 __ jr(T1);
2267 2273
2268 __ Bind(&miss); 2274 __ Bind(&miss);
2269 __ LoadIsolate(T2); 2275 __ LoadIsolate(T2);
2270 __ lw(CODE_REG, Address(T2, Isolate::ic_miss_code_offset())); 2276 __ lw(CODE_REG, Address(T2, Isolate::ic_miss_code_offset()));
2271 __ lw(T1, FieldAddress(CODE_REG, Code::entry_point_offset())); 2277 __ lw(T1, FieldAddress(CODE_REG, Code::entry_point_offset()));
2272 __ Ret(); 2278 __ jr(T1);
2273 } 2279 }
2274 2280
2275 2281
2282 // T0: receiver
2283 void StubCode::GenerateMonomorphicMissStub(Assembler* assembler) {
2284 __ EnterStubFrame();
2285 __ Push(T0); // Preserve receiver.
2286
2287 __ PushObject(Object::null_object()); // Result.
2288 __ Push(T0); // Arg0: Receiver / stub out
2289 __ CallRuntime(kMonomorphicMissRuntimeEntry, 1);
2290 __ Pop(CODE_REG);
2291 __ Pop(S5); // result = IC
2292
2293 __ Pop(T0); // Restore receiver.
2294 __ LeaveStubFrame();
2295
2296 __ lw(T1, FieldAddress(CODE_REG, Code::checked_entry_point_offset()));
2297 __ jr(T1);
2298 }
2299
2300
2276 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { 2301 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) {
2277 __ break_(0); 2302 __ break_(0);
2278 } 2303 }
2279 2304
2280 } // namespace dart 2305 } // namespace dart
2281 2306
2282 #endif // defined TARGET_ARCH_MIPS 2307 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698