| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 | 1050 |
| 1051 const int num_fixed_params = function.num_fixed_parameters(); | 1051 const int num_fixed_params = function.num_fixed_parameters(); |
| 1052 const int num_copied_params = parsed_function().num_copied_params(); | 1052 const int num_copied_params = parsed_function().num_copied_params(); |
| 1053 const int num_locals = parsed_function().num_stack_locals(); | 1053 const int num_locals = parsed_function().num_stack_locals(); |
| 1054 | 1054 |
| 1055 // We check the number of passed arguments when we have to copy them due to | 1055 // We check the number of passed arguments when we have to copy them due to |
| 1056 // the presence of optional parameters. | 1056 // the presence of optional parameters. |
| 1057 // No such checking code is generated if only fixed parameters are declared, | 1057 // No such checking code is generated if only fixed parameters are declared, |
| 1058 // unless we are in debug mode or unless we are compiling a closure. | 1058 // unless we are in debug mode or unless we are compiling a closure. |
| 1059 if (num_copied_params == 0) { | 1059 if (num_copied_params == 0) { |
| 1060 #ifdef DEBUG | |
| 1061 ASSERT(!parsed_function().function().HasOptionalParameters()); | |
| 1062 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | |
| 1063 #else | |
| 1064 const bool check_arguments = | 1060 const bool check_arguments = |
| 1065 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); | 1061 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); |
| 1066 #endif | |
| 1067 if (check_arguments) { | 1062 if (check_arguments) { |
| 1068 __ Comment("Check argument count"); | 1063 __ Comment("Check argument count"); |
| 1069 // Check that exactly num_fixed arguments are passed in. | 1064 // Check that exactly num_fixed arguments are passed in. |
| 1070 Label correct_num_arguments, wrong_num_arguments; | 1065 Label correct_num_arguments, wrong_num_arguments; |
| 1071 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1066 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 1072 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params))); | 1067 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params))); |
| 1073 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); | 1068 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); |
| 1074 __ cmpq(RAX, | 1069 __ cmpq(RAX, |
| 1075 FieldAddress(R10, | 1070 FieldAddress(R10, |
| 1076 ArgumentsDescriptor::positional_count_offset())); | 1071 ArgumentsDescriptor::positional_count_offset())); |
| 1077 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); | 1072 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); |
| 1078 | 1073 |
| 1079 __ Bind(&wrong_num_arguments); | 1074 __ Bind(&wrong_num_arguments); |
| 1080 if (function.IsClosureFunction()) { | 1075 __ LeaveDartFrame(kKeepCalleePP); // Leave arguments on the stack. |
| 1081 __ LeaveDartFrame(kKeepCalleePP); // Leave arguments on the stack. | 1076 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry()); |
| 1082 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry()); | 1077 // The noSuchMethod call may return to the caller, but not here. |
| 1083 // The noSuchMethod call may return to the caller, but not here. | |
| 1084 } else { | |
| 1085 __ Stop("Wrong number of arguments"); | |
| 1086 } | |
| 1087 __ Bind(&correct_num_arguments); | 1078 __ Bind(&correct_num_arguments); |
| 1088 } | 1079 } |
| 1089 } else if (!flow_graph().IsCompiledForOsr()) { | 1080 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1090 CopyParameters(); | 1081 CopyParameters(); |
| 1091 } | 1082 } |
| 1092 | 1083 |
| 1093 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { | 1084 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) { |
| 1094 // Load context from the closure object (first argument). | 1085 // Load context from the closure object (first argument). |
| 1095 LocalScope* scope = parsed_function().node_sequence()->scope(); | 1086 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 1096 LocalVariable* closure_parameter = scope->VariableAt(0); | 1087 LocalVariable* closure_parameter = scope->VariableAt(0); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 } | 1399 } |
| 1409 | 1400 |
| 1410 | 1401 |
| 1411 void FlowGraphCompiler::EmitOptimizedStaticCall( | 1402 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1412 const Function& function, | 1403 const Function& function, |
| 1413 const Array& arguments_descriptor, | 1404 const Array& arguments_descriptor, |
| 1414 intptr_t argument_count, | 1405 intptr_t argument_count, |
| 1415 intptr_t deopt_id, | 1406 intptr_t deopt_id, |
| 1416 TokenPosition token_pos, | 1407 TokenPosition token_pos, |
| 1417 LocationSummary* locs) { | 1408 LocationSummary* locs) { |
| 1418 __ LoadObject(R10, arguments_descriptor); | 1409 ASSERT(!function.IsClosureFunction()); |
| 1410 if (function.HasOptionalParameters()) { |
| 1411 __ LoadObject(R10, arguments_descriptor); |
| 1412 } else { |
| 1413 __ xorq(R10, R10); // GC safe smi zero because of stub. |
| 1414 } |
| 1419 // Do not use the code from the function, but let the code be patched so that | 1415 // Do not use the code from the function, but let the code be patched so that |
| 1420 // we can record the outgoing edges to other code. | 1416 // we can record the outgoing edges to other code. |
| 1421 GenerateStaticDartCall(deopt_id, | 1417 GenerateStaticDartCall(deopt_id, |
| 1422 token_pos, | 1418 token_pos, |
| 1423 *StubCode::CallStaticFunction_entry(), | 1419 *StubCode::CallStaticFunction_entry(), |
| 1424 RawPcDescriptors::kOther, | 1420 RawPcDescriptors::kOther, |
| 1425 locs, | 1421 locs, |
| 1426 function); | 1422 function); |
| 1427 __ Drop(argument_count, RCX); | 1423 __ Drop(argument_count, RCX); |
| 1428 } | 1424 } |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 __ movups(reg, Address(RSP, 0)); | 1859 __ movups(reg, Address(RSP, 0)); |
| 1864 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1860 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
| 1865 } | 1861 } |
| 1866 | 1862 |
| 1867 | 1863 |
| 1868 #undef __ | 1864 #undef __ |
| 1869 | 1865 |
| 1870 } // namespace dart | 1866 } // namespace dart |
| 1871 | 1867 |
| 1872 #endif // defined TARGET_ARCH_X64 | 1868 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |