OLD | NEW |
---|---|
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 11 matching lines...) Expand all Loading... | |
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 DECLARE_FLAG(bool, enable_simd_inline); | 28 DECLARE_FLAG(bool, enable_simd_inline); |
29 DECLARE_FLAG(bool, use_megamorphic_stub); | 29 DECLARE_FLAG(bool, use_megamorphic_stub); |
30 | 30 |
31 | 31 |
32 void MegamorphicSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) { | |
33 Assembler* assem = compiler->assembler(); | |
34 #define __ assem-> | |
35 __ Bind(entry_label()); | |
36 __ Comment("MegamorphicSlowPath"); | |
37 compiler->EmitMegamorphicInstanceCall(ic_data_, argument_count_, deopt_id_, | |
38 token_pos_, locs_, try_index_); | |
39 __ jmp(exit_label()); | |
40 #undef __ | |
41 } | |
42 | |
43 | |
32 FlowGraphCompiler::~FlowGraphCompiler() { | 44 FlowGraphCompiler::~FlowGraphCompiler() { |
33 // BlockInfos are zone-allocated, so their destructors are not called. | 45 // BlockInfos are zone-allocated, so their destructors are not called. |
34 // Verify the labels explicitly here. | 46 // Verify the labels explicitly here. |
35 for (int i = 0; i < block_info_.length(); ++i) { | 47 for (int i = 0; i < block_info_.length(); ++i) { |
36 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 48 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
37 ASSERT(!block_info_[i]->jump_label()->HasNear()); | 49 ASSERT(!block_info_[i]->jump_label()->HasNear()); |
38 } | 50 } |
39 } | 51 } |
40 | 52 |
41 | 53 |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 locs); | 1284 locs); |
1273 __ Drop(argument_count, RCX); | 1285 __ Drop(argument_count, RCX); |
1274 } | 1286 } |
1275 | 1287 |
1276 | 1288 |
1277 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1289 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1278 const ICData& ic_data, | 1290 const ICData& ic_data, |
1279 intptr_t argument_count, | 1291 intptr_t argument_count, |
1280 intptr_t deopt_id, | 1292 intptr_t deopt_id, |
1281 intptr_t token_pos, | 1293 intptr_t token_pos, |
1282 LocationSummary* locs) { | 1294 LocationSummary* locs, |
1295 intptr_t try_index) { | |
1283 const String& name = String::Handle(zone(), ic_data.target_name()); | 1296 const String& name = String::Handle(zone(), ic_data.target_name()); |
1284 const Array& arguments_descriptor = | 1297 const Array& arguments_descriptor = |
1285 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); | 1298 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); |
1286 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1299 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
1287 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), | 1300 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), |
1288 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); | 1301 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
1289 | 1302 |
1290 __ Comment("MegamorphicCall"); | 1303 __ Comment("MegamorphicCall"); |
1291 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize)); | 1304 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize)); |
1292 __ LoadObject(RBX, cache); | 1305 __ LoadObject(RBX, cache); |
1293 if (FLAG_use_megamorphic_stub) { | 1306 if (FLAG_use_megamorphic_stub) { |
1294 __ Call(*StubCode::MegamorphicLookup_entry()); | 1307 __ Call(*StubCode::MegamorphicLookup_entry()); |
1295 } else { | 1308 } else { |
1296 StubCode::EmitMegamorphicLookup(assembler()); | 1309 StubCode::EmitMegamorphicLookup(assembler()); |
1297 } | 1310 } |
1298 __ call(RCX); | 1311 __ call(RCX); |
1299 | 1312 |
1300 AddCurrentDescriptor(RawPcDescriptors::kOther, | 1313 AddCurrentDescriptor(RawPcDescriptors::kOther, |
Florian Schneider
2015/12/14 16:07:03
Move this into the else-branches below, so that we
srdjan
2015/12/15 17:52:03
Done.
| |
1301 Thread::kNoDeoptId, token_pos); | 1314 Thread::kNoDeoptId, token_pos); |
1302 RecordSafepoint(locs); | 1315 RecordSafepoint(locs); |
1303 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1316 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1304 if (is_optimizing()) { | 1317 if (Compiler::always_optimize()) { |
1318 // Megamorphic calls may occur in slow path stubs. | |
1319 // If valid use try_index argument. | |
1320 if (try_index == CatchClauseNode::kInvalidTryIndex) { | |
1321 try_index = CurrentTryIndex(); | |
1322 } | |
1323 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther, | |
1324 assembler()->CodeSize(), | |
1325 Thread::kNoDeoptId, | |
1326 token_pos, | |
1327 try_index); | |
1328 } else if (is_optimizing()) { | |
1305 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1329 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
1306 } else { | 1330 } else { |
1307 // Add deoptimization continuation point after the call and before the | 1331 // Add deoptimization continuation point after the call and before the |
1308 // arguments are removed. | 1332 // arguments are removed. |
1309 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1333 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1310 } | 1334 } |
1311 __ Drop(argument_count, RCX); | 1335 __ Drop(argument_count, RCX); |
1312 } | 1336 } |
1313 | 1337 |
1314 | 1338 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 __ movups(reg, Address(RSP, 0)); | 1819 __ movups(reg, Address(RSP, 0)); |
1796 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1820 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
1797 } | 1821 } |
1798 | 1822 |
1799 | 1823 |
1800 #undef __ | 1824 #undef __ |
1801 | 1825 |
1802 } // namespace dart | 1826 } // namespace dart |
1803 | 1827 |
1804 #endif // defined TARGET_ARCH_X64 | 1828 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |