OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/runtime_entry.h" | 5 #include "vm/runtime_entry.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 // there is a getter with the same name. If so, invoke it. If the value is | 847 // there is a getter with the same name. If so, invoke it. If the value is |
848 // a closure, invoke it with the given arguments. If the value is a | 848 // a closure, invoke it with the given arguments. If the value is a |
849 // non-closure, attempt to invoke "call" on it. | 849 // non-closure, attempt to invoke "call" on it. |
850 static bool ResolveCallThroughGetter(const Instance& receiver, | 850 static bool ResolveCallThroughGetter(const Instance& receiver, |
851 const Class& receiver_class, | 851 const Class& receiver_class, |
852 const String& target_name, | 852 const String& target_name, |
853 const Array& arguments_descriptor, | 853 const Array& arguments_descriptor, |
854 Function* result) { | 854 Function* result) { |
855 // 1. Check if there is a getter with the same name. | 855 // 1. Check if there is a getter with the same name. |
856 const String& getter_name = String::Handle(Field::GetterName(target_name)); | 856 const String& getter_name = String::Handle(Field::GetterName(target_name)); |
| 857 const int kTypeArgsLen = 0; |
857 const int kNumArguments = 1; | 858 const int kNumArguments = 1; |
858 ArgumentsDescriptor args_desc( | 859 ArgumentsDescriptor args_desc( |
859 Array::Handle(ArgumentsDescriptor::New(kNumArguments))); | 860 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments))); |
860 const Function& getter = | 861 const Function& getter = |
861 Function::Handle(Resolver::ResolveDynamicForReceiverClass( | 862 Function::Handle(Resolver::ResolveDynamicForReceiverClass( |
862 receiver_class, getter_name, args_desc)); | 863 receiver_class, getter_name, args_desc)); |
863 if (getter.IsNull() || getter.IsMethodExtractor()) { | 864 if (getter.IsNull() || getter.IsMethodExtractor()) { |
864 return false; | 865 return false; |
865 } | 866 } |
866 const Function& target_function = | 867 const Function& target_function = |
867 Function::Handle(receiver_class.GetInvocationDispatcher( | 868 Function::Handle(receiver_class.GetInvocationDispatcher( |
868 target_name, arguments_descriptor, | 869 target_name, arguments_descriptor, |
869 RawFunction::kInvokeFieldDispatcher, FLAG_lazy_dispatchers)); | 870 RawFunction::kInvokeFieldDispatcher, FLAG_lazy_dispatchers)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 ObjectStore* store = Isolate::Current()->object_store(); | 920 ObjectStore* store = Isolate::Current()->object_store(); |
920 const Function& target = | 921 const Function& target = |
921 Function::Handle(result ? store->simple_instance_of_true_function() | 922 Function::Handle(result ? store->simple_instance_of_true_function() |
922 : store->simple_instance_of_false_function()); | 923 : store->simple_instance_of_false_function()); |
923 ASSERT(!target.IsNull()); | 924 ASSERT(!target.IsNull()); |
924 return target.raw(); | 925 return target.raw(); |
925 } | 926 } |
926 | 927 |
927 | 928 |
928 static RawFunction* InlineCacheMissHandler( | 929 static RawFunction* InlineCacheMissHandler( |
929 const GrowableArray<const Instance*>& args, | 930 const GrowableArray<const Instance*>& args, // Checked arguments only. |
930 const ICData& ic_data) { | 931 const ICData& ic_data) { |
931 const Instance& receiver = *args[0]; | 932 const Instance& receiver = *args[0]; |
932 ArgumentsDescriptor arguments_descriptor( | 933 ArgumentsDescriptor arguments_descriptor( |
933 Array::Handle(ic_data.arguments_descriptor())); | 934 Array::Handle(ic_data.arguments_descriptor())); |
934 String& function_name = String::Handle(ic_data.target_name()); | 935 String& function_name = String::Handle(ic_data.target_name()); |
935 ASSERT(function_name.IsSymbol()); | 936 ASSERT(function_name.IsSymbol()); |
936 | 937 |
937 Function& target_function = Function::Handle( | 938 Function& target_function = Function::Handle( |
938 Resolver::ResolveDynamic(receiver, function_name, arguments_descriptor)); | 939 Resolver::ResolveDynamic(receiver, function_name, arguments_descriptor)); |
939 | 940 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 SingleTargetCache& cache = SingleTargetCache::Handle(zone); | 1130 SingleTargetCache& cache = SingleTargetCache::Handle(zone); |
1130 cache ^= | 1131 cache ^= |
1131 CodePatcher::GetSwitchableCallDataAt(caller_frame->pc(), caller_code); | 1132 CodePatcher::GetSwitchableCallDataAt(caller_frame->pc(), caller_code); |
1132 Code& old_target_code = Code::Handle(zone, cache.target()); | 1133 Code& old_target_code = Code::Handle(zone, cache.target()); |
1133 Function& old_target = Function::Handle(zone); | 1134 Function& old_target = Function::Handle(zone); |
1134 old_target ^= old_target_code.owner(); | 1135 old_target ^= old_target_code.owner(); |
1135 | 1136 |
1136 // We lost the original ICData when we patched to the monomorphic case. | 1137 // We lost the original ICData when we patched to the monomorphic case. |
1137 const String& name = String::Handle(zone, old_target.name()); | 1138 const String& name = String::Handle(zone, old_target.name()); |
1138 ASSERT(!old_target.HasOptionalParameters()); | 1139 ASSERT(!old_target.HasOptionalParameters()); |
1139 const Array& descriptor = Array::Handle( | 1140 ASSERT(!old_target.IsGeneric()); |
1140 zone, ArgumentsDescriptor::New(old_target.num_fixed_parameters())); | 1141 const int kTypeArgsLen = 0; |
| 1142 const Array& descriptor = |
| 1143 Array::Handle(zone, ArgumentsDescriptor::New( |
| 1144 kTypeArgsLen, old_target.num_fixed_parameters())); |
1141 const ICData& ic_data = | 1145 const ICData& ic_data = |
1142 ICData::Handle(zone, ICData::New(caller_function, name, descriptor, | 1146 ICData::Handle(zone, ICData::New(caller_function, name, descriptor, |
1143 Thread::kNoDeoptId, 1, /* args_tested */ | 1147 Thread::kNoDeoptId, 1, /* args_tested */ |
1144 false /* static_call */)); | 1148 false /* static_call */)); |
1145 | 1149 |
1146 // Maybe add the new target. | 1150 // Maybe add the new target. |
1147 Class& cls = Class::Handle(zone, receiver.clazz()); | 1151 Class& cls = Class::Handle(zone, receiver.clazz()); |
1148 ArgumentsDescriptor args_desc(descriptor); | 1152 ArgumentsDescriptor args_desc(descriptor); |
1149 Function& target_function = Function::Handle( | 1153 Function& target_function = Function::Handle( |
1150 zone, Resolver::ResolveDynamicForReceiverClass(cls, name, args_desc)); | 1154 zone, Resolver::ResolveDynamicForReceiverClass(cls, name, args_desc)); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 old_expected_cid ^= | 1286 old_expected_cid ^= |
1283 CodePatcher::GetSwitchableCallDataAt(caller_frame->pc(), caller_code); | 1287 CodePatcher::GetSwitchableCallDataAt(caller_frame->pc(), caller_code); |
1284 const Code& old_target_code = Code::Handle( | 1288 const Code& old_target_code = Code::Handle( |
1285 CodePatcher::GetSwitchableCallTargetAt(caller_frame->pc(), caller_code)); | 1289 CodePatcher::GetSwitchableCallTargetAt(caller_frame->pc(), caller_code)); |
1286 Function& old_target = Function::Handle(zone); | 1290 Function& old_target = Function::Handle(zone); |
1287 old_target ^= old_target_code.owner(); | 1291 old_target ^= old_target_code.owner(); |
1288 | 1292 |
1289 // We lost the original ICData when we patched to the monomorphic case. | 1293 // We lost the original ICData when we patched to the monomorphic case. |
1290 const String& name = String::Handle(zone, old_target.name()); | 1294 const String& name = String::Handle(zone, old_target.name()); |
1291 ASSERT(!old_target.HasOptionalParameters()); | 1295 ASSERT(!old_target.HasOptionalParameters()); |
1292 const Array& descriptor = Array::Handle( | 1296 ASSERT(!old_target.IsGeneric()); |
1293 zone, ArgumentsDescriptor::New(old_target.num_fixed_parameters())); | 1297 const int kTypeArgsLen = 0; |
| 1298 const Array& descriptor = |
| 1299 Array::Handle(zone, ArgumentsDescriptor::New( |
| 1300 kTypeArgsLen, old_target.num_fixed_parameters())); |
1294 const ICData& ic_data = | 1301 const ICData& ic_data = |
1295 ICData::Handle(zone, ICData::New(caller_function, name, descriptor, | 1302 ICData::Handle(zone, ICData::New(caller_function, name, descriptor, |
1296 Thread::kNoDeoptId, 1, /* args_tested */ | 1303 Thread::kNoDeoptId, 1, /* args_tested */ |
1297 false /* static_call */)); | 1304 false /* static_call */)); |
1298 | 1305 |
1299 // Add the first target. | 1306 // Add the first target. |
1300 ic_data.AddReceiverCheck(old_expected_cid.Value(), old_target); | 1307 ic_data.AddReceiverCheck(old_expected_cid.Value(), old_target); |
1301 | 1308 |
1302 // Maybe add the new target. | 1309 // Maybe add the new target. |
1303 Class& cls = Class::Handle(zone, receiver.clazz()); | 1310 Class& cls = Class::Handle(zone, receiver.clazz()); |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 const intptr_t new_size = 2 * old_size; | 2332 const intptr_t new_size = 2 * old_size; |
2326 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 2333 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
2327 const TypedData& new_data = | 2334 const TypedData& new_data = |
2328 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 2335 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
2329 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 2336 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
2330 typed_data_cell.SetAt(0, new_data); | 2337 typed_data_cell.SetAt(0, new_data); |
2331 arguments.SetReturn(new_data); | 2338 arguments.SetReturn(new_data); |
2332 } | 2339 } |
2333 | 2340 |
2334 } // namespace dart | 2341 } // namespace dart |
OLD | NEW |