| 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/locations.h" | 15 #include "vm/locations.h" |
| 16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
| 17 #include "vm/parser.h" | 17 #include "vm/parser.h" |
| 18 #include "vm/stack_frame.h" | 18 #include "vm/stack_frame.h" |
| 19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
| 20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); | 24 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); |
| 25 DECLARE_FLAG(bool, enable_type_checks); | 25 DECLARE_FLAG(bool, enable_type_checks); |
| 26 DECLARE_FLAG(bool, use_megamorphic_stub); |
| 26 | 27 |
| 27 | 28 |
| 28 FlowGraphCompiler::~FlowGraphCompiler() { | 29 FlowGraphCompiler::~FlowGraphCompiler() { |
| 29 // BlockInfos are zone-allocated, so their destructors are not called. | 30 // BlockInfos are zone-allocated, so their destructors are not called. |
| 30 // Verify the labels explicitly here. | 31 // Verify the labels explicitly here. |
| 31 for (int i = 0; i < block_info_.length(); ++i) { | 32 for (int i = 0; i < block_info_.length(); ++i) { |
| 32 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 33 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 intptr_t token_pos, | 1286 intptr_t token_pos, |
| 1286 LocationSummary* locs) { | 1287 LocationSummary* locs) { |
| 1287 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 1288 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
| 1288 const String& name = String::Handle(ic_data.target_name()); | 1289 const String& name = String::Handle(ic_data.target_name()); |
| 1289 const Array& arguments_descriptor = | 1290 const Array& arguments_descriptor = |
| 1290 Array::ZoneHandle(ic_data.arguments_descriptor()); | 1291 Array::ZoneHandle(ic_data.arguments_descriptor()); |
| 1291 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1292 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
| 1292 const MegamorphicCache& cache = | 1293 const MegamorphicCache& cache = |
| 1293 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 1294 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
| 1294 __ Comment("MegamorphicInstanceCall"); | 1295 __ Comment("MegamorphicInstanceCall"); |
| 1295 __ lw(T0, Address(SP, (argument_count - 1) * kWordSize)); | 1296 const Register receiverR = T0; |
| 1296 __ LoadTaggedClassIdMayBeSmi(T0, T0); | 1297 const Register cacheR = T1; |
| 1298 const Register targetR = T1; |
| 1299 __ lw(receiverR, Address(SP, (argument_count - 1) * kWordSize)); |
| 1300 __ LoadObject(cacheR, cache); |
| 1297 | 1301 |
| 1298 // T0: class ID of the receiver (smi). | 1302 if (FLAG_use_megamorphic_stub) { |
| 1299 __ LoadObject(T1, cache); | 1303 StubCode* stub_code = isolate()->stub_code(); |
| 1300 __ lw(T2, FieldAddress(T1, MegamorphicCache::buckets_offset())); | 1304 __ BranchLink(&stub_code->MegamorphicLookupLabel()); |
| 1301 __ lw(T1, FieldAddress(T1, MegamorphicCache::mask_offset())); | 1305 } else { |
| 1302 // T2: cache buckets array. | 1306 StubCode::EmitMegamorphicLookup(assembler(), receiverR, cacheR, targetR); |
| 1303 // T1: mask. | 1307 } |
| 1304 __ mov(T3, T0); | |
| 1305 | |
| 1306 Label loop, update, call_target_function; | |
| 1307 __ b(&loop); | |
| 1308 | |
| 1309 __ Bind(&update); | |
| 1310 __ addiu(T3, T3, Immediate(Smi::RawValue(1))); | |
| 1311 __ Bind(&loop); | |
| 1312 __ and_(T3, T3, T1); | |
| 1313 const intptr_t base = Array::data_offset(); | |
| 1314 // T3 is smi tagged, but table entries are two words, so LSL 2. | |
| 1315 __ sll(TMP, T3, 2); | |
| 1316 __ addu(TMP, T2, TMP); | |
| 1317 __ lw(T4, FieldAddress(TMP, base)); | |
| 1318 | |
| 1319 ASSERT(kIllegalCid == 0); | |
| 1320 __ beq(T4, ZR, &call_target_function); | |
| 1321 __ bne(T4, T0, &update); | |
| 1322 | |
| 1323 __ Bind(&call_target_function); | |
| 1324 // Call the target found in the cache. For a class id match, this is a | |
| 1325 // proper target for the given name and arguments descriptor. If the | |
| 1326 // illegal class id was found, the target is a cache miss handler that can | |
| 1327 // be invoked as a normal Dart function. | |
| 1328 __ sll(T1, T3, 2); | |
| 1329 __ addu(T1, T2, T1); | |
| 1330 __ lw(T0, FieldAddress(T1, base + kWordSize)); | |
| 1331 | |
| 1332 __ lw(T1, FieldAddress(T0, Function::instructions_offset())); | |
| 1333 __ LoadObject(S5, ic_data); | 1308 __ LoadObject(S5, ic_data); |
| 1334 __ LoadObject(S4, arguments_descriptor); | 1309 __ LoadObject(S4, arguments_descriptor); |
| 1335 __ AddImmediate(T1, Instructions::HeaderSize() - kHeapObjectTag); | 1310 __ jalr(targetR); |
| 1336 __ jalr(T1); | |
| 1337 AddCurrentDescriptor(RawPcDescriptors::kOther, | 1311 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1338 Isolate::kNoDeoptId, token_pos); | 1312 Isolate::kNoDeoptId, token_pos); |
| 1339 RecordSafepoint(locs); | 1313 RecordSafepoint(locs); |
| 1340 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); | 1314 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); |
| 1341 if (is_optimizing()) { | 1315 if (is_optimizing()) { |
| 1342 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1316 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1343 } else { | 1317 } else { |
| 1344 // Add deoptimization continuation point after the call and before the | 1318 // Add deoptimization continuation point after the call and before the |
| 1345 // arguments are removed. | 1319 // arguments are removed. |
| 1346 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1320 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 __ AddImmediate(SP, kDoubleSize); | 1827 __ AddImmediate(SP, kDoubleSize); |
| 1854 } | 1828 } |
| 1855 | 1829 |
| 1856 | 1830 |
| 1857 #undef __ | 1831 #undef __ |
| 1858 | 1832 |
| 1859 | 1833 |
| 1860 } // namespace dart | 1834 } // namespace dart |
| 1861 | 1835 |
| 1862 #endif // defined TARGET_ARCH_MIPS | 1836 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |