| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HANDLES_H_ | 5 #ifndef V8_HANDLES_H_ |
| 6 #define V8_HANDLES_H_ | 6 #define V8_HANDLES_H_ |
| 7 | 7 |
| 8 #include "src/objects.h" | 8 #include "src/objects.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 // TODO(yangguo): Values that contain empty handles should be declared as | 122 // TODO(yangguo): Values that contain empty handles should be declared as |
| 123 // MaybeHandle to force validation before being used as handles. | 123 // MaybeHandle to force validation before being used as handles. |
| 124 static Handle<T> null() { return Handle<T>(); } | 124 static Handle<T> null() { return Handle<T>(); } |
| 125 bool is_null() const { return location_ == NULL; } | 125 bool is_null() const { return location_ == NULL; } |
| 126 | 126 |
| 127 // Closes the given scope, but lets this handle escape. See | 127 // Closes the given scope, but lets this handle escape. See |
| 128 // implementation in api.h. | 128 // implementation in api.h. |
| 129 inline Handle<T> EscapeFrom(v8::EscapableHandleScope* scope); | 129 inline Handle<T> EscapeFrom(v8::EscapableHandleScope* scope); |
| 130 | 130 |
| 131 #ifdef DEBUG | 131 #ifdef ENABLE_SLOW_DCHECKS |
| 132 enum DereferenceCheckMode { INCLUDE_DEFERRED_CHECK, NO_DEFERRED_CHECK }; | 132 enum DereferenceCheckMode { INCLUDE_DEFERRED_CHECK, NO_DEFERRED_CHECK }; |
| 133 | 133 |
| 134 bool IsDereferenceAllowed(DereferenceCheckMode mode) const; | 134 bool IsDereferenceAllowed(DereferenceCheckMode mode) const; |
| 135 #endif // DEBUG | 135 #endif // ENABLE_SLOW_DCHECKS |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 T** location_; | 138 T** location_; |
| 139 | 139 |
| 140 // Handles of different classes are allowed to access each other's location_. | 140 // Handles of different classes are allowed to access each other's location_. |
| 141 template<class S> friend class Handle; | 141 template<class S> friend class Handle; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 | 144 |
| 145 // Convenience wrapper. | 145 // Convenience wrapper. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // since the creation of this DeferredHandleScope. The Handles are | 249 // since the creation of this DeferredHandleScope. The Handles are |
| 250 // alive as long as the DeferredHandles object is alive. | 250 // alive as long as the DeferredHandles object is alive. |
| 251 DeferredHandles* Detach(); | 251 DeferredHandles* Detach(); |
| 252 ~DeferredHandleScope(); | 252 ~DeferredHandleScope(); |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 Object** prev_limit_; | 255 Object** prev_limit_; |
| 256 Object** prev_next_; | 256 Object** prev_next_; |
| 257 HandleScopeImplementer* impl_; | 257 HandleScopeImplementer* impl_; |
| 258 | 258 |
| 259 #ifdef DEBUG | 259 #if DCHECK_IS_ON |
| 260 bool handles_detached_; | 260 bool handles_detached_; |
| 261 int prev_level_; | 261 int prev_level_; |
| 262 #endif | 262 #endif |
| 263 | 263 |
| 264 friend class HandleScopeImplementer; | 264 friend class HandleScopeImplementer; |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 | 267 |
| 268 // Seal off the current HandleScope so that new handles can only be created | 268 // Seal off the current HandleScope so that new handles can only be created |
| 269 // if a new HandleScope is entered. | 269 // if a new HandleScope is entered. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 289 | 289 |
| 290 void Initialize() { | 290 void Initialize() { |
| 291 next = limit = NULL; | 291 next = limit = NULL; |
| 292 level = 0; | 292 level = 0; |
| 293 } | 293 } |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 } } // namespace v8::internal | 296 } } // namespace v8::internal |
| 297 | 297 |
| 298 #endif // V8_HANDLES_H_ | 298 #endif // V8_HANDLES_H_ |
| OLD | NEW |