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

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

Issue 1418863003: Precompilation: Generate instance calls as IC calls that can switch to Megamoprhic calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/instructions_arm.h » ('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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 intptr_t argument_count, 1279 intptr_t argument_count,
1280 intptr_t deopt_id, 1280 intptr_t deopt_id,
1281 intptr_t token_pos, 1281 intptr_t token_pos,
1282 LocationSummary* locs) { 1282 LocationSummary* locs) {
1283 const String& name = String::Handle(zone(), ic_data.target_name()); 1283 const String& name = String::Handle(zone(), ic_data.target_name());
1284 const Array& arguments_descriptor = 1284 const Array& arguments_descriptor =
1285 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); 1285 Array::ZoneHandle(zone(), ic_data.arguments_descriptor());
1286 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); 1286 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
1287 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), 1287 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(),
1288 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); 1288 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor));
1289 const Register receiverR = RDI;
1290 const Register cacheR = RBX;
1291 const Register targetR = RCX;
1292 __ movq(receiverR, Address(RSP, (argument_count - 1) * kWordSize));
1293 __ LoadObject(cacheR, cache);
1294 1289
1290 __ Comment("MegamorphicCall");
1291 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize));
1292 __ LoadObject(RBX, cache);
1295 if (FLAG_use_megamorphic_stub) { 1293 if (FLAG_use_megamorphic_stub) {
1296 __ Call(*StubCode::MegamorphicLookup_entry()); 1294 __ Call(*StubCode::MegamorphicLookup_entry());
1297 } else { 1295 } else {
1298 StubCode::EmitMegamorphicLookup(assembler(), receiverR, cacheR, targetR); 1296 StubCode::EmitMegamorphicLookup(assembler());
1299 } 1297 }
1300 __ LoadObject(RBX, ic_data); 1298 __ call(RCX);
1301 __ LoadObject(R10, arguments_descriptor); 1299
1302 __ call(targetR);
1303 AddCurrentDescriptor(RawPcDescriptors::kOther, 1300 AddCurrentDescriptor(RawPcDescriptors::kOther,
1304 Thread::kNoDeoptId, token_pos); 1301 Thread::kNoDeoptId, token_pos);
1305 RecordSafepoint(locs); 1302 RecordSafepoint(locs);
1306 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); 1303 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id);
1307 if (is_optimizing()) { 1304 if (is_optimizing()) {
1308 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1305 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1309 } else { 1306 } else {
1310 // Add deoptimization continuation point after the call and before the 1307 // Add deoptimization continuation point after the call and before the
1311 // arguments are removed. 1308 // arguments are removed.
1312 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); 1309 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1313 } 1310 }
1314 __ Drop(argument_count, RCX); 1311 __ Drop(argument_count, RCX);
1315 } 1312 }
1316 1313
1317 1314
1315 void FlowGraphCompiler::EmitSwitchableInstanceCall(
1316 const ICData& ic_data,
1317 intptr_t argument_count,
1318 intptr_t deopt_id,
1319 intptr_t token_pos,
1320 LocationSummary* locs) {
1321 __ Comment("SwitchableCall");
1322 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize));
1323 if (ic_data.NumArgsTested() == 1) {
1324 __ LoadUniqueObject(RBX, ic_data);
1325 __ CallPatchable(*StubCode::ICLookup_entry());
1326 } else {
1327 const String& name = String::Handle(zone(), ic_data.target_name());
1328 const Array& arguments_descriptor =
1329 Array::ZoneHandle(zone(), ic_data.arguments_descriptor());
1330 ASSERT(!arguments_descriptor.IsNull() &&
1331 (arguments_descriptor.Length() > 0));
1332 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(),
1333 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor));
1334
1335 __ LoadUniqueObject(RBX, cache);
1336 __ CallPatchable(*StubCode::MegamorphicLookup_entry());
1337 }
1338 __ call(RCX);
1339
1340 AddCurrentDescriptor(RawPcDescriptors::kOther,
1341 Thread::kNoDeoptId, token_pos);
1342 RecordSafepoint(locs);
1343 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id);
1344 if (is_optimizing()) {
1345 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1346 } else {
1347 // Add deoptimization continuation point after the call and before the
1348 // arguments are removed.
1349 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1350 }
1351 __ Drop(argument_count, RCX);
1352 }
1353
1354
1318 void FlowGraphCompiler::EmitOptimizedStaticCall( 1355 void FlowGraphCompiler::EmitOptimizedStaticCall(
1319 const Function& function, 1356 const Function& function,
1320 const Array& arguments_descriptor, 1357 const Array& arguments_descriptor,
1321 intptr_t argument_count, 1358 intptr_t argument_count,
1322 intptr_t deopt_id, 1359 intptr_t deopt_id,
1323 intptr_t token_pos, 1360 intptr_t token_pos,
1324 LocationSummary* locs) { 1361 LocationSummary* locs) {
1325 __ LoadObject(R10, arguments_descriptor); 1362 __ LoadObject(R10, arguments_descriptor);
1326 // Do not use the code from the function, but let the code be patched so that 1363 // Do not use the code from the function, but let the code be patched so that
1327 // we can record the outgoing edges to other code. 1364 // we can record the outgoing edges to other code.
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 __ movups(reg, Address(RSP, 0)); 1795 __ movups(reg, Address(RSP, 0));
1759 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1796 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1760 } 1797 }
1761 1798
1762 1799
1763 #undef __ 1800 #undef __
1764 1801
1765 } // namespace dart 1802 } // namespace dart
1766 1803
1767 #endif // defined TARGET_ARCH_X64 1804 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/instructions_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698