| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 static void StoreError(Isolate* isolate, const Object& obj) { | 45 static void StoreError(Isolate* isolate, const Object& obj) { |
| 46 ASSERT(obj.IsError()); | 46 ASSERT(obj.IsError()); |
| 47 Error& error = Error::Handle(); | 47 Error& error = Error::Handle(); |
| 48 error ^= obj.raw(); | 48 error ^= obj.raw(); |
| 49 isolate->object_store()->set_sticky_error(error); | 49 isolate->object_store()->set_sticky_error(error); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 // TODO(turnidge): Move to DartLibraryCalls. | 53 // TODO(turnidge): Move to DartLibraryCalls. |
| 54 RawObject* ReceivePortCreate(intptr_t port_id) { | 54 static RawObject* ReceivePortCreate(intptr_t port_id) { |
| 55 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 55 Isolate* isolate = Isolate::Current(); |
| 56 ASSERT(!isolate_lib.IsNull()); | 56 Function& func = |
| 57 const String& public_class_name = | 57 Function::Handle(isolate, |
| 58 String::Handle(Symbols::New("_ReceivePortImpl")); | 58 isolate->object_store()->receive_port_create_function()); |
| 59 const String& class_name = | |
| 60 String::Handle(isolate_lib.PrivateName(public_class_name)); | |
| 61 const String& function_name = | |
| 62 String::Handle(Symbols::New("_get_or_create")); | |
| 63 const int kNumArguments = 1; | 59 const int kNumArguments = 1; |
| 64 const Array& kNoArgumentNames = Array::Handle(); | 60 if (func.IsNull()) { |
| 65 const Function& func = Function::Handle( | 61 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 66 Resolver::ResolveStatic(isolate_lib, | 62 ASSERT(!isolate_lib.IsNull()); |
| 67 class_name, | 63 const String& public_class_name = |
| 68 function_name, | 64 String::Handle(Symbols::New("_ReceivePortImpl")); |
| 69 kNumArguments, | 65 const String& class_name = |
| 70 kNoArgumentNames, | 66 String::Handle(isolate_lib.PrivateName(public_class_name)); |
| 71 Resolver::kIsQualified)); | 67 const String& function_name = |
| 72 const Array& args = Array::Handle(Array::New(kNumArguments)); | 68 String::Handle(Symbols::New("_get_or_create")); |
| 73 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 69 const Array& kNoArgumentNames = Array::Handle(); |
| 74 const Object& result = Object::Handle(DartEntry::InvokeStatic(func, args)); | 70 func = Resolver::ResolveStatic(isolate_lib, |
| 71 class_name, |
| 72 function_name, |
| 73 kNumArguments, |
| 74 kNoArgumentNames, |
| 75 Resolver::kIsQualified); |
| 76 isolate->object_store()->set_receive_port_create_function(func); |
| 77 } |
| 78 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
| 79 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id))); |
| 80 const Object& result = |
| 81 Object::Handle(isolate, DartEntry::InvokeStatic(func, args)); |
| 75 if (!result.IsError()) { | 82 if (!result.IsError()) { |
| 76 PortMap::SetLive(port_id); | 83 PortMap::SetLive(port_id); |
| 77 } | 84 } |
| 78 return result.raw(); | 85 return result.raw(); |
| 79 } | 86 } |
| 80 | 87 |
| 81 | 88 |
| 82 static void ShutdownIsolate(uword parameter) { | 89 static void ShutdownIsolate(uword parameter) { |
| 83 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); | 90 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); |
| 84 { | 91 { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 494 |
| 488 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 495 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
| 489 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 496 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
| 490 if (port.IsError()) { | 497 if (port.IsError()) { |
| 491 Exceptions::PropagateError(Error::Cast(port)); | 498 Exceptions::PropagateError(Error::Cast(port)); |
| 492 } | 499 } |
| 493 return port.raw(); | 500 return port.raw(); |
| 494 } | 501 } |
| 495 | 502 |
| 496 } // namespace dart | 503 } // namespace dart |
| OLD | NEW |