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

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

Issue 9924015: Use the ThreadPool for all isolates and native ports. Previously, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 15 matching lines...) Expand all
26 class MessageHandler; 26 class MessageHandler;
27 class Mutex; 27 class Mutex;
28 class ObjectPointerVisitor; 28 class ObjectPointerVisitor;
29 class ObjectStore; 29 class ObjectStore;
30 class RawContext; 30 class RawContext;
31 class RawError; 31 class RawError;
32 class StackResource; 32 class StackResource;
33 class StubCode; 33 class StubCode;
34 class Zone; 34 class Zone;
35 35
36
37 class Isolate : public BaseIsolate { 36 class Isolate : public BaseIsolate {
38 public: 37 public:
39 ~Isolate(); 38 ~Isolate();
40 39
41 static inline Isolate* Current() { 40 static inline Isolate* Current() {
42 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); 41 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key));
43 } 42 }
44 43
45 static void SetCurrent(Isolate* isolate); 44 static void SetCurrent(Isolate* isolate);
46 45
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); 136 void SetStackLimitFromCurrentTOS(uword isolate_stack_top);
138 137
139 uword stack_limit_address() const { 138 uword stack_limit_address() const {
140 return reinterpret_cast<uword>(&stack_limit_); 139 return reinterpret_cast<uword>(&stack_limit_);
141 } 140 }
142 141
143 // The current stack limit. This may be overwritten with a special 142 // The current stack limit. This may be overwritten with a special
144 // value to trigger interrupts. 143 // value to trigger interrupts.
145 uword stack_limit() const { return stack_limit_; } 144 uword stack_limit() const { return stack_limit_; }
146 145
147 // The true stack limit for this isolate. This does not change 146 // The true stack limit for this isolate.
148 // after isolate initialization.
149 uword saved_stack_limit() const { return saved_stack_limit_; } 147 uword saved_stack_limit() const { return saved_stack_limit_; }
150 148
151 enum { 149 enum {
152 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. 150 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate.
153 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. 151 kMessageInterrupt = 0x2, // An interrupt to process an out of band message.
154 152
155 kInterruptsMask = kApiInterrupt | kMessageInterrupt, 153 kInterruptsMask = kApiInterrupt | kMessageInterrupt,
156 }; 154 };
157 155
158 void ScheduleInterrupts(uword interrupt_bits); 156 void ScheduleInterrupts(uword interrupt_bits);
159 uword GetAndClearInterrupts(); 157 uword GetAndClearInterrupts();
160 158
161 MessageHandler* message_handler() const { return message_handler_; } 159 MessageHandler* message_handler() const { return message_handler_; }
162 void set_message_handler(MessageHandler* value) { message_handler_ = value; } 160 void set_message_handler(MessageHandler* value) { message_handler_ = value; }
163 161
164 // Returns null on success, a RawError on failure. 162 uword spawn_data() const { return spawn_data_; }
165 RawError* StandardRunLoop(); 163 void set_spawn_data(uword value) { spawn_data_ = value; }
166 164
167 intptr_t ast_node_id() const { return ast_node_id_; } 165 intptr_t ast_node_id() const { return ast_node_id_; }
168 void set_ast_node_id(int value) { ast_node_id_ = value; } 166 void set_ast_node_id(int value) { ast_node_id_ = value; }
169 167
170 Debugger* debugger() const { return debugger_; } 168 Debugger* debugger() const { return debugger_; }
171 169
172 static void SetCreateCallback(Dart_IsolateCreateCallback cback); 170 static void SetCreateCallback(Dart_IsolateCreateCallback cback);
173 static Dart_IsolateCreateCallback CreateCallback(); 171 static Dart_IsolateCreateCallback CreateCallback();
174 172
175 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); 173 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 StubCode* stub_code_; 208 StubCode* stub_code_;
211 CodeIndexTable* code_index_table_; 209 CodeIndexTable* code_index_table_;
212 Debugger* debugger_; 210 Debugger* debugger_;
213 LongJump* long_jump_base_; 211 LongJump* long_jump_base_;
214 TimerList timer_list_; 212 TimerList timer_list_;
215 intptr_t ast_node_id_; 213 intptr_t ast_node_id_;
216 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. 214 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_.
217 uword stack_limit_; 215 uword stack_limit_;
218 uword saved_stack_limit_; 216 uword saved_stack_limit_;
219 MessageHandler* message_handler_; 217 MessageHandler* message_handler_;
218 uword spawn_data_;
220 GcPrologueCallbacks gc_prologue_callbacks_; 219 GcPrologueCallbacks gc_prologue_callbacks_;
221 GcEpilogueCallbacks gc_epilogue_callbacks_; 220 GcEpilogueCallbacks gc_epilogue_callbacks_;
222 221
223 static Dart_IsolateCreateCallback create_callback_; 222 static Dart_IsolateCreateCallback create_callback_;
224 static Dart_IsolateInterruptCallback interrupt_callback_; 223 static Dart_IsolateInterruptCallback interrupt_callback_;
225 224
226 DISALLOW_COPY_AND_ASSIGN(Isolate); 225 DISALLOW_COPY_AND_ASSIGN(Isolate);
227 }; 226 };
228 227
228 // When we are starting to execute code in a new isolate, we use the
229 // StartIsolateScope.
siva 2012/04/18 22:05:00 It is not necessarily a new isolate right, anytime
turnidge 2012/04/19 19:46:55 Done.
230 class StartIsolateScope {
231 public:
232 explicit StartIsolateScope(Isolate* new_isolate)
233 : saved_isolate_(Isolate::Current()) {
234 if (saved_isolate_ != new_isolate) {
235 ASSERT(Isolate::Current() == NULL);
236 Isolate::SetCurrent(new_isolate);
237 new_isolate->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(this));
238 }
239 }
240
241 ~StartIsolateScope() {
siva 2012/04/18 22:05:00 Should we set the stack limit of the isolate we ar
turnidge 2012/04/19 19:46:55 Done. Had to rework ShutdownIsolate a bit in lib/
242 Isolate::SetCurrent(saved_isolate_);
243 }
244
245 private:
246 Isolate* saved_isolate_;
247
248 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope);
249 };
250
251 // When we need to temporarily become another isolate, we use the
252 // SwitchIsolateScope. It is not permitted to run dart code while in
253 // a SwitchIsolateScope.
254 class SwitchIsolateScope {
255 public:
256 explicit SwitchIsolateScope(Isolate* new_isolate)
257 : saved_isolate_(Isolate::Current()) {
258 Isolate::SetCurrent(new_isolate);
259 if (new_isolate != NULL) {
260 // Don't allow dart code to execute.
261 new_isolate->SetStackLimit(~static_cast<uword>(0));
262 }
263 }
264
265 ~SwitchIsolateScope() {
266 Isolate::SetCurrent(saved_isolate_);
siva 2012/04/18 22:05:00 Shouldn't we be restoring the stack limit of new_i
turnidge 2012/04/19 19:46:55 Done.
267 }
268
269 private:
270 Isolate* saved_isolate_;
271
272 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope);
273 };
274
229 } // namespace dart 275 } // namespace dart
230 276
231 #endif // VM_ISOLATE_H_ 277 #endif // VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698