| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 Register instance_reg, | 230 Register instance_reg, |
| 231 Register type_arguments_reg, | 231 Register type_arguments_reg, |
| 232 Register temp_reg, | 232 Register temp_reg, |
| 233 Label* is_instance_lbl, | 233 Label* is_instance_lbl, |
| 234 Label* is_not_instance_lbl) { | 234 Label* is_not_instance_lbl) { |
| 235 ASSERT(instance_reg == R0); | 235 ASSERT(instance_reg == R0); |
| 236 ASSERT(temp_reg == kNoRegister); // Unused on ARM. | 236 ASSERT(temp_reg == kNoRegister); // Unused on ARM. |
| 237 const SubtypeTestCache& type_test_cache = | 237 const SubtypeTestCache& type_test_cache = |
| 238 SubtypeTestCache::ZoneHandle(SubtypeTestCache::New()); | 238 SubtypeTestCache::ZoneHandle(SubtypeTestCache::New()); |
| 239 StubCode* stub_code = isolate()->stub_code(); | 239 StubCode* stub_code = isolate()->stub_code(); |
| 240 __ LoadObject(R2, type_test_cache); | 240 __ LoadUniqueObject(R2, type_test_cache); |
| 241 if (test_kind == kTestTypeOneArg) { | 241 if (test_kind == kTestTypeOneArg) { |
| 242 ASSERT(type_arguments_reg == kNoRegister); | 242 ASSERT(type_arguments_reg == kNoRegister); |
| 243 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); | 243 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); |
| 244 __ BranchLink(&stub_code->Subtype1TestCacheLabel()); | 244 __ BranchLink(&stub_code->Subtype1TestCacheLabel()); |
| 245 } else if (test_kind == kTestTypeTwoArgs) { | 245 } else if (test_kind == kTestTypeTwoArgs) { |
| 246 ASSERT(type_arguments_reg == kNoRegister); | 246 ASSERT(type_arguments_reg == kNoRegister); |
| 247 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); | 247 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); |
| 248 __ BranchLink(&stub_code->Subtype2TestCacheLabel()); | 248 __ BranchLink(&stub_code->Subtype2TestCacheLabel()); |
| 249 } else if (test_kind == kTestTypeThreeArgs) { | 249 } else if (test_kind == kTestTypeThreeArgs) { |
| 250 ASSERT(type_arguments_reg == R1); | 250 ASSERT(type_arguments_reg == R1); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 Label done; | 620 Label done; |
| 621 if (!test_cache.IsNull()) { | 621 if (!test_cache.IsNull()) { |
| 622 // Generate runtime call. | 622 // Generate runtime call. |
| 623 // Load instantiator (R2) and its type arguments (R1). | 623 // Load instantiator (R2) and its type arguments (R1). |
| 624 __ ldm(IA, SP, (1 << R1) | (1 << R2)); | 624 __ ldm(IA, SP, (1 << R1) | (1 << R2)); |
| 625 __ PushObject(Object::null_object()); // Make room for the result. | 625 __ PushObject(Object::null_object()); // Make room for the result. |
| 626 __ Push(R0); // Push the instance. | 626 __ Push(R0); // Push the instance. |
| 627 __ PushObject(type); // Push the type. | 627 __ PushObject(type); // Push the type. |
| 628 // Push instantiator (R2) and its type arguments (R1). | 628 // Push instantiator (R2) and its type arguments (R1). |
| 629 __ PushList((1 << R1) | (1 << R2)); | 629 __ PushList((1 << R1) | (1 << R2)); |
| 630 __ LoadObject(R0, test_cache); | 630 __ LoadUniqueObject(R0, test_cache); |
| 631 __ Push(R0); | 631 __ Push(R0); |
| 632 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 5, locs); | 632 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 5, locs); |
| 633 // Pop the parameters supplied to the runtime entry. The result of the | 633 // Pop the parameters supplied to the runtime entry. The result of the |
| 634 // instanceof runtime call will be left as the result of the operation. | 634 // instanceof runtime call will be left as the result of the operation. |
| 635 __ Drop(5); | 635 __ Drop(5); |
| 636 if (negate_result) { | 636 if (negate_result) { |
| 637 __ Pop(R1); | 637 __ Pop(R1); |
| 638 __ LoadObject(R0, Bool::True()); | 638 __ LoadObject(R0, Bool::True()); |
| 639 __ cmp(R1, Operand(R0)); | 639 __ cmp(R1, Operand(R0)); |
| 640 __ b(&done, NE); | 640 __ b(&done, NE); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 | 713 |
| 714 __ Bind(&runtime_call); | 714 __ Bind(&runtime_call); |
| 715 // Load instantiator (R2) and its type arguments (R1). | 715 // Load instantiator (R2) and its type arguments (R1). |
| 716 __ ldm(IA, SP, (1 << R1) | (1 << R2)); | 716 __ ldm(IA, SP, (1 << R1) | (1 << R2)); |
| 717 __ PushObject(Object::null_object()); // Make room for the result. | 717 __ PushObject(Object::null_object()); // Make room for the result. |
| 718 __ Push(R0); // Push the source object. | 718 __ Push(R0); // Push the source object. |
| 719 __ PushObject(dst_type); // Push the type of the destination. | 719 __ PushObject(dst_type); // Push the type of the destination. |
| 720 // Push instantiator (R2) and its type arguments (R1). | 720 // Push instantiator (R2) and its type arguments (R1). |
| 721 __ PushList((1 << R1) | (1 << R2)); | 721 __ PushList((1 << R1) | (1 << R2)); |
| 722 __ PushObject(dst_name); // Push the name of the destination. | 722 __ PushObject(dst_name); // Push the name of the destination. |
| 723 __ LoadObject(R0, test_cache); | 723 __ LoadUniqueObject(R0, test_cache); |
| 724 __ Push(R0); | 724 __ Push(R0); |
| 725 GenerateRuntimeCall(token_pos, deopt_id, kTypeCheckRuntimeEntry, 6, locs); | 725 GenerateRuntimeCall(token_pos, deopt_id, kTypeCheckRuntimeEntry, 6, locs); |
| 726 // Pop the parameters supplied to the runtime entry. The result of the | 726 // Pop the parameters supplied to the runtime entry. The result of the |
| 727 // type check runtime call is the checked value. | 727 // type check runtime call is the checked value. |
| 728 __ Drop(6); | 728 __ Drop(6); |
| 729 __ Pop(R0); | 729 __ Pop(R0); |
| 730 | 730 |
| 731 __ Bind(&is_assignable); | 731 __ Bind(&is_assignable); |
| 732 // Restore instantiator (R2) and its type arguments (R1). | 732 // Restore instantiator (R2) and its type arguments (R1). |
| 733 __ PopList((1 << R1) | (1 << R2)); | 733 __ PopList((1 << R1) | (1 << R2)); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 | 1197 |
| 1198 void FlowGraphCompiler::EmitEdgeCounter() { | 1198 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1199 // We do not check for overflow when incrementing the edge counter. The | 1199 // We do not check for overflow when incrementing the edge counter. The |
| 1200 // function should normally be optimized long before the counter can | 1200 // function should normally be optimized long before the counter can |
| 1201 // overflow; and though we do not reset the counters when we optimize or | 1201 // overflow; and though we do not reset the counters when we optimize or |
| 1202 // deoptimize, there is a bound on the number of | 1202 // deoptimize, there is a bound on the number of |
| 1203 // optimization/deoptimization cycles we will attempt. | 1203 // optimization/deoptimization cycles we will attempt. |
| 1204 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); | 1204 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1205 counter.SetAt(0, Smi::Handle(Smi::New(0))); | 1205 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1206 __ Comment("Edge counter"); | 1206 __ Comment("Edge counter"); |
| 1207 __ LoadObject(R0, counter); | 1207 __ LoadUniqueObject(R0, counter); |
| 1208 intptr_t increment_start = assembler_->CodeSize(); | 1208 intptr_t increment_start = assembler_->CodeSize(); |
| 1209 #if defined(DEBUG) | 1209 #if defined(DEBUG) |
| 1210 bool old_use_far_branches = assembler_->use_far_branches(); | 1210 bool old_use_far_branches = assembler_->use_far_branches(); |
| 1211 assembler_->set_use_far_branches(true); | 1211 assembler_->set_use_far_branches(true); |
| 1212 #endif // DEBUG | 1212 #endif // DEBUG |
| 1213 __ ldr(IP, FieldAddress(R0, Array::element_offset(0))); | 1213 __ ldr(IP, FieldAddress(R0, Array::element_offset(0))); |
| 1214 __ add(IP, IP, Operand(Smi::RawValue(1))); | 1214 __ add(IP, IP, Operand(Smi::RawValue(1))); |
| 1215 __ StoreIntoSmiField(FieldAddress(R0, Array::element_offset(0)), IP); | 1215 __ StoreIntoSmiField(FieldAddress(R0, Array::element_offset(0)), IP); |
| 1216 int32_t size = assembler_->CodeSize() - increment_start; | 1216 int32_t size = assembler_->CodeSize() - increment_start; |
| 1217 if (isolate()->edge_counter_increment_size() == -1) { | 1217 if (isolate()->edge_counter_increment_size() == -1) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1241 LocationSummary* locs) { | 1241 LocationSummary* locs) { |
| 1242 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); | 1242 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); |
| 1243 // Each ICData propagated from unoptimized to optimized code contains the | 1243 // Each ICData propagated from unoptimized to optimized code contains the |
| 1244 // function that corresponds to the Dart function of that IC call. Due | 1244 // function that corresponds to the Dart function of that IC call. Due |
| 1245 // to inlining in optimized code, that function may not correspond to the | 1245 // to inlining in optimized code, that function may not correspond to the |
| 1246 // top-level function (parsed_function().function()) which could be | 1246 // top-level function (parsed_function().function()) which could be |
| 1247 // reoptimized and which counter needs to be incremented. | 1247 // reoptimized and which counter needs to be incremented. |
| 1248 // Pass the function explicitly, it is used in IC stub. | 1248 // Pass the function explicitly, it is used in IC stub. |
| 1249 | 1249 |
| 1250 __ LoadObject(R6, parsed_function().function()); | 1250 __ LoadObject(R6, parsed_function().function()); |
| 1251 __ LoadObject(R5, ic_data); | 1251 __ LoadUniqueObject(R5, ic_data); |
| 1252 GenerateDartCall(deopt_id, | 1252 GenerateDartCall(deopt_id, |
| 1253 token_pos, | 1253 token_pos, |
| 1254 target_label, | 1254 target_label, |
| 1255 RawPcDescriptors::kIcCall, | 1255 RawPcDescriptors::kIcCall, |
| 1256 locs); | 1256 locs); |
| 1257 __ Drop(argument_count); | 1257 __ Drop(argument_count); |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 | 1260 |
| 1261 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, | 1261 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, |
| 1262 const ICData& ic_data, | 1262 const ICData& ic_data, |
| 1263 intptr_t argument_count, | 1263 intptr_t argument_count, |
| 1264 intptr_t deopt_id, | 1264 intptr_t deopt_id, |
| 1265 intptr_t token_pos, | 1265 intptr_t token_pos, |
| 1266 LocationSummary* locs) { | 1266 LocationSummary* locs) { |
| 1267 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); | 1267 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); |
| 1268 __ LoadObject(R5, ic_data); | 1268 __ LoadUniqueObject(R5, ic_data); |
| 1269 GenerateDartCall(deopt_id, | 1269 GenerateDartCall(deopt_id, |
| 1270 token_pos, | 1270 token_pos, |
| 1271 target_label, | 1271 target_label, |
| 1272 RawPcDescriptors::kIcCall, | 1272 RawPcDescriptors::kIcCall, |
| 1273 locs); | 1273 locs); |
| 1274 __ Drop(argument_count); | 1274 __ Drop(argument_count); |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 | 1277 |
| 1278 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1278 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 DRegister dreg = EvenDRegisterOf(reg); | 1899 DRegister dreg = EvenDRegisterOf(reg); |
| 1900 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1900 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
| 1901 } | 1901 } |
| 1902 | 1902 |
| 1903 | 1903 |
| 1904 #undef __ | 1904 #undef __ |
| 1905 | 1905 |
| 1906 } // namespace dart | 1906 } // namespace dart |
| 1907 | 1907 |
| 1908 #endif // defined TARGET_ARCH_ARM | 1908 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |