| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 | 1065 |
| 1066 const int num_fixed_params = function.num_fixed_parameters(); | 1066 const int num_fixed_params = function.num_fixed_parameters(); |
| 1067 const int num_copied_params = parsed_function().num_copied_params(); | 1067 const int num_copied_params = parsed_function().num_copied_params(); |
| 1068 const int num_locals = parsed_function().num_stack_locals(); | 1068 const int num_locals = parsed_function().num_stack_locals(); |
| 1069 | 1069 |
| 1070 // We check the number of passed arguments when we have to copy them due to | 1070 // We check the number of passed arguments when we have to copy them due to |
| 1071 // the presence of optional parameters. | 1071 // the presence of optional parameters. |
| 1072 // No such checking code is generated if only fixed parameters are declared, | 1072 // No such checking code is generated if only fixed parameters are declared, |
| 1073 // unless we are in debug mode or unless we are compiling a closure. | 1073 // unless we are in debug mode or unless we are compiling a closure. |
| 1074 if (num_copied_params == 0) { | 1074 if (num_copied_params == 0) { |
| 1075 #ifdef DEBUG | |
| 1076 ASSERT(!parsed_function().function().HasOptionalParameters()); | |
| 1077 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | |
| 1078 #else | |
| 1079 const bool check_arguments = | 1075 const bool check_arguments = |
| 1080 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); | 1076 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); |
| 1081 #endif | |
| 1082 if (check_arguments) { | 1077 if (check_arguments) { |
| 1083 __ Comment("Check argument count"); | 1078 __ Comment("Check argument count"); |
| 1084 // Check that exactly num_fixed arguments are passed in. | 1079 // Check that exactly num_fixed arguments are passed in. |
| 1085 Label correct_num_arguments, wrong_num_arguments; | 1080 Label correct_num_arguments, wrong_num_arguments; |
| 1086 __ lw(T0, FieldAddress(S4, ArgumentsDescriptor::count_offset())); | 1081 __ lw(T0, FieldAddress(S4, ArgumentsDescriptor::count_offset())); |
| 1087 __ BranchNotEqual(T0, Immediate(Smi::RawValue(num_fixed_params)), | 1082 __ BranchNotEqual(T0, Immediate(Smi::RawValue(num_fixed_params)), |
| 1088 &wrong_num_arguments); | 1083 &wrong_num_arguments); |
| 1089 | 1084 |
| 1090 __ lw(T1, FieldAddress(S4, | 1085 __ lw(T1, FieldAddress(S4, |
| 1091 ArgumentsDescriptor::positional_count_offset())); | 1086 ArgumentsDescriptor::positional_count_offset())); |
| 1092 __ beq(T0, T1, &correct_num_arguments); | 1087 __ beq(T0, T1, &correct_num_arguments); |
| 1093 __ Bind(&wrong_num_arguments); | 1088 __ Bind(&wrong_num_arguments); |
| 1094 if (function.IsClosureFunction()) { | 1089 __ LeaveDartFrame(kKeepCalleePP); // Arguments are still on the stack. |
| 1095 __ LeaveDartFrame(kKeepCalleePP); // Arguments are still on the stack. | 1090 __ Branch(*StubCode::CallClosureNoSuchMethod_entry()); |
| 1096 __ Branch(*StubCode::CallClosureNoSuchMethod_entry()); | 1091 // The noSuchMethod call may return to the caller, but not here. |
| 1097 // The noSuchMethod call may return to the caller, but not here. | |
| 1098 } else { | |
| 1099 __ Stop("Wrong number of arguments"); | |
| 1100 } | |
| 1101 __ Bind(&correct_num_arguments); | 1092 __ Bind(&correct_num_arguments); |
| 1102 } | 1093 } |
| 1103 } else if (!flow_graph().IsCompiledForOsr()) { | 1094 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1104 CopyParameters(); | 1095 CopyParameters(); |
| 1105 } | 1096 } |
| 1106 | 1097 |
| 1107 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { | 1098 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { |
| 1108 // Load context from the closure object (first argument). | 1099 // Load context from the closure object (first argument). |
| 1109 LocalScope* scope = parsed_function().node_sequence()->scope(); | 1100 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 1110 LocalVariable* closure_parameter = scope->VariableAt(0); | 1101 LocalVariable* closure_parameter = scope->VariableAt(0); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 | 1419 |
| 1429 | 1420 |
| 1430 void FlowGraphCompiler::EmitOptimizedStaticCall( | 1421 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1431 const Function& function, | 1422 const Function& function, |
| 1432 const Array& arguments_descriptor, | 1423 const Array& arguments_descriptor, |
| 1433 intptr_t argument_count, | 1424 intptr_t argument_count, |
| 1434 intptr_t deopt_id, | 1425 intptr_t deopt_id, |
| 1435 TokenPosition token_pos, | 1426 TokenPosition token_pos, |
| 1436 LocationSummary* locs) { | 1427 LocationSummary* locs) { |
| 1437 __ Comment("StaticCall"); | 1428 __ Comment("StaticCall"); |
| 1438 __ LoadObject(S4, arguments_descriptor); | 1429 ASSERT(!function.IsClosureFunction()); |
| 1430 if (function.HasOptionalParameters()) { |
| 1431 __ LoadObject(S4, arguments_descriptor); |
| 1432 } else { |
| 1433 __ LoadImmediate(S4, 0); // GC safe smi zero because of stub. |
| 1434 } |
| 1439 // Do not use the code from the function, but let the code be patched so that | 1435 // Do not use the code from the function, but let the code be patched so that |
| 1440 // we can record the outgoing edges to other code. | 1436 // we can record the outgoing edges to other code. |
| 1441 GenerateStaticDartCall(deopt_id, | 1437 GenerateStaticDartCall(deopt_id, |
| 1442 token_pos, | 1438 token_pos, |
| 1443 *StubCode::CallStaticFunction_entry(), | 1439 *StubCode::CallStaticFunction_entry(), |
| 1444 RawPcDescriptors::kOther, | 1440 RawPcDescriptors::kOther, |
| 1445 locs, | 1441 locs, |
| 1446 function); | 1442 function); |
| 1447 __ Drop(argument_count); | 1443 __ Drop(argument_count); |
| 1448 } | 1444 } |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 __ AddImmediate(SP, kDoubleSize); | 1953 __ AddImmediate(SP, kDoubleSize); |
| 1958 } | 1954 } |
| 1959 | 1955 |
| 1960 | 1956 |
| 1961 #undef __ | 1957 #undef __ |
| 1962 | 1958 |
| 1963 | 1959 |
| 1964 } // namespace dart | 1960 } // namespace dart |
| 1965 | 1961 |
| 1966 #endif // defined TARGET_ARCH_MIPS | 1962 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |