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

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

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 years, 3 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 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 return Api::Success(); 1247 return Api::Success();
1248 } 1248 }
1249 1249
1250 1250
1251 // --- Initialization and Globals --- 1251 // --- Initialization and Globals ---
1252 1252
1253 DART_EXPORT const char* Dart_VersionString() { 1253 DART_EXPORT const char* Dart_VersionString() {
1254 return Version::String(); 1254 return Version::String();
1255 } 1255 }
1256 1256
1257 DART_EXPORT bool Dart_Initialize( 1257 DART_EXPORT char* Dart_Initialize(
1258 const uint8_t* vm_isolate_snapshot, 1258 const uint8_t* vm_isolate_snapshot,
1259 const uint8_t* instructions_snapshot, 1259 const uint8_t* instructions_snapshot,
1260 Dart_IsolateCreateCallback create, 1260 Dart_IsolateCreateCallback create,
1261 Dart_IsolateInterruptCallback interrupt, 1261 Dart_IsolateInterruptCallback interrupt,
1262 Dart_IsolateUnhandledExceptionCallback unhandled, 1262 Dart_IsolateUnhandledExceptionCallback unhandled,
1263 Dart_IsolateShutdownCallback shutdown, 1263 Dart_IsolateShutdownCallback shutdown,
1264 Dart_FileOpenCallback file_open, 1264 Dart_FileOpenCallback file_open,
1265 Dart_FileReadCallback file_read, 1265 Dart_FileReadCallback file_read,
1266 Dart_FileWriteCallback file_write, 1266 Dart_FileWriteCallback file_write,
1267 Dart_FileCloseCallback file_close, 1267 Dart_FileCloseCallback file_close,
1268 Dart_EntropySource entropy_source) { 1268 Dart_EntropySource entropy_source) {
1269 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, 1269 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot,
1270 instructions_snapshot, 1270 instructions_snapshot,
1271 create, interrupt, unhandled, shutdown, 1271 create, interrupt, unhandled, shutdown,
1272 file_open, file_read, file_write, 1272 file_open, file_read, file_write,
1273 file_close, entropy_source); 1273 file_close, entropy_source);
1274 if (err_msg != NULL) { 1274 if (err_msg != NULL) {
1275 OS::PrintErr("Dart_Initialize: %s\n", err_msg); 1275 return strdup(err_msg);
1276 return false;
1277 } 1276 }
1278 return true; 1277 return NULL;
1279 } 1278 }
1280 1279
1281 1280
1282 DART_EXPORT bool Dart_Cleanup() { 1281 DART_EXPORT char* Dart_Cleanup() {
1283 CHECK_NO_ISOLATE(Isolate::Current()); 1282 CHECK_NO_ISOLATE(Isolate::Current());
1284 const char* err_msg = Dart::Cleanup(); 1283 const char* err_msg = Dart::Cleanup();
1285 if (err_msg != NULL) { 1284 if (err_msg != NULL) {
1286 OS::PrintErr("Dart_Cleanup: %s\n", err_msg); 1285 return strdup(err_msg);
1287 return false;
1288 } 1286 }
1289 return true; 1287 return NULL;
1290 } 1288 }
1291 1289
1292 1290
1293 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { 1291 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) {
1294 return Flags::ProcessCommandLineFlags(argc, argv); 1292 return Flags::ProcessCommandLineFlags(argc, argv);
1295 } 1293 }
1296 1294
1297 1295
1298 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { 1296 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
1299 return Flags::IsSet(flag_name); 1297 return Flags::IsSet(flag_name);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 1348
1351 // Setup default flags in case none were passed. 1349 // Setup default flags in case none were passed.
1352 Dart_IsolateFlags api_flags; 1350 Dart_IsolateFlags api_flags;
1353 if (flags == NULL) { 1351 if (flags == NULL) {
1354 Isolate::Flags vm_flags; 1352 Isolate::Flags vm_flags;
1355 vm_flags.CopyTo(&api_flags); 1353 vm_flags.CopyTo(&api_flags);
1356 flags = &api_flags; 1354 flags = &api_flags;
1357 } 1355 }
1358 Isolate* I = Dart::CreateIsolate(isolate_name, *flags); 1356 Isolate* I = Dart::CreateIsolate(isolate_name, *flags);
1359 free(isolate_name); 1357 free(isolate_name);
1358 if (I == NULL) {
1359 *error = strdup("Isolate creation failed");
1360 return reinterpret_cast<Dart_Isolate>(NULL);
1361 }
1360 { 1362 {
1361 Thread* T = Thread::Current(); 1363 Thread* T = Thread::Current();
1362 StackZone zone(T); 1364 StackZone zone(T);
1363 HANDLESCOPE(T); 1365 HANDLESCOPE(T);
1364 // We enter an API scope here as InitializeIsolate could compile some 1366 // We enter an API scope here as InitializeIsolate could compile some
1365 // bootstrap library files which call out to a tag handler that may create 1367 // bootstrap library files which call out to a tag handler that may create
1366 // Api Handles when an error is encountered. 1368 // Api Handles when an error is encountered.
1367 Dart_EnterScope(); 1369 Dart_EnterScope();
1368 const Error& error_obj = 1370 const Error& error_obj =
1369 Error::Handle(Z, Dart::InitializeIsolate(snapshot, callback_data)); 1371 Error::Handle(Z, Dart::InitializeIsolate(snapshot, callback_data));
(...skipping 4563 matching lines...) Expand 10 before | Expand all | Expand 10 after
5933 ApiReallocate); 5935 ApiReallocate);
5934 writer.WriteFullSnapshot(); 5936 writer.WriteFullSnapshot();
5935 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 5937 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
5936 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 5938 *isolate_snapshot_size = writer.IsolateSnapshotSize();
5937 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); 5939 *instructions_snapshot_size = writer.InstructionsSnapshotSize();
5938 5940
5939 return Api::Success(); 5941 return Api::Success();
5940 } 5942 }
5941 5943
5942 } // namespace dart 5944 } // 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