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 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 | 38 |
39 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 39 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
40 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 40 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
41 return reinterpret_cast<uint8_t*>(new_ptr); | 41 return reinterpret_cast<uint8_t*>(new_ptr); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 // TODO(turnidge): Move to DartLibraryCalls. | 45 // TODO(turnidge): Move to DartLibraryCalls. |
46 static RawObject* ReceivePortCreate(intptr_t port_id) { | 46 static RawObject* ReceivePortCreate(Dart_Port port_id) { |
47 Isolate* isolate = Isolate::Current(); | 47 Isolate* isolate = Isolate::Current(); |
48 Function& func = | 48 Function& func = |
49 Function::Handle(isolate, | 49 Function::Handle(isolate, |
50 isolate->object_store()->receive_port_create_function()); | 50 isolate->object_store()->receive_port_create_function()); |
51 const int kNumArguments = 1; | 51 const int kNumArguments = 1; |
52 if (func.IsNull()) { | 52 if (func.IsNull()) { |
53 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 53 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
54 ASSERT(!isolate_lib.IsNull()); | 54 ASSERT(!isolate_lib.IsNull()); |
55 const String& class_name = | 55 const String& class_name = |
56 String::Handle(isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); | 56 String::Handle(isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); |
(...skipping 14 matching lines...) Expand all Loading... |
71 if (!result.IsError()) { | 71 if (!result.IsError()) { |
72 PortMap::SetLive(port_id); | 72 PortMap::SetLive(port_id); |
73 } | 73 } |
74 return result.raw(); | 74 return result.raw(); |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { | 78 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { |
79 ASSERT(AbstractTypeArguments::CheckedHandle( | 79 ASSERT(AbstractTypeArguments::CheckedHandle( |
80 arguments->NativeArgAt(0)).IsNull()); | 80 arguments->NativeArgAt(0)).IsNull()); |
81 intptr_t port_id = | 81 Dart_Port port_id = |
82 PortMap::CreatePort(arguments->isolate()->message_handler()); | 82 PortMap::CreatePort(arguments->isolate()->message_handler()); |
83 const Object& port = Object::Handle(ReceivePortCreate(port_id)); | 83 const Object& port = Object::Handle(ReceivePortCreate(port_id)); |
84 if (port.IsError()) { | 84 if (port.IsError()) { |
85 Exceptions::PropagateError(Error::Cast(port)); | 85 Exceptions::PropagateError(Error::Cast(port)); |
86 } | 86 } |
87 return port.raw(); | 87 return port.raw(); |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_closeInternal, 1) { | 91 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_closeInternal, 1) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 // The control port is being accessed as a regular port from Dart code. This | 261 // The control port is being accessed as a regular port from Dart code. This |
262 // is most likely due to the _startIsolate code in dart:isolate. Account for | 262 // is most likely due to the _startIsolate code in dart:isolate. Account for |
263 // this by increasing the number of open control ports. | 263 // this by increasing the number of open control ports. |
264 isolate->message_handler()->increment_control_ports(); | 264 isolate->message_handler()->increment_control_ports(); |
265 | 265 |
266 return port.raw(); | 266 return port.raw(); |
267 } | 267 } |
268 | 268 |
269 } // namespace dart | 269 } // namespace dart |
OLD | NEW |