Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: address review comments and sync Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/code_patcher_x64_test.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 static const int kExtNewRatio = 16; 347 static const int kExtNewRatio = 16;
348 if (size > (heap->CapacityInWords(Heap::kNew) * kWordSize) / kExtNewRatio) { 348 if (size > (heap->CapacityInWords(Heap::kNew) * kWordSize) / kExtNewRatio) {
349 return Heap::kOld; 349 return Heap::kOld;
350 } else { 350 } else {
351 return Heap::kNew; 351 return Heap::kNew;
352 } 352 }
353 } 353 }
354 354
355 355
356 static RawObject* Send0Arg(const Instance& receiver, const String& selector) { 356 static RawObject* Send0Arg(const Instance& receiver, const String& selector) {
357 const intptr_t kTypeArgsLen = 0;
357 const intptr_t kNumArgs = 1; 358 const intptr_t kNumArgs = 1;
358 ArgumentsDescriptor args_desc( 359 ArgumentsDescriptor args_desc(
359 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 360 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
360 const Function& function = 361 const Function& function =
361 Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc)); 362 Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc));
362 if (function.IsNull()) { 363 if (function.IsNull()) {
363 return ApiError::New(String::Handle(String::New(""))); 364 return ApiError::New(String::Handle(String::New("")));
364 } 365 }
365 const Array& args = Array::Handle(Array::New(kNumArgs)); 366 const Array& args = Array::Handle(Array::New(kNumArgs));
366 args.SetAt(0, receiver); 367 args.SetAt(0, receiver);
367 return DartEntry::InvokeFunction(function, args); 368 return DartEntry::InvokeFunction(function, args);
368 } 369 }
369 370
370 371
371 static RawObject* Send1Arg(const Instance& receiver, 372 static RawObject* Send1Arg(const Instance& receiver,
372 const String& selector, 373 const String& selector,
373 const Instance& argument) { 374 const Instance& argument) {
375 const intptr_t kTypeArgsLen = 0;
374 const intptr_t kNumArgs = 2; 376 const intptr_t kNumArgs = 2;
375 ArgumentsDescriptor args_desc( 377 ArgumentsDescriptor args_desc(
376 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 378 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
377 const Function& function = 379 const Function& function =
378 Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc)); 380 Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc));
379 if (function.IsNull()) { 381 if (function.IsNull()) {
380 return ApiError::New(String::Handle(String::New(""))); 382 return ApiError::New(String::Handle(String::New("")));
381 } 383 }
382 const Array& args = Array::Handle(Array::New(kNumArgs)); 384 const Array& args = Array::Handle(Array::New(kNumArgs));
383 args.SetAt(0, receiver); 385 args.SetAt(0, receiver);
384 args.SetAt(1, argument); 386 args.SetAt(1, argument);
385 return DartEntry::InvokeFunction(function, args); 387 return DartEntry::InvokeFunction(function, args);
386 } 388 }
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 GET_LIST_LENGTH(Z, ExternalTypedData, obj, len); 2720 GET_LIST_LENGTH(Z, ExternalTypedData, obj, len);
2719 } 2721 }
2720 CHECK_CALLBACK_STATE(T); 2722 CHECK_CALLBACK_STATE(T);
2721 2723
2722 // Now check and handle a dart object that implements the List interface. 2724 // Now check and handle a dart object that implements the List interface.
2723 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj)); 2725 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
2724 if (instance.IsNull()) { 2726 if (instance.IsNull()) {
2725 return Api::NewError("Object does not implement the List interface"); 2727 return Api::NewError("Object does not implement the List interface");
2726 } 2728 }
2727 const String& name = String::Handle(Z, Field::GetterName(Symbols::Length())); 2729 const String& name = String::Handle(Z, Field::GetterName(Symbols::Length()));
2730 const int kTypeArgsLen = 0;
2728 const int kNumArgs = 1; 2731 const int kNumArgs = 1;
2729 ArgumentsDescriptor args_desc( 2732 ArgumentsDescriptor args_desc(
2730 Array::Handle(Z, ArgumentsDescriptor::New(kNumArgs))); 2733 Array::Handle(Z, ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
2731 const Function& function = 2734 const Function& function =
2732 Function::Handle(Z, Resolver::ResolveDynamic(instance, name, args_desc)); 2735 Function::Handle(Z, Resolver::ResolveDynamic(instance, name, args_desc));
2733 if (function.IsNull()) { 2736 if (function.IsNull()) {
2734 return Api::NewError("List object does not have a 'length' field."); 2737 return Api::NewError("List object does not have a 'length' field.");
2735 } 2738 }
2736 2739
2737 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 2740 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
2738 args.SetAt(0, instance); // Set up the receiver as the first argument. 2741 args.SetAt(0, instance); // Set up the receiver as the first argument.
2739 const Object& retval = 2742 const Object& retval =
2740 Object::Handle(Z, DartEntry::InvokeFunction(function, args)); 2743 Object::Handle(Z, DartEntry::InvokeFunction(function, args));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 GET_LIST_RANGE(T, Array, obj, offset, length); 2827 GET_LIST_RANGE(T, Array, obj, offset, length);
2825 } else if (obj.IsGrowableObjectArray()) { 2828 } else if (obj.IsGrowableObjectArray()) {
2826 GET_LIST_RANGE(T, GrowableObjectArray, obj, offset, length); 2829 GET_LIST_RANGE(T, GrowableObjectArray, obj, offset, length);
2827 } else if (obj.IsError()) { 2830 } else if (obj.IsError()) {
2828 return list; 2831 return list;
2829 } else { 2832 } else {
2830 CHECK_CALLBACK_STATE(T); 2833 CHECK_CALLBACK_STATE(T);
2831 // Check and handle a dart object that implements the List interface. 2834 // Check and handle a dart object that implements the List interface.
2832 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj)); 2835 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
2833 if (!instance.IsNull()) { 2836 if (!instance.IsNull()) {
2837 const intptr_t kTypeArgsLen = 0;
2834 const intptr_t kNumArgs = 2; 2838 const intptr_t kNumArgs = 2;
2835 ArgumentsDescriptor args_desc( 2839 ArgumentsDescriptor args_desc(
2836 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 2840 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
2837 const Function& function = Function::Handle( 2841 const Function& function = Function::Handle(
2838 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(), 2842 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
2839 args_desc)); 2843 args_desc));
2840 if (!function.IsNull()) { 2844 if (!function.IsNull()) {
2841 const Array& args = Array::Handle(Array::New(kNumArgs)); 2845 const Array& args = Array::Handle(Array::New(kNumArgs));
2842 args.SetAt(0, instance); 2846 args.SetAt(0, instance);
2843 Instance& index = Instance::Handle(Z); 2847 Instance& index = Instance::Handle(Z);
2844 for (intptr_t i = 0; i < length; ++i) { 2848 for (intptr_t i = 0; i < length; ++i) {
2845 index = Integer::New(i); 2849 index = Integer::New(i);
2846 args.SetAt(1, index); 2850 args.SetAt(1, index);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 } else if (obj.IsGrowableObjectArray()) { 2886 } else if (obj.IsGrowableObjectArray()) {
2883 SET_LIST_ELEMENT(GrowableObjectArray, obj, index, value); 2887 SET_LIST_ELEMENT(GrowableObjectArray, obj, index, value);
2884 } else if (obj.IsError()) { 2888 } else if (obj.IsError()) {
2885 return list; 2889 return list;
2886 } else { 2890 } else {
2887 CHECK_CALLBACK_STATE(T); 2891 CHECK_CALLBACK_STATE(T);
2888 2892
2889 // Check and handle a dart object that implements the List interface. 2893 // Check and handle a dart object that implements the List interface.
2890 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj)); 2894 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
2891 if (!instance.IsNull()) { 2895 if (!instance.IsNull()) {
2896 const intptr_t kTypeArgsLen = 0;
2892 const intptr_t kNumArgs = 3; 2897 const intptr_t kNumArgs = 3;
2893 ArgumentsDescriptor args_desc( 2898 ArgumentsDescriptor args_desc(
2894 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 2899 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
2895 const Function& function = Function::Handle( 2900 const Function& function = Function::Handle(
2896 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(), 2901 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
2897 args_desc)); 2902 args_desc));
2898 if (!function.IsNull()) { 2903 if (!function.IsNull()) {
2899 const Integer& index_obj = Integer::Handle(Z, Integer::New(index)); 2904 const Integer& index_obj = Integer::Handle(Z, Integer::New(index));
2900 const Object& value_obj = Object::Handle(Z, Api::UnwrapHandle(value)); 2905 const Object& value_obj = Object::Handle(Z, Api::UnwrapHandle(value));
2901 if (!value_obj.IsNull() && !value_obj.IsInstance()) { 2906 if (!value_obj.IsNull() && !value_obj.IsInstance()) {
2902 RETURN_TYPE_ERROR(Z, value, Instance); 2907 RETURN_TYPE_ERROR(Z, value, Instance);
2903 } 2908 }
2904 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 2909 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 length); 3073 length);
3069 } 3074 }
3070 if (obj.IsError()) { 3075 if (obj.IsError()) {
3071 return list; 3076 return list;
3072 } 3077 }
3073 CHECK_CALLBACK_STATE(T); 3078 CHECK_CALLBACK_STATE(T);
3074 3079
3075 // Check and handle a dart object that implements the List interface. 3080 // Check and handle a dart object that implements the List interface.
3076 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj)); 3081 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
3077 if (!instance.IsNull()) { 3082 if (!instance.IsNull()) {
3083 const int kTypeArgsLen = 0;
3078 const int kNumArgs = 2; 3084 const int kNumArgs = 2;
3079 ArgumentsDescriptor args_desc( 3085 ArgumentsDescriptor args_desc(
3080 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 3086 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
3081 const Function& function = Function::Handle( 3087 const Function& function = Function::Handle(
3082 Z, 3088 Z,
3083 Resolver::ResolveDynamic(instance, Symbols::IndexToken(), args_desc)); 3089 Resolver::ResolveDynamic(instance, Symbols::IndexToken(), args_desc));
3084 if (!function.IsNull()) { 3090 if (!function.IsNull()) {
3085 Object& result = Object::Handle(Z); 3091 Object& result = Object::Handle(Z);
3086 Integer& intobj = Integer::Handle(Z); 3092 Integer& intobj = Integer::Handle(Z);
3087 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 3093 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
3088 args.SetAt(0, instance); // Set up the receiver as the first argument. 3094 args.SetAt(0, instance); // Set up the receiver as the first argument.
3089 for (int i = 0; i < length; i++) { 3095 for (int i = 0; i < length; i++) {
3090 HANDLESCOPE(T); 3096 HANDLESCOPE(T);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 length); 3161 length);
3156 } 3162 }
3157 if (obj.IsError()) { 3163 if (obj.IsError()) {
3158 return list; 3164 return list;
3159 } 3165 }
3160 CHECK_CALLBACK_STATE(T); 3166 CHECK_CALLBACK_STATE(T);
3161 3167
3162 // Check and handle a dart object that implements the List interface. 3168 // Check and handle a dart object that implements the List interface.
3163 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj)); 3169 const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
3164 if (!instance.IsNull()) { 3170 if (!instance.IsNull()) {
3171 const int kTypeArgsLen = 0;
3165 const int kNumArgs = 3; 3172 const int kNumArgs = 3;
3166 ArgumentsDescriptor args_desc( 3173 ArgumentsDescriptor args_desc(
3167 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); 3174 Array::Handle(Z, ArgumentsDescriptor::New(kTypeArgsLen, kNumArgs)));
3168 const Function& function = Function::Handle( 3175 const Function& function = Function::Handle(
3169 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(), 3176 Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
3170 args_desc)); 3177 args_desc));
3171 if (!function.IsNull()) { 3178 if (!function.IsNull()) {
3172 Integer& indexobj = Integer::Handle(Z); 3179 Integer& indexobj = Integer::Handle(Z);
3173 Integer& valueobj = Integer::Handle(Z); 3180 Integer& valueobj = Integer::Handle(Z);
3174 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 3181 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
3175 args.SetAt(0, instance); // Set up the receiver as the first argument. 3182 args.SetAt(0, instance); // Set up the receiver as the first argument.
3176 for (int i = 0; i < length; i++) { 3183 for (int i = 0; i < length; i++) {
3177 indexobj = Integer::New(offset + i); 3184 indexobj = Integer::New(offset + i);
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 "%s: could not find factory '%s' in class '%s'.", current_func, 3792 "%s: could not find factory '%s' in class '%s'.", current_func,
3786 constr_name.ToCString(), lookup_class_name.ToCString())); 3793 constr_name.ToCString(), lookup_class_name.ToCString()));
3787 return ApiError::New(message); 3794 return ApiError::New(message);
3788 } else { 3795 } else {
3789 const String& message = String::Handle( 3796 const String& message = String::Handle(
3790 String::NewFormatted("%s: could not find constructor '%s'.", 3797 String::NewFormatted("%s: could not find constructor '%s'.",
3791 current_func, constr_name.ToCString())); 3798 current_func, constr_name.ToCString()));
3792 return ApiError::New(message); 3799 return ApiError::New(message);
3793 } 3800 }
3794 } 3801 }
3795 int extra_args = 1; 3802 const int kTypeArgsLen = 0;
3803 const int extra_args = 1;
3796 String& error_message = String::Handle(); 3804 String& error_message = String::Handle();
3797 if (!constructor.AreValidArgumentCounts(num_args + extra_args, 0, 3805 if (!constructor.AreValidArgumentCounts(kTypeArgsLen, num_args + extra_args,
3798 &error_message)) { 3806 0, &error_message)) {
3799 const String& message = String::Handle(String::NewFormatted( 3807 const String& message = String::Handle(String::NewFormatted(
3800 "%s: wrong argument count for " 3808 "%s: wrong argument count for "
3801 "constructor '%s': %s.", 3809 "constructor '%s': %s.",
3802 current_func, constr_name.ToCString(), error_message.ToCString())); 3810 current_func, constr_name.ToCString(), error_message.ToCString()));
3803 return ApiError::New(message); 3811 return ApiError::New(message);
3804 } 3812 }
3805 return constructor.raw(); 3813 return constructor.raw();
3806 } 3814 }
3807 3815
3808 3816
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 if (constructor_name.IsNull()) { 4109 if (constructor_name.IsNull()) {
4102 strings.SetAt(2, Symbols::Empty()); 4110 strings.SetAt(2, Symbols::Empty());
4103 } else { 4111 } else {
4104 strings.SetAt(2, constructor_name); 4112 strings.SetAt(2, constructor_name);
4105 } 4113 }
4106 const String& dot_name = String::Handle(Z, String::ConcatAll(strings)); 4114 const String& dot_name = String::Handle(Z, String::ConcatAll(strings));
4107 const TypeArguments& type_arguments = 4115 const TypeArguments& type_arguments =
4108 TypeArguments::Handle(Z, type_obj.arguments()); 4116 TypeArguments::Handle(Z, type_obj.arguments());
4109 const Function& constructor = 4117 const Function& constructor =
4110 Function::Handle(Z, cls.LookupFunctionAllowPrivate(dot_name)); 4118 Function::Handle(Z, cls.LookupFunctionAllowPrivate(dot_name));
4119 const int kTypeArgsLen = 0;
4111 const int extra_args = 1; 4120 const int extra_args = 1;
4112 if (!constructor.IsNull() && constructor.IsGenerativeConstructor() && 4121 if (!constructor.IsNull() && constructor.IsGenerativeConstructor() &&
4113 constructor.AreValidArgumentCounts(number_of_arguments + extra_args, 0, 4122 constructor.AreValidArgumentCounts(
4114 NULL)) { 4123 kTypeArgsLen, number_of_arguments + extra_args, 0, NULL)) {
4115 // Create the argument list. 4124 // Create the argument list.
4116 // Constructors get the uninitialized object. 4125 // Constructors get the uninitialized object.
4117 if (!type_arguments.IsNull()) { 4126 if (!type_arguments.IsNull()) {
4118 // The type arguments will be null if the class has no type 4127 // The type arguments will be null if the class has no type
4119 // parameters, in which case the following call would fail 4128 // parameters, in which case the following call would fail
4120 // because there is no slot reserved in the object for the 4129 // because there is no slot reserved in the object for the
4121 // type vector. 4130 // type vector.
4122 instance.SetTypeArguments(type_arguments); 4131 instance.SetTypeArguments(type_arguments);
4123 } 4132 }
4124 Dart_Handle result; 4133 Dart_Handle result;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 return Api::NewError( 4167 return Api::NewError(
4159 "%s expects argument 'number_of_arguments' to be non-negative.", 4168 "%s expects argument 'number_of_arguments' to be non-negative.",
4160 CURRENT_FUNC); 4169 CURRENT_FUNC);
4161 } 4170 }
4162 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target)); 4171 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target));
4163 if (obj.IsError()) { 4172 if (obj.IsError()) {
4164 return target; 4173 return target;
4165 } 4174 }
4166 Dart_Handle result; 4175 Dart_Handle result;
4167 Array& args = Array::Handle(Z); 4176 Array& args = Array::Handle(Z);
4177 const intptr_t kTypeArgsLen = 0;
4168 if (obj.IsType()) { 4178 if (obj.IsType()) {
4169 if (!Type::Cast(obj).IsFinalized()) { 4179 if (!Type::Cast(obj).IsFinalized()) {
4170 return Api::NewError( 4180 return Api::NewError(
4171 "%s expects argument 'target' to be a fully resolved type.", 4181 "%s expects argument 'target' to be a fully resolved type.",
4172 CURRENT_FUNC); 4182 CURRENT_FUNC);
4173 } 4183 }
4174 4184
4175 const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); 4185 const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class());
4176 const Function& function = Function::Handle( 4186 const Function& function =
4177 Z, Resolver::ResolveStaticAllowPrivate( 4187 Function::Handle(Z, Resolver::ResolveStaticAllowPrivate(
4178 cls, function_name, number_of_arguments, Object::empty_array())); 4188 cls, function_name, kTypeArgsLen,
4189 number_of_arguments, Object::empty_array()));
4179 if (function.IsNull()) { 4190 if (function.IsNull()) {
4180 const String& cls_name = String::Handle(Z, cls.Name()); 4191 const String& cls_name = String::Handle(Z, cls.Name());
4181 return Api::NewError("%s: did not find static method '%s.%s'.", 4192 return Api::NewError("%s: did not find static method '%s.%s'.",
4182 CURRENT_FUNC, cls_name.ToCString(), 4193 CURRENT_FUNC, cls_name.ToCString(),
4183 function_name.ToCString()); 4194 function_name.ToCString());
4184 } 4195 }
4185 #if !defined(PRODUCT) 4196 #if !defined(PRODUCT)
4186 if (tds.enabled()) { 4197 if (tds.enabled()) {
4187 const String& cls_name = String::Handle(Z, cls.Name()); 4198 const String& cls_name = String::Handle(Z, cls.Name());
4188 tds.SetNumArguments(1); 4199 tds.SetNumArguments(1);
4189 tds.FormatArgument(0, "name", "%s.%s", cls_name.ToCString(), 4200 tds.FormatArgument(0, "name", "%s.%s", cls_name.ToCString(),
4190 function_name.ToCString()); 4201 function_name.ToCString());
4191 } 4202 }
4192 #endif // !defined(PRODUCT) 4203 #endif // !defined(PRODUCT)
4193 // Setup args and check for malformed arguments in the arguments list. 4204 // Setup args and check for malformed arguments in the arguments list.
4194 result = SetupArguments(T, number_of_arguments, arguments, 0, &args); 4205 result = SetupArguments(T, number_of_arguments, arguments, 0, &args);
4195 if (!::Dart_IsError(result)) { 4206 if (!::Dart_IsError(result)) {
4196 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args)); 4207 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
4197 } 4208 }
4198 return result; 4209 return result;
4199 } else if (obj.IsNull() || obj.IsInstance()) { 4210 } else if (obj.IsNull() || obj.IsInstance()) {
4200 // Since we have allocated an object it would mean that the type of the 4211 // Since we have allocated an object it would mean that the type of the
4201 // receiver is already resolved and finalized, hence it is not necessary 4212 // receiver is already resolved and finalized, hence it is not necessary
4202 // to check here. 4213 // to check here.
4203 Instance& instance = Instance::Handle(Z); 4214 Instance& instance = Instance::Handle(Z);
4204 instance ^= obj.raw(); 4215 instance ^= obj.raw();
4205 ArgumentsDescriptor args_desc( 4216 ArgumentsDescriptor args_desc(Array::Handle(
4206 Array::Handle(Z, ArgumentsDescriptor::New(number_of_arguments + 1))); 4217 Z, ArgumentsDescriptor::New(kTypeArgsLen, number_of_arguments + 1)));
4207 const Function& function = Function::Handle( 4218 const Function& function = Function::Handle(
4208 Z, Resolver::ResolveDynamic(instance, function_name, args_desc)); 4219 Z, Resolver::ResolveDynamic(instance, function_name, args_desc));
4209 if (function.IsNull()) { 4220 if (function.IsNull()) {
4210 // Setup args and check for malformed arguments in the arguments list. 4221 // Setup args and check for malformed arguments in the arguments list.
4211 result = SetupArguments(T, number_of_arguments, arguments, 1, &args); 4222 result = SetupArguments(T, number_of_arguments, arguments, 1, &args);
4212 if (!::Dart_IsError(result)) { 4223 if (!::Dart_IsError(result)) {
4213 args.SetAt(0, instance); 4224 args.SetAt(0, instance);
4214 const Array& args_descriptor = 4225 const Array& args_descriptor = Array::Handle(
4215 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); 4226 Z, ArgumentsDescriptor::New(kTypeArgsLen, args.Length()));
4216 result = Api::NewHandle( 4227 result = Api::NewHandle(
4217 T, DartEntry::InvokeNoSuchMethod(instance, function_name, args, 4228 T, DartEntry::InvokeNoSuchMethod(instance, function_name, args,
4218 args_descriptor)); 4229 args_descriptor));
4219 } 4230 }
4220 return result; 4231 return result;
4221 } 4232 }
4222 #if !defined(PRODUCT) 4233 #if !defined(PRODUCT)
4223 if (tds.enabled()) { 4234 if (tds.enabled()) {
4224 const Class& cls = Class::Handle(Z, instance.clazz()); 4235 const Class& cls = Class::Handle(Z, instance.clazz());
4225 ASSERT(!cls.IsNull()); 4236 ASSERT(!cls.IsNull());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 const String& lib_name = String::Handle(Z, lib.url()); 4269 const String& lib_name = String::Handle(Z, lib.url());
4259 tds.SetNumArguments(1); 4270 tds.SetNumArguments(1);
4260 tds.FormatArgument(0, "name", "%s.%s", lib_name.ToCString(), 4271 tds.FormatArgument(0, "name", "%s.%s", lib_name.ToCString(),
4261 function_name.ToCString()); 4272 function_name.ToCString());
4262 } 4273 }
4263 #endif // !defined(PRODUCT) 4274 #endif // !defined(PRODUCT)
4264 4275
4265 // LookupFunctionAllowPrivate does not check argument arity, so we 4276 // LookupFunctionAllowPrivate does not check argument arity, so we
4266 // do it here. 4277 // do it here.
4267 String& error_message = String::Handle(Z); 4278 String& error_message = String::Handle(Z);
4268 if (!function.AreValidArgumentCounts(number_of_arguments, 0, 4279 if (!function.AreValidArgumentCounts(kTypeArgsLen, number_of_arguments, 0,
4269 &error_message)) { 4280 &error_message)) {
4270 return Api::NewError("%s: wrong argument count for function '%s': %s.", 4281 return Api::NewError("%s: wrong argument count for function '%s': %s.",
4271 CURRENT_FUNC, function_name.ToCString(), 4282 CURRENT_FUNC, function_name.ToCString(),
4272 error_message.ToCString()); 4283 error_message.ToCString());
4273 } 4284 }
4274 // Setup args and check for malformed arguments in the arguments list. 4285 // Setup args and check for malformed arguments in the arguments list.
4275 result = SetupArguments(T, number_of_arguments, arguments, 0, &args); 4286 result = SetupArguments(T, number_of_arguments, arguments, 0, &args);
4276 if (!::Dart_IsError(result)) { 4287 if (!::Dart_IsError(result)) {
4277 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args)); 4288 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
4278 } 4289 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 #if !defined(PRODUCT) 4399 #if !defined(PRODUCT)
4389 if (tds.enabled()) { 4400 if (tds.enabled()) {
4390 const String& cls_name = String::Handle(cls.Name()); 4401 const String& cls_name = String::Handle(cls.Name());
4391 tds.SetNumArguments(1); 4402 tds.SetNumArguments(1);
4392 tds.FormatArgument(0, "name", "%s.%s", cls_name.ToCString(), 4403 tds.FormatArgument(0, "name", "%s.%s", cls_name.ToCString(),
4393 field_name.ToCString()); 4404 field_name.ToCString());
4394 } 4405 }
4395 #endif // !defined(PRODUCT) 4406 #endif // !defined(PRODUCT)
4396 4407
4397 // Invoke the getter and return the result. 4408 // Invoke the getter and return the result.
4409 const int kTypeArgsLen = 0;
4398 const int kNumArgs = 1; 4410 const int kNumArgs = 1;
4399 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 4411 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
4400 args.SetAt(0, instance); 4412 args.SetAt(0, instance);
4401 if (getter.IsNull()) { 4413 if (getter.IsNull()) {
4402 const Array& args_descriptor = 4414 const Array& args_descriptor = Array::Handle(
4403 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); 4415 Z, ArgumentsDescriptor::New(kTypeArgsLen, args.Length()));
4404 return Api::NewHandle( 4416 return Api::NewHandle(
4405 T, DartEntry::InvokeNoSuchMethod(instance, getter_name, args, 4417 T, DartEntry::InvokeNoSuchMethod(instance, getter_name, args,
4406 args_descriptor)); 4418 args_descriptor));
4407 } 4419 }
4408 return Api::NewHandle(T, DartEntry::InvokeFunction(getter, args)); 4420 return Api::NewHandle(T, DartEntry::InvokeFunction(getter, args));
4409 4421
4410 } else if (obj.IsLibrary()) { 4422 } else if (obj.IsLibrary()) {
4411 // To access a top-level we may need to use the Field or the 4423 // To access a top-level we may need to use the Field or the
4412 // getter Function. The getter function may either be in the 4424 // getter Function. The getter function may either be in the
4413 // library or in the field's owner class, depending. 4425 // library or in the field's owner class, depending.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 field_name.ToCString()); 4556 field_name.ToCString());
4545 } 4557 }
4546 setter = cls.LookupDynamicFunctionAllowPrivate(setter_name); 4558 setter = cls.LookupDynamicFunctionAllowPrivate(setter_name);
4547 if (!setter.IsNull()) { 4559 if (!setter.IsNull()) {
4548 break; 4560 break;
4549 } 4561 }
4550 cls = cls.SuperClass(); 4562 cls = cls.SuperClass();
4551 } 4563 }
4552 4564
4553 // Invoke the setter and return the result. 4565 // Invoke the setter and return the result.
4566 const int kTypeArgsLen = 0;
4554 const int kNumArgs = 2; 4567 const int kNumArgs = 2;
4555 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 4568 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
4556 args.SetAt(0, instance); 4569 args.SetAt(0, instance);
4557 args.SetAt(1, value_instance); 4570 args.SetAt(1, value_instance);
4558 if (setter.IsNull()) { 4571 if (setter.IsNull()) {
4559 const Array& args_descriptor = 4572 const Array& args_descriptor = Array::Handle(
4560 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); 4573 Z, ArgumentsDescriptor::New(kTypeArgsLen, args.Length()));
4561 return Api::NewHandle( 4574 return Api::NewHandle(
4562 T, DartEntry::InvokeNoSuchMethod(instance, setter_name, args, 4575 T, DartEntry::InvokeNoSuchMethod(instance, setter_name, args,
4563 args_descriptor)); 4576 args_descriptor));
4564 } 4577 }
4565 return Api::NewHandle(T, DartEntry::InvokeFunction(setter, args)); 4578 return Api::NewHandle(T, DartEntry::InvokeFunction(setter, args));
4566 4579
4567 } else if (obj.IsLibrary()) { 4580 } else if (obj.IsLibrary()) {
4568 // To access a top-level we may need to use the Field or the 4581 // To access a top-level we may need to use the Field or the
4569 // setter Function. The setter function may either be in the 4582 // setter Function. The setter function may either be in the
4570 // library or in the field's owner class, depending. 4583 // library or in the field's owner class, depending.
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after
6846 } 6859 }
6847 6860
6848 6861
6849 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { 6862 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) {
6850 #ifndef PRODUCT 6863 #ifndef PRODUCT
6851 Profiler::DumpStackTrace(context); 6864 Profiler::DumpStackTrace(context);
6852 #endif 6865 #endif
6853 } 6866 }
6854 6867
6855 } // namespace dart 6868 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_x64_test.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698