OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 template<typename P> | 509 template<typename P> |
510 V8_INLINE void SetWeak( | 510 V8_INLINE void SetWeak( |
511 P* parameter, | 511 P* parameter, |
512 typename WeakCallbackData<T, P>::Callback callback); | 512 typename WeakCallbackData<T, P>::Callback callback); |
513 | 513 |
514 template<typename S, typename P> | 514 template<typename S, typename P> |
515 V8_INLINE void SetWeak( | 515 V8_INLINE void SetWeak( |
516 P* parameter, | 516 P* parameter, |
517 typename WeakCallbackData<S, P>::Callback callback); | 517 typename WeakCallbackData<S, P>::Callback callback); |
518 | 518 |
| 519 // Phantom persistents work like weak persistents, except that the pointer to |
| 520 // the object being collected is not available in the finalization callback. |
| 521 // This enables the garbage collector to collect the object and any objects |
| 522 // it references transitively in one GC cycle. |
| 523 template <typename P> |
| 524 V8_INLINE void SetPhantom(P* parameter, |
| 525 typename WeakCallbackData<T, P>::Callback callback); |
| 526 |
| 527 template <typename S, typename P> |
| 528 V8_INLINE void SetPhantom(P* parameter, |
| 529 typename WeakCallbackData<S, P>::Callback callback); |
| 530 |
519 template<typename P> | 531 template<typename P> |
520 V8_INLINE P* ClearWeak(); | 532 V8_INLINE P* ClearWeak(); |
521 | 533 |
522 // TODO(dcarney): remove this. | 534 // TODO(dcarney): remove this. |
523 V8_INLINE void ClearWeak() { ClearWeak<void>(); } | 535 V8_INLINE void ClearWeak() { ClearWeak<void>(); } |
524 | 536 |
525 /** | 537 /** |
526 * Marks the reference to this object independent. Garbage collector is free | 538 * Marks the reference to this object independent. Garbage collector is free |
527 * to ignore any object groups containing this object. Weak callback for an | 539 * to ignore any object groups containing this object. Weak callback for an |
528 * independent handle should not assume that it will be preceded by a global | 540 * independent handle should not assume that it will be preceded by a global |
(...skipping 4941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5470 | 5482 |
5471 /** | 5483 /** |
5472 * Clears all references to the v8::Platform. This should be invoked after | 5484 * Clears all references to the v8::Platform. This should be invoked after |
5473 * V8 was disposed. | 5485 * V8 was disposed. |
5474 */ | 5486 */ |
5475 static void ShutdownPlatform(); | 5487 static void ShutdownPlatform(); |
5476 | 5488 |
5477 private: | 5489 private: |
5478 V8(); | 5490 V8(); |
5479 | 5491 |
| 5492 enum WeakHandleType { PhantomHandle, NonphantomHandle }; |
| 5493 |
5480 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 5494 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
5481 internal::Object** handle); | 5495 internal::Object** handle); |
5482 static internal::Object** CopyPersistent(internal::Object** handle); | 5496 static internal::Object** CopyPersistent(internal::Object** handle); |
5483 static void DisposeGlobal(internal::Object** global_handle); | 5497 static void DisposeGlobal(internal::Object** global_handle); |
5484 typedef WeakCallbackData<Value, void>::Callback WeakCallback; | 5498 typedef WeakCallbackData<Value, void>::Callback WeakCallback; |
5485 static void MakeWeak(internal::Object** global_handle, | 5499 static void MakeWeak(internal::Object** global_handle, void* data, |
5486 void* data, | 5500 WeakCallback weak_callback, WeakHandleType phantom); |
5487 WeakCallback weak_callback); | |
5488 static void* ClearWeak(internal::Object** global_handle); | 5501 static void* ClearWeak(internal::Object** global_handle); |
5489 static void Eternalize(Isolate* isolate, | 5502 static void Eternalize(Isolate* isolate, |
5490 Value* handle, | 5503 Value* handle, |
5491 int* index); | 5504 int* index); |
5492 static Local<Value> GetEternal(Isolate* isolate, int index); | 5505 static Local<Value> GetEternal(Isolate* isolate, int index); |
5493 | 5506 |
5494 template <class T> friend class Handle; | 5507 template <class T> friend class Handle; |
5495 template <class T> friend class Local; | 5508 template <class T> friend class Local; |
5496 template <class T> friend class Eternal; | 5509 template <class T> friend class Eternal; |
5497 template <class T> friend class PersistentBase; | 5510 template <class T> friend class PersistentBase; |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6348 } | 6361 } |
6349 | 6362 |
6350 | 6363 |
6351 template <class T> | 6364 template <class T> |
6352 template <typename S, typename P> | 6365 template <typename S, typename P> |
6353 void PersistentBase<T>::SetWeak( | 6366 void PersistentBase<T>::SetWeak( |
6354 P* parameter, | 6367 P* parameter, |
6355 typename WeakCallbackData<S, P>::Callback callback) { | 6368 typename WeakCallbackData<S, P>::Callback callback) { |
6356 TYPE_CHECK(S, T); | 6369 TYPE_CHECK(S, T); |
6357 typedef typename WeakCallbackData<Value, void>::Callback Callback; | 6370 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
6358 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | 6371 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, |
6359 parameter, | 6372 reinterpret_cast<Callback>(callback), V8::NonphantomHandle); |
6360 reinterpret_cast<Callback>(callback)); | |
6361 } | 6373 } |
6362 | 6374 |
6363 | 6375 |
6364 template <class T> | 6376 template <class T> |
6365 template <typename P> | 6377 template <typename P> |
6366 void PersistentBase<T>::SetWeak( | 6378 void PersistentBase<T>::SetWeak( |
6367 P* parameter, | 6379 P* parameter, |
6368 typename WeakCallbackData<T, P>::Callback callback) { | 6380 typename WeakCallbackData<T, P>::Callback callback) { |
6369 SetWeak<T, P>(parameter, callback); | 6381 SetWeak<T, P>(parameter, callback); |
6370 } | 6382 } |
6371 | 6383 |
6372 | 6384 |
6373 template <class T> | 6385 template <class T> |
6374 template<typename P> | 6386 template <typename S, typename P> |
| 6387 void PersistentBase<T>::SetPhantom( |
| 6388 P* parameter, typename WeakCallbackData<S, P>::Callback callback) { |
| 6389 TYPE_CHECK(S, T); |
| 6390 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
| 6391 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, |
| 6392 reinterpret_cast<Callback>(callback), V8::PhantomHandle); |
| 6393 } |
| 6394 |
| 6395 |
| 6396 template <class T> |
| 6397 template <typename P> |
| 6398 void PersistentBase<T>::SetPhantom( |
| 6399 P* parameter, typename WeakCallbackData<T, P>::Callback callback) { |
| 6400 SetPhantom<T, P>(parameter, callback); |
| 6401 } |
| 6402 |
| 6403 |
| 6404 template <class T> |
| 6405 template <typename P> |
6375 P* PersistentBase<T>::ClearWeak() { | 6406 P* PersistentBase<T>::ClearWeak() { |
6376 return reinterpret_cast<P*>( | 6407 return reinterpret_cast<P*>( |
6377 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); | 6408 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); |
6378 } | 6409 } |
6379 | 6410 |
6380 | 6411 |
6381 template <class T> | 6412 template <class T> |
6382 void PersistentBase<T>::MarkIndependent() { | 6413 void PersistentBase<T>::MarkIndependent() { |
6383 typedef internal::Internals I; | 6414 typedef internal::Internals I; |
6384 if (this->IsEmpty()) return; | 6415 if (this->IsEmpty()) return; |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7356 */ | 7387 */ |
7357 | 7388 |
7358 | 7389 |
7359 } // namespace v8 | 7390 } // namespace v8 |
7360 | 7391 |
7361 | 7392 |
7362 #undef TYPE_CHECK | 7393 #undef TYPE_CHECK |
7363 | 7394 |
7364 | 7395 |
7365 #endif // V8_H_ | 7396 #endif // V8_H_ |
OLD | NEW |