OLD | NEW |
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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "vm/stub_code.h" | 21 #include "vm/stub_code.h" |
22 #include "vm/symbols.h" | 22 #include "vm/symbols.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 DECLARE_FLAG(bool, enable_simd_inline); | 27 DECLARE_FLAG(bool, enable_simd_inline); |
28 DECLARE_FLAG(bool, use_megamorphic_stub); | 28 DECLARE_FLAG(bool, use_megamorphic_stub); |
29 | 29 |
30 | 30 |
| 31 void MegamorphicSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 32 Assembler* assembler = compiler->assembler(); |
| 33 #define __ assembler-> |
| 34 __ Bind(entry_label()); |
| 35 __ Comment("MegamorphicSlowPath"); |
| 36 compiler->EmitMegamorphicInstanceCall(ic_data_, argument_count_, deopt_id_, |
| 37 token_pos_, locs_, try_index_); |
| 38 __ b(exit_label()); |
| 39 #undef __ |
| 40 } |
| 41 |
| 42 |
31 FlowGraphCompiler::~FlowGraphCompiler() { | 43 FlowGraphCompiler::~FlowGraphCompiler() { |
32 // BlockInfos are zone-allocated, so their destructors are not called. | 44 // BlockInfos are zone-allocated, so their destructors are not called. |
33 // Verify the labels explicitly here. | 45 // Verify the labels explicitly here. |
34 for (int i = 0; i < block_info_.length(); ++i) { | 46 for (int i = 0; i < block_info_.length(); ++i) { |
35 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 47 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
36 } | 48 } |
37 } | 49 } |
38 | 50 |
39 | 51 |
40 bool FlowGraphCompiler::SupportsUnboxedDoubles() { | 52 bool FlowGraphCompiler::SupportsUnboxedDoubles() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 177 } |
166 | 178 |
167 return builder->CreateDeoptInfo(deopt_table); | 179 return builder->CreateDeoptInfo(deopt_table); |
168 } | 180 } |
169 | 181 |
170 | 182 |
171 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, | 183 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, |
172 intptr_t stub_ix) { | 184 intptr_t stub_ix) { |
173 // Calls do not need stubs, they share a deoptimization trampoline. | 185 // Calls do not need stubs, they share a deoptimization trampoline. |
174 ASSERT(reason() != ICData::kDeoptAtCall); | 186 ASSERT(reason() != ICData::kDeoptAtCall); |
175 Assembler* assem = compiler->assembler(); | 187 Assembler* assembler = compiler->assembler(); |
176 #define __ assem-> | 188 #define __ assembler-> |
177 __ Comment("%s", Name()); | 189 __ Comment("%s", Name()); |
178 __ Bind(entry_label()); | 190 __ Bind(entry_label()); |
179 if (FLAG_trap_on_deoptimization) { | 191 if (FLAG_trap_on_deoptimization) { |
180 __ brk(0); | 192 __ brk(0); |
181 } | 193 } |
182 | 194 |
183 ASSERT(deopt_env() != NULL); | 195 ASSERT(deopt_env() != NULL); |
184 __ Push(CODE_REG); | 196 __ Push(CODE_REG); |
185 __ BranchLink(*StubCode::Deoptimize_entry()); | 197 __ BranchLink(*StubCode::Deoptimize_entry()); |
186 set_pc_offset(assem->CodeSize()); | 198 set_pc_offset(assembler->CodeSize()); |
187 #undef __ | 199 #undef __ |
188 } | 200 } |
189 | 201 |
190 | 202 |
191 #define __ assembler()-> | 203 #define __ assembler()-> |
192 | 204 |
193 | 205 |
194 // Fall through if bool_register contains null. | 206 // Fall through if bool_register contains null. |
195 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, | 207 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, |
196 Label* is_true, | 208 Label* is_true, |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 locs); | 1253 locs); |
1242 __ Drop(argument_count); | 1254 __ Drop(argument_count); |
1243 } | 1255 } |
1244 | 1256 |
1245 | 1257 |
1246 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1258 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1247 const ICData& ic_data, | 1259 const ICData& ic_data, |
1248 intptr_t argument_count, | 1260 intptr_t argument_count, |
1249 intptr_t deopt_id, | 1261 intptr_t deopt_id, |
1250 intptr_t token_pos, | 1262 intptr_t token_pos, |
1251 LocationSummary* locs) { | 1263 LocationSummary* locs, |
| 1264 intptr_t try_index) { |
1252 const String& name = String::Handle(zone(), ic_data.target_name()); | 1265 const String& name = String::Handle(zone(), ic_data.target_name()); |
1253 const Array& arguments_descriptor = | 1266 const Array& arguments_descriptor = |
1254 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); | 1267 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); |
1255 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1268 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
1256 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), | 1269 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), |
1257 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); | 1270 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
1258 | 1271 |
1259 __ Comment("MegamorphicCall"); | 1272 __ Comment("MegamorphicCall"); |
1260 __ LoadFromOffset(R0, SP, (argument_count - 1) * kWordSize); | 1273 __ LoadFromOffset(R0, SP, (argument_count - 1) * kWordSize); |
1261 __ LoadObject(R5, cache); | 1274 __ LoadObject(R5, cache); |
1262 if (FLAG_use_megamorphic_stub) { | 1275 if (FLAG_use_megamorphic_stub) { |
1263 __ BranchLink(*StubCode::MegamorphicLookup_entry()); | 1276 __ BranchLink(*StubCode::MegamorphicLookup_entry()); |
1264 } else { | 1277 } else { |
1265 StubCode::EmitMegamorphicLookup(assembler()); | 1278 StubCode::EmitMegamorphicLookup(assembler()); |
1266 } | 1279 } |
1267 __ blr(R1); | 1280 __ blr(R1); |
1268 | 1281 |
1269 AddCurrentDescriptor(RawPcDescriptors::kOther, | |
1270 Thread::kNoDeoptId, token_pos); | |
1271 RecordSafepoint(locs); | 1282 RecordSafepoint(locs); |
1272 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1283 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1273 if (is_optimizing()) { | 1284 if (Compiler::always_optimize()) { |
| 1285 // Megamorphic calls may occur in slow path stubs. |
| 1286 // If valid use try_index argument. |
| 1287 if (try_index == CatchClauseNode::kInvalidTryIndex) { |
| 1288 try_index = CurrentTryIndex(); |
| 1289 } |
| 1290 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther, |
| 1291 assembler()->CodeSize(), |
| 1292 Thread::kNoDeoptId, |
| 1293 token_pos, |
| 1294 try_index); |
| 1295 } else if (is_optimizing()) { |
| 1296 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1297 Thread::kNoDeoptId, token_pos); |
1274 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1298 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
1275 } else { | 1299 } else { |
| 1300 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1301 Thread::kNoDeoptId, token_pos); |
1276 // Add deoptimization continuation point after the call and before the | 1302 // Add deoptimization continuation point after the call and before the |
1277 // arguments are removed. | 1303 // arguments are removed. |
1278 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1304 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1279 } | 1305 } |
1280 __ Drop(argument_count); | 1306 __ Drop(argument_count); |
1281 } | 1307 } |
1282 | 1308 |
1283 | 1309 |
1284 void FlowGraphCompiler::EmitSwitchableInstanceCall( | 1310 void FlowGraphCompiler::EmitSwitchableInstanceCall( |
1285 const ICData& ic_data, | 1311 const ICData& ic_data, |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1883 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
1858 __ PopDouble(reg); | 1884 __ PopDouble(reg); |
1859 } | 1885 } |
1860 | 1886 |
1861 | 1887 |
1862 #undef __ | 1888 #undef __ |
1863 | 1889 |
1864 } // namespace dart | 1890 } // namespace dart |
1865 | 1891 |
1866 #endif // defined TARGET_ARCH_ARM64 | 1892 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |