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

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

Issue 1236403004: Migrate handle scope fields to Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Ready for review. Created 5 years, 5 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/handles_impl.h ('k') | runtime/vm/thread_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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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_THREAD_H_ 5 #ifndef VM_THREAD_H_
6 #define VM_THREAD_H_ 6 #define VM_THREAD_H_
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/os_thread.h" 9 #include "vm/os_thread.h"
10 #include "vm/store_buffer.h" 10 #include "vm/store_buffer.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 class CHA; 14 class CHA;
15 class HandleScope;
15 class Isolate; 16 class Isolate;
16 class Object; 17 class Object;
17 class RawBool; 18 class RawBool;
18 class RawObject; 19 class RawObject;
19 class StackResource; 20 class StackResource;
20 class Zone; 21 class Zone;
21 22
22 // List of VM-global objects/addresses cached in each Thread object. 23 // List of VM-global objects/addresses cached in each Thread object.
23 #define CACHED_VM_OBJECTS_LIST(V) \ 24 #define CACHED_VM_OBJECTS_LIST(V) \
24 V(RawObject*, object_null_, Object::null(), NULL) \ 25 V(RawObject*, object_null_, Object::null(), NULL) \
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 110 }
110 111
111 StackResource* top_resource() const { return state_.top_resource; } 112 StackResource* top_resource() const { return state_.top_resource; }
112 void set_top_resource(StackResource* value) { 113 void set_top_resource(StackResource* value) {
113 state_.top_resource = value; 114 state_.top_resource = value;
114 } 115 }
115 static intptr_t top_resource_offset() { 116 static intptr_t top_resource_offset() {
116 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource); 117 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource);
117 } 118 }
118 119
120 int32_t no_handle_scope_depth() const {
121 #if defined(DEBUG)
122 return state_.no_handle_scope_depth;
123 #else
124 return 0;
125 #endif
126 }
127
128 void IncrementNoHandleScopeDepth() {
129 #if defined(DEBUG)
130 ASSERT(state_.no_handle_scope_depth < INT_MAX);
131 state_.no_handle_scope_depth += 1;
132 #endif
133 }
134
135 void DecrementNoHandleScopeDepth() {
136 #if defined(DEBUG)
137 ASSERT(state_.no_handle_scope_depth > 0);
138 state_.no_handle_scope_depth -= 1;
139 #endif
140 }
141
142 HandleScope* top_handle_scope() const {
143 #if defined(DEBUG)
144 return state_.top_handle_scope;
145 #else
146 return 0;
147 #endif
148 }
149
150 void set_top_handle_scope(HandleScope* handle_scope) {
151 #if defined(DEBUG)
152 state_.top_handle_scope = handle_scope;
153 #endif
154 }
155
119 // Collection of isolate-specific state of a thread that is saved/restored 156 // Collection of isolate-specific state of a thread that is saved/restored
120 // on isolate exit/re-entry. 157 // on isolate exit/re-entry.
121 struct State { 158 struct State {
122 Zone* zone; 159 Zone* zone;
123 uword top_exit_frame_info; 160 uword top_exit_frame_info;
124 StackResource* top_resource; 161 StackResource* top_resource;
162 #if defined(DEBUG)
163 HandleScope* top_handle_scope;
164 intptr_t no_handle_scope_depth;
165 #endif
125 }; 166 };
126 167
127 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ 168 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \
128 static intptr_t member_name##offset() { \ 169 static intptr_t member_name##offset() { \
129 return OFFSET_OF(Thread, member_name); \ 170 return OFFSET_OF(Thread, member_name); \
130 } 171 }
131 CACHED_CONSTANTS_LIST(DEFINE_OFFSET_METHOD) 172 CACHED_CONSTANTS_LIST(DEFINE_OFFSET_METHOD)
132 #undef DEFINE_OFFSET_METHOD 173 #undef DEFINE_OFFSET_METHOD
133 174
134 static bool CanLoadFromThread(const Object& object); 175 static bool CanLoadFromThread(const Object& object);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void Unschedule(); 208 void Unschedule();
168 209
169 friend class Isolate; 210 friend class Isolate;
170 friend class StackZone; 211 friend class StackZone;
171 DISALLOW_COPY_AND_ASSIGN(Thread); 212 DISALLOW_COPY_AND_ASSIGN(Thread);
172 }; 213 };
173 214
174 } // namespace dart 215 } // namespace dart
175 216
176 #endif // VM_THREAD_H_ 217 #endif // VM_THREAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/handles_impl.h ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698