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

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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/isolate.dart » ('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) 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 =
91 String::Handle(String::NewSymbol("_get_or_create"));
91 const int kNumArguments = 1; 92 const int kNumArguments = 1;
92 const Array& kNoArgumentNames = Array::Handle(); 93 const Array& kNoArgumentNames = Array::Handle();
93 const Function& function = Function::Handle( 94 const Function& function = Function::Handle(
94 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 95 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
95 class_name, 96 class_name,
96 function_name, 97 function_name,
97 kNumArguments, 98 kNumArguments,
98 kNoArgumentNames, 99 kNoArgumentNames,
99 Resolver::kIsQualified)); 100 Resolver::kIsQualified));
100 GrowableArray<const Object*> arguments(kNumArguments); 101 GrowableArray<const Object*> arguments(kNumArguments);
101 arguments.Add(&Integer::Handle(Integer::New(port_id))); 102 arguments.Add(&Integer::Handle(Integer::New(port_id)));
102 const Instance& result = Instance::Handle( 103 const Instance& result = Instance::Handle(
103 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 104 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
104 if (result.IsUnhandledException()) { 105 if (result.IsUnhandledException()) {
105 UnhandledException& uhe = UnhandledException::Handle(); 106 UnhandledException& uhe = UnhandledException::Handle();
106 uhe ^= result.raw(); 107 uhe ^= result.raw();
107 ProcessUnhandledException(uhe); 108 ProcessUnhandledException(uhe);
109 } else {
110 PortMap::SetLive(port_id);
108 } 111 }
109 return result.raw(); 112 return result.raw();
110 } 113 }
111 114
112 115
113 static RawInstance* SendPortCreate(intptr_t port_id) { 116 static RawInstance* SendPortCreate(intptr_t port_id) {
114 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); 117 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
115 const String& function_name = String::Handle(String::NewSymbol("create_")); 118 const String& function_name = String::Handle(String::NewSymbol("_create"));
116 const int kNumArguments = 1; 119 const int kNumArguments = 1;
117 const Array& kNoArgumentNames = Array::Handle(); 120 const Array& kNoArgumentNames = Array::Handle();
118 const Function& function = Function::Handle( 121 const Function& function = Function::Handle(
119 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 122 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
120 class_name, 123 class_name,
121 function_name, 124 function_name,
122 kNumArguments, 125 kNumArguments,
123 kNoArgumentNames, 126 kNoArgumentNames,
124 Resolver::kIsQualified)); 127 Resolver::kIsQualified));
125 GrowableArray<const Object*> arguments(kNumArguments); 128 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); 272 spawned_isolate->set_long_jump_base(&jump);
270 if (setjmp(*jump.Set()) == 0) { 273 if (setjmp(*jump.Set()) == 0) {
271 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data()); 274 Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data());
272 } else { 275 } else {
273 init_successful = false; 276 init_successful = false;
274 } 277 }
275 spawned_isolate->set_long_jump_base(base); 278 spawned_isolate->set_long_jump_base(base);
276 // Check arguments to see if the specified library and classes are 279 // Check arguments to see if the specified library and classes are
277 // loaded, this check will throw an exception if they are not loaded. 280 // loaded, this check will throw an exception if they are not loaded.
278 if (init_successful && CheckArguments(library_url, class_name)) { 281 if (init_successful && CheckArguments(library_url, class_name)) {
279 port_id = PortMap::CreatePort(); 282 port_id = spawned_isolate->main_port();
280 uword data = reinterpret_cast<uword>( 283 uword data = reinterpret_cast<uword>(
281 new IsolateStartData(spawned_isolate, 284 new IsolateStartData(spawned_isolate,
282 strdup(library_url), 285 strdup(library_url),
283 strdup(class_name), 286 strdup(class_name),
284 port_id)); 287 port_id));
285 new Thread(RunIsolate, data); 288 new Thread(RunIsolate, data);
286 } else { 289 } else {
287 // Error spawning the isolate, maybe due to initialization errors or 290 // Error spawning the isolate, maybe due to initialization errors or
288 // errors while loading the application into spawned isolate, shut 291 // errors while loading the application into spawned isolate, shut
289 // it down and report error. 292 // 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(); 350 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value();
348 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 351 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
349 // TODO(iposva): Allow for arbitrary messages to be sent. 352 // TODO(iposva): Allow for arbitrary messages to be sent.
350 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 353 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
351 354
352 // TODO(turnidge): Throw an exception when the return value is false? 355 // TODO(turnidge): Throw an exception when the return value is false?
353 PortMap::PostMessage(send_id, reply_id, data); 356 PortMap::PostMessage(send_id, reply_id, data);
354 } 357 }
355 358
356 } // namespace dart 359 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698