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

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

Issue 1393373003: Remove isolate argument from handle allocation: Part I (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanups Created 5 years, 2 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/constant_propagator.cc ('k') | runtime/vm/debugger.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) 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/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const int kNumArguments = 2; 222 const int kNumArguments = 2;
223 ArgumentsDescriptor args_desc( 223 ArgumentsDescriptor args_desc(
224 Array::Handle(ArgumentsDescriptor::New(kNumArguments))); 224 Array::Handle(ArgumentsDescriptor::New(kNumArguments)));
225 Function& function = Function::Handle( 225 Function& function = Function::Handle(
226 Resolver::ResolveDynamic(receiver, 226 Resolver::ResolveDynamic(receiver,
227 Symbols::NoSuchMethod(), 227 Symbols::NoSuchMethod(),
228 args_desc)); 228 args_desc));
229 if (function.IsNull()) { 229 if (function.IsNull()) {
230 ASSERT(!FLAG_lazy_dispatchers); 230 ASSERT(!FLAG_lazy_dispatchers);
231 // If noSuchMethod(invocation) is not found, call Object::noSuchMethod. 231 // If noSuchMethod(invocation) is not found, call Object::noSuchMethod.
232 Isolate* isolate = Isolate::Current(); 232 Thread* thread = Thread::Current();
233 function ^= Resolver::ResolveDynamicForReceiverClass( 233 function ^= Resolver::ResolveDynamicForReceiverClass(
234 Class::Handle(isolate, isolate->object_store()->object_class()), 234 Class::Handle(thread->zone(),
235 thread->isolate()->object_store()->object_class()),
235 Symbols::NoSuchMethod(), 236 Symbols::NoSuchMethod(),
236 args_desc); 237 args_desc);
237 } 238 }
238 ASSERT(!function.IsNull()); 239 ASSERT(!function.IsNull());
239 const Array& args = Array::Handle(Array::New(kNumArguments)); 240 const Array& args = Array::Handle(Array::New(kNumArguments));
240 args.SetAt(0, receiver); 241 args.SetAt(0, receiver);
241 args.SetAt(1, invocation_mirror); 242 args.SetAt(1, invocation_mirror);
242 return InvokeFunction(function, args); 243 return InvokeFunction(function, args);
243 } 244 }
244 245
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 args.SetAt(0, left); 477 args.SetAt(0, left);
477 args.SetAt(1, right); 478 args.SetAt(1, right);
478 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 479 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
479 args)); 480 args));
480 ASSERT(result.IsInstance() || result.IsError()); 481 ASSERT(result.IsInstance() || result.IsError());
481 return result.raw(); 482 return result.raw();
482 } 483 }
483 484
484 485
485 RawObject* DartLibraryCalls::LookupHandler(Dart_Port port_id) { 486 RawObject* DartLibraryCalls::LookupHandler(Dart_Port port_id) {
486 Isolate* isolate = Isolate::Current(); 487 Thread* thread = Thread::Current();
487 Function& function = 488 Function& function = Function::Handle(thread->zone(),
488 Function::Handle(isolate, 489 thread->isolate()->object_store()->lookup_port_handler());
489 isolate->object_store()->lookup_port_handler());
490 const int kNumArguments = 1; 490 const int kNumArguments = 1;
491 if (function.IsNull()) { 491 if (function.IsNull()) {
492 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 492 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
493 ASSERT(!isolate_lib.IsNull()); 493 ASSERT(!isolate_lib.IsNull());
494 const String& class_name = 494 const String& class_name =
495 String::Handle(isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); 495 String::Handle(isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
496 const String& function_name = 496 const String& function_name =
497 String::Handle(isolate_lib.PrivateName(Symbols::_lookupHandler())); 497 String::Handle(isolate_lib.PrivateName(Symbols::_lookupHandler()));
498 function = Resolver::ResolveStatic(isolate_lib, 498 function = Resolver::ResolveStatic(isolate_lib,
499 class_name, 499 class_name,
500 function_name, 500 function_name,
501 kNumArguments, 501 kNumArguments,
502 Object::empty_array()); 502 Object::empty_array());
503 ASSERT(!function.IsNull()); 503 ASSERT(!function.IsNull());
504 isolate->object_store()->set_lookup_port_handler(function); 504 thread->isolate()->object_store()->set_lookup_port_handler(function);
505 } 505 }
506 const Array& args = Array::Handle(Array::New(kNumArguments)); 506 const Array& args = Array::Handle(Array::New(kNumArguments));
507 args.SetAt(0, Integer::Handle(Integer::New(port_id))); 507 args.SetAt(0, Integer::Handle(Integer::New(port_id)));
508 const Object& result = 508 const Object& result =
509 Object::Handle(DartEntry::InvokeFunction(function, args)); 509 Object::Handle(DartEntry::InvokeFunction(function, args));
510 return result.raw(); 510 return result.raw();
511 } 511 }
512 512
513 513
514 RawObject* DartLibraryCalls::HandleMessage(const Object& handler, 514 RawObject* DartLibraryCalls::HandleMessage(const Object& handler,
515 const Instance& message) { 515 const Instance& message) {
516 Isolate* isolate = Isolate::Current(); 516 Thread* thread = Thread::Current();
517 Function& function = Function::Handle(isolate, 517 Zone* zone = thread->zone();
518 Isolate* isolate = thread->isolate();
519 Function& function = Function::Handle(zone,
518 isolate->object_store()->handle_message_function()); 520 isolate->object_store()->handle_message_function());
519 const int kNumArguments = 2; 521 const int kNumArguments = 2;
520 if (function.IsNull()) { 522 if (function.IsNull()) {
521 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); 523 Library& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
522 ASSERT(!isolate_lib.IsNull()); 524 ASSERT(!isolate_lib.IsNull());
523 const String& class_name = String::Handle(isolate, 525 const String& class_name = String::Handle(zone,
524 isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); 526 isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
525 const String& function_name = String::Handle(isolate, 527 const String& function_name = String::Handle(zone,
526 isolate_lib.PrivateName(Symbols::_handleMessage())); 528 isolate_lib.PrivateName(Symbols::_handleMessage()));
527 function = Resolver::ResolveStatic(isolate_lib, 529 function = Resolver::ResolveStatic(isolate_lib,
528 class_name, 530 class_name,
529 function_name, 531 function_name,
530 kNumArguments, 532 kNumArguments,
531 Object::empty_array()); 533 Object::empty_array());
532 ASSERT(!function.IsNull()); 534 ASSERT(!function.IsNull());
533 isolate->object_store()->set_handle_message_function(function); 535 isolate->object_store()->set_handle_message_function(function);
534 } 536 }
535 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); 537 const Array& args = Array::Handle(zone, Array::New(kNumArguments));
536 args.SetAt(0, handler); 538 args.SetAt(0, handler);
537 args.SetAt(1, message); 539 args.SetAt(1, message);
538 if (isolate->debugger()->IsStepping()) { 540 if (isolate->debugger()->IsStepping()) {
539 // If the isolate is being debugged and the debugger was stepping 541 // If the isolate is being debugged and the debugger was stepping
540 // through code, enable single stepping so debugger will stop 542 // through code, enable single stepping so debugger will stop
541 // at the first location the user is interested in. 543 // at the first location the user is interested in.
542 isolate->debugger()->SetSingleStep(); 544 isolate->debugger()->SetSingleStep();
543 } 545 }
544 const Object& result = Object::Handle(isolate, 546 const Object& result = Object::Handle(zone,
545 DartEntry::InvokeFunction(function, args)); 547 DartEntry::InvokeFunction(function, args));
546 ASSERT(result.IsNull() || result.IsError()); 548 ASSERT(result.IsNull() || result.IsError());
547 return result.raw(); 549 return result.raw();
548 } 550 }
549 551
550 552
551 RawObject* DartLibraryCalls::DrainMicrotaskQueue() { 553 RawObject* DartLibraryCalls::DrainMicrotaskQueue() {
552 Isolate* isolate = Isolate::Current(); 554 Zone* zone = Thread::Current()->zone();
553 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); 555 Library& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
554 ASSERT(!isolate_lib.IsNull()); 556 ASSERT(!isolate_lib.IsNull());
555 Function& function = Function::Handle(isolate, 557 Function& function = Function::Handle(zone,
556 isolate_lib.LookupFunctionAllowPrivate( 558 isolate_lib.LookupFunctionAllowPrivate(
557 Symbols::_runPendingImmediateCallback())); 559 Symbols::_runPendingImmediateCallback()));
558 const Object& result = Object::Handle(isolate, 560 const Object& result = Object::Handle(zone,
559 DartEntry::InvokeFunction(function, Object::empty_array())); 561 DartEntry::InvokeFunction(function, Object::empty_array()));
560 ASSERT(result.IsNull() || result.IsError()); 562 ASSERT(result.IsNull() || result.IsError());
561 return result.raw(); 563 return result.raw();
562 } 564 }
563 565
564 566
565 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, 567 RawObject* DartLibraryCalls::MapSetAt(const Instance& map,
566 const Instance& key, 568 const Instance& key,
567 const Instance& value) { 569 const Instance& value) {
568 const int kNumArguments = 3; 570 const int kNumArguments = 3;
569 ArgumentsDescriptor args_desc( 571 ArgumentsDescriptor args_desc(
570 Array::Handle(ArgumentsDescriptor::New(kNumArguments))); 572 Array::Handle(ArgumentsDescriptor::New(kNumArguments)));
571 const Function& function = Function::Handle( 573 const Function& function = Function::Handle(
572 Resolver::ResolveDynamic(map, 574 Resolver::ResolveDynamic(map,
573 Symbols::AssignIndexToken(), 575 Symbols::AssignIndexToken(),
574 args_desc)); 576 args_desc));
575 ASSERT(!function.IsNull()); 577 ASSERT(!function.IsNull());
576 const Array& args = Array::Handle(Array::New(kNumArguments)); 578 const Array& args = Array::Handle(Array::New(kNumArguments));
577 args.SetAt(0, map); 579 args.SetAt(0, map);
578 args.SetAt(1, key); 580 args.SetAt(1, key);
579 args.SetAt(2, value); 581 args.SetAt(2, value);
580 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 582 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
581 args)); 583 args));
582 return result.raw(); 584 return result.raw();
583 } 585 }
584 586
585 } // namespace dart 587 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698