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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 * NOTE: There is no guarantee as to *when* or even *if* the callback is | 538 * NOTE: There is no guarantee as to *when* or even *if* the callback is |
539 * invoked. The invocation is performed solely on a best effort basis. | 539 * invoked. The invocation is performed solely on a best effort basis. |
540 * As always, GC-based finalization should *not* be relied upon for any | 540 * As always, GC-based finalization should *not* be relied upon for any |
541 * critical form of resource management! | 541 * critical form of resource management! |
542 */ | 542 */ |
543 template <typename P> | 543 template <typename P> |
544 V8_INLINE void SetWeak(P* parameter, | 544 V8_INLINE void SetWeak(P* parameter, |
545 typename WeakCallbackInfo<P>::Callback callback, | 545 typename WeakCallbackInfo<P>::Callback callback, |
546 WeakCallbackType type); | 546 WeakCallbackType type); |
547 | 547 |
| 548 /** |
| 549 * Turns this handle into a weak phantom handle without finalization callback. |
| 550 * The handle will be reset automatically when the garbage collector detects |
| 551 * that the object is no longer reachable. |
| 552 * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall |
| 553 * returns how many phantom handles were reset by the garbage collector. |
| 554 */ |
| 555 V8_INLINE void SetWeak(); |
| 556 |
548 template<typename P> | 557 template<typename P> |
549 V8_INLINE P* ClearWeak(); | 558 V8_INLINE P* ClearWeak(); |
550 | 559 |
551 // TODO(dcarney): remove this. | 560 // TODO(dcarney): remove this. |
552 V8_INLINE void ClearWeak() { ClearWeak<void>(); } | 561 V8_INLINE void ClearWeak() { ClearWeak<void>(); } |
553 | 562 |
554 /** | 563 /** |
555 * Allows the embedder to tell the v8 garbage collector that a certain object | 564 * Allows the embedder to tell the v8 garbage collector that a certain object |
556 * is alive. Only allowed when the embedder is asked to trace its heap by | 565 * is alive. Only allowed when the embedder is asked to trace its heap by |
557 * EmbedderHeapTracer. | 566 * EmbedderHeapTracer. |
(...skipping 5219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5777 * allocated memory alive. | 5786 * allocated memory alive. |
5778 * | 5787 * |
5779 * \param change_in_bytes the change in externally allocated memory that is | 5788 * \param change_in_bytes the change in externally allocated memory that is |
5780 * kept alive by JavaScript objects. | 5789 * kept alive by JavaScript objects. |
5781 * \returns the adjusted value. | 5790 * \returns the adjusted value. |
5782 */ | 5791 */ |
5783 V8_INLINE int64_t | 5792 V8_INLINE int64_t |
5784 AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes); | 5793 AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes); |
5785 | 5794 |
5786 /** | 5795 /** |
| 5796 * Returns the number of phantom handles without callbacks that were reset |
| 5797 * by the garbage collector since the last call to this function. |
| 5798 */ |
| 5799 size_t NumberOfPhantomHandleResetsSinceLastCall(); |
| 5800 |
| 5801 /** |
5787 * Returns heap profiler for this isolate. Will return NULL until the isolate | 5802 * Returns heap profiler for this isolate. Will return NULL until the isolate |
5788 * is initialized. | 5803 * is initialized. |
5789 */ | 5804 */ |
5790 HeapProfiler* GetHeapProfiler(); | 5805 HeapProfiler* GetHeapProfiler(); |
5791 | 5806 |
5792 /** | 5807 /** |
5793 * Returns CPU profiler for this isolate. Will return NULL unless the isolate | 5808 * Returns CPU profiler for this isolate. Will return NULL unless the isolate |
5794 * is initialized. It is the embedder's responsibility to stop all CPU | 5809 * is initialized. It is the embedder's responsibility to stop all CPU |
5795 * profiling activities if it has started any. | 5810 * profiling activities if it has started any. |
5796 */ | 5811 */ |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6621 */ | 6636 */ |
6622 static void ShutdownPlatform(); | 6637 static void ShutdownPlatform(); |
6623 | 6638 |
6624 private: | 6639 private: |
6625 V8(); | 6640 V8(); |
6626 | 6641 |
6627 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 6642 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
6628 internal::Object** handle); | 6643 internal::Object** handle); |
6629 static internal::Object** CopyPersistent(internal::Object** handle); | 6644 static internal::Object** CopyPersistent(internal::Object** handle); |
6630 static void DisposeGlobal(internal::Object** global_handle); | 6645 static void DisposeGlobal(internal::Object** global_handle); |
6631 static void MakeWeak(internal::Object** global_handle, void* data, | 6646 static void MakeWeak(internal::Object** location, void* data, |
6632 WeakCallbackInfo<void>::Callback weak_callback, | 6647 WeakCallbackInfo<void>::Callback weak_callback, |
6633 WeakCallbackType type); | 6648 WeakCallbackType type); |
6634 static void MakeWeak(internal::Object** global_handle, void* data, | 6649 static void MakeWeak(internal::Object** location, void* data, |
6635 // Must be 0 or -1. | 6650 // Must be 0 or -1. |
6636 int internal_field_index1, | 6651 int internal_field_index1, |
6637 // Must be 1 or -1. | 6652 // Must be 1 or -1. |
6638 int internal_field_index2, | 6653 int internal_field_index2, |
6639 WeakCallbackInfo<void>::Callback weak_callback); | 6654 WeakCallbackInfo<void>::Callback weak_callback); |
6640 static void* ClearWeak(internal::Object** global_handle); | 6655 static void MakeWeak(internal::Object*** location_addr); |
| 6656 static void* ClearWeak(internal::Object** location); |
6641 static void Eternalize(Isolate* isolate, | 6657 static void Eternalize(Isolate* isolate, |
6642 Value* handle, | 6658 Value* handle, |
6643 int* index); | 6659 int* index); |
6644 static Local<Value> GetEternal(Isolate* isolate, int index); | 6660 static Local<Value> GetEternal(Isolate* isolate, int index); |
6645 | 6661 |
6646 static void RegisterExternallyReferencedObject(internal::Object** object, | 6662 static void RegisterExternallyReferencedObject(internal::Object** object, |
6647 internal::Isolate* isolate); | 6663 internal::Isolate* isolate); |
6648 template <class K, class V, class T> | 6664 template <class K, class V, class T> |
6649 friend class PersistentValueMapBase; | 6665 friend class PersistentValueMapBase; |
6650 | 6666 |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7602 template <class T> | 7618 template <class T> |
7603 template <typename P> | 7619 template <typename P> |
7604 V8_INLINE void PersistentBase<T>::SetWeak( | 7620 V8_INLINE void PersistentBase<T>::SetWeak( |
7605 P* parameter, typename WeakCallbackInfo<P>::Callback callback, | 7621 P* parameter, typename WeakCallbackInfo<P>::Callback callback, |
7606 WeakCallbackType type) { | 7622 WeakCallbackType type) { |
7607 typedef typename WeakCallbackInfo<void>::Callback Callback; | 7623 typedef typename WeakCallbackInfo<void>::Callback Callback; |
7608 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, | 7624 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, |
7609 reinterpret_cast<Callback>(callback), type); | 7625 reinterpret_cast<Callback>(callback), type); |
7610 } | 7626 } |
7611 | 7627 |
| 7628 template <class T> |
| 7629 void PersistentBase<T>::SetWeak() { |
| 7630 V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_)); |
| 7631 } |
7612 | 7632 |
7613 template <class T> | 7633 template <class T> |
7614 template <typename P> | 7634 template <typename P> |
7615 P* PersistentBase<T>::ClearWeak() { | 7635 P* PersistentBase<T>::ClearWeak() { |
7616 return reinterpret_cast<P*>( | 7636 return reinterpret_cast<P*>( |
7617 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); | 7637 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); |
7618 } | 7638 } |
7619 | 7639 |
7620 template <class T> | 7640 template <class T> |
7621 void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const { | 7641 void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const { |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8705 */ | 8725 */ |
8706 | 8726 |
8707 | 8727 |
8708 } // namespace v8 | 8728 } // namespace v8 |
8709 | 8729 |
8710 | 8730 |
8711 #undef TYPE_CHECK | 8731 #undef TYPE_CHECK |
8712 | 8732 |
8713 | 8733 |
8714 #endif // INCLUDE_V8_H_ | 8734 #endif // INCLUDE_V8_H_ |
OLD | NEW |