| 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" |
| 11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 12 #include "vm/cpu.h" | 12 #include "vm/cpu.h" |
| 13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 14 #include "vm/deopt_instructions.h" | 14 #include "vm/deopt_instructions.h" |
| 15 #include "vm/il_printer.h" | 15 #include "vm/il_printer.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, enable_simd_inline); | 26 DECLARE_FLAG(bool, enable_simd_inline); |
| 27 DECLARE_FLAG(bool, use_megamorphic_stub); |
| 27 | 28 |
| 28 | 29 |
| 29 FlowGraphCompiler::~FlowGraphCompiler() { | 30 FlowGraphCompiler::~FlowGraphCompiler() { |
| 30 // BlockInfos are zone-allocated, so their destructors are not called. | 31 // BlockInfos are zone-allocated, so their destructors are not called. |
| 31 // Verify the labels explicitly here. | 32 // Verify the labels explicitly here. |
| 32 for (int i = 0; i < block_info_.length(); ++i) { | 33 for (int i = 0; i < block_info_.length(); ++i) { |
| 33 ASSERT(!block_info_[i]->jump_label()->IsLinked()); | 34 ASSERT(!block_info_[i]->jump_label()->IsLinked()); |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 intptr_t token_pos, | 1264 intptr_t token_pos, |
| 1264 LocationSummary* locs) { | 1265 LocationSummary* locs) { |
| 1265 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 1266 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
| 1266 const String& name = String::Handle(ic_data.target_name()); | 1267 const String& name = String::Handle(ic_data.target_name()); |
| 1267 const Array& arguments_descriptor = | 1268 const Array& arguments_descriptor = |
| 1268 Array::ZoneHandle(ic_data.arguments_descriptor()); | 1269 Array::ZoneHandle(ic_data.arguments_descriptor()); |
| 1269 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); | 1270 ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0)); |
| 1270 const MegamorphicCache& cache = | 1271 const MegamorphicCache& cache = |
| 1271 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 1272 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
| 1272 __ LoadFromOffset(R0, SP, (argument_count - 1) * kWordSize, PP); | 1273 __ LoadFromOffset(R0, SP, (argument_count - 1) * kWordSize, PP); |
| 1273 __ LoadTaggedClassIdMayBeSmi(R0, R0); | 1274 __ LoadObject(R1, cache, PP); |
| 1274 | 1275 |
| 1275 // R0: class ID of the receiver (smi). | 1276 if (FLAG_use_megamorphic_stub) { |
| 1276 __ LoadObject(R1, cache, PP); | 1277 StubCode* stub_code = isolate()->stub_code(); |
| 1277 __ LoadFieldFromOffset(R2, R1, MegamorphicCache::buckets_offset(), PP); | 1278 __ BranchLink(&stub_code->MegamorphicLookupLabel(), PP); |
| 1278 __ LoadFieldFromOffset(R1, R1, MegamorphicCache::mask_offset(), PP); | 1279 } else { |
| 1279 // R2: cache buckets array. | 1280 // R0: class ID of the receiver (smi). |
| 1280 // R1: mask. | 1281 __ LoadTaggedClassIdMayBeSmi(R0, R0); |
| 1281 __ mov(R3, R0); | 1282 __ LoadFieldFromOffset(R2, R1, MegamorphicCache::buckets_offset(), PP); |
| 1283 __ LoadFieldFromOffset(R1, R1, MegamorphicCache::mask_offset(), PP); |
| 1284 // R2: cache buckets array. |
| 1285 // R1: mask. |
| 1286 __ mov(R3, R0); |
| 1282 | 1287 |
| 1283 Label loop, update, call_target_function; | 1288 Label loop, update, call_target_function; |
| 1284 __ b(&loop); | 1289 __ b(&loop); |
| 1285 | 1290 |
| 1286 __ Bind(&update); | 1291 __ Bind(&update); |
| 1287 __ add(R3, R3, Operand(Smi::RawValue(1))); | 1292 __ add(R3, R3, Operand(Smi::RawValue(1))); |
| 1288 __ Bind(&loop); | 1293 __ Bind(&loop); |
| 1289 __ and_(R3, R3, Operand(R1)); | 1294 __ and_(R3, R3, Operand(R1)); |
| 1290 const intptr_t base = Array::data_offset(); | 1295 const intptr_t base = Array::data_offset(); |
| 1291 // R3 is smi tagged, but table entries are 16 bytes, so LSL 3. | 1296 // R3 is smi tagged, but table entries are 16 bytes, so LSL 3. |
| 1292 __ add(TMP, R2, Operand(R3, LSL, 3)); | 1297 __ add(TMP, R2, Operand(R3, LSL, 3)); |
| 1293 __ LoadFieldFromOffset(R4, TMP, base, PP); | 1298 __ LoadFieldFromOffset(R4, TMP, base, PP); |
| 1294 | 1299 |
| 1295 ASSERT(kIllegalCid == 0); | 1300 ASSERT(kIllegalCid == 0); |
| 1296 __ tst(R4, Operand(R4)); | 1301 __ tst(R4, Operand(R4)); |
| 1297 __ b(&call_target_function, EQ); | 1302 __ b(&call_target_function, EQ); |
| 1298 __ CompareRegisters(R4, R0); | 1303 __ CompareRegisters(R4, R0); |
| 1299 __ b(&update, NE); | 1304 __ b(&update, NE); |
| 1300 | 1305 |
| 1301 __ Bind(&call_target_function); | 1306 __ Bind(&call_target_function); |
| 1302 // Call the target found in the cache. For a class id match, this is a | 1307 // Call the target found in the cache. For a class id match, this is a |
| 1303 // proper target for the given name and arguments descriptor. If the | 1308 // proper target for the given name and arguments descriptor. If the |
| 1304 // illegal class id was found, the target is a cache miss handler that can | 1309 // illegal class id was found, the target is a cache miss handler that can |
| 1305 // be invoked as a normal Dart function. | 1310 // be invoked as a normal Dart function. |
| 1306 __ add(TMP, R2, Operand(R3, LSL, 3)); | 1311 __ add(TMP, R2, Operand(R3, LSL, 3)); |
| 1307 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP); | 1312 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP); |
| 1308 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP); | 1313 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP); |
| 1314 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); |
| 1315 } |
| 1309 __ LoadObject(R5, ic_data, PP); | 1316 __ LoadObject(R5, ic_data, PP); |
| 1310 __ LoadObject(R4, arguments_descriptor, PP); | 1317 __ LoadObject(R4, arguments_descriptor, PP); |
| 1311 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); | |
| 1312 __ blr(R1); | 1318 __ blr(R1); |
| 1313 AddCurrentDescriptor(RawPcDescriptors::kOther, | 1319 AddCurrentDescriptor(RawPcDescriptors::kOther, |
| 1314 Isolate::kNoDeoptId, token_pos); | 1320 Isolate::kNoDeoptId, token_pos); |
| 1315 RecordSafepoint(locs); | 1321 RecordSafepoint(locs); |
| 1316 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); | 1322 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); |
| 1317 if (is_optimizing()) { | 1323 if (is_optimizing()) { |
| 1318 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1324 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1319 } else { | 1325 } else { |
| 1320 // Add deoptimization continuation point after the call and before the | 1326 // Add deoptimization continuation point after the call and before the |
| 1321 // arguments are removed. | 1327 // arguments are removed. |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1835 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1830 __ PopDouble(reg); | 1836 __ PopDouble(reg); |
| 1831 } | 1837 } |
| 1832 | 1838 |
| 1833 | 1839 |
| 1834 #undef __ | 1840 #undef __ |
| 1835 | 1841 |
| 1836 } // namespace dart | 1842 } // namespace dart |
| 1837 | 1843 |
| 1838 #endif // defined TARGET_ARCH_ARM64 | 1844 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |