| OLD | NEW |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return result.raw(); | 79 return result.raw(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 static void ShutdownIsolate(uword parameter) { | 83 static void ShutdownIsolate(uword parameter) { |
| 84 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); | 84 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); |
| 85 { | 85 { |
| 86 // Print the error if there is one. This may execute dart code to | 86 // Print the error if there is one. This may execute dart code to |
| 87 // print the exception object, so we need to use a StartIsolateScope. | 87 // print the exception object, so we need to use a StartIsolateScope. |
| 88 StartIsolateScope start_scope(isolate); | 88 StartIsolateScope start_scope(isolate); |
| 89 Zone zone(isolate); | 89 StackZone zone(isolate); |
| 90 HandleScope handle_scope(isolate); | 90 HandleScope handle_scope(isolate); |
| 91 Error& error = Error::Handle(); | 91 Error& error = Error::Handle(); |
| 92 error = isolate->object_store()->sticky_error(); | 92 error = isolate->object_store()->sticky_error(); |
| 93 if (!error.IsNull()) { | 93 if (!error.IsNull()) { |
| 94 OS::PrintErr("%s\n", error.ToErrorCString()); | 94 OS::PrintErr("%s\n", error.ToErrorCString()); |
| 95 exit(255); | 95 exit(255); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 { | 98 { |
| 99 // Shut the isolate down. | 99 // Shut the isolate down. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 args.Add(&message); | 161 args.Add(&message); |
| 162 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args); | 162 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args); |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 static bool CanonicalizeUri(Isolate* isolate, | 166 static bool CanonicalizeUri(Isolate* isolate, |
| 167 const Library& library, | 167 const Library& library, |
| 168 const String& uri, | 168 const String& uri, |
| 169 char** canonical_uri, | 169 char** canonical_uri, |
| 170 char** error) { | 170 char** error) { |
| 171 Zone* zone = isolate->current_zone(); | 171 StackZone* zone = isolate->current_zone(); |
| 172 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); | 172 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); |
| 173 if (handler == NULL) { | 173 if (handler == NULL) { |
| 174 *error = zone->PrintToString( | 174 *error = zone->PrintToString( |
| 175 "Unable to canonicalize uri '%s': no library tag handler found.", | 175 "Unable to canonicalize uri '%s': no library tag handler found.", |
| 176 uri.ToCString()); | 176 uri.ToCString()); |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 Dart_Handle result = handler(kCanonicalizeUrl, | 179 Dart_Handle result = handler(kCanonicalizeUrl, |
| 180 Api::NewHandle(isolate, library.raw()), | 180 Api::NewHandle(isolate, library.raw()), |
| 181 Api::NewHandle(isolate, uri.raw())); | 181 Api::NewHandle(isolate, uri.raw())); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 Isolate* child_isolate = Isolate::Current(); | 304 Isolate* child_isolate = Isolate::Current(); |
| 305 ASSERT(child_isolate); | 305 ASSERT(child_isolate); |
| 306 state->set_isolate(child_isolate); | 306 state->set_isolate(child_isolate); |
| 307 | 307 |
| 308 // Attempt to resolve the entry function now, so that we fail fast | 308 // Attempt to resolve the entry function now, so that we fail fast |
| 309 // in the case that the function cannot be resolved. | 309 // in the case that the function cannot be resolved. |
| 310 // | 310 // |
| 311 // TODO(turnidge): Revisit this once we have an isolate death api. | 311 // TODO(turnidge): Revisit this once we have an isolate death api. |
| 312 bool resolve_error = false; | 312 bool resolve_error = false; |
| 313 { | 313 { |
| 314 Zone zone(child_isolate); | 314 StackZone zone(child_isolate); |
| 315 HandleScope handle_scope(child_isolate); | 315 HandleScope handle_scope(child_isolate); |
| 316 const Object& result = Object::Handle(state->ResolveFunction()); | 316 const Object& result = Object::Handle(state->ResolveFunction()); |
| 317 if (result.IsError()) { | 317 if (result.IsError()) { |
| 318 Error& errobj = Error::Handle(); | 318 Error& errobj = Error::Handle(); |
| 319 errobj ^= result.raw(); | 319 errobj ^= result.raw(); |
| 320 *error = strdup(errobj.ToErrorCString()); | 320 *error = strdup(errobj.ToErrorCString()); |
| 321 resolve_error = true; | 321 resolve_error = true; |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 if (resolve_error) { | 324 if (resolve_error) { |
| 325 Dart::ShutdownIsolate(); | 325 Dart::ShutdownIsolate(); |
| 326 Isolate::SetCurrent(parent_isolate); | 326 Isolate::SetCurrent(parent_isolate); |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 Isolate::SetCurrent(parent_isolate); | 330 Isolate::SetCurrent(parent_isolate); |
| 331 return true; | 331 return true; |
| 332 } | 332 } |
| 333 | 333 |
| 334 | 334 |
| 335 static bool RunIsolate(uword parameter) { | 335 static bool RunIsolate(uword parameter) { |
| 336 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); | 336 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); |
| 337 SpawnState* state = reinterpret_cast<SpawnState*>(isolate->spawn_data()); | 337 SpawnState* state = reinterpret_cast<SpawnState*>(isolate->spawn_data()); |
| 338 isolate->set_spawn_data(NULL); | 338 isolate->set_spawn_data(NULL); |
| 339 { | 339 { |
| 340 StartIsolateScope start_scope(isolate); | 340 StartIsolateScope start_scope(isolate); |
| 341 Zone zone(isolate); | 341 StackZone zone(isolate); |
| 342 HandleScope handle_scope(isolate); | 342 HandleScope handle_scope(isolate); |
| 343 if (!ClassFinalizer::FinalizePendingClasses()) { | 343 if (!ClassFinalizer::FinalizePendingClasses()) { |
| 344 // Error is in sticky error already. | 344 // Error is in sticky error already. |
| 345 return false; | 345 return false; |
| 346 } | 346 } |
| 347 Object& result = Object::Handle(); | 347 Object& result = Object::Handle(); |
| 348 | 348 |
| 349 result = state->ResolveFunction(); | 349 result = state->ResolveFunction(); |
| 350 delete state; | 350 delete state; |
| 351 state = NULL; | 351 state = NULL; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 439 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
| 440 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 440 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
| 441 if (port.IsError()) { | 441 if (port.IsError()) { |
| 442 Exceptions::PropagateError(Error::Cast(port)); | 442 Exceptions::PropagateError(Error::Cast(port)); |
| 443 } | 443 } |
| 444 return port.raw(); | 444 return port.raw(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace dart | 447 } // namespace dart |
| OLD | NEW |