OLD | NEW |
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_BASE_ISOLATE_H_ | 5 #ifndef VM_BASE_ISOLATE_H_ |
6 #define VM_BASE_ISOLATE_H_ | 6 #define VM_BASE_ISOLATE_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class HandleScope; | 13 class HandleScope; |
14 class StackResource; | 14 class StackResource; |
15 class Thread; | 15 class Thread; |
16 class Zone; | 16 class Zone; |
17 | 17 |
18 // A BaseIsolate contains just enough functionality to allocate | 18 // A BaseIsolate contains just enough functionality to allocate |
19 // StackResources. This allows us to inline the StackResource | 19 // StackResources. This allows us to inline the StackResource |
20 // constructor/destructor for performance. | 20 // constructor/destructor for performance. |
21 class BaseIsolate { | 21 class BaseIsolate { |
22 public: | 22 public: |
23 #if defined(DEBUG) | 23 #if defined(DEBUG) |
24 void AssertCurrentThreadIsMutator() const; | 24 void AssertCurrentThreadIsMutator() const; |
25 #else | 25 #else |
26 void AssertCurrentThreadIsMutator() const {} | 26 void AssertCurrentThreadIsMutator() const {} |
27 #endif // DEBUG | 27 #endif // DEBUG |
28 | 28 |
29 int32_t no_callback_scope_depth() const { | |
30 return no_callback_scope_depth_; | |
31 } | |
32 | |
33 void IncrementNoCallbackScopeDepth() { | |
34 ASSERT(no_callback_scope_depth_ < INT_MAX); | |
35 no_callback_scope_depth_ += 1; | |
36 } | |
37 | |
38 void DecrementNoCallbackScopeDepth() { | |
39 ASSERT(no_callback_scope_depth_ > 0); | |
40 no_callback_scope_depth_ -= 1; | |
41 } | |
42 | |
43 #if defined(DEBUG) | 29 #if defined(DEBUG) |
44 static void AssertCurrent(BaseIsolate* isolate); | 30 static void AssertCurrent(BaseIsolate* isolate); |
45 #endif | 31 #endif |
46 | 32 |
47 protected: | 33 protected: |
48 BaseIsolate() | 34 BaseIsolate() |
49 : mutator_thread_(NULL), | 35 : mutator_thread_(NULL) { |
50 no_callback_scope_depth_(0) { | |
51 } | 36 } |
52 | 37 |
53 ~BaseIsolate() { | 38 ~BaseIsolate() { |
54 // Do not delete stack resources: top_resource_ and current_zone_. | 39 // Do not delete stack resources: top_resource_ and current_zone_. |
55 } | 40 } |
56 | 41 |
57 Thread* mutator_thread_; | 42 Thread* mutator_thread_; |
58 int32_t no_callback_scope_depth_; | |
59 | 43 |
60 private: | 44 private: |
61 // During migration, some deprecated interfaces will default to using the | 45 // During migration, some deprecated interfaces will default to using the |
62 // mutator_thread_ (can't use accessor in Isolate due to circular deps). | 46 // mutator_thread_ (can't use accessor in Isolate due to circular deps). |
63 friend class StackResource; | 47 friend class StackResource; |
64 DISALLOW_COPY_AND_ASSIGN(BaseIsolate); | 48 DISALLOW_COPY_AND_ASSIGN(BaseIsolate); |
65 }; | 49 }; |
66 | 50 |
67 } // namespace dart | 51 } // namespace dart |
68 | 52 |
69 #endif // VM_BASE_ISOLATE_H_ | 53 #endif // VM_BASE_ISOLATE_H_ |
OLD | NEW |