| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 static Handle<T> null() { return Handle<T>(); } | 80 static Handle<T> null() { return Handle<T>(); } |
| 81 bool is_null() const { return location_ == NULL; } | 81 bool is_null() const { return location_ == NULL; } |
| 82 | 82 |
| 83 // Closes the given scope, but lets this handle escape. See | 83 // Closes the given scope, but lets this handle escape. See |
| 84 // implementation in api.h. | 84 // implementation in api.h. |
| 85 inline Handle<T> EscapeFrom(v8::HandleScope* scope); | 85 inline Handle<T> EscapeFrom(v8::HandleScope* scope); |
| 86 | 86 |
| 87 #ifdef DEBUG | 87 #ifdef DEBUG |
| 88 bool IsDereferenceAllowed(bool allow_deferred) const; | 88 bool IsDereferenceAllowed(bool explicitly_allow_deferred) const; |
| 89 #endif // DEBUG | 89 #endif // DEBUG |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 T** location_; | 92 T** location_; |
| 93 | 93 |
| 94 // Handles of different classes are allowed to access each other's location_. | 94 // Handles of different classes are allowed to access each other's location_. |
| 95 template<class S> friend class Handle; | 95 template<class S> friend class Handle; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 | 98 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table, | 323 Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table, |
| 324 Handle<Object> key); | 324 Handle<Object> key); |
| 325 | 325 |
| 326 Handle<ObjectHashSet> ObjectHashSetRemove(Handle<ObjectHashSet> table, | 326 Handle<ObjectHashSet> ObjectHashSetRemove(Handle<ObjectHashSet> table, |
| 327 Handle<Object> key); | 327 Handle<Object> key); |
| 328 | 328 |
| 329 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, | 329 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, |
| 330 Handle<Object> key, | 330 Handle<Object> key, |
| 331 Handle<Object> value); | 331 Handle<Object> value); |
| 332 | 332 |
| 333 class NoHandleAllocation BASE_EMBEDDED { | 333 |
| 334 // Seal off the current HandleScope so that new handles can only be created |
| 335 // if a new HandleScope is entered. |
| 336 class SealHandleScope BASE_EMBEDDED { |
| 334 public: | 337 public: |
| 335 #ifndef DEBUG | 338 #ifndef DEBUG |
| 336 explicit NoHandleAllocation(Isolate* isolate) {} | 339 explicit SealHandleScope(Isolate* isolate) {} |
| 337 ~NoHandleAllocation() {} | 340 ~SealHandleScope() {} |
| 338 #else | 341 #else |
| 339 explicit inline NoHandleAllocation(Isolate* isolate); | 342 explicit inline SealHandleScope(Isolate* isolate); |
| 340 inline ~NoHandleAllocation(); | 343 inline ~SealHandleScope(); |
| 341 private: | 344 private: |
| 342 Isolate* isolate_; | 345 Isolate* isolate_; |
| 343 Object** limit_; | 346 Object** limit_; |
| 344 int level_; | 347 int level_; |
| 345 bool active_; | 348 bool active_; |
| 346 #endif | 349 #endif |
| 347 }; | 350 }; |
| 348 | 351 |
| 349 | |
| 350 class HandleDereferenceGuard BASE_EMBEDDED { | |
| 351 public: | |
| 352 enum State { ALLOW, DISALLOW, DISALLOW_DEFERRED }; | |
| 353 #ifndef DEBUG | |
| 354 HandleDereferenceGuard(Isolate* isolate, State state) { } | |
| 355 ~HandleDereferenceGuard() { } | |
| 356 #else | |
| 357 inline HandleDereferenceGuard(Isolate* isolate, State state); | |
| 358 inline ~HandleDereferenceGuard(); | |
| 359 private: | |
| 360 Isolate* isolate_; | |
| 361 State old_state_; | |
| 362 #endif | |
| 363 }; | |
| 364 | |
| 365 #ifdef DEBUG | |
| 366 #define ALLOW_HANDLE_DEREF(isolate, why_this_is_safe) \ | |
| 367 HandleDereferenceGuard allow_deref(isolate, \ | |
| 368 HandleDereferenceGuard::ALLOW); | |
| 369 #else | |
| 370 #define ALLOW_HANDLE_DEREF(isolate, why_this_is_safe) | |
| 371 #endif // DEBUG | |
| 372 | |
| 373 } } // namespace v8::internal | 352 } } // namespace v8::internal |
| 374 | 353 |
| 375 #endif // V8_HANDLES_H_ | 354 #endif // V8_HANDLES_H_ |
| OLD | NEW |