Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 return NULL; | 458 return NULL; |
| 459 } | 459 } |
| 460 | 460 |
| 461 | 461 |
| 462 // --- Initialization and Globals --- | 462 // --- Initialization and Globals --- |
| 463 | 463 |
| 464 | 464 |
| 465 // TODO(iposva): This is a placeholder for the eventual external Dart API. | 465 // TODO(iposva): This is a placeholder for the eventual external Dart API. |
| 466 DART_EXPORT bool Dart_Initialize(int argc, | 466 DART_EXPORT bool Dart_Initialize(int argc, |
| 467 const char** argv, | 467 const char** argv, |
| 468 Dart_IsolateInitCallback callback) { | 468 Dart_IsolateCreateCallback callback) { |
| 469 if (callback == NULL) { | |
|
Ivan Posva
2011/11/30 00:58:21
Why is NULL not a legal value? Maybe the embedder
siva
2011/11/30 18:56:31
Removed the check for NULL and in isolate spawn I
| |
| 470 // TODO(asiva): Need to provide an error message here. | |
| 471 return false; | |
| 472 } | |
| 469 return Dart::InitOnce(argc, argv, callback); | 473 return Dart::InitOnce(argc, argv, callback); |
| 470 } | 474 } |
| 471 | 475 |
| 472 | 476 |
| 473 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { | 477 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { |
| 474 if (Flags::Lookup(flag_name) != NULL) { | 478 if (Flags::Lookup(flag_name) != NULL) { |
| 475 return true; | 479 return true; |
| 476 } | 480 } |
| 477 return false; | 481 return false; |
| 478 } | 482 } |
| 479 | 483 |
| 480 | 484 |
| 481 // --- Isolates --- | 485 // --- Isolates --- |
| 482 | 486 |
| 483 | 487 |
| 484 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 488 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
| 485 void* data) { | 489 void* callback_data, |
| 490 Dart_ErrorBuffer error) { | |
| 486 Isolate* isolate = Dart::CreateIsolate(); | 491 Isolate* isolate = Dart::CreateIsolate(); |
| 487 ASSERT(isolate != NULL); | 492 ASSERT(isolate != NULL); |
| 488 LongJump* base = isolate->long_jump_base(); | 493 LongJump* base = isolate->long_jump_base(); |
| 489 LongJump jump; | 494 LongJump jump; |
| 490 isolate->set_long_jump_base(&jump); | 495 isolate->set_long_jump_base(&jump); |
| 491 if (setjmp(*jump.Set()) == 0) { | 496 if (setjmp(*jump.Set()) == 0) { |
| 492 Dart::InitializeIsolate(snapshot, data); | 497 Dart::InitializeIsolate(snapshot, callback_data); |
| 493 START_TIMER(time_total_runtime); | 498 START_TIMER(time_total_runtime); |
| 494 isolate->set_long_jump_base(base); | 499 isolate->set_long_jump_base(base); |
| 495 return reinterpret_cast<Dart_Isolate>(isolate); | 500 return reinterpret_cast<Dart_Isolate>(isolate); |
| 496 } else { | 501 } else { |
| 497 { | 502 { |
| 498 DARTSCOPE(isolate); | 503 DARTSCOPE(isolate); |
| 499 const String& error = | 504 const String& errmsg = |
| 500 String::Handle(isolate->object_store()->sticky_error()); | 505 String::Handle(isolate->object_store()->sticky_error()); |
| 501 // TODO(asiva): Need to return this as a error. | 506 OS::SNPrint(error.buffer, error.length, "%s", errmsg.ToCString()); |
| 502 OS::PrintErr(error.ToCString()); | |
| 503 } | 507 } |
| 504 Dart::ShutdownIsolate(); | 508 Dart::ShutdownIsolate(); |
| 505 } | 509 } |
| 506 return reinterpret_cast<Dart_Isolate>(NULL); | 510 return reinterpret_cast<Dart_Isolate>(NULL); |
| 507 } | 511 } |
| 508 | 512 |
| 509 | 513 |
| 510 DART_EXPORT void Dart_ShutdownIsolate() { | 514 DART_EXPORT void Dart_ShutdownIsolate() { |
| 511 ASSERT(Isolate::Current() != NULL); | 515 ASSERT(Isolate::Current() != NULL); |
| 512 STOP_TIMER(time_total_runtime); | 516 STOP_TIMER(time_total_runtime); |
| (...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2297 } | 2301 } |
| 2298 delete debug_region; | 2302 delete debug_region; |
| 2299 } else { | 2303 } else { |
| 2300 *buffer = NULL; | 2304 *buffer = NULL; |
| 2301 *buffer_size = 0; | 2305 *buffer_size = 0; |
| 2302 } | 2306 } |
| 2303 } | 2307 } |
| 2304 | 2308 |
| 2305 | 2309 |
| 2306 } // namespace dart | 2310 } // namespace dart |
| OLD | NEW |