| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 Register instance_reg, | 217 Register instance_reg, |
| 218 Register type_arguments_reg, | 218 Register type_arguments_reg, |
| 219 Register temp_reg, | 219 Register temp_reg, |
| 220 Label* is_instance_lbl, | 220 Label* is_instance_lbl, |
| 221 Label* is_not_instance_lbl) { | 221 Label* is_not_instance_lbl) { |
| 222 ASSERT(instance_reg == R0); | 222 ASSERT(instance_reg == R0); |
| 223 ASSERT(temp_reg == kNoRegister); // Unused on ARM. | 223 ASSERT(temp_reg == kNoRegister); // Unused on ARM. |
| 224 const SubtypeTestCache& type_test_cache = | 224 const SubtypeTestCache& type_test_cache = |
| 225 SubtypeTestCache::ZoneHandle(SubtypeTestCache::New()); | 225 SubtypeTestCache::ZoneHandle(SubtypeTestCache::New()); |
| 226 StubCode* stub_code = isolate()->stub_code(); | 226 StubCode* stub_code = isolate()->stub_code(); |
| 227 __ LoadObject(R2, type_test_cache, PP); | 227 __ LoadUniqueObject(R2, type_test_cache, PP); |
| 228 if (test_kind == kTestTypeOneArg) { | 228 if (test_kind == kTestTypeOneArg) { |
| 229 ASSERT(type_arguments_reg == kNoRegister); | 229 ASSERT(type_arguments_reg == kNoRegister); |
| 230 __ LoadObject(R1, Object::null_object(), PP); | 230 __ LoadObject(R1, Object::null_object(), PP); |
| 231 __ BranchLink(&stub_code->Subtype1TestCacheLabel(), PP); | 231 __ BranchLink(&stub_code->Subtype1TestCacheLabel(), PP); |
| 232 } else if (test_kind == kTestTypeTwoArgs) { | 232 } else if (test_kind == kTestTypeTwoArgs) { |
| 233 ASSERT(type_arguments_reg == kNoRegister); | 233 ASSERT(type_arguments_reg == kNoRegister); |
| 234 __ LoadObject(R1, Object::null_object(), PP); | 234 __ LoadObject(R1, Object::null_object(), PP); |
| 235 __ BranchLink(&stub_code->Subtype2TestCacheLabel(), PP); | 235 __ BranchLink(&stub_code->Subtype2TestCacheLabel(), PP); |
| 236 } else if (test_kind == kTestTypeThreeArgs) { | 236 } else if (test_kind == kTestTypeThreeArgs) { |
| 237 ASSERT(type_arguments_reg == R1); | 237 ASSERT(type_arguments_reg == R1); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 // Generate runtime call. | 610 // Generate runtime call. |
| 611 // Load instantiator (R2) and its type arguments (R1). | 611 // Load instantiator (R2) and its type arguments (R1). |
| 612 __ ldr(R1, Address(SP, 0 * kWordSize)); | 612 __ ldr(R1, Address(SP, 0 * kWordSize)); |
| 613 __ ldr(R2, Address(SP, 1 * kWordSize)); | 613 __ ldr(R2, Address(SP, 1 * kWordSize)); |
| 614 __ PushObject(Object::null_object(), PP); // Make room for the result. | 614 __ PushObject(Object::null_object(), PP); // Make room for the result. |
| 615 __ Push(R0); // Push the instance. | 615 __ Push(R0); // Push the instance. |
| 616 __ PushObject(type, PP); // Push the type. | 616 __ PushObject(type, PP); // Push the type. |
| 617 // Push instantiator (R2) and its type arguments (R1). | 617 // Push instantiator (R2) and its type arguments (R1). |
| 618 __ Push(R2); | 618 __ Push(R2); |
| 619 __ Push(R1); | 619 __ Push(R1); |
| 620 __ LoadObject(R0, test_cache, PP); | 620 __ LoadUniqueObject(R0, test_cache, PP); |
| 621 __ Push(R0); | 621 __ Push(R0); |
| 622 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 5, locs); | 622 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 5, locs); |
| 623 // Pop the parameters supplied to the runtime entry. The result of the | 623 // Pop the parameters supplied to the runtime entry. The result of the |
| 624 // instanceof runtime call will be left as the result of the operation. | 624 // instanceof runtime call will be left as the result of the operation. |
| 625 __ Drop(5); | 625 __ Drop(5); |
| 626 if (negate_result) { | 626 if (negate_result) { |
| 627 __ Pop(R1); | 627 __ Pop(R1); |
| 628 __ LoadObject(R0, Bool::True(), PP); | 628 __ LoadObject(R0, Bool::True(), PP); |
| 629 __ CompareRegisters(R1, R0); | 629 __ CompareRegisters(R1, R0); |
| 630 __ b(&done, NE); | 630 __ b(&done, NE); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Load instantiator (R2) and its type arguments (R1). | 707 // Load instantiator (R2) and its type arguments (R1). |
| 708 __ ldr(R1, Address(SP)); | 708 __ ldr(R1, Address(SP)); |
| 709 __ ldr(R2, Address(SP, 1 * kWordSize)); | 709 __ ldr(R2, Address(SP, 1 * kWordSize)); |
| 710 __ PushObject(Object::null_object(), PP); // Make room for the result. | 710 __ PushObject(Object::null_object(), PP); // Make room for the result. |
| 711 __ Push(R0); // Push the source object. | 711 __ Push(R0); // Push the source object. |
| 712 __ PushObject(dst_type, PP); // Push the type of the destination. | 712 __ PushObject(dst_type, PP); // Push the type of the destination. |
| 713 // Push instantiator (R2) and its type arguments (R1). | 713 // Push instantiator (R2) and its type arguments (R1). |
| 714 __ Push(R2); | 714 __ Push(R2); |
| 715 __ Push(R1); | 715 __ Push(R1); |
| 716 __ PushObject(dst_name, PP); // Push the name of the destination. | 716 __ PushObject(dst_name, PP); // Push the name of the destination. |
| 717 __ LoadObject(R0, test_cache, PP); | 717 __ LoadUniqueObject(R0, test_cache, PP); |
| 718 __ Push(R0); | 718 __ Push(R0); |
| 719 GenerateRuntimeCall(token_pos, deopt_id, kTypeCheckRuntimeEntry, 6, locs); | 719 GenerateRuntimeCall(token_pos, deopt_id, kTypeCheckRuntimeEntry, 6, locs); |
| 720 // Pop the parameters supplied to the runtime entry. The result of the | 720 // Pop the parameters supplied to the runtime entry. The result of the |
| 721 // type check runtime call is the checked value. | 721 // type check runtime call is the checked value. |
| 722 __ Drop(6); | 722 __ Drop(6); |
| 723 __ Pop(R0); | 723 __ Pop(R0); |
| 724 | 724 |
| 725 __ Bind(&is_assignable); | 725 __ Bind(&is_assignable); |
| 726 // Restore instantiator (R2) and its type arguments (R1). | 726 // Restore instantiator (R2) and its type arguments (R1). |
| 727 __ Pop(R1); | 727 __ Pop(R1); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 | 1200 |
| 1201 void FlowGraphCompiler::EmitEdgeCounter() { | 1201 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1202 // We do not check for overflow when incrementing the edge counter. The | 1202 // We do not check for overflow when incrementing the edge counter. The |
| 1203 // function should normally be optimized long before the counter can | 1203 // function should normally be optimized long before the counter can |
| 1204 // overflow; and though we do not reset the counters when we optimize or | 1204 // overflow; and though we do not reset the counters when we optimize or |
| 1205 // deoptimize, there is a bound on the number of | 1205 // deoptimize, there is a bound on the number of |
| 1206 // optimization/deoptimization cycles we will attempt. | 1206 // optimization/deoptimization cycles we will attempt. |
| 1207 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); | 1207 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1208 counter.SetAt(0, Smi::Handle(Smi::New(0))); | 1208 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1209 __ Comment("Edge counter"); | 1209 __ Comment("Edge counter"); |
| 1210 __ LoadObject(R0, counter, PP); | 1210 __ LoadUniqueObject(R0, counter, PP); |
| 1211 __ LoadFieldFromOffset(TMP, R0, Array::element_offset(0), PP); | 1211 __ LoadFieldFromOffset(TMP, R0, Array::element_offset(0), PP); |
| 1212 __ add(TMP, TMP, Operand(Smi::RawValue(1))); | 1212 __ add(TMP, TMP, Operand(Smi::RawValue(1))); |
| 1213 __ StoreFieldToOffset(TMP, R0, Array::element_offset(0), PP); | 1213 __ StoreFieldToOffset(TMP, R0, Array::element_offset(0), PP); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 | 1216 |
| 1217 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1217 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
| 1218 ExternalLabel* target_label, | 1218 ExternalLabel* target_label, |
| 1219 const ICData& ic_data, | 1219 const ICData& ic_data, |
| 1220 intptr_t argument_count, | 1220 intptr_t argument_count, |
| 1221 intptr_t deopt_id, | 1221 intptr_t deopt_id, |
| 1222 intptr_t token_pos, | 1222 intptr_t token_pos, |
| 1223 LocationSummary* locs) { | 1223 LocationSummary* locs) { |
| 1224 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); | 1224 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); |
| 1225 // Each ICData propagated from unoptimized to optimized code contains the | 1225 // Each ICData propagated from unoptimized to optimized code contains the |
| 1226 // function that corresponds to the Dart function of that IC call. Due | 1226 // function that corresponds to the Dart function of that IC call. Due |
| 1227 // to inlining in optimized code, that function may not correspond to the | 1227 // to inlining in optimized code, that function may not correspond to the |
| 1228 // top-level function (parsed_function().function()) which could be | 1228 // top-level function (parsed_function().function()) which could be |
| 1229 // reoptimized and which counter needs to be incremented. | 1229 // reoptimized and which counter needs to be incremented. |
| 1230 // Pass the function explicitly, it is used in IC stub. | 1230 // Pass the function explicitly, it is used in IC stub. |
| 1231 | 1231 |
| 1232 __ LoadObject(R6, parsed_function().function(), PP); | 1232 __ LoadObject(R6, parsed_function().function(), PP); |
| 1233 __ LoadObject(R5, ic_data, PP); | 1233 __ LoadUniqueObject(R5, ic_data, PP); |
| 1234 GenerateDartCall(deopt_id, | 1234 GenerateDartCall(deopt_id, |
| 1235 token_pos, | 1235 token_pos, |
| 1236 target_label, | 1236 target_label, |
| 1237 RawPcDescriptors::kIcCall, | 1237 RawPcDescriptors::kIcCall, |
| 1238 locs); | 1238 locs); |
| 1239 __ Drop(argument_count); | 1239 __ Drop(argument_count); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 | 1242 |
| 1243 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, | 1243 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, |
| 1244 const ICData& ic_data, | 1244 const ICData& ic_data, |
| 1245 intptr_t argument_count, | 1245 intptr_t argument_count, |
| 1246 intptr_t deopt_id, | 1246 intptr_t deopt_id, |
| 1247 intptr_t token_pos, | 1247 intptr_t token_pos, |
| 1248 LocationSummary* locs) { | 1248 LocationSummary* locs) { |
| 1249 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); | 1249 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); |
| 1250 __ LoadObject(R5, ic_data, PP); | 1250 __ LoadUniqueObject(R5, ic_data, PP); |
| 1251 GenerateDartCall(deopt_id, | 1251 GenerateDartCall(deopt_id, |
| 1252 token_pos, | 1252 token_pos, |
| 1253 target_label, | 1253 target_label, |
| 1254 RawPcDescriptors::kIcCall, | 1254 RawPcDescriptors::kIcCall, |
| 1255 locs); | 1255 locs); |
| 1256 __ Drop(argument_count); | 1256 __ Drop(argument_count); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 | 1259 |
| 1260 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1260 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1847 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1848 __ PopDouble(reg); | 1848 __ PopDouble(reg); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 | 1851 |
| 1852 #undef __ | 1852 #undef __ |
| 1853 | 1853 |
| 1854 } // namespace dart | 1854 } // namespace dart |
| 1855 | 1855 |
| 1856 #endif // defined TARGET_ARCH_ARM64 | 1856 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |