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

Side by Side Diff: runtime/vm/isolate.h

Issue 1427583009: 1. Get rid of SwitchIsolateScope as it is not clear when this should be used and there is also a bu… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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_api_impl.cc ('k') | runtime/vm/isolate.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 #ifndef VM_ISOLATE_H_ 5 #ifndef VM_ISOLATE_H_
6 #define VM_ISOLATE_H_ 6 #define VM_ISOLATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/atomic.h" 10 #include "vm/atomic.h"
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 } 916 }
917 } 917 }
918 918
919 private: 919 private:
920 Isolate* new_isolate_; 920 Isolate* new_isolate_;
921 Isolate* saved_isolate_; 921 Isolate* saved_isolate_;
922 922
923 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); 923 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope);
924 }; 924 };
925 925
926 // When we need to temporarily become another isolate, we use the
927 // SwitchIsolateScope. It is not permitted to run dart code while in
928 // a SwitchIsolateScope.
929 class SwitchIsolateScope {
930 public:
931 explicit SwitchIsolateScope(Isolate* new_isolate)
932 : new_isolate_(new_isolate),
933 saved_isolate_(Isolate::Current()),
934 saved_stack_limit_(saved_isolate_
935 ? saved_isolate_->saved_stack_limit() : 0) {
936 // TODO(koda): Audit users; why would these two ever be equal?
937 if (saved_isolate_ != new_isolate_) {
938 if (new_isolate_ == NULL) {
939 Thread::ExitIsolate();
940 } else {
941 Thread::EnterIsolate(new_isolate_);
942 // Don't allow dart code to execute.
943 new_isolate_->SetStackLimit(~static_cast<uword>(0));
944 }
945 }
946 }
947
948 ~SwitchIsolateScope() {
949 if (saved_isolate_ != new_isolate_) {
950 if (new_isolate_ != NULL) {
951 Thread::ExitIsolate();
952 }
953 if (saved_isolate_ != NULL) {
954 Thread::EnterIsolate(saved_isolate_);
955 saved_isolate_->SetStackLimit(saved_stack_limit_);
956 }
957 }
958 }
959
960 private:
961 Isolate* new_isolate_;
962 Isolate* saved_isolate_;
963 uword saved_stack_limit_;
964
965 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope);
966 };
967
968 926
969 class IsolateSpawnState { 927 class IsolateSpawnState {
970 public: 928 public:
971 IsolateSpawnState(Dart_Port parent_port, 929 IsolateSpawnState(Dart_Port parent_port,
972 const Function& func, 930 const Function& func,
973 const Instance& message, 931 const Instance& message,
974 bool paused, 932 bool paused,
975 bool errorsAreFatal, 933 bool errorsAreFatal,
976 Dart_Port onExit, 934 Dart_Port onExit,
977 Dart_Port onError); 935 Dart_Port onError);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 uint8_t* serialized_message_; 982 uint8_t* serialized_message_;
1025 intptr_t serialized_message_len_; 983 intptr_t serialized_message_len_;
1026 Isolate::Flags isolate_flags_; 984 Isolate::Flags isolate_flags_;
1027 bool paused_; 985 bool paused_;
1028 bool errors_are_fatal_; 986 bool errors_are_fatal_;
1029 }; 987 };
1030 988
1031 } // namespace dart 989 } // namespace dart
1032 990
1033 #endif // VM_ISOLATE_H_ 991 #endif // VM_ISOLATE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698