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

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

Issue 1951003002: Include the field name and function name in Dart_GetField and Dart_Invoke timeline events (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | « no previous file | no next file » | 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 4103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4114 function_name, 4114 function_name,
4115 number_of_arguments, 4115 number_of_arguments,
4116 Object::empty_array())); 4116 Object::empty_array()));
4117 if (function.IsNull()) { 4117 if (function.IsNull()) {
4118 const String& cls_name = String::Handle(Z, cls.Name()); 4118 const String& cls_name = String::Handle(Z, cls.Name());
4119 return Api::NewError("%s: did not find static method '%s.%s'.", 4119 return Api::NewError("%s: did not find static method '%s.%s'.",
4120 CURRENT_FUNC, 4120 CURRENT_FUNC,
4121 cls_name.ToCString(), 4121 cls_name.ToCString(),
4122 function_name.ToCString()); 4122 function_name.ToCString());
4123 } 4123 }
4124 NOT_IN_PRODUCT(if (tds.enabled()) {
4125 const String& cls_name = String::Handle(Z, cls.Name());
4126 tds.SetNumArguments(1);
4127 tds.FormatArgument(0,
4128 "name",
4129 "%s.%s",
4130 cls_name.ToCString(),
4131 function_name.ToCString());
4132 });
4124 // Setup args and check for malformed arguments in the arguments list. 4133 // Setup args and check for malformed arguments in the arguments list.
4125 result = SetupArguments(T, number_of_arguments, arguments, 0, &args); 4134 result = SetupArguments(T, number_of_arguments, arguments, 0, &args);
4126 if (!::Dart_IsError(result)) { 4135 if (!::Dart_IsError(result)) {
4127 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args)); 4136 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
4128 } 4137 }
4129 return result; 4138 return result;
4130 } else if (obj.IsNull() || obj.IsInstance()) { 4139 } else if (obj.IsNull() || obj.IsInstance()) {
4131 // Since we have allocated an object it would mean that the type of the 4140 // Since we have allocated an object it would mean that the type of the
4132 // receiver is already resolved and finalized, hence it is not necessary 4141 // receiver is already resolved and finalized, hence it is not necessary
4133 // to check here. 4142 // to check here.
(...skipping 15 matching lines...) Expand all
4149 const Array& args_descriptor = 4158 const Array& args_descriptor =
4150 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); 4159 Array::Handle(Z, ArgumentsDescriptor::New(args.Length()));
4151 result = Api::NewHandle(T, 4160 result = Api::NewHandle(T,
4152 DartEntry::InvokeNoSuchMethod(instance, 4161 DartEntry::InvokeNoSuchMethod(instance,
4153 function_name, 4162 function_name,
4154 args, 4163 args,
4155 args_descriptor)); 4164 args_descriptor));
4156 } 4165 }
4157 return result; 4166 return result;
4158 } 4167 }
4168 NOT_IN_PRODUCT(if (tds.enabled()) {
4169 const Class& cls = Class::Handle(Z, instance.clazz());
4170 ASSERT(!cls.IsNull());
4171 const String& cls_name = String::Handle(Z, cls.Name());
4172 tds.SetNumArguments(1);
4173 tds.FormatArgument(0,
4174 "name",
4175 "%s.%s",
4176 cls_name.ToCString(),
4177 function_name.ToCString());
4178 });
4159 // Setup args and check for malformed arguments in the arguments list. 4179 // Setup args and check for malformed arguments in the arguments list.
4160 result = SetupArguments(T, number_of_arguments, arguments, 1, &args); 4180 result = SetupArguments(T, number_of_arguments, arguments, 1, &args);
4161 if (!::Dart_IsError(result)) { 4181 if (!::Dart_IsError(result)) {
4162 args.SetAt(0, instance); 4182 args.SetAt(0, instance);
4163 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args)); 4183 result = Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
4164 } 4184 }
4165 return result; 4185 return result;
4166 } else if (obj.IsLibrary()) { 4186 } else if (obj.IsLibrary()) {
4167 // Check whether class finalization is needed. 4187 // Check whether class finalization is needed.
4168 const Library& lib = Library::Cast(obj); 4188 const Library& lib = Library::Cast(obj);
4169 4189
4170 // Check that the library is loaded. 4190 // Check that the library is loaded.
4171 if (!lib.Loaded()) { 4191 if (!lib.Loaded()) {
4172 return Api::NewError( 4192 return Api::NewError(
4173 "%s expects library argument 'target' to be loaded.", 4193 "%s expects library argument 'target' to be loaded.",
4174 CURRENT_FUNC); 4194 CURRENT_FUNC);
4175 } 4195 }
4176 4196
4177 const Function& function = 4197 const Function& function =
4178 Function::Handle(Z, lib.LookupFunctionAllowPrivate(function_name)); 4198 Function::Handle(Z, lib.LookupFunctionAllowPrivate(function_name));
4179 if (function.IsNull()) { 4199 if (function.IsNull()) {
4180 return Api::NewError("%s: did not find top-level function '%s'.", 4200 return Api::NewError("%s: did not find top-level function '%s'.",
4181 CURRENT_FUNC, 4201 CURRENT_FUNC,
4182 function_name.ToCString()); 4202 function_name.ToCString());
4183 } 4203 }
4204
4205 NOT_IN_PRODUCT(if (tds.enabled()) {
4206 const String& lib_name = String::Handle(Z, lib.url());
4207 tds.SetNumArguments(1);
4208 tds.FormatArgument(0,
4209 "name",
4210 "%s.%s",
4211 lib_name.ToCString(),
4212 function_name.ToCString());
4213 });
4214
4184 // LookupFunctionAllowPrivate does not check argument arity, so we 4215 // LookupFunctionAllowPrivate does not check argument arity, so we
4185 // do it here. 4216 // do it here.
4186 String& error_message = String::Handle(Z); 4217 String& error_message = String::Handle(Z);
4187 if (!function.AreValidArgumentCounts(number_of_arguments, 4218 if (!function.AreValidArgumentCounts(number_of_arguments,
4188 0, 4219 0,
4189 &error_message)) { 4220 &error_message)) {
4190 return Api::NewError("%s: wrong argument count for function '%s': %s.", 4221 return Api::NewError("%s: wrong argument count for function '%s': %s.",
4191 CURRENT_FUNC, 4222 CURRENT_FUNC,
4192 function_name.ToCString(), 4223 function_name.ToCString(),
4193 error_message.ToCString()); 4224 error_message.ToCString());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4264 // getter Function. 4295 // getter Function.
4265 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); 4296 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class());
4266 4297
4267 field = cls.LookupStaticFieldAllowPrivate(field_name); 4298 field = cls.LookupStaticFieldAllowPrivate(field_name);
4268 if (field.IsNull() || field.IsUninitialized()) { 4299 if (field.IsNull() || field.IsUninitialized()) {
4269 const String& getter_name = 4300 const String& getter_name =
4270 String::Handle(Z, Field::GetterName(field_name)); 4301 String::Handle(Z, Field::GetterName(field_name));
4271 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); 4302 getter = cls.LookupStaticFunctionAllowPrivate(getter_name);
4272 } 4303 }
4273 4304
4305 NOT_IN_PRODUCT(if (tds.enabled()) {
4306 const String& cls_name = String::Handle(cls.Name());
4307 tds.SetNumArguments(1);
4308 tds.FormatArgument(0,
4309 "name",
4310 "%s.%s",
4311 cls_name.ToCString(), field_name.ToCString());
4312 });
4313
4274 if (!getter.IsNull()) { 4314 if (!getter.IsNull()) {
4275 // Invoke the getter and return the result. 4315 // Invoke the getter and return the result.
4276 return Api::NewHandle( 4316 return Api::NewHandle(
4277 T, DartEntry::InvokeFunction(getter, Object::empty_array())); 4317 T, DartEntry::InvokeFunction(getter, Object::empty_array()));
4278 } else if (!field.IsNull()) { 4318 } else if (!field.IsNull()) {
4279 return Api::NewHandle(T, field.StaticValue()); 4319 return Api::NewHandle(T, field.StaticValue());
4280 } else { 4320 } else {
4281 return Api::NewError("%s: did not find static field '%s'.", 4321 return Api::NewError("%s: did not find static field '%s'.",
4282 CURRENT_FUNC, field_name.ToCString()); 4322 CURRENT_FUNC, field_name.ToCString());
4283 } 4323 }
4284 4324
4285 } else if (obj.IsInstance()) { 4325 } else if (obj.IsInstance()) {
4286 // Every instance field has a getter Function. Try to find the 4326 // Every instance field has a getter Function. Try to find the
4287 // getter in any superclass and use that function to access the 4327 // getter in any superclass and use that function to access the
4288 // field. 4328 // field.
4289 const Instance& instance = Instance::Cast(obj); 4329 const Instance& instance = Instance::Cast(obj);
4290 Class& cls = Class::Handle(Z, instance.clazz()); 4330 Class& cls = Class::Handle(Z, instance.clazz());
4291 String& getter_name = String::Handle(Z, Field::GetterName(field_name)); 4331 String& getter_name = String::Handle(Z, Field::GetterName(field_name));
4292 while (!cls.IsNull()) { 4332 while (!cls.IsNull()) {
4293 getter = cls.LookupDynamicFunctionAllowPrivate(getter_name); 4333 getter = cls.LookupDynamicFunctionAllowPrivate(getter_name);
4294 if (!getter.IsNull()) { 4334 if (!getter.IsNull()) {
4295 break; 4335 break;
4296 } 4336 }
4297 cls = cls.SuperClass(); 4337 cls = cls.SuperClass();
4298 } 4338 }
4299 4339
4340 NOT_IN_PRODUCT(if (tds.enabled()) {
4341 const String& cls_name = String::Handle(cls.Name());
4342 tds.SetNumArguments(1);
4343 tds.FormatArgument(0,
4344 "name",
4345 "%s.%s",
4346 cls_name.ToCString(), field_name.ToCString());
4347 });
4348
4300 // Invoke the getter and return the result. 4349 // Invoke the getter and return the result.
4301 const int kNumArgs = 1; 4350 const int kNumArgs = 1;
4302 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); 4351 const Array& args = Array::Handle(Z, Array::New(kNumArgs));
4303 args.SetAt(0, instance); 4352 args.SetAt(0, instance);
4304 if (getter.IsNull()) { 4353 if (getter.IsNull()) {
4305 const Array& args_descriptor = 4354 const Array& args_descriptor =
4306 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); 4355 Array::Handle(Z, ArgumentsDescriptor::New(args.Length()));
4307 return Api::NewHandle(T, DartEntry::InvokeNoSuchMethod(instance, 4356 return Api::NewHandle(T, DartEntry::InvokeNoSuchMethod(instance,
4308 getter_name, 4357 getter_name,
4309 args, 4358 args,
(...skipping 19 matching lines...) Expand all
4329 String::Handle(Z, Field::GetterName(field_name)); 4378 String::Handle(Z, Field::GetterName(field_name));
4330 getter = lib.LookupFunctionAllowPrivate(getter_name); 4379 getter = lib.LookupFunctionAllowPrivate(getter_name);
4331 } else if (!field.IsNull() && field.IsUninitialized()) { 4380 } else if (!field.IsNull() && field.IsUninitialized()) {
4332 // A field was found. Check for a getter in the field's owner classs. 4381 // A field was found. Check for a getter in the field's owner classs.
4333 const Class& cls = Class::Handle(Z, field.Owner()); 4382 const Class& cls = Class::Handle(Z, field.Owner());
4334 const String& getter_name = String::Handle(Z, 4383 const String& getter_name = String::Handle(Z,
4335 Field::GetterName(field_name)); 4384 Field::GetterName(field_name));
4336 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); 4385 getter = cls.LookupStaticFunctionAllowPrivate(getter_name);
4337 } 4386 }
4338 4387
4388 NOT_IN_PRODUCT(if (tds.enabled()) {
4389 const String& lib_name = String::Handle(lib.url());
4390 tds.SetNumArguments(1);
4391 tds.FormatArgument(0,
4392 "name",
4393 "%s.%s",
4394 lib_name.ToCString(), field_name.ToCString());
4395 });
4396
4339 if (!getter.IsNull()) { 4397 if (!getter.IsNull()) {
4340 // Invoke the getter and return the result. 4398 // Invoke the getter and return the result.
4341 return Api::NewHandle( 4399 return Api::NewHandle(
4342 T, DartEntry::InvokeFunction(getter, Object::empty_array())); 4400 T, DartEntry::InvokeFunction(getter, Object::empty_array()));
4343 } 4401 }
4344 if (!field.IsNull()) { 4402 if (!field.IsNull()) {
4345 return Api::NewHandle(T, field.StaticValue()); 4403 return Api::NewHandle(T, field.StaticValue());
4346 } 4404 }
4347 return Api::NewError("%s: did not find top-level variable '%s'.", 4405 return Api::NewError("%s: did not find top-level variable '%s'.",
4348 CURRENT_FUNC, field_name.ToCString()); 4406 CURRENT_FUNC, field_name.ToCString());
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
6302 6360
6303 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6361 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6304 #if defined(DART_PRECOMPILED_RUNTIME) 6362 #if defined(DART_PRECOMPILED_RUNTIME)
6305 return true; 6363 return true;
6306 #else 6364 #else
6307 return false; 6365 return false;
6308 #endif 6366 #endif
6309 } 6367 }
6310 6368
6311 } // namespace dart 6369 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698