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

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

Issue 11968022: Lookup functions by name that contains the private key, except for dart_api which allows ignoring t… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 143
144 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, 144 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver,
145 const String& target_name, 145 const String& target_name,
146 const Array& arguments, 146 const Array& arguments,
147 const Array& arguments_descriptor) { 147 const Array& arguments_descriptor) {
148 ASSERT(receiver.raw() == arguments.At(0)); 148 ASSERT(receiver.raw() == arguments.At(0));
149 // Allocate an InvocationMirror object. 149 // Allocate an InvocationMirror object.
150 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 150 const Library& core_lib = Library::Handle(Library::CoreLibrary());
151 Class& invocation_mirror_class = Class::Handle( 151 Class& invocation_mirror_class = Class::Handle(
152 core_lib.LookupClassAllowPrivate(Symbols::InvocationMirror())); 152 core_lib.LookupClassAllowPrivate(Symbols::InvocationMirror()));
Ivan Posva 2013/01/17 00:25:14 Why are we allowing private here?
srdjan 2013/01/17 00:31:11 Changed to use private key.
153 ASSERT(!invocation_mirror_class.IsNull()); 153 ASSERT(!invocation_mirror_class.IsNull());
154 const String& function_name =
155 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror()));
154 const Function& allocation_function = Function::Handle( 156 const Function& allocation_function = Function::Handle(
155 Resolver::ResolveStaticByName(invocation_mirror_class, 157 Resolver::ResolveStaticByName(invocation_mirror_class,
156 Symbols::AllocateInvocationMirror(), 158 function_name,
157 Resolver::kIsQualified)); 159 Resolver::kIsQualified));
158 ASSERT(!allocation_function.IsNull()); 160 ASSERT(!allocation_function.IsNull());
159 const int kNumAllocationArgs = 3; 161 const int kNumAllocationArgs = 3;
160 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); 162 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs));
161 allocation_args.SetAt(0, target_name); 163 allocation_args.SetAt(0, target_name);
162 allocation_args.SetAt(1, arguments_descriptor); 164 allocation_args.SetAt(1, arguments_descriptor);
163 allocation_args.SetAt(2, arguments); 165 allocation_args.SetAt(2, arguments);
164 const Object& invocation_mirror = Object::Handle( 166 const Object& invocation_mirror = Object::Handle(
165 InvokeStatic(allocation_function, allocation_args)); 167 InvokeStatic(allocation_function, allocation_args));
166 168
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 Isolate* isolate = Isolate::Current(); 396 Isolate* isolate = Isolate::Current();
395 Function& function = 397 Function& function =
396 Function::Handle(isolate, 398 Function::Handle(isolate,
397 isolate->object_store()->lookup_receive_port_function()); 399 isolate->object_store()->lookup_receive_port_function());
398 const int kNumArguments = 1; 400 const int kNumArguments = 1;
399 if (function.IsNull()) { 401 if (function.IsNull()) {
400 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 402 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
401 ASSERT(!isolate_lib.IsNull()); 403 ASSERT(!isolate_lib.IsNull());
402 const String& class_name = 404 const String& class_name =
403 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); 405 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl()));
406 const String& function_name =
407 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort()));
404 function = Resolver::ResolveStatic(isolate_lib, 408 function = Resolver::ResolveStatic(isolate_lib,
405 class_name, 409 class_name,
406 Symbols::_lookupReceivePort(), 410 function_name,
407 kNumArguments, 411 kNumArguments,
408 Object::empty_array(), 412 Object::empty_array(),
409 Resolver::kIsQualified); 413 Resolver::kIsQualified);
410 isolate->object_store()->set_lookup_receive_port_function(function); 414 isolate->object_store()->set_lookup_receive_port_function(function);
411 } 415 }
412 const Array& args = Array::Handle(Array::New(kNumArguments)); 416 const Array& args = Array::Handle(Array::New(kNumArguments));
413 args.SetAt(0, Integer::Handle(Integer::New(port_id))); 417 args.SetAt(0, Integer::Handle(Integer::New(port_id)));
414 const Object& result = 418 const Object& result =
415 Object::Handle(DartEntry::InvokeStatic(function, args)); 419 Object::Handle(DartEntry::InvokeStatic(function, args));
416 return result.raw(); 420 return result.raw();
417 } 421 }
418 422
419 423
420 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, 424 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port,
421 Dart_Port reply_port_id, 425 Dart_Port reply_port_id,
422 const Instance& message) { 426 const Instance& message) {
423 Isolate* isolate = Isolate::Current(); 427 Isolate* isolate = Isolate::Current();
424 Function& function = 428 Function& function =
425 Function::Handle(isolate, 429 Function::Handle(isolate,
426 isolate->object_store()->handle_message_function()); 430 isolate->object_store()->handle_message_function());
427 const int kNumArguments = 3; 431 const int kNumArguments = 3;
428 if (function.IsNull()) { 432 if (function.IsNull()) {
429 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 433 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
430 ASSERT(!isolate_lib.IsNull()); 434 ASSERT(!isolate_lib.IsNull());
431 const String& class_name = 435 const String& class_name =
432 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); 436 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl()));
437 const String& function_name =
438 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage()));
433 function = Resolver::ResolveStatic(isolate_lib, 439 function = Resolver::ResolveStatic(isolate_lib,
434 class_name, 440 class_name,
435 Symbols::_handleMessage(), 441 function_name,
436 kNumArguments, 442 kNumArguments,
437 Object::empty_array(), 443 Object::empty_array(),
438 Resolver::kIsQualified); 444 Resolver::kIsQualified);
439 isolate->object_store()->set_handle_message_function(function); 445 isolate->object_store()->set_handle_message_function(function);
440 } 446 }
441 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); 447 const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
442 args.SetAt(0, receive_port); 448 args.SetAt(0, receive_port);
443 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); 449 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id)));
444 args.SetAt(2, message); 450 args.SetAt(2, message);
445 const Object& result = 451 const Object& result =
446 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); 452 Object::Handle(isolate, DartEntry::InvokeStatic(function, args));
447 ASSERT(result.IsNull() || result.IsError()); 453 ASSERT(result.IsNull() || result.IsError());
448 return result.raw(); 454 return result.raw();
449 } 455 }
450 456
451 457
452 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { 458 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
453 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 459 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
454 ASSERT(!isolate_lib.IsNull()); 460 ASSERT(!isolate_lib.IsNull());
455 const String& class_name = 461 const String& class_name =
456 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); 462 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl()));
457 const int kNumArguments = 1; 463 const int kNumArguments = 1;
464 const String& function_name =
465 String::Handle(isolate_lib.PrivateName(Symbols::_create()));
458 const Function& function = Function::Handle( 466 const Function& function = Function::Handle(
459 Resolver::ResolveStatic(isolate_lib, 467 Resolver::ResolveStatic(isolate_lib,
460 class_name, 468 class_name,
461 Symbols::_create(), 469 function_name,
462 kNumArguments, 470 kNumArguments,
463 Object::empty_array(), 471 Object::empty_array(),
464 Resolver::kIsQualified)); 472 Resolver::kIsQualified));
465 const Array& args = Array::Handle(Array::New(kNumArguments)); 473 const Array& args = Array::Handle(Array::New(kNumArguments));
466 args.SetAt(0, Integer::Handle(Integer::New(port_id))); 474 args.SetAt(0, Integer::Handle(Integer::New(port_id)));
467 return DartEntry::InvokeStatic(function, args); 475 return DartEntry::InvokeStatic(function, args);
468 } 476 }
469 477
470 478
471 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, 479 RawObject* DartLibraryCalls::MapSetAt(const Instance& map,
(...skipping 11 matching lines...) Expand all
483 args.SetAt(1, key); 491 args.SetAt(1, key);
484 args.SetAt(2, value); 492 args.SetAt(2, value);
485 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, 493 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function,
486 args)); 494 args));
487 return result.raw(); 495 return result.raw();
488 } 496 }
489 497
490 498
491 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { 499 RawObject* DartLibraryCalls::PortGetId(const Instance& port) {
492 const Class& cls = Class::Handle(port.clazz()); 500 const Class& cls = Class::Handle(port.clazz());
493 const String& func_name = String::Handle(Field::GetterName(Symbols::_id())); 501 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
502 const String& func_name =
503 String::Handle(isolate_lib.PrivateName(
504 String::Handle(Field::GetterName(Symbols::_id()))));
494 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); 505 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
495 ASSERT(!func.IsNull()); 506 ASSERT(!func.IsNull());
496 const Array& args = Array::Handle(Array::New(1)); 507 const Array& args = Array::Handle(Array::New(1));
497 args.SetAt(0, port); 508 args.SetAt(0, port);
498 return DartEntry::InvokeDynamic(func, args); 509 return DartEntry::InvokeDynamic(func, args);
499 } 510 }
500 511
501 512
502 } // namespace dart 513 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698