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

Side by Side Diff: runtime/vm/flow_graph_compiler_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/flow_graph_compiler.cc ('k') | runtime/vm/flow_graph_compiler_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" // Needed here to get TARGET_ARCH_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 10 matching lines...) Expand all
21 #include "vm/symbols.h" 21 #include "vm/symbols.h"
22 #include "vm/verified_memory.h" 22 #include "vm/verified_memory.h"
23 23
24 namespace dart { 24 namespace dart {
25 25
26 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); 26 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
27 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); 27 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic.");
28 DEFINE_FLAG(bool, unbox_doubles, true, "Optimize double arithmetic."); 28 DEFINE_FLAG(bool, unbox_doubles, true, "Optimize double arithmetic.");
29 DECLARE_FLAG(bool, enable_type_checks); 29 DECLARE_FLAG(bool, enable_type_checks);
30 DECLARE_FLAG(bool, enable_simd_inline); 30 DECLARE_FLAG(bool, enable_simd_inline);
31 DECLARE_FLAG(bool, use_megamorphic_stub);
31 32
32 33
33 FlowGraphCompiler::~FlowGraphCompiler() { 34 FlowGraphCompiler::~FlowGraphCompiler() {
34 // BlockInfos are zone-allocated, so their destructors are not called. 35 // BlockInfos are zone-allocated, so their destructors are not called.
35 // Verify the labels explicitly here. 36 // Verify the labels explicitly here.
36 for (int i = 0; i < block_info_.length(); ++i) { 37 for (int i = 0; i < block_info_.length(); ++i) {
37 ASSERT(!block_info_[i]->jump_label()->IsLinked()); 38 ASSERT(!block_info_[i]->jump_label()->IsLinked());
38 } 39 }
39 } 40 }
40 41
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 intptr_t token_pos, 1283 intptr_t token_pos,
1283 LocationSummary* locs) { 1284 LocationSummary* locs) {
1284 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); 1285 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
1285 const String& name = String::Handle(ic_data.target_name()); 1286 const String& name = String::Handle(ic_data.target_name());
1286 const Array& arguments_descriptor = 1287 const Array& arguments_descriptor =
1287 Array::ZoneHandle(ic_data.arguments_descriptor()); 1288 Array::ZoneHandle(ic_data.arguments_descriptor());
1288 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); 1289 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
1289 const MegamorphicCache& cache = 1290 const MegamorphicCache& cache =
1290 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); 1291 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
1291 __ LoadFromOffset(kWord, R0, SP, (argument_count - 1) * kWordSize); 1292 __ LoadFromOffset(kWord, R0, SP, (argument_count - 1) * kWordSize);
1292 __ LoadTaggedClassIdMayBeSmi(R0, R0); 1293 __ LoadObject(R1, cache);
1293 1294
1294 // R0: class ID of the receiver (smi). 1295 if (FLAG_use_megamorphic_stub) {
Florian Schneider 2015/05/04 22:06:20 To avoid performance regression in optimized code,
srdjan 2015/05/05 07:15:29 There are no measureable (< 0.5% diffs) in optimiz
srdjan 2015/05/05 12:13:28 Measured dart2js optimized: with out-of-line megam
Florian Schneider 2015/05/05 16:34:43 If the difference is not noticable in optimized co
1295 __ LoadObject(R1, cache); 1296 StubCode* stub_code = isolate()->stub_code();
1296 __ ldr(R2, FieldAddress(R1, MegamorphicCache::buckets_offset())); 1297 __ BranchLink(&stub_code->MegamorphicLookupLabel());
1297 __ ldr(R1, FieldAddress(R1, MegamorphicCache::mask_offset())); 1298 } else {
1298 // R2: cache buckets array. 1299 // R0: class ID of the receiver (smi).
1299 // R1: mask. 1300 __ LoadTaggedClassIdMayBeSmi(R0, R0);
1300 __ mov(R3, Operand(R0)); 1301 __ ldr(R2, FieldAddress(R1, MegamorphicCache::buckets_offset()));
1302 __ ldr(R1, FieldAddress(R1, MegamorphicCache::mask_offset()));
1303 // R2: cache buckets array.
1304 // R1: mask.
1305 __ mov(R3, Operand(R0));
1301 1306
1302 Label loop, update, call_target_function; 1307 Label loop, update, call_target_function;
1303 __ b(&loop); 1308 __ b(&loop);
1304 1309
1305 __ Bind(&update); 1310 __ Bind(&update);
1306 __ add(R3, R3, Operand(Smi::RawValue(1))); 1311 __ add(R3, R3, Operand(Smi::RawValue(1)));
1307 __ Bind(&loop); 1312 __ Bind(&loop);
1308 __ and_(R3, R3, Operand(R1)); 1313 __ and_(R3, R3, Operand(R1));
1309 const intptr_t base = Array::data_offset(); 1314 const intptr_t base = Array::data_offset();
1310 // R3 is smi tagged, but table entries are two words, so LSL 2. 1315 // R3 is smi tagged, but table entries are two words, so LSL 2.
1311 __ add(IP, R2, Operand(R3, LSL, 2)); 1316 __ add(IP, R2, Operand(R3, LSL, 2));
1312 __ ldr(R4, FieldAddress(IP, base)); 1317 __ ldr(R4, FieldAddress(IP, base));
1313 1318
1314 ASSERT(kIllegalCid == 0); 1319 ASSERT(kIllegalCid == 0);
1315 __ tst(R4, Operand(R4)); 1320 __ tst(R4, Operand(R4));
1316 __ b(&call_target_function, EQ); 1321 __ b(&call_target_function, EQ);
1317 __ cmp(R4, Operand(R0)); 1322 __ cmp(R4, Operand(R0));
1318 __ b(&update, NE); 1323 __ b(&update, NE);
1319 1324
1320 __ Bind(&call_target_function); 1325 __ Bind(&call_target_function);
1321 // Call the target found in the cache. For a class id match, this is a 1326 // Call the target found in the cache. For a class id match, this is a
1322 // proper target for the given name and arguments descriptor. If the 1327 // proper target for the given name and arguments descriptor. If the
1323 // illegal class id was found, the target is a cache miss handler that can 1328 // illegal class id was found, the target is a cache miss handler that can
1324 // be invoked as a normal Dart function. 1329 // be invoked as a normal Dart function.
1325 __ add(IP, R2, Operand(R3, LSL, 2)); 1330 __ add(IP, R2, Operand(R3, LSL, 2));
1326 __ ldr(R0, FieldAddress(IP, base + kWordSize)); 1331 __ ldr(R0, FieldAddress(IP, base + kWordSize));
1327 __ ldr(R1, FieldAddress(R0, Function::instructions_offset())); 1332 __ ldr(R1, FieldAddress(R0, Function::instructions_offset()));
1333 __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag);
1334 }
Florian Schneider 2015/05/04 22:06:20 Maybe you can factor this lookup code into a commo
srdjan 2015/05/05 07:15:29 Will do.
1328 __ LoadObject(R5, ic_data); 1335 __ LoadObject(R5, ic_data);
1329 __ LoadObject(R4, arguments_descriptor); 1336 __ LoadObject(R4, arguments_descriptor);
1330 __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag);
1331 __ blx(R1); 1337 __ blx(R1);
1332 AddCurrentDescriptor(RawPcDescriptors::kOther, 1338 AddCurrentDescriptor(RawPcDescriptors::kOther,
1333 Isolate::kNoDeoptId, token_pos); 1339 Isolate::kNoDeoptId, token_pos);
1334 RecordSafepoint(locs); 1340 RecordSafepoint(locs);
1335 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1341 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1336 if (is_optimizing()) { 1342 if (is_optimizing()) {
1337 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1343 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1338 } else { 1344 } else {
1339 // Add deoptimization continuation point after the call and before the 1345 // Add deoptimization continuation point after the call and before the
1340 // arguments are removed. 1346 // arguments are removed.
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 DRegister dreg = EvenDRegisterOf(reg); 1889 DRegister dreg = EvenDRegisterOf(reg);
1884 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); 1890 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex));
1885 } 1891 }
1886 1892
1887 1893
1888 #undef __ 1894 #undef __
1889 1895
1890 } // namespace dart 1896 } // namespace dart
1891 1897
1892 #endif // defined TARGET_ARCH_ARM 1898 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698