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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 namespace dart { | 27 namespace dart { |
28 | 28 |
29 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); | 29 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); |
30 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); | 30 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); |
31 | 31 |
32 DECLARE_FLAG(bool, enable_simd_inline); | 32 DECLARE_FLAG(bool, enable_simd_inline); |
33 DECLARE_FLAG(bool, use_megamorphic_stub); | 33 DECLARE_FLAG(bool, use_megamorphic_stub); |
34 | 34 |
35 | 35 |
36 void MegamorphicSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) { | |
37 Assembler* assem = compiler->assembler(); | |
38 #define __ assem-> | |
39 __ Bind(entry_label()); | |
40 __ Comment("MegamorphicSlowPath"); | |
41 compiler->EmitMegamorphicInstanceCall(ic_data_, argument_count_, deopt_id_, | |
42 token_pos_, locs_, try_index_); | |
43 __ jmp(exit_label()); | |
44 #undef __ | |
45 } | |
46 | |
47 | |
36 FlowGraphCompiler::~FlowGraphCompiler() { | 48 FlowGraphCompiler::~FlowGraphCompiler() { |
37 // BlockInfos are zone-allocated, so their destructors are not called. | 49 // BlockInfos are zone-allocated, so their destructors are not called. |
38 // Verify the labels explicitly here. | 50 // Verify the labels explicitly here. |
39 for (int i = 0; i < block_info_.length(); ++i) { | 51 for (int i = 0; i < block_info_.length(); ++i) { |
40 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 52 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
41 ASSERT(!block_info_[i]->jump_label()->HasNear()); | 53 ASSERT(!block_info_[i]->jump_label()->HasNear()); |
42 } | 54 } |
43 } | 55 } |
44 | 56 |
45 | 57 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1271 locs); | 1283 locs); |
1272 __ Drop(argument_count); | 1284 __ Drop(argument_count); |
1273 } | 1285 } |
1274 | 1286 |
1275 | 1287 |
1276 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1288 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1277 const ICData& ic_data, | 1289 const ICData& ic_data, |
1278 intptr_t argument_count, | 1290 intptr_t argument_count, |
1279 intptr_t deopt_id, | 1291 intptr_t deopt_id, |
1280 intptr_t token_pos, | 1292 intptr_t token_pos, |
1281 LocationSummary* locs) { | 1293 LocationSummary* locs, |
1294 intptr_t try_index) { | |
1282 const String& name = String::Handle(zone(), ic_data.target_name()); | 1295 const String& name = String::Handle(zone(), ic_data.target_name()); |
1283 const Array& arguments_descriptor = | 1296 const Array& arguments_descriptor = |
1284 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); | 1297 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); |
1285 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1298 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
1286 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), | 1299 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), |
1287 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); | 1300 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
1288 | 1301 |
1289 __ Comment("MegamorphicCall"); | 1302 __ Comment("MegamorphicCall"); |
1290 __ movl(EBX, Address(ESP, (argument_count - 1) * kWordSize)); | 1303 __ movl(EBX, Address(ESP, (argument_count - 1) * kWordSize)); |
1291 __ LoadObject(ECX, cache); | 1304 __ LoadObject(ECX, cache); |
1292 if (FLAG_use_megamorphic_stub) { | 1305 if (FLAG_use_megamorphic_stub) { |
1293 __ Call(*StubCode::MegamorphicLookup_entry()); | 1306 __ Call(*StubCode::MegamorphicLookup_entry()); |
1294 } else { | 1307 } else { |
1295 StubCode::EmitMegamorphicLookup(assembler()); | 1308 StubCode::EmitMegamorphicLookup(assembler()); |
1296 } | 1309 } |
1297 __ call(EBX); | 1310 __ call(EBX); |
1298 | 1311 |
1299 AddCurrentDescriptor(RawPcDescriptors::kOther, | 1312 AddCurrentDescriptor(RawPcDescriptors::kOther, |
1300 Thread::kNoDeoptId, token_pos); | 1313 Thread::kNoDeoptId, token_pos); |
1301 RecordSafepoint(locs); | 1314 RecordSafepoint(locs); |
1302 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1315 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1303 if (is_optimizing()) { | 1316 if (Compiler::always_optimize()) { |
Florian Schneider
2015/12/14 16:07:03
This seems never true on ia32 and won't be tested.
srdjan
2015/12/15 17:52:03
Done.
| |
1317 // Megamorphic calls may occur in slow path stubs. | |
1318 // If valid use try_index argument. | |
1319 if (try_index == CatchClauseNode::kInvalidTryIndex) { | |
1320 try_index = CurrentTryIndex(); | |
1321 } | |
1322 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther, | |
1323 assembler()->CodeSize(), | |
1324 Thread::kNoDeoptId, | |
1325 token_pos, | |
1326 try_index); | |
1327 } else if (is_optimizing()) { | |
1304 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1328 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
1305 } else { | 1329 } else { |
1306 // Add deoptimization continuation point after the call and before the | 1330 // Add deoptimization continuation point after the call and before the |
1307 // arguments are removed. | 1331 // arguments are removed. |
1308 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1332 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1309 } | 1333 } |
1310 __ Drop(argument_count); | 1334 __ Drop(argument_count); |
1311 } | 1335 } |
1312 | 1336 |
1313 | 1337 |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1834 __ movups(reg, Address(ESP, 0)); | 1858 __ movups(reg, Address(ESP, 0)); |
1835 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1859 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1836 } | 1860 } |
1837 | 1861 |
1838 | 1862 |
1839 #undef __ | 1863 #undef __ |
1840 | 1864 |
1841 } // namespace dart | 1865 } // namespace dart |
1842 | 1866 |
1843 #endif // defined TARGET_ARCH_IA32 | 1867 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |