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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 1177153005: Enables clean VM shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix error propagation Created 5 years, 4 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
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/debugger_api_impl_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 return Api::Success(); 1256 return Api::Success();
1257 } 1257 }
1258 1258
1259 1259
1260 // --- Initialization and Globals --- 1260 // --- Initialization and Globals ---
1261 1261
1262 DART_EXPORT const char* Dart_VersionString() { 1262 DART_EXPORT const char* Dart_VersionString() {
1263 return Version::String(); 1263 return Version::String();
1264 } 1264 }
1265 1265
1266 DART_EXPORT bool Dart_Initialize( 1266 DART_EXPORT char* Dart_Initialize(
1267 const uint8_t* vm_isolate_snapshot, 1267 const uint8_t* vm_isolate_snapshot,
1268 Dart_IsolateCreateCallback create, 1268 Dart_IsolateCreateCallback create,
1269 Dart_IsolateInterruptCallback interrupt, 1269 Dart_IsolateInterruptCallback interrupt,
1270 Dart_IsolateUnhandledExceptionCallback unhandled, 1270 Dart_IsolateUnhandledExceptionCallback unhandled,
1271 Dart_IsolateShutdownCallback shutdown, 1271 Dart_IsolateShutdownCallback shutdown,
1272 Dart_FileOpenCallback file_open, 1272 Dart_FileOpenCallback file_open,
1273 Dart_FileReadCallback file_read, 1273 Dart_FileReadCallback file_read,
1274 Dart_FileWriteCallback file_write, 1274 Dart_FileWriteCallback file_write,
1275 Dart_FileCloseCallback file_close, 1275 Dart_FileCloseCallback file_close,
1276 Dart_EntropySource entropy_source) { 1276 Dart_EntropySource entropy_source) {
1277 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, 1277 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot,
1278 create, interrupt, unhandled, shutdown, 1278 create, interrupt, unhandled, shutdown,
1279 file_open, file_read, file_write, 1279 file_open, file_read, file_write,
1280 file_close, entropy_source); 1280 file_close, entropy_source);
1281 if (err_msg != NULL) { 1281 if (err_msg != NULL) {
1282 OS::PrintErr("Dart_Initialize: %s\n", err_msg); 1282 return strdup(err_msg);
1283 return false;
1284 } 1283 }
1285 return true; 1284 return NULL;
1286 } 1285 }
1287 1286
1288 1287
1289 DART_EXPORT bool Dart_Cleanup() { 1288 DART_EXPORT char* Dart_Cleanup() {
1290 CHECK_NO_ISOLATE(Isolate::Current()); 1289 CHECK_NO_ISOLATE(Isolate::Current());
1291 const char* err_msg = Dart::Cleanup(); 1290 const char* err_msg = Dart::Cleanup();
1292 if (err_msg != NULL) { 1291 if (err_msg != NULL) {
1293 OS::PrintErr("Dart_Cleanup: %s\n", err_msg); 1292 return strdup(err_msg);
1294 return false;
1295 } 1293 }
1296 return true; 1294 return NULL;
1297 } 1295 }
1298 1296
1299 1297
1300 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { 1298 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) {
1301 return Flags::ProcessCommandLineFlags(argc, argv); 1299 return Flags::ProcessCommandLineFlags(argc, argv);
1302 } 1300 }
1303 1301
1304 1302
1305 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { 1303 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
1306 return Flags::IsSet(flag_name); 1304 return Flags::IsSet(flag_name);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 1355
1358 // Setup default flags in case none were passed. 1356 // Setup default flags in case none were passed.
1359 Dart_IsolateFlags api_flags; 1357 Dart_IsolateFlags api_flags;
1360 if (flags == NULL) { 1358 if (flags == NULL) {
1361 Isolate::Flags vm_flags; 1359 Isolate::Flags vm_flags;
1362 vm_flags.CopyTo(&api_flags); 1360 vm_flags.CopyTo(&api_flags);
1363 flags = &api_flags; 1361 flags = &api_flags;
1364 } 1362 }
1365 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags); 1363 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags);
1366 free(isolate_name); 1364 free(isolate_name);
1365 if (isolate == NULL) {
1366 *error = strdup("Isolate creation failed");
1367 return reinterpret_cast<Dart_Isolate>(NULL);
1368 }
1367 { 1369 {
1368 StackZone zone(isolate); 1370 StackZone zone(isolate);
1369 HANDLESCOPE(isolate); 1371 HANDLESCOPE(isolate);
1370 // We enter an API scope here as InitializeIsolate could compile some 1372 // We enter an API scope here as InitializeIsolate could compile some
1371 // bootstrap library files which call out to a tag handler that may create 1373 // bootstrap library files which call out to a tag handler that may create
1372 // Api Handles when an error is encountered. 1374 // Api Handles when an error is encountered.
1373 Dart_EnterScope(); 1375 Dart_EnterScope();
1374 const Error& error_obj = 1376 const Error& error_obj =
1375 Error::Handle(isolate, 1377 Error::Handle(isolate,
1376 Dart::InitializeIsolate(snapshot, callback_data)); 1378 Dart::InitializeIsolate(snapshot, callback_data));
(...skipping 4483 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 ASSERT(stream != NULL); 5862 ASSERT(stream != NULL);
5861 TimelineEvent* event = stream->StartEvent(); 5863 TimelineEvent* event = stream->StartEvent();
5862 if (event != NULL) { 5864 if (event != NULL) {
5863 event->AsyncEnd(label, async_id); 5865 event->AsyncEnd(label, async_id);
5864 event->Complete(); 5866 event->Complete();
5865 } 5867 }
5866 return Api::Success(); 5868 return Api::Success();
5867 } 5869 }
5868 5870
5869 } // namespace dart 5871 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698