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

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

Issue 9420038: Heartbeat implementation of dart:mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 arguments.Add(&Integer::Handle(Integer::New(port_id))); 100 arguments.Add(&Integer::Handle(Integer::New(port_id)));
101 const Object& result = Object::Handle( 101 const Object& result = Object::Handle(
102 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 102 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
103 if (!result.IsError()) { 103 if (!result.IsError()) {
104 PortMap::SetLive(port_id); 104 PortMap::SetLive(port_id);
105 } 105 }
106 return result.raw(); 106 return result.raw();
107 } 107 }
108 108
109 109
110 // TODO(turnidge): Move to DartLibraryCalls.
111 static RawObject* SendPortCreate(intptr_t port_id) {
112 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
113 const String& function_name = String::Handle(String::NewSymbol("_create"));
114 const int kNumArguments = 1;
115 const Array& kNoArgumentNames = Array::Handle();
116 const Function& function = Function::Handle(
117 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
118 class_name,
119 function_name,
120 kNumArguments,
121 kNoArgumentNames,
122 Resolver::kIsQualified));
123 GrowableArray<const Object*> arguments(kNumArguments);
124 arguments.Add(&Integer::Handle(Integer::New(port_id)));
125 const Object& result = Object::Handle(
126 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
127 return result.raw();
128 }
129
130
131 static void RunIsolate(uword parameter) { 110 static void RunIsolate(uword parameter) {
132 IsolateStartData* data = reinterpret_cast<IsolateStartData*>(parameter); 111 IsolateStartData* data = reinterpret_cast<IsolateStartData*>(parameter);
133 Isolate* isolate = data->isolate_; 112 Isolate* isolate = data->isolate_;
134 char* library_url = data->library_url_; 113 char* library_url = data->library_url_;
135 char* class_name = data->class_name_; 114 char* class_name = data->class_name_;
136 intptr_t port_id = data->port_id_; 115 intptr_t port_id = data->port_id_;
137 delete data; 116 delete data;
138 117
139 Isolate::SetCurrent(isolate); 118 Isolate::SetCurrent(isolate);
140 // Intialize stack limit in case we are running isolate in a 119 // Intialize stack limit in case we are running isolate in a
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // Unable to spawn isolate correctly, throw exception. 309 // Unable to spawn isolate correctly, throw exception.
331 ThrowErrorException(Exceptions::kIllegalArgument, 310 ThrowErrorException(Exceptions::kIllegalArgument,
332 error, 311 error,
333 library_url, 312 library_url,
334 class_name); 313 class_name);
335 } 314 }
336 315
337 // TODO(turnidge): Move this code up before we launch the new 316 // TODO(turnidge): Move this code up before we launch the new
338 // thread. That way we won't have a thread hanging around that we 317 // thread. That way we won't have a thread hanging around that we
339 // can't talk to. 318 // can't talk to.
340 const Object& port = Object::Handle(SendPortCreate(port_id)); 319 const Object& port = Object::Handle(DartLibraryCalls::NewSendPort(port_id));
341 if (port.IsError()) { 320 if (port.IsError()) {
342 Exceptions::PropagateError(port); 321 Exceptions::PropagateError(port);
343 } 322 }
344 arguments->SetReturn(port); 323 arguments->SetReturn(port);
345 } 324 }
346 325
347 326
348 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) { 327 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) {
349 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull()); 328 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull());
350 intptr_t port_id = 329 intptr_t port_id =
(...skipping 17 matching lines...) Expand all
368 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 347 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
369 // TODO(iposva): Allow for arbitrary messages to be sent. 348 // TODO(iposva): Allow for arbitrary messages to be sent.
370 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 349 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
371 350
372 // TODO(turnidge): Throw an exception when the return value is false? 351 // TODO(turnidge): Throw an exception when the return value is false?
373 PortMap::PostMessage(new Message( 352 PortMap::PostMessage(new Message(
374 send_id, reply_id, data, Message::kNormalPriority)); 353 send_id, reply_id, data, Message::kNormalPriority));
375 } 354 }
376 355
377 } // namespace dart 356 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698