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

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

Issue 9186058: Make the "sticky error" an Error instead of a String. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/allocation_test.cc » ('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_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 free(class_name); 199 free(class_name);
200 result = isolate->StandardRunLoop(); 200 result = isolate->StandardRunLoop();
201 if (result.IsError()) { 201 if (result.IsError()) {
202 ProcessError(result); 202 ProcessError(result);
203 } 203 }
204 ASSERT(result.IsNull()); 204 ASSERT(result.IsNull());
205 205
206 } else { 206 } else {
207 Zone zone(isolate); 207 Zone zone(isolate);
208 HandleScope handle_scope(isolate); 208 HandleScope handle_scope(isolate);
209 const String& error = String::Handle( 209 const Error& error = Error::Handle(
210 Isolate::Current()->object_store()->sticky_error()); 210 Isolate::Current()->object_store()->sticky_error());
211 const char* errmsg = error.ToCString(); 211 const char* errmsg = error.ToErrorCString();
212 OS::PrintErr("%s\n", errmsg); 212 OS::PrintErr("%s\n", errmsg);
213 exit(255); 213 exit(255);
214 } 214 }
215 isolate->set_long_jump_base(base); 215 isolate->set_long_jump_base(base);
216 Dart::ShutdownIsolate(); 216 Dart::ShutdownIsolate();
217 } 217 }
218 218
219 219
220 static bool CheckArguments(const char* library_url, const char* class_name) { 220 static bool CheckArguments(const char* library_url, const char* class_name) {
221 Isolate* isolate = Isolate::Current(); 221 Isolate* isolate = Isolate::Current();
222 Zone zone(isolate); 222 Zone zone(isolate);
223 HandleScope handle_scope(isolate); 223 HandleScope handle_scope(isolate);
224 String& name = String::Handle(); 224 String& name = String::Handle();
225 if (!ClassFinalizer::FinalizePendingClasses()) { 225 if (!ClassFinalizer::FinalizePendingClasses()) {
226 return false; 226 return false;
227 } 227 }
228 // Lookup the target class by name, create an instance and call the run 228 // Lookup the target class by name, create an instance and call the run
229 // method. 229 // method.
230 name ^= String::NewSymbol(library_url); 230 name ^= String::NewSymbol(library_url);
231 const Library& lib = Library::Handle(Library::LookupLibrary(name)); 231 const Library& lib = Library::Handle(Library::LookupLibrary(name));
232 if (lib.IsNull()) { 232 if (lib.IsNull()) {
233 const String& error = String::Handle( 233 const String& error_str = String::Handle(
234 String::New("Error starting Isolate, library not loaded : ")); 234 String::New("Error starting Isolate, library not loaded : "));
235 const Error& error = Error::Handle(LanguageError::New(error_str));
235 Isolate::Current()->object_store()->set_sticky_error(error); 236 Isolate::Current()->object_store()->set_sticky_error(error);
236 return false; 237 return false;
237 } 238 }
238 name ^= String::NewSymbol(class_name); 239 name ^= String::NewSymbol(class_name);
239 const Class& target_class = Class::Handle(lib.LookupClass(name)); 240 const Class& target_class = Class::Handle(lib.LookupClass(name));
240 if (target_class.IsNull()) { 241 if (target_class.IsNull()) {
241 const String& error = String::Handle( 242 const String& error_str = String::Handle(
242 String::New("Error starting Isolate, class not loaded : ")); 243 String::New("Error starting Isolate, class not loaded : "));
244 const Error& error = Error::Handle(LanguageError::New(error_str));
243 Isolate::Current()->object_store()->set_sticky_error(error); 245 Isolate::Current()->object_store()->set_sticky_error(error);
244 return false; 246 return false;
245 } 247 }
246 return true; // No errors. 248 return true; // No errors.
247 } 249 }
248 250
249 251
250 DEFINE_NATIVE_ENTRY(IsolateNatives_start, 2) { 252 DEFINE_NATIVE_ENTRY(IsolateNatives_start, 2) {
251 Isolate* preserved_isolate = Isolate::Current(); 253 Isolate* preserved_isolate = Isolate::Current();
252 const Instance& runnable = Instance::CheckedHandle(arguments->At(0)); 254 const Instance& runnable = Instance::CheckedHandle(arguments->At(0));
(...skipping 26 matching lines...) Expand all
279 new Thread(RunIsolate, data); 281 new Thread(RunIsolate, data);
280 } else { 282 } else {
281 // Error spawning the isolate, maybe due to initialization errors or 283 // Error spawning the isolate, maybe due to initialization errors or
282 // errors while loading the application into spawned isolate, shut 284 // errors while loading the application into spawned isolate, shut
283 // it down and report error. 285 // it down and report error.
284 // Make sure to grab the error message out of the isolate before it has 286 // Make sure to grab the error message out of the isolate before it has
285 // been shutdown and to allocate it in the preserved isolates zone. 287 // been shutdown and to allocate it in the preserved isolates zone.
286 { 288 {
287 Zone zone(spawned_isolate); 289 Zone zone(spawned_isolate);
288 HandleScope scope(spawned_isolate); 290 HandleScope scope(spawned_isolate);
289 const String& errmsg = String::Handle( 291 const Error& errobj = Error::Handle(
hausner 2012/01/13 01:49:06 err_obj?
turnidge 2012/01/17 19:53:46 Done.
290 spawned_isolate->object_store()->sticky_error()); 292 spawned_isolate->object_store()->sticky_error());
291 error = strdup(errmsg.ToCString()); 293 error = strdup(errobj.ToErrorCString());
292 } 294 }
293 Dart::ShutdownIsolate(); 295 Dart::ShutdownIsolate();
294 spawned_isolate = NULL; 296 spawned_isolate = NULL;
295 } 297 }
296 } 298 }
297 299
298 // Switch back to the original isolate and return. 300 // Switch back to the original isolate and return.
299 Isolate::SetCurrent(preserved_isolate); 301 Isolate::SetCurrent(preserved_isolate);
300 if (spawned_isolate == NULL) { 302 if (spawned_isolate == NULL) {
301 // Unable to spawn isolate correctly, throw exception. 303 // Unable to spawn isolate correctly, throw exception.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); 339 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value();
338 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 340 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
339 // TODO(iposva): Allow for arbitrary messages to be sent. 341 // TODO(iposva): Allow for arbitrary messages to be sent.
340 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 342 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
341 343
342 // TODO(turnidge): Throw an exception when the return value is false? 344 // TODO(turnidge): Throw an exception when the return value is false?
343 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); 345 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data));
344 } 346 }
345 347
346 } // namespace dart 348 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/allocation_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698