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

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: 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
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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 return Api::Success(); 1257 return Api::Success();
1258 } 1258 }
1259 1259
1260 1260
1261 // --- Initialization and Globals --- 1261 // --- Initialization and Globals ---
1262 1262
1263 DART_EXPORT const char* Dart_VersionString() { 1263 DART_EXPORT const char* Dart_VersionString() {
1264 return Version::String(); 1264 return Version::String();
1265 } 1265 }
1266 1266
1267 DART_EXPORT bool Dart_Initialize( 1267 DART_EXPORT char* Dart_Initialize(
1268 const uint8_t* vm_isolate_snapshot, 1268 const uint8_t* vm_isolate_snapshot,
1269 Dart_IsolateCreateCallback create, 1269 Dart_IsolateCreateCallback create,
1270 Dart_IsolateInterruptCallback interrupt, 1270 Dart_IsolateInterruptCallback interrupt,
1271 Dart_IsolateUnhandledExceptionCallback unhandled, 1271 Dart_IsolateUnhandledExceptionCallback unhandled,
1272 Dart_IsolateShutdownCallback shutdown, 1272 Dart_IsolateShutdownCallback shutdown,
1273 Dart_FileOpenCallback file_open, 1273 Dart_FileOpenCallback file_open,
1274 Dart_FileReadCallback file_read, 1274 Dart_FileReadCallback file_read,
1275 Dart_FileWriteCallback file_write, 1275 Dart_FileWriteCallback file_write,
1276 Dart_FileCloseCallback file_close, 1276 Dart_FileCloseCallback file_close,
1277 Dart_EntropySource entropy_source) { 1277 Dart_EntropySource entropy_source) {
1278 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, 1278 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot,
1279 create, interrupt, unhandled, shutdown, 1279 create, interrupt, unhandled, shutdown,
1280 file_open, file_read, file_write, 1280 file_open, file_read, file_write,
1281 file_close, entropy_source); 1281 file_close, entropy_source);
1282 if (err_msg != NULL) { 1282 if (err_msg != NULL) {
1283 OS::PrintErr("Dart_Initialize: %s\n", err_msg); 1283 return strdup(err_msg);
1284 return false;
1285 } 1284 }
1286 return true; 1285 return NULL;
1287 } 1286 }
1288 1287
1289 1288
1290 DART_EXPORT bool Dart_Cleanup() { 1289 DART_EXPORT char* Dart_Cleanup() {
1291 CHECK_NO_ISOLATE(Isolate::Current()); 1290 CHECK_NO_ISOLATE(Isolate::Current());
1292 const char* err_msg = Dart::Cleanup(); 1291 const char* err_msg = Dart::Cleanup();
1293 if (err_msg != NULL) { 1292 if (err_msg != NULL) {
1294 OS::PrintErr("Dart_Cleanup: %s\n", err_msg); 1293 return strdup(err_msg);
1295 return false;
1296 } 1294 }
1297 return true; 1295 return NULL;
1298 } 1296 }
1299 1297
1300 1298
1301 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { 1299 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) {
1302 return Flags::ProcessCommandLineFlags(argc, argv); 1300 return Flags::ProcessCommandLineFlags(argc, argv);
1303 } 1301 }
1304 1302
1305 1303
1306 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { 1304 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
1307 return Flags::IsSet(flag_name); 1305 return Flags::IsSet(flag_name);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 1356
1359 // Setup default flags in case none were passed. 1357 // Setup default flags in case none were passed.
1360 Dart_IsolateFlags api_flags; 1358 Dart_IsolateFlags api_flags;
1361 if (flags == NULL) { 1359 if (flags == NULL) {
1362 Isolate::Flags vm_flags; 1360 Isolate::Flags vm_flags;
1363 vm_flags.CopyTo(&api_flags); 1361 vm_flags.CopyTo(&api_flags);
1364 flags = &api_flags; 1362 flags = &api_flags;
1365 } 1363 }
1366 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags); 1364 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags);
1367 free(isolate_name); 1365 free(isolate_name);
1366 if (isolate == NULL) {
1367 *error = strdup("Isolate creation failed");
1368 return reinterpret_cast<Dart_Isolate>(NULL);
1369 }
1368 { 1370 {
1369 StackZone zone(isolate); 1371 StackZone zone(isolate);
1370 HANDLESCOPE(isolate); 1372 HANDLESCOPE(isolate);
1371 // We enter an API scope here as InitializeIsolate could compile some 1373 // We enter an API scope here as InitializeIsolate could compile some
1372 // bootstrap library files which call out to a tag handler that may create 1374 // bootstrap library files which call out to a tag handler that may create
1373 // Api Handles when an error is encountered. 1375 // Api Handles when an error is encountered.
1374 Dart_EnterScope(); 1376 Dart_EnterScope();
1375 const Error& error_obj = 1377 const Error& error_obj =
1376 Error::Handle(isolate, 1378 Error::Handle(isolate,
1377 Dart::InitializeIsolate(snapshot, callback_data)); 1379 Dart::InitializeIsolate(snapshot, callback_data));
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 Dart::thread_pool(), 1666 Dart::thread_pool(),
1665 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); 1667 NULL, RunLoopDone, reinterpret_cast<uword>(&data));
1666 while (!data.done) { 1668 while (!data.done) {
1667 ml.Wait(); 1669 ml.Wait();
1668 } 1670 }
1669 } 1671 }
1670 if (isolate->object_store()->sticky_error() != Object::null()) { 1672 if (isolate->object_store()->sticky_error() != Object::null()) {
1671 Dart_Handle error = Api::NewHandle(isolate, 1673 Dart_Handle error = Api::NewHandle(isolate,
1672 isolate->object_store()->sticky_error()); 1674 isolate->object_store()->sticky_error());
1673 isolate->object_store()->clear_sticky_error(); 1675 isolate->object_store()->clear_sticky_error();
1676 OS::PrintErr("RunLoop returning error\n");
Ivan Posva 2015/08/17 13:35:51 Debug print left over?
zra 2015/08/18 06:23:14 Removed.
1674 return error; 1677 return error;
1675 } 1678 }
1676 if (FLAG_print_class_table) { 1679 if (FLAG_print_class_table) {
1677 HANDLESCOPE(isolate); 1680 HANDLESCOPE(isolate);
1678 isolate->class_table()->Print(); 1681 isolate->class_table()->Print();
1679 } 1682 }
1680 return Api::Success(); 1683 return Api::Success();
1681 } 1684 }
1682 1685
1683 1686
(...skipping 4271 matching lines...) Expand 10 before | Expand all | Expand 10 after
5955 ASSERT(stream != NULL); 5958 ASSERT(stream != NULL);
5956 TimelineEvent* event = stream->StartEvent(); 5959 TimelineEvent* event = stream->StartEvent();
5957 if (event != NULL) { 5960 if (event != NULL) {
5958 event->AsyncEnd(label, async_id); 5961 event->AsyncEnd(label, async_id);
5959 event->Complete(); 5962 event->Complete();
5960 } 5963 }
5961 return Api::Success(); 5964 return Api::Success();
5962 } 5965 }
5963 5966
5964 } // namespace dart 5967 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698