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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 1870343002: - Refactor Symbol allocation to expect a thread parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review feedback. Created 4 years, 8 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 | runtime/lib/regexp.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "lib/mirrors.h" 5 #include "lib/mirrors.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 // Argument 0 is the mirror, which is unused by the native. It exists 1293 // Argument 0 is the mirror, which is unused by the native. It exists
1294 // because this native is an instance method in order to be polymorphic 1294 // because this native is an instance method in order to be polymorphic
1295 // with its cousins. 1295 // with its cousins.
1296 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1)); 1296 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1));
1297 GET_NON_NULL_NATIVE_ARGUMENT( 1297 GET_NON_NULL_NATIVE_ARGUMENT(
1298 String, function_name, arguments->NativeArgAt(2)); 1298 String, function_name, arguments->NativeArgAt(2));
1299 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3)); 1299 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3));
1300 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4)); 1300 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4));
1301 1301
1302 Class& klass = Class::Handle(reflectee.clazz()); 1302 Class& klass = Class::Handle(reflectee.clazz());
1303 Function& function = Function::Handle( 1303 Function& function = Function::Handle(zone,
1304 Resolver::ResolveDynamicAnyArgs(klass, function_name)); 1304 Resolver::ResolveDynamicAnyArgs(zone, klass, function_name));
1305 1305
1306 const Array& args_descriptor = 1306 const Array& args_descriptor =
1307 Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names)); 1307 Array::Handle(zone, ArgumentsDescriptor::New(args.Length(), arg_names));
1308 1308
1309 if (function.IsNull()) { 1309 if (function.IsNull()) {
1310 // Didn't find a method: try to find a getter and invoke call on its result. 1310 // Didn't find a method: try to find a getter and invoke call on its result.
1311 const String& getter_name = 1311 const String& getter_name =
1312 String::Handle(Field::GetterName(function_name)); 1312 String::Handle(zone, Field::GetterName(function_name));
1313 function = Resolver::ResolveDynamicAnyArgs(klass, getter_name); 1313 function = Resolver::ResolveDynamicAnyArgs(zone, klass, getter_name);
1314 if (!function.IsNull()) { 1314 if (!function.IsNull()) {
1315 ASSERT(function.kind() != RawFunction::kMethodExtractor); 1315 ASSERT(function.kind() != RawFunction::kMethodExtractor);
1316 // Invoke the getter. 1316 // Invoke the getter.
1317 const int kNumArgs = 1; 1317 const int kNumArgs = 1;
1318 const Array& getter_args = Array::Handle(Array::New(kNumArgs)); 1318 const Array& getter_args = Array::Handle(zone, Array::New(kNumArgs));
1319 getter_args.SetAt(0, reflectee); 1319 getter_args.SetAt(0, reflectee);
1320 const Array& getter_args_descriptor = 1320 const Array& getter_args_descriptor =
1321 Array::Handle(ArgumentsDescriptor::New(getter_args.Length())); 1321 Array::Handle(zone, ArgumentsDescriptor::New(getter_args.Length()));
1322 const Instance& getter_result = Instance::Handle( 1322 const Instance& getter_result = Instance::Handle(zone,
1323 InvokeDynamicFunction(reflectee, 1323 InvokeDynamicFunction(reflectee,
1324 function, 1324 function,
1325 getter_name, 1325 getter_name,
1326 getter_args, 1326 getter_args,
1327 getter_args_descriptor)); 1327 getter_args_descriptor));
1328 // Replace the closure as the receiver in the arguments list. 1328 // Replace the closure as the receiver in the arguments list.
1329 args.SetAt(0, getter_result); 1329 args.SetAt(0, getter_result);
1330 // Call the closure. 1330 // Call the closure.
1331 const Object& call_result = 1331 const Object& call_result =
1332 Object::Handle(DartEntry::InvokeClosure(args, args_descriptor)); 1332 Object::Handle(zone, DartEntry::InvokeClosure(args, args_descriptor));
1333 if (call_result.IsError()) { 1333 if (call_result.IsError()) {
1334 Exceptions::PropagateError(Error::Cast(call_result)); 1334 Exceptions::PropagateError(Error::Cast(call_result));
1335 UNREACHABLE(); 1335 UNREACHABLE();
1336 } 1336 }
1337 return call_result.raw(); 1337 return call_result.raw();
1338 } 1338 }
1339 } 1339 }
1340 1340
1341 // Found an ordinary method. 1341 // Found an ordinary method.
1342 return InvokeDynamicFunction(reflectee, 1342 return InvokeDynamicFunction(reflectee,
1343 function, 1343 function,
1344 function_name, 1344 function_name,
1345 args, 1345 args,
1346 args_descriptor); 1346 args_descriptor);
1347 } 1347 }
1348 1348
1349 1349
1350 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) { 1350 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) {
1351 // Argument 0 is the mirror, which is unused by the native. It exists 1351 // Argument 0 is the mirror, which is unused by the native. It exists
1352 // because this native is an instance method in order to be polymorphic 1352 // because this native is an instance method in order to be polymorphic
1353 // with its cousins. 1353 // with its cousins.
1354 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1)); 1354 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1));
1355 GET_NON_NULL_NATIVE_ARGUMENT(String, getter_name, arguments->NativeArgAt(2)); 1355 GET_NON_NULL_NATIVE_ARGUMENT(String, getter_name, arguments->NativeArgAt(2));
1356 Class& klass = Class::Handle(reflectee.clazz()); 1356 Class& klass = Class::Handle(reflectee.clazz());
1357 1357
1358 const String& internal_getter_name = String::Handle( 1358 const String& internal_getter_name = String::Handle(
1359 Field::GetterName(getter_name)); 1359 Field::GetterName(getter_name));
1360 Function& function = Function::Handle( 1360 Function& function = Function::Handle(zone,
1361 Resolver::ResolveDynamicAnyArgs(klass, internal_getter_name)); 1361 Resolver::ResolveDynamicAnyArgs(zone, klass, internal_getter_name));
1362 1362
1363 // Check for method extraction when method extractors are not created. 1363 // Check for method extraction when method extractors are not created.
1364 if (function.IsNull() && !FLAG_lazy_dispatchers) { 1364 if (function.IsNull() && !FLAG_lazy_dispatchers) {
1365 function = Resolver::ResolveDynamicAnyArgs(klass, getter_name); 1365 function = Resolver::ResolveDynamicAnyArgs(zone, klass, getter_name);
1366 if (!function.IsNull()) { 1366 if (!function.IsNull()) {
1367 const Function& closure_function = 1367 const Function& closure_function =
1368 Function::Handle(function.ImplicitClosureFunction()); 1368 Function::Handle(zone, function.ImplicitClosureFunction());
1369 return closure_function.ImplicitInstanceClosure(reflectee); 1369 return closure_function.ImplicitInstanceClosure(reflectee);
1370 } 1370 }
1371 } 1371 }
1372 1372
1373 const int kNumArgs = 1; 1373 const int kNumArgs = 1;
1374 const Array& args = Array::Handle(Array::New(kNumArgs)); 1374 const Array& args = Array::Handle(zone, Array::New(kNumArgs));
1375 args.SetAt(0, reflectee); 1375 args.SetAt(0, reflectee);
1376 const Array& args_descriptor = 1376 const Array& args_descriptor =
1377 Array::Handle(ArgumentsDescriptor::New(args.Length())); 1377 Array::Handle(zone, ArgumentsDescriptor::New(args.Length()));
1378 1378
1379 // InvokeDynamic invokes NoSuchMethod if the provided function is null. 1379 // InvokeDynamic invokes NoSuchMethod if the provided function is null.
1380 return InvokeDynamicFunction(reflectee, 1380 return InvokeDynamicFunction(reflectee,
1381 function, 1381 function,
1382 internal_getter_name, 1382 internal_getter_name,
1383 args, 1383 args,
1384 args_descriptor); 1384 args_descriptor);
1385 } 1385 }
1386 1386
1387 1387
1388 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeSetter, 4) { 1388 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeSetter, 4) {
1389 // Argument 0 is the mirror, which is unused by the native. It exists 1389 // Argument 0 is the mirror, which is unused by the native. It exists
1390 // because this native is an instance method in order to be polymorphic 1390 // because this native is an instance method in order to be polymorphic
1391 // with its cousins. 1391 // with its cousins.
1392 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1)); 1392 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1));
1393 GET_NON_NULL_NATIVE_ARGUMENT(String, setter_name, arguments->NativeArgAt(2)); 1393 GET_NON_NULL_NATIVE_ARGUMENT(String, setter_name, arguments->NativeArgAt(2));
1394 GET_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(3)); 1394 GET_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(3));
1395 1395
1396 const Class& klass = Class::Handle(reflectee.clazz()); 1396 const Class& klass = Class::Handle(zone, reflectee.clazz());
1397 const String& internal_setter_name = 1397 const String& internal_setter_name =
1398 String::Handle(Field::SetterName(setter_name)); 1398 String::Handle(zone, Field::SetterName(setter_name));
1399 const Function& setter = Function::Handle( 1399 const Function& setter = Function::Handle(zone,
1400 Resolver::ResolveDynamicAnyArgs(klass, internal_setter_name)); 1400 Resolver::ResolveDynamicAnyArgs(zone, klass, internal_setter_name));
1401 1401
1402 const int kNumArgs = 2; 1402 const int kNumArgs = 2;
1403 const Array& args = Array::Handle(Array::New(kNumArgs)); 1403 const Array& args = Array::Handle(zone, Array::New(kNumArgs));
1404 args.SetAt(0, reflectee); 1404 args.SetAt(0, reflectee);
1405 args.SetAt(1, value); 1405 args.SetAt(1, value);
1406 const Array& args_descriptor = 1406 const Array& args_descriptor =
1407 Array::Handle(ArgumentsDescriptor::New(args.Length())); 1407 Array::Handle(zone, ArgumentsDescriptor::New(args.Length()));
1408 1408
1409 return InvokeDynamicFunction(reflectee, 1409 return InvokeDynamicFunction(reflectee,
1410 setter, 1410 setter,
1411 internal_setter_name, 1411 internal_setter_name,
1412 args, 1412 args,
1413 args_descriptor); 1413 args_descriptor);
1414 } 1414 }
1415 1415
1416 1416
1417 DEFINE_NATIVE_ENTRY(InstanceMirror_computeType, 1) { 1417 DEFINE_NATIVE_ENTRY(InstanceMirror_computeType, 1) {
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 2106
2107 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2107 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2108 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2108 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2109 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2109 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2110 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); 2110 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw();
2111 } 2111 }
2112 2112
2113 #endif // !PRODUCT 2113 #endif // !PRODUCT
2114 2114
2115 } // namespace dart 2115 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698