| 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_safepoint_scope_depth() const { |  | 
| 30 #if defined(DEBUG) |  | 
| 31     return no_safepoint_scope_depth_; |  | 
| 32 #else |  | 
| 33     return 0; |  | 
| 34 #endif |  | 
| 35   } |  | 
| 36 |  | 
| 37   void IncrementNoSafepointScopeDepth() { |  | 
| 38 #if defined(DEBUG) |  | 
| 39     ASSERT(no_safepoint_scope_depth_ < INT_MAX); |  | 
| 40     no_safepoint_scope_depth_ += 1; |  | 
| 41 #endif |  | 
| 42   } |  | 
| 43 |  | 
| 44   void DecrementNoSafepointScopeDepth() { |  | 
| 45 #if defined(DEBUG) |  | 
| 46     ASSERT(no_safepoint_scope_depth_ > 0); |  | 
| 47     no_safepoint_scope_depth_ -= 1; |  | 
| 48 #endif |  | 
| 49   } |  | 
| 50 |  | 
| 51   int32_t no_callback_scope_depth() const { | 29   int32_t no_callback_scope_depth() const { | 
| 52     return no_callback_scope_depth_; | 30     return no_callback_scope_depth_; | 
| 53   } | 31   } | 
| 54 | 32 | 
| 55   void IncrementNoCallbackScopeDepth() { | 33   void IncrementNoCallbackScopeDepth() { | 
| 56     ASSERT(no_callback_scope_depth_ < INT_MAX); | 34     ASSERT(no_callback_scope_depth_ < INT_MAX); | 
| 57     no_callback_scope_depth_ += 1; | 35     no_callback_scope_depth_ += 1; | 
| 58   } | 36   } | 
| 59 | 37 | 
| 60   void DecrementNoCallbackScopeDepth() { | 38   void DecrementNoCallbackScopeDepth() { | 
| 61     ASSERT(no_callback_scope_depth_ > 0); | 39     ASSERT(no_callback_scope_depth_ > 0); | 
| 62     no_callback_scope_depth_ -= 1; | 40     no_callback_scope_depth_ -= 1; | 
| 63   } | 41   } | 
| 64 | 42 | 
| 65 #if defined(DEBUG) | 43 #if defined(DEBUG) | 
| 66   static void AssertCurrent(BaseIsolate* isolate); | 44   static void AssertCurrent(BaseIsolate* isolate); | 
| 67 #endif | 45 #endif | 
| 68 | 46 | 
| 69  protected: | 47  protected: | 
| 70   BaseIsolate() | 48   BaseIsolate() | 
| 71       : mutator_thread_(NULL), | 49       : mutator_thread_(NULL), | 
| 72 #if defined(DEBUG) | 50         no_callback_scope_depth_(0) { | 
| 73         no_safepoint_scope_depth_(0), | 51   } | 
| 74 #endif |  | 
| 75         no_callback_scope_depth_(0) |  | 
| 76   {} |  | 
| 77 | 52 | 
| 78   ~BaseIsolate() { | 53   ~BaseIsolate() { | 
| 79     // Do not delete stack resources: top_resource_ and current_zone_. | 54     // Do not delete stack resources: top_resource_ and current_zone_. | 
| 80   } | 55   } | 
| 81 | 56 | 
| 82   Thread* mutator_thread_; | 57   Thread* mutator_thread_; | 
| 83 #if defined(DEBUG) |  | 
| 84   int32_t no_safepoint_scope_depth_; |  | 
| 85 #endif |  | 
| 86   int32_t no_callback_scope_depth_; | 58   int32_t no_callback_scope_depth_; | 
| 87 | 59 | 
| 88  private: | 60  private: | 
| 89   // During migration, some deprecated interfaces will default to using the | 61   // During migration, some deprecated interfaces will default to using the | 
| 90   // mutator_thread_ (can't use accessor in Isolate due to circular deps). | 62   // mutator_thread_ (can't use accessor in Isolate due to circular deps). | 
| 91   friend class StackResource; | 63   friend class StackResource; | 
| 92   DISALLOW_COPY_AND_ASSIGN(BaseIsolate); | 64   DISALLOW_COPY_AND_ASSIGN(BaseIsolate); | 
| 93 }; | 65 }; | 
| 94 | 66 | 
| 95 }  // namespace dart | 67 }  // namespace dart | 
| 96 | 68 | 
| 97 #endif  // VM_BASE_ISOLATE_H_ | 69 #endif  // VM_BASE_ISOLATE_H_ | 
| OLD | NEW | 
|---|