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

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

Issue 771993003: Add Isolate.current getter, returning the current isolate as an Isolate object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « no previous file | runtime/lib/isolate_patch.dart » ('j') | runtime/lib/isolate_patch.dart » ('J')
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"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 utf8_package_root = zone->Alloc<char>(len + 1); 243 utf8_package_root = zone->Alloc<char>(len + 1);
244 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); 244 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len);
245 utf8_package_root[len] = '\0'; 245 utf8_package_root[len] = '\0';
246 } 246 }
247 247
248 return Spawn(isolate, new IsolateSpawnState( 248 return Spawn(isolate, new IsolateSpawnState(
249 port.Id(), canonical_uri, utf8_package_root, args, message)); 249 port.Id(), canonical_uri, utf8_package_root, args, message));
250 } 250 }
251 251
252 252
253 DEFINE_NATIVE_ENTRY(Isolate_getCurrent, 0) {
254 const Array& result = Array::Handle(Array::New(3));
255 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port())));
256 result.SetAt(1, Capability::Handle(
257 Capability::New(isolate->pause_capability())));
258 result.SetAt(2, Capability::Handle(
259 Capability::New(isolate->terminate_capability())));
Lasse Reichstein Nielsen 2014/12/02 10:47:39 This doesn't seem to be working. Ivan: Does the VM
260 return result.raw();
261 }
262
263
253 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { 264 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) {
254 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 265 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
255 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); 266 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1));
256 267
257 // Make sure to route this request to the isolate library OOB mesage handler. 268 // Make sure to route this request to the isolate library OOB mesage handler.
258 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); 269 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg)));
259 270
260 uint8_t* data = NULL; 271 uint8_t* data = NULL;
261 MessageWriter writer(&data, &allocator); 272 MessageWriter writer(&data, &allocator);
262 writer.WriteMessage(msg); 273 writer.WriteMessage(msg);
263 274
264 PortMap::PostMessage(new Message(port.Id(), 275 PortMap::PostMessage(new Message(port.Id(),
265 data, writer.BytesWritten(), 276 data, writer.BytesWritten(),
266 Message::kOOBPriority)); 277 Message::kOOBPriority));
267 return Object::null(); 278 return Object::null();
268 } 279 }
269 280
270 } // namespace dart 281 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate_patch.dart » ('j') | runtime/lib/isolate_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698