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

Side by Side Diff: runtime/lib/isolate.cc

Issue 889443002: Service isolate rework take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/tools/gyp/runtime-configurations.gypi » ('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) 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"
11 #include "vm/exceptions.h" 11 #include "vm/exceptions.h"
12 #include "vm/lockers.h" 12 #include "vm/lockers.h"
13 #include "vm/longjump.h" 13 #include "vm/longjump.h"
14 #include "vm/message_handler.h" 14 #include "vm/message_handler.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_store.h" 16 #include "vm/object_store.h"
17 #include "vm/port.h" 17 #include "vm/port.h"
18 #include "vm/resolver.h" 18 #include "vm/resolver.h"
19 #include "vm/service.h"
19 #include "vm/snapshot.h" 20 #include "vm/snapshot.h"
20 #include "vm/symbols.h" 21 #include "vm/symbols.h"
21 #include "vm/unicode.h" 22 #include "vm/unicode.h"
22 23
23 namespace dart { 24 namespace dart {
24 25
25 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 26 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
26 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 27 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
27 return reinterpret_cast<uint8_t*>(new_ptr); 28 return reinterpret_cast<uint8_t*>(new_ptr);
28 } 29 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return Smi::New(hash); 96 return Smi::New(hash);
96 } 97 }
97 98
98 99
99 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) { 100 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) {
100 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 101 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
101 // TODO(iposva): Allow for arbitrary messages to be sent. 102 // TODO(iposva): Allow for arbitrary messages to be sent.
102 GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1)); 103 GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1));
103 104
104 uint8_t* data = NULL; 105 uint8_t* data = NULL;
105 bool can_send_any_object = (isolate->origin_id() == port.origin_id()); 106
107 const Dart_Port destination_port_id = port.Id();
108 const bool can_send_any_object = isolate->origin_id() == port.origin_id();
109
106 MessageWriter writer(&data, &allocator, can_send_any_object); 110 MessageWriter writer(&data, &allocator, can_send_any_object);
107 writer.WriteMessage(obj); 111 writer.WriteMessage(obj);
108 112
109 // TODO(turnidge): Throw an exception when the return value is false? 113 // TODO(turnidge): Throw an exception when the return value is false?
110 PortMap::PostMessage(new Message(port.Id(), 114 PortMap::PostMessage(new Message(destination_port_id,
111 data, writer.BytesWritten(), 115 data, writer.BytesWritten(),
112 Message::kNormalPriority)); 116 Message::kNormalPriority));
113 return Object::null(); 117 return Object::null();
114 } 118 }
115 119
116 120
117 static void ThrowIsolateSpawnException(const String& message) { 121 static void ThrowIsolateSpawnException(const String& message) {
118 const Array& args = Array::Handle(Array::New(1)); 122 const Array& args = Array::Handle(Array::New(1));
119 args.SetAt(0, message); 123 args.SetAt(0, message);
120 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args); 124 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 MessageWriter writer(&data, &allocator, false); 303 MessageWriter writer(&data, &allocator, false);
300 writer.WriteMessage(msg); 304 writer.WriteMessage(msg);
301 305
302 PortMap::PostMessage(new Message(port.Id(), 306 PortMap::PostMessage(new Message(port.Id(),
303 data, writer.BytesWritten(), 307 data, writer.BytesWritten(),
304 Message::kOOBPriority)); 308 Message::kOOBPriority));
305 return Object::null(); 309 return Object::null();
306 } 310 }
307 311
308 } // namespace dart 312 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/tools/gyp/runtime-configurations.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698