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

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

Issue 8851008: Add support for interrupting an isolate in the vm. Interrupts are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 <limits.h> 8 #include <limits.h>
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
11 #include "vm/assert.h" 11 #include "vm/assert.h"
12 #include "vm/store_buffer.h" 12 #include "vm/store_buffer.h"
13 #include "vm/timer.h" 13 #include "vm/timer.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 // Forward declarations. 17 // Forward declarations.
18 class ApiState; 18 class ApiState;
19 class BigintStore; 19 class BigintStore;
20 class CodeIndexTable; 20 class CodeIndexTable;
21 class Debugger; 21 class Debugger;
22 class HandleScope; 22 class HandleScope;
23 class Heap; 23 class Heap;
24 class LongJump; 24 class LongJump;
25 class MessageQueue; 25 class MessageQueue;
26 class Monitor; 26 class Mutex;
27 class ObjectPointerVisitor; 27 class ObjectPointerVisitor;
28 class ObjectStore; 28 class ObjectStore;
29 class RawContext; 29 class RawContext;
30 class RawObject; 30 class RawObject;
31 class StackResource; 31 class StackResource;
32 class StubCode; 32 class StubCode;
33 class Zone; 33 class Zone;
34 34
35 class Isolate { 35 class Isolate {
36 public: 36 public:
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return init_callback_data_; 212 return init_callback_data_;
213 } 213 }
214 214
215 Dart_LibraryTagHandler library_tag_handler() const { 215 Dart_LibraryTagHandler library_tag_handler() const {
216 return library_tag_handler_; 216 return library_tag_handler_;
217 } 217 }
218 void set_library_tag_handler(Dart_LibraryTagHandler value) { 218 void set_library_tag_handler(Dart_LibraryTagHandler value) {
219 library_tag_handler_ = value; 219 library_tag_handler_ = value;
220 } 220 }
221 221
222 static void SetCreateCallback(Dart_IsolateCreateCallback cback); 222 void SetStackLimit(uword value);
223 static Dart_IsolateCreateCallback CreateCallback(); 223 void SetStackLimitFromCurrentTOS(uword isolate_stack_top);
224 224
225 uword stack_limit_address() const { 225 uword stack_limit_address() const {
226 return reinterpret_cast<uword>(&stack_limit_); 226 return reinterpret_cast<uword>(&stack_limit_);
227 } 227 }
228 228
229 void SetStackLimit(uword value); 229 // The current stack limit. This may be overwritten with a special
230 // value to trigger interrupts.
230 uword stack_limit() const { return stack_limit_; } 231 uword stack_limit() const { return stack_limit_; }
231 232
232 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); 233 // The true stack limit for this isolate. This does not change
234 // after isolate initialization.
235 uword saved_stack_limit() const { return saved_stack_limit_; }
236
237 enum {
238 kInterruptsMask = 0x1,
239 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate.
240 // More interrupt types will go here.
241 };
242
243 void ScheduleInterrupts(uword interrupt_bits);
244 uword GetAndClearInterrupts();
233 245
234 // Returns null on success, unhandled exception on failure. 246 // Returns null on success, unhandled exception on failure.
235 RawObject* StandardRunLoop(); 247 RawObject* StandardRunLoop();
236 248
237 intptr_t ast_node_id() const { return ast_node_id_; } 249 intptr_t ast_node_id() const { return ast_node_id_; }
238 void set_ast_node_id(int value) { ast_node_id_ = value; } 250 void set_ast_node_id(int value) { ast_node_id_ = value; }
239 251
240 Debugger* debugger() const { return debugger_; } 252 Debugger* debugger() const { return debugger_; }
241 253
254 static void SetCreateCallback(Dart_IsolateCreateCallback cback);
255 static Dart_IsolateCreateCallback CreateCallback();
256
257 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback);
258 static Dart_IsolateInterruptCallback InterruptCallback();
259
242 private: 260 private:
243 Isolate(); 261 Isolate();
244 262
245 void PrintInvokedFunctions(); 263 void PrintInvokedFunctions();
246 264
247 static uword GetSpecifiedStackSize(); 265 static uword GetSpecifiedStackSize();
248 266
249 static const uword kStackSizeBuffer = (128 * KB); 267 static const uword kStackSizeBuffer = (128 * KB);
250 static const uword kDefaultStackSize = (1 * MB); 268 static const uword kDefaultStackSize = (1 * MB);
251 269
252 StoreBufferBlock store_buffer_; 270 StoreBufferBlock store_buffer_;
253 Monitor* monitor_;
254 MessageQueue* message_queue_; 271 MessageQueue* message_queue_;
255 Dart_PostMessageCallback post_message_callback_; 272 Dart_PostMessageCallback post_message_callback_;
256 Dart_ClosePortCallback close_port_callback_; 273 Dart_ClosePortCallback close_port_callback_;
257 intptr_t num_ports_; 274 intptr_t num_ports_;
258 intptr_t live_ports_; 275 intptr_t live_ports_;
259 Dart_Port main_port_; 276 Dart_Port main_port_;
260 Heap* heap_; 277 Heap* heap_;
261 ObjectStore* object_store_; 278 ObjectStore* object_store_;
262 StackResource* top_resource_; 279 StackResource* top_resource_;
263 RawContext* top_context_; 280 RawContext* top_context_;
264 Zone* current_zone_; 281 Zone* current_zone_;
265 #if defined(DEBUG) 282 #if defined(DEBUG)
266 int32_t no_gc_scope_depth_; 283 int32_t no_gc_scope_depth_;
267 int32_t no_handle_scope_depth_; 284 int32_t no_handle_scope_depth_;
268 HandleScope* top_handle_scope_; 285 HandleScope* top_handle_scope_;
269 #endif 286 #endif
270 int32_t random_seed_; 287 int32_t random_seed_;
271 BigintStore* bigint_store_; 288 BigintStore* bigint_store_;
272 uword top_exit_frame_info_; 289 uword top_exit_frame_info_;
273 void* init_callback_data_; 290 void* init_callback_data_;
274 Dart_LibraryTagHandler library_tag_handler_; 291 Dart_LibraryTagHandler library_tag_handler_;
275 ApiState* api_state_; 292 ApiState* api_state_;
276 StubCode* stub_code_; 293 StubCode* stub_code_;
277 CodeIndexTable* code_index_table_; 294 CodeIndexTable* code_index_table_;
278 Debugger* debugger_; 295 Debugger* debugger_;
279 LongJump* long_jump_base_; 296 LongJump* long_jump_base_;
280 TimerList timer_list_; 297 TimerList timer_list_;
298 intptr_t ast_node_id_;
299 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_.
281 uword stack_limit_; 300 uword stack_limit_;
282 intptr_t ast_node_id_; 301 uword saved_stack_limit_;
283 302
284 static Dart_IsolateCreateCallback create_callback_; 303 static Dart_IsolateCreateCallback create_callback_;
304 static Dart_IsolateInterruptCallback interrupt_callback_;
285 305
286 DISALLOW_COPY_AND_ASSIGN(Isolate); 306 DISALLOW_COPY_AND_ASSIGN(Isolate);
287 }; 307 };
288 308
289 } // namespace dart 309 } // namespace dart
290 310
291 #if defined(TARGET_OS_LINUX) 311 #if defined(TARGET_OS_LINUX)
292 #include "vm/isolate_linux.h" 312 #include "vm/isolate_linux.h"
293 #elif defined(TARGET_OS_MACOS) 313 #elif defined(TARGET_OS_MACOS)
294 #include "vm/isolate_macos.h" 314 #include "vm/isolate_macos.h"
295 #elif defined(TARGET_OS_WINDOWS) 315 #elif defined(TARGET_OS_WINDOWS)
296 #include "vm/isolate_win.h" 316 #include "vm/isolate_win.h"
297 #else 317 #else
298 #error Unknown target os. 318 #error Unknown target os.
299 #endif 319 #endif
300 320
301 #endif // VM_ISOLATE_H_ 321 #endif // VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698