| 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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 900 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 901 __ SmiUntag(RBX); | 901 __ SmiUntag(RBX); |
| 902 // Check that RCX equals RBX, i.e. no named arguments passed. | 902 // Check that RCX equals RBX, i.e. no named arguments passed. |
| 903 __ cmpq(RCX, RBX); | 903 __ cmpq(RCX, RBX); |
| 904 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); | 904 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 | 907 |
| 908 __ Bind(&wrong_num_arguments); | 908 __ Bind(&wrong_num_arguments); |
| 909 if (function.IsClosureFunction()) { | 909 if (function.IsClosureFunction()) { |
| 910 // Invoke noSuchMethod function passing "call" as the original name. | |
| 911 StubCode* stub_code = isolate()->stub_code(); | |
| 912 const int kNumArgsChecked = 1; | |
| 913 const ICData& ic_data = ICData::ZoneHandle( | |
| 914 ICData::New(function, Symbols::Call(), Object::empty_array(), | |
| 915 Isolate::kNoDeoptId, kNumArgsChecked)); | |
| 916 __ LoadObject(RBX, ic_data, PP); | |
| 917 __ LeaveDartFrame(); // The arguments are still on the stack. | 910 __ LeaveDartFrame(); // The arguments are still on the stack. |
| 918 __ jmp(&stub_code->CallNoSuchMethodFunctionLabel()); | 911 __ jmp(&isolate()->stub_code()->CallNoSuchMethodFunctionLabel()); |
| 919 // The noSuchMethod call may return to the caller, but not here. | 912 // The noSuchMethod call may return to the caller, but not here. |
| 920 __ int3(); | |
| 921 } else if (check_correct_named_args) { | 913 } else if (check_correct_named_args) { |
| 922 __ Stop("Wrong arguments"); | 914 __ Stop("Wrong arguments"); |
| 923 } | 915 } |
| 924 | 916 |
| 925 __ Bind(&all_arguments_processed); | 917 __ Bind(&all_arguments_processed); |
| 926 // Nullify originally passed arguments only after they have been copied and | 918 // Nullify originally passed arguments only after they have been copied and |
| 927 // checked, otherwise noSuchMethod would not see their original values. | 919 // checked, otherwise noSuchMethod would not see their original values. |
| 928 // This step can be skipped in case we decide that formal parameters are | 920 // This step can be skipped in case we decide that formal parameters are |
| 929 // implicitly final, since garbage collecting the unmodified value is not | 921 // implicitly final, since garbage collecting the unmodified value is not |
| 930 // an issue anymore. | 922 // an issue anymore. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1085 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 1094 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params)), PP); | 1086 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params)), PP); |
| 1095 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); | 1087 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); |
| 1096 __ cmpq(RAX, | 1088 __ cmpq(RAX, |
| 1097 FieldAddress(R10, | 1089 FieldAddress(R10, |
| 1098 ArgumentsDescriptor::positional_count_offset())); | 1090 ArgumentsDescriptor::positional_count_offset())); |
| 1099 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); | 1091 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); |
| 1100 | 1092 |
| 1101 __ Bind(&wrong_num_arguments); | 1093 __ Bind(&wrong_num_arguments); |
| 1102 if (function.IsClosureFunction()) { | 1094 if (function.IsClosureFunction()) { |
| 1103 // Invoke noSuchMethod function passing the original function name. | |
| 1104 // For closure functions, use "call" as the original name. | |
| 1105 const String& name = | |
| 1106 String::Handle(function.IsClosureFunction() | |
| 1107 ? Symbols::Call().raw() | |
| 1108 : function.name()); | |
| 1109 const int kNumArgsChecked = 1; | |
| 1110 const ICData& ic_data = ICData::ZoneHandle( | |
| 1111 ICData::New(function, name, Object::empty_array(), | |
| 1112 Isolate::kNoDeoptId, kNumArgsChecked)); | |
| 1113 __ LoadObject(RBX, ic_data, PP); | |
| 1114 __ LeaveDartFrame(); // The arguments are still on the stack. | 1095 __ LeaveDartFrame(); // The arguments are still on the stack. |
| 1115 __ jmp(&stub_code->CallNoSuchMethodFunctionLabel()); | 1096 __ jmp(&stub_code->CallNoSuchMethodFunctionLabel()); |
| 1116 // The noSuchMethod call may return to the caller, but not here. | 1097 // The noSuchMethod call may return to the caller, but not here. |
| 1117 __ int3(); | |
| 1118 } else { | 1098 } else { |
| 1119 __ Stop("Wrong number of arguments"); | 1099 __ Stop("Wrong number of arguments"); |
| 1120 } | 1100 } |
| 1121 __ Bind(&correct_num_arguments); | 1101 __ Bind(&correct_num_arguments); |
| 1122 } | 1102 } |
| 1123 } else if (!flow_graph().IsCompiledForOsr()) { | 1103 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1124 CopyParameters(); | 1104 CopyParameters(); |
| 1125 } | 1105 } |
| 1126 | 1106 |
| 1127 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1107 // In unoptimized code, initialize (non-argument) stack allocated slots to |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 __ movups(reg, Address(RSP, 0)); | 1708 __ movups(reg, Address(RSP, 0)); |
| 1729 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1709 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
| 1730 } | 1710 } |
| 1731 | 1711 |
| 1732 | 1712 |
| 1733 #undef __ | 1713 #undef __ |
| 1734 | 1714 |
| 1735 } // namespace dart | 1715 } // namespace dart |
| 1736 | 1716 |
| 1737 #endif // defined TARGET_ARCH_X64 | 1717 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |