Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 Isolate* isolate = Isolate::Current(); | 643 Isolate* isolate = Isolate::Current(); |
| 644 // Process all OOB messages and at most one normal message. | 644 // Process all OOB messages and at most one normal message. |
| 645 Message* message = NULL; | 645 Message* message = NULL; |
| 646 Message::Priority priority = Message::kNormalPriority; | 646 Message::Priority priority = Message::kNormalPriority; |
| 647 do { | 647 do { |
| 648 DARTSCOPE(isolate); | 648 DARTSCOPE(isolate); |
| 649 message = isolate->message_handler()->queue()->DequeueNoWait(); | 649 message = isolate->message_handler()->queue()->DequeueNoWait(); |
| 650 if (message == NULL) { | 650 if (message == NULL) { |
| 651 break; | 651 break; |
| 652 } | 652 } |
| 653 const Instance& msg = | |
| 654 Instance::Handle(DeserializeMessage(message->data())); | |
| 653 priority = message->priority(); | 655 priority = message->priority(); |
| 654 if (priority == Message::kOOBPriority) { | 656 if (priority == Message::kOOBPriority) { |
| 655 // TODO(turnidge): Out of band messages will not go through the | 657 // For now the only OOB messages are Mirrors messages. |
| 656 // regular message handler. Instead they will be dispatched to | 658 const Object& result = Object::Handle( |
| 657 // special vm code. Implement. | 659 DartLibraryCalls::HandleMirrorsMessage( |
| 658 UNIMPLEMENTED(); | 660 message->dest_port(), message->reply_port(), msg)); |
| 661 delete message; | |
| 662 if (result.IsError()) { | |
| 663 // TODO(turnidge): Propagating the error is probably wrong here. | |
| 664 return Api::NewLocalHandle(result); | |
| 665 } | |
| 666 ASSERT(result.IsNull()); | |
|
siva
2012/02/18 01:25:55
There seems to be some duplication here and in cod
turnidge
2012/03/07 20:00:14
Yes. There is duplication. Can I clean it up dur
siva
2012/03/08 22:24:02
Ok (maybe add a TODO at the duplication points).
turnidge
2012/03/08 22:50:51
Done.
| |
| 667 } else { | |
| 668 const Object& result = Object::Handle( | |
| 669 DartLibraryCalls::HandleMessage( | |
| 670 message->dest_port(), message->reply_port(), msg)); | |
| 671 delete message; | |
| 672 if (result.IsError()) { | |
| 673 return Api::NewLocalHandle(result); | |
| 674 } | |
| 675 ASSERT(result.IsNull()); | |
| 659 } | 676 } |
| 660 const Instance& msg = | |
| 661 Instance::Handle(DeserializeMessage(message->data())); | |
| 662 const Object& result = Object::Handle( | |
| 663 DartLibraryCalls::HandleMessage( | |
| 664 message->dest_port(), message->reply_port(), msg)); | |
| 665 delete message; | |
| 666 if (result.IsError()) { | |
| 667 return Api::NewLocalHandle(result); | |
| 668 } | |
| 669 ASSERT(result.IsNull()); | |
| 670 } while (priority >= Message::kOOBPriority); | 677 } while (priority >= Message::kOOBPriority); |
| 671 return Api::Success(); | 678 return Api::Success(); |
| 672 } | 679 } |
| 673 | 680 |
| 674 | 681 |
| 675 DART_EXPORT bool Dart_HasLivePorts() { | 682 DART_EXPORT bool Dart_HasLivePorts() { |
| 676 Isolate* isolate = Isolate::Current(); | 683 Isolate* isolate = Isolate::Current(); |
| 677 ASSERT(isolate); | 684 ASSERT(isolate); |
| 678 return isolate->message_handler()->HasLivePorts(); | 685 return isolate->message_handler()->HasLivePorts(); |
| 679 } | 686 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 Isolate::SetCurrent(NULL); | 759 Isolate::SetCurrent(NULL); |
| 753 | 760 |
| 754 // TODO(turnidge): Check that the port is native before trying to close. | 761 // TODO(turnidge): Check that the port is native before trying to close. |
| 755 return PortMap::ClosePort(native_port_id); | 762 return PortMap::ClosePort(native_port_id); |
| 756 } | 763 } |
| 757 | 764 |
| 758 | 765 |
| 759 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { | 766 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { |
| 760 Isolate* isolate = Isolate::Current(); | 767 Isolate* isolate = Isolate::Current(); |
| 761 DARTSCOPE(isolate); | 768 DARTSCOPE(isolate); |
| 762 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); | 769 const Object& result = Object::Handle(DartLibraryCalls::NewSendPort(port_id)); |
| 763 const String& function_name = String::Handle(String::NewSymbol("_create")); | |
| 764 const int kNumArguments = 1; | |
| 765 const Array& kNoArgumentNames = Array::Handle(); | |
| 766 // TODO(turnidge): Consider adding a helper function to make | |
| 767 // function resolution by class name and function name more concise. | |
| 768 const Function& function = Function::Handle( | |
| 769 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), | |
| 770 class_name, | |
| 771 function_name, | |
| 772 kNumArguments, | |
| 773 kNoArgumentNames, | |
| 774 Resolver::kIsQualified)); | |
| 775 GrowableArray<const Object*> arguments(kNumArguments); | |
| 776 arguments.Add(&Integer::Handle(Integer::New(port_id))); | |
| 777 const Object& result = Object::Handle( | |
| 778 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); | |
| 779 return Api::NewLocalHandle(result); | 770 return Api::NewLocalHandle(result); |
| 780 } | 771 } |
| 781 | 772 |
| 782 | 773 |
| 783 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { | 774 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { |
| 784 Isolate* isolate = Isolate::Current(); | 775 Isolate* isolate = Isolate::Current(); |
| 785 DARTSCOPE(isolate); | 776 DARTSCOPE(isolate); |
| 786 const String& class_name = | 777 const String& class_name = |
| 787 String::Handle(String::NewSymbol("ReceivePortImpl")); | 778 String::Handle(String::NewSymbol("ReceivePortImpl")); |
| 788 const String& function_name = | 779 const String& function_name = |
| (...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2688 *buffer = NULL; | 2679 *buffer = NULL; |
| 2689 } | 2680 } |
| 2690 delete debug_region; | 2681 delete debug_region; |
| 2691 } else { | 2682 } else { |
| 2692 *buffer = NULL; | 2683 *buffer = NULL; |
| 2693 *buffer_size = 0; | 2684 *buffer_size = 0; |
| 2694 } | 2685 } |
| 2695 } | 2686 } |
| 2696 | 2687 |
| 2697 } // namespace dart | 2688 } // namespace dart |
| OLD | NEW |