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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
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" |
11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
13 #include "vm/deopt_instructions.h" | 13 #include "vm/deopt_instructions.h" |
14 #include "vm/il_printer.h" | 14 #include "vm/il_printer.h" |
15 #include "vm/instructions.h" | 15 #include "vm/instructions.h" |
16 #include "vm/locations.h" | 16 #include "vm/locations.h" |
17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
18 #include "vm/parser.h" | 18 #include "vm/parser.h" |
19 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
20 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
21 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
25 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); | 25 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); |
26 DECLARE_FLAG(bool, use_megamorphic_stub); | 26 DECLARE_FLAG(bool, use_megamorphic_stub); |
27 | 27 |
28 | 28 |
| 29 void MegamorphicSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 30 Assembler* assembler = compiler->assembler(); |
| 31 #define __ assembler-> |
| 32 __ Bind(entry_label()); |
| 33 __ Comment("MegamorphicSlowPath"); |
| 34 compiler->EmitMegamorphicInstanceCall(ic_data_, argument_count_, deopt_id_, |
| 35 token_pos_, locs_, try_index_); |
| 36 __ b(exit_label()); |
| 37 #undef __ |
| 38 } |
| 39 |
| 40 |
29 FlowGraphCompiler::~FlowGraphCompiler() { | 41 FlowGraphCompiler::~FlowGraphCompiler() { |
30 // BlockInfos are zone-allocated, so their destructors are not called. | 42 // BlockInfos are zone-allocated, so their destructors are not called. |
31 // Verify the labels explicitly here. | 43 // Verify the labels explicitly here. |
32 for (int i = 0; i < block_info_.length(); ++i) { | 44 for (int i = 0; i < block_info_.length(); ++i) { |
33 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 45 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
34 } | 46 } |
35 } | 47 } |
36 | 48 |
37 | 49 |
38 bool FlowGraphCompiler::SupportsUnboxedDoubles() { | 50 bool FlowGraphCompiler::SupportsUnboxedDoubles() { |
(...skipping 126 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 __ break_(0); | 192 __ break_(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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 __ Comment("InstanceCall return"); | 1274 __ Comment("InstanceCall return"); |
1263 __ Drop(argument_count); | 1275 __ Drop(argument_count); |
1264 } | 1276 } |
1265 | 1277 |
1266 | 1278 |
1267 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1279 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1268 const ICData& ic_data, | 1280 const ICData& ic_data, |
1269 intptr_t argument_count, | 1281 intptr_t argument_count, |
1270 intptr_t deopt_id, | 1282 intptr_t deopt_id, |
1271 intptr_t token_pos, | 1283 intptr_t token_pos, |
1272 LocationSummary* locs) { | 1284 LocationSummary* locs, |
| 1285 intptr_t try_index) { |
1273 const String& name = String::Handle(zone(), ic_data.target_name()); | 1286 const String& name = String::Handle(zone(), ic_data.target_name()); |
1274 const Array& arguments_descriptor = | 1287 const Array& arguments_descriptor = |
1275 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); | 1288 Array::ZoneHandle(zone(), ic_data.arguments_descriptor()); |
1276 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1289 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
1277 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), | 1290 const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(zone(), |
1278 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); | 1291 MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
1279 | 1292 |
1280 __ Comment("MegamorphicCall"); | 1293 __ Comment("MegamorphicCall"); |
1281 __ lw(T0, Address(SP, (argument_count - 1) * kWordSize)); | 1294 __ lw(T0, Address(SP, (argument_count - 1) * kWordSize)); |
1282 __ LoadObject(S5, cache); | 1295 __ LoadObject(S5, cache); |
1283 if (FLAG_use_megamorphic_stub) { | 1296 if (FLAG_use_megamorphic_stub) { |
1284 __ BranchLink(*StubCode::MegamorphicLookup_entry()); | 1297 __ BranchLink(*StubCode::MegamorphicLookup_entry()); |
1285 } else { | 1298 } else { |
1286 StubCode::EmitMegamorphicLookup(assembler()); | 1299 StubCode::EmitMegamorphicLookup(assembler()); |
1287 } | 1300 } |
1288 __ jalr(T1); | 1301 __ jalr(T1); |
1289 | 1302 |
1290 AddCurrentDescriptor(RawPcDescriptors::kOther, | |
1291 Thread::kNoDeoptId, token_pos); | |
1292 RecordSafepoint(locs); | 1303 RecordSafepoint(locs); |
1293 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1304 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1294 if (is_optimizing()) { | 1305 if (Compiler::always_optimize()) { |
| 1306 // Megamorphic calls may occur in slow path stubs. |
| 1307 // If valid use try_index argument. |
| 1308 if (try_index == CatchClauseNode::kInvalidTryIndex) { |
| 1309 try_index = CurrentTryIndex(); |
| 1310 } |
| 1311 pc_descriptors_list()->AddDescriptor(RawPcDescriptors::kOther, |
| 1312 assembler()->CodeSize(), |
| 1313 Thread::kNoDeoptId, |
| 1314 token_pos, |
| 1315 try_index); |
| 1316 } else if (is_optimizing()) { |
| 1317 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1318 Thread::kNoDeoptId, token_pos); |
1295 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1319 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
1296 } else { | 1320 } else { |
| 1321 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1322 Thread::kNoDeoptId, token_pos); |
1297 // Add deoptimization continuation point after the call and before the | 1323 // Add deoptimization continuation point after the call and before the |
1298 // arguments are removed. | 1324 // arguments are removed. |
1299 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1325 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1300 } | 1326 } |
1301 __ Drop(argument_count); | 1327 __ Drop(argument_count); |
1302 } | 1328 } |
1303 | 1329 |
1304 | 1330 |
1305 void FlowGraphCompiler::EmitSwitchableInstanceCall( | 1331 void FlowGraphCompiler::EmitSwitchableInstanceCall( |
1306 const ICData& ic_data, | 1332 const ICData& ic_data, |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 __ AddImmediate(SP, kDoubleSize); | 1905 __ AddImmediate(SP, kDoubleSize); |
1880 } | 1906 } |
1881 | 1907 |
1882 | 1908 |
1883 #undef __ | 1909 #undef __ |
1884 | 1910 |
1885 | 1911 |
1886 } // namespace dart | 1912 } // namespace dart |
1887 | 1913 |
1888 #endif // defined TARGET_ARCH_MIPS | 1914 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |