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

Side by Side Diff: runtime/vm/flow_graph_compiler_arm64.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_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/cpu.h" 12 #include "vm/cpu.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/deopt_instructions.h" 14 #include "vm/deopt_instructions.h"
15 #include "vm/il_printer.h" 15 #include "vm/il_printer.h"
16 #include "vm/locations.h" 16 #include "vm/locations.h"
17 #include "vm/object_store.h" 17 #include "vm/object_store.h"
18 #include "vm/parser.h" 18 #include "vm/parser.h"
19 #include "vm/stack_frame.h" 19 #include "vm/stack_frame.h"
20 #include "vm/stub_code.h" 20 #include "vm/stub_code.h"
21 #include "vm/symbols.h" 21 #include "vm/symbols.h"
22 22
23 namespace dart { 23 namespace dart {
24 24
25 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); 25 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
26 DECLARE_FLAG(bool, enable_simd_inline); 26 DECLARE_FLAG(bool, enable_simd_inline);
27 DECLARE_FLAG(bool, use_megamorphic_stub);
27 28
28 29
29 FlowGraphCompiler::~FlowGraphCompiler() { 30 FlowGraphCompiler::~FlowGraphCompiler() {
30 // BlockInfos are zone-allocated, so their destructors are not called. 31 // BlockInfos are zone-allocated, so their destructors are not called.
31 // Verify the labels explicitly here. 32 // Verify the labels explicitly here.
32 for (int i = 0; i < block_info_.length(); ++i) { 33 for (int i = 0; i < block_info_.length(); ++i) {
33 ASSERT(!block_info_[i]->jump_label()->IsLinked()); 34 ASSERT(!block_info_[i]->jump_label()->IsLinked());
34 } 35 }
35 } 36 }
36 37
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 intptr_t deopt_id, 1263 intptr_t deopt_id,
1263 intptr_t token_pos, 1264 intptr_t token_pos,
1264 LocationSummary* locs) { 1265 LocationSummary* locs) {
1265 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); 1266 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
1266 const String& name = String::Handle(ic_data.target_name()); 1267 const String& name = String::Handle(ic_data.target_name());
1267 const Array& arguments_descriptor = 1268 const Array& arguments_descriptor =
1268 Array::ZoneHandle(ic_data.arguments_descriptor()); 1269 Array::ZoneHandle(ic_data.arguments_descriptor());
1269 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); 1270 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
1270 const MegamorphicCache& cache = 1271 const MegamorphicCache& cache =
1271 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); 1272 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
1272 __ LoadFromOffset(R0, SP, (argument_count - 1) * kWordSize, PP); 1273 const Register receiverR = R0;
1273 __ LoadTaggedClassIdMayBeSmi(R0, R0); 1274 const Register cacheR = R1;
1275 const Register targetR = R1;
1276 __ LoadFromOffset(receiverR, SP, (argument_count - 1) * kWordSize, PP);
1277 __ LoadObject(cacheR, cache, PP);
1274 1278
1275 // R0: class ID of the receiver (smi). 1279 if (FLAG_use_megamorphic_stub) {
1276 __ LoadObject(R1, cache, PP); 1280 StubCode* stub_code = isolate()->stub_code();
1277 __ LoadFieldFromOffset(R2, R1, MegamorphicCache::buckets_offset(), PP); 1281 __ BranchLink(&stub_code->MegamorphicLookupLabel(), PP);
1278 __ LoadFieldFromOffset(R1, R1, MegamorphicCache::mask_offset(), PP); 1282 } else {
1279 // R2: cache buckets array. 1283 StubCode::EmitMegamorphicLookup(assembler(), receiverR, cacheR, targetR);
1280 // R1: mask. 1284 }
1281 __ mov(R3, R0);
1282
1283 Label loop, update, call_target_function;
1284 __ b(&loop);
1285
1286 __ Bind(&update);
1287 __ add(R3, R3, Operand(Smi::RawValue(1)));
1288 __ Bind(&loop);
1289 __ and_(R3, R3, Operand(R1));
1290 const intptr_t base = Array::data_offset();
1291 // R3 is smi tagged, but table entries are 16 bytes, so LSL 3.
1292 __ add(TMP, R2, Operand(R3, LSL, 3));
1293 __ LoadFieldFromOffset(R4, TMP, base, PP);
1294
1295 ASSERT(kIllegalCid == 0);
1296 __ tst(R4, Operand(R4));
1297 __ b(&call_target_function, EQ);
1298 __ CompareRegisters(R4, R0);
1299 __ b(&update, NE);
1300
1301 __ Bind(&call_target_function);
1302 // Call the target found in the cache. For a class id match, this is a
1303 // proper target for the given name and arguments descriptor. If the
1304 // illegal class id was found, the target is a cache miss handler that can
1305 // be invoked as a normal Dart function.
1306 __ add(TMP, R2, Operand(R3, LSL, 3));
1307 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP);
1308 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP);
1309 __ LoadObject(R5, ic_data, PP); 1285 __ LoadObject(R5, ic_data, PP);
1310 __ LoadObject(R4, arguments_descriptor, PP); 1286 __ LoadObject(R4, arguments_descriptor, PP);
1311 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); 1287 __ blr(targetR);
1312 __ blr(R1);
1313 AddCurrentDescriptor(RawPcDescriptors::kOther, 1288 AddCurrentDescriptor(RawPcDescriptors::kOther,
1314 Isolate::kNoDeoptId, token_pos); 1289 Isolate::kNoDeoptId, token_pos);
1315 RecordSafepoint(locs); 1290 RecordSafepoint(locs);
1316 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1291 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1317 if (is_optimizing()) { 1292 if (is_optimizing()) {
1318 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1293 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1319 } else { 1294 } else {
1320 // Add deoptimization continuation point after the call and before the 1295 // Add deoptimization continuation point after the call and before the
1321 // arguments are removed. 1296 // arguments are removed.
1322 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); 1297 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1804 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1830 __ PopDouble(reg); 1805 __ PopDouble(reg);
1831 } 1806 }
1832 1807
1833 1808
1834 #undef __ 1809 #undef __
1835 1810
1836 } // namespace dart 1811 } // namespace dart
1837 1812
1838 #endif // defined TARGET_ARCH_ARM64 1813 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698