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

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 14 matching lines...) Expand all
25 class MessageHandler; 25 class MessageHandler;
26 class Mutex; 26 class Mutex;
27 class ObjectPointerVisitor; 27 class ObjectPointerVisitor;
28 class ObjectStore; 28 class ObjectStore;
29 class RawContext; 29 class RawContext;
30 class RawError; 30 class RawError;
31 class StackResource; 31 class StackResource;
32 class StubCode; 32 class StubCode;
33 class Zone; 33 class Zone;
34 34
35
36 class Isolate { 35 class Isolate {
37 public: 36 public:
38 ~Isolate(); 37 ~Isolate();
39 38
40 static inline Isolate* Current() { 39 static inline Isolate* Current() {
41 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); 40 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key));
42 } 41 }
43 42
44 static void SetCurrent(Isolate* isolate); 43 static void SetCurrent(Isolate* isolate);
45 44
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); 198 void SetStackLimitFromCurrentTOS(uword isolate_stack_top);
200 199
201 uword stack_limit_address() const { 200 uword stack_limit_address() const {
202 return reinterpret_cast<uword>(&stack_limit_); 201 return reinterpret_cast<uword>(&stack_limit_);
203 } 202 }
204 203
205 // The current stack limit. This may be overwritten with a special 204 // The current stack limit. This may be overwritten with a special
206 // value to trigger interrupts. 205 // value to trigger interrupts.
207 uword stack_limit() const { return stack_limit_; } 206 uword stack_limit() const { return stack_limit_; }
208 207
209 // The true stack limit for this isolate. This does not change 208 // The true stack limit for this isolate.
210 // after isolate initialization.
211 uword saved_stack_limit() const { return saved_stack_limit_; } 209 uword saved_stack_limit() const { return saved_stack_limit_; }
212 210
213 enum { 211 enum {
214 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. 212 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate.
215 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. 213 kMessageInterrupt = 0x2, // An interrupt to process an out of band message.
216 214
217 kInterruptsMask = kApiInterrupt | kMessageInterrupt, 215 kInterruptsMask = kApiInterrupt | kMessageInterrupt,
218 }; 216 };
219 217
220 void ScheduleInterrupts(uword interrupt_bits); 218 void ScheduleInterrupts(uword interrupt_bits);
221 uword GetAndClearInterrupts(); 219 uword GetAndClearInterrupts();
222 220
223 MessageHandler* message_handler() const { return message_handler_; } 221 MessageHandler* message_handler() const { return message_handler_; }
224 void set_message_handler(MessageHandler* value) { message_handler_ = value; } 222 void set_message_handler(MessageHandler* value) { message_handler_ = value; }
225 223
226 // Returns null on success, a RawError on failure.
227 RawError* StandardRunLoop();
228
229 intptr_t ast_node_id() const { return ast_node_id_; } 224 intptr_t ast_node_id() const { return ast_node_id_; }
230 void set_ast_node_id(int value) { ast_node_id_ = value; } 225 void set_ast_node_id(int value) { ast_node_id_ = value; }
231 226
232 Debugger* debugger() const { return debugger_; } 227 Debugger* debugger() const { return debugger_; }
233 228
234 static void SetCreateCallback(Dart_IsolateCreateCallback cback); 229 static void SetCreateCallback(Dart_IsolateCreateCallback cback);
235 static Dart_IsolateCreateCallback CreateCallback(); 230 static Dart_IsolateCreateCallback CreateCallback();
236 231
237 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); 232 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback);
238 static Dart_IsolateInterruptCallback InterruptCallback(); 233 static Dart_IsolateInterruptCallback InterruptCallback();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 MessageHandler* message_handler_; 283 MessageHandler* message_handler_;
289 GcPrologueCallbacks gc_prologue_callbacks_; 284 GcPrologueCallbacks gc_prologue_callbacks_;
290 GcEpilogueCallbacks gc_epilogue_callbacks_; 285 GcEpilogueCallbacks gc_epilogue_callbacks_;
291 286
292 static Dart_IsolateCreateCallback create_callback_; 287 static Dart_IsolateCreateCallback create_callback_;
293 static Dart_IsolateInterruptCallback interrupt_callback_; 288 static Dart_IsolateInterruptCallback interrupt_callback_;
294 289
295 DISALLOW_COPY_AND_ASSIGN(Isolate); 290 DISALLOW_COPY_AND_ASSIGN(Isolate);
296 }; 291 };
297 292
293 class SetIsolateScope {
294 public:
295 explicit SetIsolateScope(Isolate* new_isolate)
296 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) {
297 Isolate::SetCurrent(new_isolate);
298 if (new_isolate) {
Ivan Posva 2012/04/08 22:58:27 if (new_isolate != NULL) {
turnidge 2012/04/11 19:37:16 Done.
299 new_isolate->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(this));
300 }
301 }
302
303 ~SetIsolateScope() {
304 ASSERT(Isolate::Current() == new_isolate_);
305 Isolate::SetCurrent(saved_isolate_);
306 }
307
308 private:
309 Isolate* new_isolate_;
310 Isolate* saved_isolate_;
311
312 DISALLOW_COPY_AND_ASSIGN(SetIsolateScope);
313 };
314
298 } // namespace dart 315 } // namespace dart
299 316
300 #endif // VM_ISOLATE_H_ 317 #endif // VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698