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

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, 1 month 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 } 108 }
109 return result.raw(); 109 return result.raw();
110 } 110 }
111 111
112 112
113 static RawInstance* SendPortCreate(intptr_t port_id) { 113 static RawInstance* SendPortCreate(intptr_t port_id) {
114 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); 114 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
115 const String& function_name = String::Handle(String::NewSymbol("create_")); 115 const String& function_name = String::Handle(String::NewSymbol("_create"));
116 const int kNumArguments = 1; 116 const int kNumArguments = 1;
117 const Array& kNoArgumentNames = Array::Handle(); 117 const Array& kNoArgumentNames = Array::Handle();
118 const Function& function = Function::Handle( 118 const Function& function = Function::Handle(
119 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 119 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
120 class_name, 120 class_name,
121 function_name, 121 function_name,
122 kNumArguments, 122 kNumArguments,
123 kNoArgumentNames, 123 kNoArgumentNames,
124 Resolver::kIsQualified)); 124 Resolver::kIsQualified));
125 GrowableArray<const Object*> arguments(kNumArguments); 125 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); 269 spawned_isolate->set_long_jump_base(&jump);
270 if (setjmp(*jump.Set()) == 0) { 270 if (setjmp(*jump.Set()) == 0) {
271 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data()); 271 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data());
272 } else { 272 } else {
273 init_successful = false; 273 init_successful = false;
274 } 274 }
275 spawned_isolate->set_long_jump_base(base); 275 spawned_isolate->set_long_jump_base(base);
276 // Check arguments to see if the specified library and classes are 276 // Check arguments to see if the specified library and classes are
277 // loaded, this check will throw an exception if they are not loaded. 277 // loaded, this check will throw an exception if they are not loaded.
278 if (init_successful && CheckArguments(library_url, class_name)) { 278 if (init_successful && CheckArguments(library_url, class_name)) {
279 port_id = PortMap::CreatePort(); 279 port_id = spawned_isolate->main_port();
280 uword data = reinterpret_cast<uword>( 280 uword data = reinterpret_cast<uword>(
281 new IsolateStartData(spawned_isolate, 281 new IsolateStartData(spawned_isolate,
282 strdup(library_url), 282 strdup(library_url),
283 strdup(class_name), 283 strdup(class_name),
284 port_id)); 284 port_id));
285 new Thread(RunIsolate, data); 285 new Thread(RunIsolate, data);
286 } else { 286 } else {
287 // Error spawning the isolate, maybe due to initialization errors or 287 // Error spawning the isolate, maybe due to initialization errors or
288 // errors while loading the application into spawned isolate, shut 288 // errors while loading the application into spawned isolate, shut
289 // it down and report error. 289 // 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(); 347 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value();
348 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 348 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
349 // TODO(iposva): Allow for arbitrary messages to be sent. 349 // TODO(iposva): Allow for arbitrary messages to be sent.
350 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 350 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
351 351
352 // TODO(turnidge): Throw an exception when the return value is false? 352 // TODO(turnidge): Throw an exception when the return value is false?
353 PortMap::PostMessage(send_id, reply_id, data); 353 PortMap::PostMessage(send_id, reply_id, data);
354 } 354 }
355 355
356 } // namespace dart 356 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698