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

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.
165 RawError* StandardRunLoop();
166
167 intptr_t ast_node_id() const { return ast_node_id_; } 162 intptr_t ast_node_id() const { return ast_node_id_; }
168 void set_ast_node_id(int value) { ast_node_id_ = value; } 163 void set_ast_node_id(int value) { ast_node_id_ = value; }
169 164
170 Debugger* debugger() const { return debugger_; } 165 Debugger* debugger() const { return debugger_; }
171 166
172 static void SetCreateCallback(Dart_IsolateCreateCallback cback); 167 static void SetCreateCallback(Dart_IsolateCreateCallback cback);
173 static Dart_IsolateCreateCallback CreateCallback(); 168 static Dart_IsolateCreateCallback CreateCallback();
174 169
175 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); 170 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback);
176 static Dart_IsolateInterruptCallback InterruptCallback(); 171 static Dart_IsolateInterruptCallback InterruptCallback();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 MessageHandler* message_handler_; 214 MessageHandler* message_handler_;
220 GcPrologueCallbacks gc_prologue_callbacks_; 215 GcPrologueCallbacks gc_prologue_callbacks_;
221 GcEpilogueCallbacks gc_epilogue_callbacks_; 216 GcEpilogueCallbacks gc_epilogue_callbacks_;
222 217
223 static Dart_IsolateCreateCallback create_callback_; 218 static Dart_IsolateCreateCallback create_callback_;
224 static Dart_IsolateInterruptCallback interrupt_callback_; 219 static Dart_IsolateInterruptCallback interrupt_callback_;
225 220
226 DISALLOW_COPY_AND_ASSIGN(Isolate); 221 DISALLOW_COPY_AND_ASSIGN(Isolate);
227 }; 222 };
228 223
224 class SetIsolateScope {
siva 2012/04/14 00:29:53 In two out of the three places where this is used
turnidge 2012/04/17 23:46:55 Added a new StartIsolateScope for those cases.
225 public:
226 explicit SetIsolateScope(Isolate* new_isolate)
227 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) {
228 Isolate::SetCurrent(new_isolate);
229 if (new_isolate != NULL) {
230 new_isolate->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(this));
231 }
232 }
233
234 ~SetIsolateScope() {
235 ASSERT(Isolate::Current() == new_isolate_);
236 Isolate::SetCurrent(saved_isolate_);
237 }
238
239 private:
240 Isolate* new_isolate_;
241 Isolate* saved_isolate_;
242
243 DISALLOW_COPY_AND_ASSIGN(SetIsolateScope);
244 };
245
229 } // namespace dart 246 } // namespace dart
230 247
231 #endif // VM_ISOLATE_H_ 248 #endif // VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698