| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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/symbols.h" | 21 #include "vm/symbols.h" |
| 22 #include "vm/verified_memory.h" | 22 #include "vm/verified_memory.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 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); | 27 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); |
| 28 DEFINE_FLAG(bool, unbox_doubles, true, "Optimize double arithmetic."); | 28 DEFINE_FLAG(bool, unbox_doubles, true, "Optimize double arithmetic."); |
| 29 DECLARE_FLAG(bool, enable_type_checks); | 29 DECLARE_FLAG(bool, enable_type_checks); |
| 30 DECLARE_FLAG(bool, enable_simd_inline); | 30 DECLARE_FLAG(bool, enable_simd_inline); |
| 31 DECLARE_FLAG(bool, use_megamorphic_stub); |
| 31 | 32 |
| 32 | 33 |
| 33 FlowGraphCompiler::~FlowGraphCompiler() { | 34 FlowGraphCompiler::~FlowGraphCompiler() { |
| 34 // BlockInfos are zone-allocated, so their destructors are not called. | 35 // BlockInfos are zone-allocated, so their destructors are not called. |
| 35 // Verify the labels explicitly here. | 36 // Verify the labels explicitly here. |
| 36 for (int i = 0; i < block_info_.length(); ++i) { | 37 for (int i = 0; i < block_info_.length(); ++i) { |
| 37 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 38 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 intptr_t deopt_id, | 1282 intptr_t deopt_id, |
| 1282 intptr_t token_pos, | 1283 intptr_t token_pos, |
| 1283 LocationSummary* locs) { | 1284 LocationSummary* locs) { |
| 1284 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 1285 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
| 1285 const String& name = String::Handle(ic_data.target_name()); | 1286 const String& name = String::Handle(ic_data.target_name()); |
| 1286 const Array& arguments_descriptor = | 1287 const Array& arguments_descriptor = |
| 1287 Array::ZoneHandle(ic_data.arguments_descriptor()); | 1288 Array::ZoneHandle(ic_data.arguments_descriptor()); |
| 1288 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1289 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
| 1289 const MegamorphicCache& cache = | 1290 const MegamorphicCache& cache = |
| 1290 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 1291 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
| 1291 __ LoadFromOffset(kWord, R0, SP, (argument_count - 1) * kWordSize); | 1292 const Register receiverR = R0; |
| 1292 __ LoadTaggedClassIdMayBeSmi(R0, R0); | 1293 const Register cacheR = R1; |
| 1294 const Register targetR = R1; |
| 1295 __ LoadFromOffset(kWord, receiverR, SP, (argument_count - 1) * kWordSize); |
| 1296 __ LoadObject(cacheR, cache); |
| 1293 | 1297 |
| 1294 // R0: class ID of the receiver (smi). | 1298 if (FLAG_use_megamorphic_stub) { |
| 1295 __ LoadObject(R1, cache); | 1299 StubCode* stub_code = isolate()->stub_code(); |
| 1296 __ ldr(R2, FieldAddress(R1, MegamorphicCache::buckets_offset())); | 1300 __ BranchLink(&stub_code->MegamorphicLookupLabel()); |
| 1297 __ ldr(R1, FieldAddress(R1, MegamorphicCache::mask_offset())); | 1301 } else { |
| 1298 // R2: cache buckets array. | 1302 StubCode::EmitMegamorphicLookup(assembler(), receiverR, cacheR, targetR); |
| 1299 // R1: mask. | 1303 } |
| 1300 __ mov(R3, Operand(R0)); | |
| 1301 | |
| 1302 Label loop, update, call_target_function; | |
| 1303 __ b(&loop); | |
| 1304 | |
| 1305 __ Bind(&update); | |
| 1306 __ add(R3, R3, Operand(Smi::RawValue(1))); | |
| 1307 __ Bind(&loop); | |
| 1308 __ and_(R3, R3, Operand(R1)); | |
| 1309 const intptr_t base = Array::data_offset(); | |
| 1310 // R3 is smi tagged, but table entries are two words, so LSL 2. | |
| 1311 __ add(IP, R2, Operand(R3, LSL, 2)); | |
| 1312 __ ldr(R4, FieldAddress(IP, base)); | |
| 1313 | |
| 1314 ASSERT(kIllegalCid == 0); | |
| 1315 __ tst(R4, Operand(R4)); | |
| 1316 __ b(&call_target_function, EQ); | |
| 1317 __ cmp(R4, Operand(R0)); | |
| 1318 __ b(&update, NE); | |
| 1319 | |
| 1320 __ Bind(&call_target_function); | |
| 1321 // Call the target found in the cache. For a class id match, this is a | |
| 1322 // proper target for the given name and arguments descriptor. If the | |
| 1323 // illegal class id was found, the target is a cache miss handler that can | |
| 1324 // be invoked as a normal Dart function. | |
| 1325 __ add(IP, R2, Operand(R3, LSL, 2)); | |
| 1326 __ ldr(R0, FieldAddress(IP, base + kWordSize)); | |
| 1327 __ ldr(R1, FieldAddress(R0, Function::instructions_offset())); | |
| 1328 __ LoadObject(R5, ic_data); | 1304 __ LoadObject(R5, ic_data); |
| 1329 __ LoadObject(R4, arguments_descriptor); | 1305 __ LoadObject(R4, arguments_descriptor); |
| 1330 __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag); | 1306 __ blx(targetR); |
| 1331 __ blx(R1); | |
| 1332 AddCurrentDescriptor(RawPcDescriptors::kOther, | 1307 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1333 Isolate::kNoDeoptId, token_pos); | 1308 Isolate::kNoDeoptId, token_pos); |
| 1334 RecordSafepoint(locs); | 1309 RecordSafepoint(locs); |
| 1335 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); | 1310 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); |
| 1336 if (is_optimizing()) { | 1311 if (is_optimizing()) { |
| 1337 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1312 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1338 } else { | 1313 } else { |
| 1339 // Add deoptimization continuation point after the call and before the | 1314 // Add deoptimization continuation point after the call and before the |
| 1340 // arguments are removed. | 1315 // arguments are removed. |
| 1341 AddCurrentDescriptor(RawPcDescriptors::kDeopt, | 1316 AddCurrentDescriptor(RawPcDescriptors::kDeopt, |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 DRegister dreg = EvenDRegisterOf(reg); | 1858 DRegister dreg = EvenDRegisterOf(reg); |
| 1884 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1859 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
| 1885 } | 1860 } |
| 1886 | 1861 |
| 1887 | 1862 |
| 1888 #undef __ | 1863 #undef __ |
| 1889 | 1864 |
| 1890 } // namespace dart | 1865 } // namespace dart |
| 1891 | 1866 |
| 1892 #endif // defined TARGET_ARCH_ARM | 1867 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |