OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 }; | 213 }; |
214 | 214 |
215 // --- Handles --- | 215 // --- Handles --- |
216 | 216 |
217 #define TYPE_CHECK(T, S) \ | 217 #define TYPE_CHECK(T, S) \ |
218 while (false) { \ | 218 while (false) { \ |
219 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ | 219 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ |
220 } | 220 } |
221 | 221 |
222 | 222 |
| 223 #define V8_USE_UNSAFE_HANDLES |
| 224 |
223 /** | 225 /** |
224 * An object reference managed by the v8 garbage collector. | 226 * An object reference managed by the v8 garbage collector. |
225 * | 227 * |
226 * All objects returned from v8 have to be tracked by the garbage | 228 * All objects returned from v8 have to be tracked by the garbage |
227 * collector so that it knows that the objects are still alive. Also, | 229 * collector so that it knows that the objects are still alive. Also, |
228 * because the garbage collector may move objects, it is unsafe to | 230 * because the garbage collector may move objects, it is unsafe to |
229 * point directly to an object. Instead, all objects are stored in | 231 * point directly to an object. Instead, all objects are stored in |
230 * handles which are known by the garbage collector and updated | 232 * handles which are known by the garbage collector and updated |
231 * whenever an object moves. Handles should always be passed by value | 233 * whenever an object moves. Handles should always be passed by value |
232 * (except in cases like out-parameters) and they should never be | 234 * (except in cases like out-parameters) and they should never be |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 */ | 485 */ |
484 template <class T> class Persistent // NOLINT | 486 template <class T> class Persistent // NOLINT |
485 #ifdef V8_USE_UNSAFE_HANDLES | 487 #ifdef V8_USE_UNSAFE_HANDLES |
486 : public Handle<T> { | 488 : public Handle<T> { |
487 #else | 489 #else |
488 { // NOLINT | 490 { // NOLINT |
489 #endif | 491 #endif |
490 public: | 492 public: |
491 #ifndef V8_USE_UNSAFE_HANDLES | 493 #ifndef V8_USE_UNSAFE_HANDLES |
492 V8_INLINE(Persistent()) : val_(0) { } | 494 V8_INLINE(Persistent()) : val_(0) { } |
493 // TODO(dcarney): add this back before cutover. | 495 V8_INLINE(~Persistent()) { |
494 // V8_INLINE(~Persistent()) { | 496 // TODO(dcarney): add this back before cutover. |
495 // Dispose(); | 497 // Dispose(); |
496 // } | 498 } |
497 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } | 499 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } |
498 // TODO(dcarney): remove somehow before cutover | 500 // TODO(dcarney): remove somehow before cutover |
499 // The handle should either be 0, or a pointer to a live cell. | 501 // The handle should either be 0, or a pointer to a live cell. |
500 V8_INLINE(void Clear()) { val_ = 0; } | 502 V8_INLINE(void Clear()) { val_ = 0; } |
501 | 503 |
502 /** | 504 /** |
503 * A constructor that creates a new global cell pointing to that. In contrast | 505 * A constructor that creates a new global cell pointing to that. In contrast |
504 * to the copy constructor, this creates a new persistent handle which needs | 506 * to the copy constructor, this creates a new persistent handle which needs |
505 * to be separately disposed. | 507 * to be separately disposed. |
506 */ | 508 */ |
(...skipping 5858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6365 | 6367 |
6366 | 6368 |
6367 } // namespace v8 | 6369 } // namespace v8 |
6368 | 6370 |
6369 | 6371 |
6370 #undef V8EXPORT | 6372 #undef V8EXPORT |
6371 #undef TYPE_CHECK | 6373 #undef TYPE_CHECK |
6372 | 6374 |
6373 | 6375 |
6374 #endif // V8_H_ | 6376 #endif // V8_H_ |
OLD | NEW |