| 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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 | 1043 |
| 1044 const int num_fixed_params = function.num_fixed_parameters(); | 1044 const int num_fixed_params = function.num_fixed_parameters(); |
| 1045 const int num_copied_params = parsed_function().num_copied_params(); | 1045 const int num_copied_params = parsed_function().num_copied_params(); |
| 1046 const int num_locals = parsed_function().num_stack_locals(); | 1046 const int num_locals = parsed_function().num_stack_locals(); |
| 1047 | 1047 |
| 1048 // We check the number of passed arguments when we have to copy them due to | 1048 // We check the number of passed arguments when we have to copy them due to |
| 1049 // the presence of optional parameters. | 1049 // the presence of optional parameters. |
| 1050 // No such checking code is generated if only fixed parameters are declared, | 1050 // No such checking code is generated if only fixed parameters are declared, |
| 1051 // unless we are in debug mode or unless we are compiling a closure. | 1051 // unless we are in debug mode or unless we are compiling a closure. |
| 1052 if (num_copied_params == 0) { | 1052 if (num_copied_params == 0) { |
| 1053 #ifdef DEBUG | |
| 1054 ASSERT(!parsed_function().function().HasOptionalParameters()); | |
| 1055 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | |
| 1056 #else | |
| 1057 const bool check_arguments = | 1053 const bool check_arguments = |
| 1058 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); | 1054 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); |
| 1059 #endif | |
| 1060 if (check_arguments) { | 1055 if (check_arguments) { |
| 1061 __ Comment("Check argument count"); | 1056 __ Comment("Check argument count"); |
| 1062 // Check that exactly num_fixed arguments are passed in. | 1057 // Check that exactly num_fixed arguments are passed in. |
| 1063 Label correct_num_arguments, wrong_num_arguments; | 1058 Label correct_num_arguments, wrong_num_arguments; |
| 1064 __ LoadFieldFromOffset(R0, R4, ArgumentsDescriptor::count_offset()); | 1059 __ LoadFieldFromOffset(R0, R4, ArgumentsDescriptor::count_offset()); |
| 1065 __ CompareImmediate(R0, Smi::RawValue(num_fixed_params)); | 1060 __ CompareImmediate(R0, Smi::RawValue(num_fixed_params)); |
| 1066 __ b(&wrong_num_arguments, NE); | 1061 __ b(&wrong_num_arguments, NE); |
| 1067 __ LoadFieldFromOffset(R1, R4, | 1062 __ LoadFieldFromOffset(R1, R4, |
| 1068 ArgumentsDescriptor::positional_count_offset()); | 1063 ArgumentsDescriptor::positional_count_offset()); |
| 1069 __ CompareRegisters(R0, R1); | 1064 __ CompareRegisters(R0, R1); |
| 1070 __ b(&correct_num_arguments, EQ); | 1065 __ b(&correct_num_arguments, EQ); |
| 1071 __ Bind(&wrong_num_arguments); | 1066 __ Bind(&wrong_num_arguments); |
| 1072 if (function.IsClosureFunction()) { | 1067 __ LeaveDartFrame(kKeepCalleePP); // Arguments are still on the stack. |
| 1073 __ LeaveDartFrame(kKeepCalleePP); // Arguments are still on the stack. | 1068 __ BranchPatchable(*StubCode::CallClosureNoSuchMethod_entry()); |
| 1074 __ BranchPatchable(*StubCode::CallClosureNoSuchMethod_entry()); | 1069 // The noSuchMethod call may return to the caller, but not here. |
| 1075 // The noSuchMethod call may return to the caller, but not here. | |
| 1076 } else { | |
| 1077 __ Stop("Wrong number of arguments"); | |
| 1078 } | |
| 1079 __ Bind(&correct_num_arguments); | 1070 __ Bind(&correct_num_arguments); |
| 1080 } | 1071 } |
| 1081 } else if (!flow_graph().IsCompiledForOsr()) { | 1072 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1082 CopyParameters(); | 1073 CopyParameters(); |
| 1083 } | 1074 } |
| 1084 | 1075 |
| 1085 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { | 1076 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { |
| 1086 // Load context from the closure object (first argument). | 1077 // Load context from the closure object (first argument). |
| 1087 LocalScope* scope = parsed_function().node_sequence()->scope(); | 1078 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 1088 LocalVariable* closure_parameter = scope->VariableAt(0); | 1079 LocalVariable* closure_parameter = scope->VariableAt(0); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 } | 1393 } |
| 1403 | 1394 |
| 1404 | 1395 |
| 1405 void FlowGraphCompiler::EmitOptimizedStaticCall( | 1396 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1406 const Function& function, | 1397 const Function& function, |
| 1407 const Array& arguments_descriptor, | 1398 const Array& arguments_descriptor, |
| 1408 intptr_t argument_count, | 1399 intptr_t argument_count, |
| 1409 intptr_t deopt_id, | 1400 intptr_t deopt_id, |
| 1410 TokenPosition token_pos, | 1401 TokenPosition token_pos, |
| 1411 LocationSummary* locs) { | 1402 LocationSummary* locs) { |
| 1412 __ LoadObject(R4, arguments_descriptor); | 1403 ASSERT(!function.IsClosureFunction()); |
| 1404 if (function.HasOptionalParameters()) { |
| 1405 __ LoadObject(R4, arguments_descriptor); |
| 1406 } else { |
| 1407 __ LoadImmediate(R4, 0); // GC safe smi zero because of stub. |
| 1408 } |
| 1413 // Do not use the code from the function, but let the code be patched so that | 1409 // Do not use the code from the function, but let the code be patched so that |
| 1414 // we can record the outgoing edges to other code. | 1410 // we can record the outgoing edges to other code. |
| 1415 GenerateStaticDartCall(deopt_id, | 1411 GenerateStaticDartCall(deopt_id, |
| 1416 token_pos, | 1412 token_pos, |
| 1417 *StubCode::CallStaticFunction_entry(), | 1413 *StubCode::CallStaticFunction_entry(), |
| 1418 RawPcDescriptors::kOther, | 1414 RawPcDescriptors::kOther, |
| 1419 locs, | 1415 locs, |
| 1420 function); | 1416 function); |
| 1421 __ Drop(argument_count); | 1417 __ Drop(argument_count); |
| 1422 } | 1418 } |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1928 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1933 __ PopDouble(reg); | 1929 __ PopDouble(reg); |
| 1934 } | 1930 } |
| 1935 | 1931 |
| 1936 | 1932 |
| 1937 #undef __ | 1933 #undef __ |
| 1938 | 1934 |
| 1939 } // namespace dart | 1935 } // namespace dart |
| 1940 | 1936 |
| 1941 #endif // defined TARGET_ARCH_ARM64 | 1937 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |