524 V8_INLINE void SetWeak(P* parameter,
525 typename WeakCallbackInfo::Callback callback,
526 WeakCallbackType type);
527
528 /**
529 * Turns this handle into a weak phantom handle without finalization callback.
530 * The handle will be reset automatically when the garbage collector detects
531 * that the object is no longer reachable.
532 * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall
533 * returns how many phantom handles were reset by the garbage collector.
534 */
535 V8_INLINE void SetWeak();
536
537 template
538 V8_INLINE P* ClearWeak();
539
540 // TODO(dcarney): remove this.
541 V8_INLINE void ClearWeak() { ClearWeak(); }
542
543 /**
544 * Annotates the strong handle with the given label, which is then used by the
545 * heap snapshot generator as a name of the edge from the root to the handle.
546 * The function does not take ownership of the label and assumes that the
547 * label is valid as long as the handle is valid.
548 */
549 V8_INLINE void AnnotateStrongRetainer(const char* label);
550
551 /**
552 * Allows the embedder to tell the v8 garbage collector that a certain object
553 * is alive. Only allowed when the embedder is asked to trace its heap by
554 * EmbedderHeapTracer.
555 */
556 V8_DEPRECATED(
557 "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
558 V8_INLINE void RegisterExternalReference(Isolate* isolate) const);
559
560 /**
561 * Marks the reference to this object independent. Garbage collector is free
562 * to ignore any object groups containing this object. Weak callback for an
563 * independent handle should not assume that it will be preceded by a global
564 * GC prologue callback or followed by a global GC epilogue callback.
565 */
566 V8_DEPRECATED(
567 "Weak objects are always considered independent. "
568 "Use TracedGlobal when trying to use EmbedderHeapTracer. "
569 "Use a strong handle when trying to keep an object alive.",
570 V8_INLINE void MarkIndependent());
571
572 /**
573 * Marks the reference to this object as active. The scavenge garbage
574 * collection should not reclaim the objects marked as active, even if the
575 * object held by the handle is otherwise unreachable.
576 *
577 * This bit is cleared after the each garbage collection pass.
578 */
579 V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive());
580
581 V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
582
583 /** Returns true if the handle's reference is weak. */
584 V8_INLINE bool IsWeak() const;
585
586 /**
587 * Assigns a wrapper class ID to the handle.
588 */
589 V8_INLINE void SetWrapperClassId(uint16_t class_id);
590
591 /**
592 * Returns the class ID previously assigned to this handle or 0 if no class ID
593 * was previously assigned.
594 */
595 V8_INLINE uint16_t WrapperClassId() const;
596
597 PersistentBase(const PersistentBase& other) = delete; // NOLINT
598 void operator=(const PersistentBase&) = delete;
599
600 private:
601 friend class Isolate;
602 friend class Utils;
603 template friend class Local;
604 template friend class Persistent;
605 template
606 friend class Global;
607 template friend class PersistentBase;
608 template friend class ReturnValue;
609 template
610 friend class PersistentValueMapBase;
611 template friend class PersistentValueVector;
612 friend class Object;
613
614 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
615 V8_INLINE static T* New(Isolate* isolate, T* that);
616
617 T* val_;
618 };
619
620
621 /**
622 * Default traits for Persistent. This class does not allow
623 * use of the copy constructor or assignment operator.
624 * At present kResetInDestructor is not set, but that will change in a future
625 * version.
626 */
627 template
628 class NonCopyablePersistentTraits {
629 public:
630 typedef Persistent > NonCopyablePersistent;
631 static const bool kResetInDestructor = false;
632 template
633 V8_INLINE static void Copy(const Persistent& source,
634 NonCopyablePersistent* dest) {
635 Uncompilable