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

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

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/assert.h" 7 #include "vm/assert.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 str ^= String::Concat(str, name); 80 str ^= String::Concat(str, name);
81 GrowableArray<const Object*> arguments(1); 81 GrowableArray<const Object*> arguments(1);
82 arguments.Add(&str); 82 arguments.Add(&str);
83 Exceptions::ThrowByType(type, arguments); 83 Exceptions::ThrowByType(type, arguments);
84 } 84 }
85 85
86 86
87 RawInstance* ReceivePortCreate(intptr_t port_id) { 87 RawInstance* ReceivePortCreate(intptr_t port_id) {
88 const String& class_name = 88 const String& class_name =
89 String::Handle(String::NewSymbol("ReceivePortImpl")); 89 String::Handle(String::NewSymbol("ReceivePortImpl"));
90 const String& function_name = String::Handle(String::NewSymbol("create_")); 90 const String& function_name = String::Handle(String::NewSymbol("_create"));
91 const int kNumArguments = 1; 91 const int kNumArguments = 1;
92 const Array& kNoArgumentNames = Array::Handle(); 92 const Array& kNoArgumentNames = Array::Handle();
93 const Function& function = Function::Handle( 93 const Function& function = Function::Handle(
94 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 94 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
95 class_name, 95 class_name,
96 function_name, 96 function_name,
97 kNumArguments, 97 kNumArguments,
98 kNoArgumentNames, 98 kNoArgumentNames,
99 Resolver::kIsQualified)); 99 Resolver::kIsQualified));
100 GrowableArray<const Object*> arguments(kNumArguments); 100 GrowableArray<const Object*> arguments(kNumArguments);
101 arguments.Add(&Integer::Handle(Integer::New(port_id))); 101 arguments.Add(&Integer::Handle(Integer::New(port_id)));
102 const Instance& result = Instance::Handle( 102 const Instance& result = Instance::Handle(
103 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 103 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
104 if (result.IsUnhandledException()) { 104 if (result.IsUnhandledException()) {
105 UnhandledException& uhe = UnhandledException::Handle(); 105 UnhandledException& uhe = UnhandledException::Handle();
106 uhe ^= result.raw(); 106 uhe ^= result.raw();
107 ProcessUnhandledException(uhe); 107 ProcessUnhandledException(uhe);
108 } else {
109 PortMap::SetLive(port_id);
siva 2011/11/29 19:50:27 I think we should add a comment that a port once i
turnidge 2011/12/05 17:53:34 Added comment in port.h. On 2011/11/29 19:50:27,
108 } 110 }
109 return result.raw(); 111 return result.raw();
110 } 112 }
111 113
112 114
113 static RawInstance* SendPortCreate(intptr_t port_id) { 115 static RawInstance* SendPortCreate(intptr_t port_id) {
114 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); 116 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
115 const String& function_name = String::Handle(String::NewSymbol("create_")); 117 const String& function_name = String::Handle(String::NewSymbol("_create"));
116 const int kNumArguments = 1; 118 const int kNumArguments = 1;
117 const Array& kNoArgumentNames = Array::Handle(); 119 const Array& kNoArgumentNames = Array::Handle();
118 const Function& function = Function::Handle( 120 const Function& function = Function::Handle(
119 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 121 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
120 class_name, 122 class_name,
121 function_name, 123 function_name,
122 kNumArguments, 124 kNumArguments,
123 kNoArgumentNames, 125 kNoArgumentNames,
124 Resolver::kIsQualified)); 126 Resolver::kIsQualified));
125 GrowableArray<const Object*> arguments(kNumArguments); 127 GrowableArray<const Object*> arguments(kNumArguments);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 spawned_isolate->set_long_jump_base(&jump); 271 spawned_isolate->set_long_jump_base(&jump);
270 if (setjmp(*jump.Set()) == 0) { 272 if (setjmp(*jump.Set()) == 0) {
271 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data()); 273 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data());
272 } else { 274 } else {
273 init_successful = false; 275 init_successful = false;
274 } 276 }
275 spawned_isolate->set_long_jump_base(base); 277 spawned_isolate->set_long_jump_base(base);
276 // Check arguments to see if the specified library and classes are 278 // Check arguments to see if the specified library and classes are
277 // loaded, this check will throw an exception if they are not loaded. 279 // loaded, this check will throw an exception if they are not loaded.
278 if (init_successful && CheckArguments(library_url, class_name)) { 280 if (init_successful && CheckArguments(library_url, class_name)) {
279 port_id = PortMap::CreatePort(); 281 port_id = spawned_isolate->main_port();
280 uword data = reinterpret_cast<uword>( 282 uword data = reinterpret_cast<uword>(
281 new IsolateStartData(spawned_isolate, 283 new IsolateStartData(spawned_isolate,
282 strdup(library_url), 284 strdup(library_url),
283 strdup(class_name), 285 strdup(class_name),
284 port_id)); 286 port_id));
285 new Thread(RunIsolate, data); 287 new Thread(RunIsolate, data);
286 } else { 288 } else {
287 // Error spawning the isolate, maybe due to initialization errors or 289 // Error spawning the isolate, maybe due to initialization errors or
288 // errors while loading the application into spawned isolate, shut 290 // errors while loading the application into spawned isolate, shut
289 // it down and report error. 291 // it down and report error.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); 349 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value();
348 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 350 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
349 // TODO(iposva): Allow for arbitrary messages to be sent. 351 // TODO(iposva): Allow for arbitrary messages to be sent.
350 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 352 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
351 353
352 // TODO(turnidge): Throw an exception when the return value is false? 354 // TODO(turnidge): Throw an exception when the return value is false?
353 PortMap::PostMessage(send_id, reply_id, data); 355 PortMap::PostMessage(send_id, reply_id, data);
354 } 356 }
355 357
356 } // namespace dart 358 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698