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

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

Issue 1371193005: VM restart + shutdown fixes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: more code review Created 5 years, 2 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.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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 return Api::ClassId(object) == kLanguageErrorCid; 740 return Api::ClassId(object) == kLanguageErrorCid;
741 } 741 }
742 742
743 743
744 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) { 744 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
745 TRACE_API_CALL(CURRENT_FUNC); 745 TRACE_API_CALL(CURRENT_FUNC);
746 return Api::ClassId(object) == kUnwindErrorCid; 746 return Api::ClassId(object) == kUnwindErrorCid;
747 } 747 }
748 748
749 749
750 DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) {
751 DARTSCOPE(Thread::Current());
752 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle));
753 return (obj.IsUnwindError() && UnwindError::Cast(obj).is_vm_restart());
754 }
755
756
750 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) { 757 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) {
751 DARTSCOPE(Thread::Current()); 758 DARTSCOPE(Thread::Current());
752 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); 759 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle));
753 if (obj.IsError()) { 760 if (obj.IsError()) {
754 const Error& error = Error::Cast(obj); 761 const Error& error = Error::Cast(obj);
755 const char* str = error.ToErrorCString(); 762 const char* str = error.ToErrorCString();
756 intptr_t len = strlen(str) + 1; 763 intptr_t len = strlen(str) + 1;
757 char* str_copy = Api::TopScope(I)->zone()->Alloc<char>(len); 764 char* str_copy = Api::TopScope(I)->zone()->Alloc<char>(len);
758 strncpy(str_copy, str, len); 765 strncpy(str_copy, str, len);
759 // Strip a possible trailing '\n'. 766 // Strip a possible trailing '\n'.
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 I->class_table()->Print(); 1674 I->class_table()->Print();
1668 } 1675 }
1669 return Api::Success(); 1676 return Api::Success();
1670 } 1677 }
1671 1678
1672 1679
1673 DART_EXPORT Dart_Handle Dart_HandleMessage() { 1680 DART_EXPORT Dart_Handle Dart_HandleMessage() {
1674 Isolate* isolate = Isolate::Current(); 1681 Isolate* isolate = Isolate::Current();
1675 CHECK_ISOLATE_SCOPE(isolate); 1682 CHECK_ISOLATE_SCOPE(isolate);
1676 CHECK_CALLBACK_STATE(isolate); 1683 CHECK_CALLBACK_STATE(isolate);
1677 if (!isolate->message_handler()->HandleNextMessage()) { 1684 if (isolate->message_handler()->HandleNextMessage() != MessageHandler::kOK) {
1678 Dart_Handle error = Api::NewHandle(isolate, 1685 Dart_Handle error = Api::NewHandle(isolate,
1679 isolate->object_store()->sticky_error()); 1686 isolate->object_store()->sticky_error());
1680 isolate->object_store()->clear_sticky_error(); 1687 isolate->object_store()->clear_sticky_error();
1681 return error; 1688 return error;
1682 } 1689 }
1683 return Api::Success(); 1690 return Api::Success();
1684 } 1691 }
1685 1692
1686 1693
1687 DART_EXPORT bool Dart_HandleServiceMessages() { 1694 DART_EXPORT bool Dart_HandleServiceMessages() {
1688 Isolate* isolate = Isolate::Current(); 1695 Isolate* isolate = Isolate::Current();
1689 CHECK_ISOLATE_SCOPE(isolate); 1696 CHECK_ISOLATE_SCOPE(isolate);
1690 CHECK_CALLBACK_STATE(isolate); 1697 CHECK_CALLBACK_STATE(isolate);
1691 1698
1692 ASSERT(isolate->GetAndClearResumeRequest() == false); 1699 ASSERT(isolate->GetAndClearResumeRequest() == false);
1693 isolate->message_handler()->HandleOOBMessages(); 1700 MessageHandler::MessageStatus status =
1694 return isolate->GetAndClearResumeRequest(); 1701 isolate->message_handler()->HandleOOBMessages();
1702 bool resume = isolate->GetAndClearResumeRequest();
1703 return (status != MessageHandler::kOK) || resume;
1695 } 1704 }
1696 1705
1697 1706
1698 DART_EXPORT bool Dart_HasServiceMessages() { 1707 DART_EXPORT bool Dart_HasServiceMessages() {
1699 Isolate* isolate = Isolate::Current(); 1708 Isolate* isolate = Isolate::Current();
1700 ASSERT(isolate); 1709 ASSERT(isolate);
1701 return isolate->message_handler()->HasOOBMessages(); 1710 return isolate->message_handler()->HasOOBMessages();
1702 } 1711 }
1703 1712
1704 1713
(...skipping 4356 matching lines...) Expand 10 before | Expand all | Expand 10 after
6061 ApiReallocate); 6070 ApiReallocate);
6062 writer.WriteFullSnapshot(); 6071 writer.WriteFullSnapshot();
6063 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 6072 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
6064 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 6073 *isolate_snapshot_size = writer.IsolateSnapshotSize();
6065 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); 6074 *instructions_snapshot_size = writer.InstructionsSnapshotSize();
6066 6075
6067 return Api::Success(); 6076 return Api::Success();
6068 } 6077 }
6069 6078
6070 } // namespace dart 6079 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698