| 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* assembler = compiler->assembler(); |
| 38 #define __ assembler-> |
| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 180 } |
| 169 | 181 |
| 170 return builder->CreateDeoptInfo(deopt_table); | 182 return builder->CreateDeoptInfo(deopt_table); |
| 171 } | 183 } |
| 172 | 184 |
| 173 | 185 |
| 174 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, | 186 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, |
| 175 intptr_t stub_ix) { | 187 intptr_t stub_ix) { |
| 176 // Calls do not need stubs, they share a deoptimization trampoline. | 188 // Calls do not need stubs, they share a deoptimization trampoline. |
| 177 ASSERT(reason() != ICData::kDeoptAtCall); | 189 ASSERT(reason() != ICData::kDeoptAtCall); |
| 178 Assembler* assem = compiler->assembler(); | 190 Assembler* assembler = compiler->assembler(); |
| 179 #define __ assem-> | 191 #define __ assembler-> |
| 180 __ Comment("%s", Name()); | 192 __ Comment("%s", Name()); |
| 181 __ Bind(entry_label()); | 193 __ Bind(entry_label()); |
| 182 if (FLAG_trap_on_deoptimization) { | 194 if (FLAG_trap_on_deoptimization) { |
| 183 __ int3(); | 195 __ int3(); |
| 184 } | 196 } |
| 185 | 197 |
| 186 ASSERT(deopt_env() != NULL); | 198 ASSERT(deopt_env() != NULL); |
| 187 __ pushl(CODE_REG); | 199 __ pushl(CODE_REG); |
| 188 __ Call(*StubCode::Deoptimize_entry()); | 200 __ Call(*StubCode::Deoptimize_entry()); |
| 189 set_pc_offset(assem->CodeSize()); | 201 set_pc_offset(assembler->CodeSize()); |
| 190 __ int3(); | 202 __ int3(); |
| 191 #undef __ | 203 #undef __ |
| 192 } | 204 } |
| 193 | 205 |
| 194 | 206 |
| 195 #define __ assembler()-> | 207 #define __ assembler()-> |
| 196 | 208 |
| 197 | 209 |
| 198 // Fall through if bool_register contains null. | 210 // Fall through if bool_register contains null. |
| 199 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, | 211 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, |
| (...skipping 1071 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); |
| 1316 // Precompilation not implemented on ia32 platform. |
| 1317 ASSERT(!Compiler::always_optimize()); |
| 1303 if (is_optimizing()) { | 1318 if (is_optimizing()) { |
| 1304 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1319 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1305 } else { | 1320 } else { |
| 1306 // Add deoptimization continuation point after the call and before the | 1321 // Add deoptimization continuation point after the call and before the |
| 1307 // arguments are removed. | 1322 // arguments are removed. |
| 1308 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1323 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
| 1309 } | 1324 } |
| 1310 __ Drop(argument_count); | 1325 __ Drop(argument_count); |
| 1311 } | 1326 } |
| 1312 | 1327 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 __ movups(reg, Address(ESP, 0)); | 1849 __ movups(reg, Address(ESP, 0)); |
| 1835 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1850 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1836 } | 1851 } |
| 1837 | 1852 |
| 1838 | 1853 |
| 1839 #undef __ | 1854 #undef __ |
| 1840 | 1855 |
| 1841 } // namespace dart | 1856 } // namespace dart |
| 1842 | 1857 |
| 1843 #endif // defined TARGET_ARCH_IA32 | 1858 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |