| 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 #endif | 625 #endif |
| 626 | 626 |
| 627 V8_INLINE(void Dispose()); | 627 V8_INLINE(void Dispose()); |
| 628 | 628 |
| 629 /** | 629 /** |
| 630 * Releases the storage cell referenced by this persistent handle. | 630 * Releases the storage cell referenced by this persistent handle. |
| 631 * Does not remove the reference to the cell from any handles. | 631 * Does not remove the reference to the cell from any handles. |
| 632 * This handle's reference, and any other references to the storage | 632 * This handle's reference, and any other references to the storage |
| 633 * cell remain and IsEmpty will still return false. | 633 * cell remain and IsEmpty will still return false. |
| 634 */ | 634 */ |
| 635 // TODO(dcarney): remove before cutover | 635 // TODO(dcarney): deprecate |
| 636 V8_INLINE(void Dispose(Isolate* isolate)); | 636 V8_INLINE(void Dispose(Isolate* isolate)) { Dispose(); } |
| 637 | |
| 638 template<typename S, typename P> | |
| 639 V8_INLINE(void MakeWeak( | |
| 640 Isolate* isolate, | |
| 641 P* parameters, | |
| 642 typename WeakReferenceCallbacks<S, P>::Revivable callback)); | |
| 643 | |
| 644 template<typename P> | |
| 645 V8_INLINE(void MakeWeak( | |
| 646 Isolate* isolate, | |
| 647 P* parameters, | |
| 648 typename WeakReferenceCallbacks<T, P>::Revivable callback)); | |
| 649 | 637 |
| 650 /** | 638 /** |
| 651 * Make the reference to this object weak. When only weak handles | 639 * Make the reference to this object weak. When only weak handles |
| 652 * refer to the object, the garbage collector will perform a | 640 * refer to the object, the garbage collector will perform a |
| 653 * callback to the given V8::NearDeathCallback function, passing | 641 * callback to the given V8::NearDeathCallback function, passing |
| 654 * it the object reference and the given parameters. | 642 * it the object reference and the given parameters. |
| 655 */ | 643 */ |
| 644 template<typename S, typename P> |
| 645 V8_INLINE(void MakeWeak( |
| 646 P* parameters, |
| 647 typename WeakReferenceCallbacks<S, P>::Revivable callback)); |
| 648 |
| 649 template<typename P> |
| 650 V8_INLINE(void MakeWeak( |
| 651 P* parameters, |
| 652 typename WeakReferenceCallbacks<T, P>::Revivable callback)); |
| 653 |
| 654 // TODO(dcarney): deprecate |
| 655 template<typename S, typename P> |
| 656 V8_INLINE(void MakeWeak( |
| 657 Isolate* isolate, |
| 658 P* parameters, |
| 659 typename WeakReferenceCallbacks<S, P>::Revivable callback)) { |
| 660 MakeWeak<S, P>(parameters, callback); |
| 661 } |
| 662 |
| 663 // TODO(dcarney): deprecate |
| 664 template<typename P> |
| 665 V8_INLINE(void MakeWeak( |
| 666 Isolate* isolate, |
| 667 P* parameters, |
| 668 typename WeakReferenceCallbacks<T, P>::Revivable callback)) { |
| 669 MakeWeak<P>(parameters, callback); |
| 670 } |
| 671 |
| 656 // TODO(dcarney): remove before cutover | 672 // TODO(dcarney): remove before cutover |
| 657 V8_INLINE(void MakeWeak(Isolate* isolate, | 673 V8_INLINE(void MakeWeak(Isolate* isolate, |
| 658 void* parameters, | 674 void* parameters, |
| 659 NearDeathCallback callback)); | 675 NearDeathCallback callback)); |
| 660 | 676 |
| 661 V8_INLINE(void ClearWeak()); | 677 V8_INLINE(void ClearWeak()); |
| 662 | 678 |
| 663 // TODO(dcarney): remove before cutover | 679 // TODO(dcarney): deprecate |
| 664 V8_INLINE(void ClearWeak(Isolate* isolate)); | 680 V8_INLINE(void ClearWeak(Isolate* isolate)) { ClearWeak(); } |
| 665 | |
| 666 V8_INLINE(void MarkIndependent()); | |
| 667 | 681 |
| 668 /** | 682 /** |
| 669 * Marks the reference to this object independent. Garbage collector is free | 683 * Marks the reference to this object independent. Garbage collector is free |
| 670 * to ignore any object groups containing this object. Weak callback for an | 684 * to ignore any object groups containing this object. Weak callback for an |
| 671 * independent handle should not assume that it will be preceded by a global | 685 * independent handle should not assume that it will be preceded by a global |
| 672 * GC prologue callback or followed by a global GC epilogue callback. | 686 * GC prologue callback or followed by a global GC epilogue callback. |
| 673 */ | 687 */ |
| 674 // TODO(dcarney): remove before cutover | 688 V8_INLINE(void MarkIndependent()); |
| 675 V8_INLINE(void MarkIndependent(Isolate* isolate)); | |
| 676 | 689 |
| 677 V8_INLINE(void MarkPartiallyDependent()); | 690 // TODO(dcarney): deprecate |
| 691 V8_INLINE(void MarkIndependent(Isolate* isolate)) { MarkIndependent(); } |
| 678 | 692 |
| 679 /** | 693 /** |
| 680 * Marks the reference to this object partially dependent. Partially dependent | 694 * Marks the reference to this object partially dependent. Partially dependent |
| 681 * handles only depend on other partially dependent handles and these | 695 * handles only depend on other partially dependent handles and these |
| 682 * dependencies are provided through object groups. It provides a way to build | 696 * dependencies are provided through object groups. It provides a way to build |
| 683 * smaller object groups for young objects that represent only a subset of all | 697 * smaller object groups for young objects that represent only a subset of all |
| 684 * external dependencies. This mark is automatically cleared after each | 698 * external dependencies. This mark is automatically cleared after each |
| 685 * garbage collection. | 699 * garbage collection. |
| 686 */ | 700 */ |
| 687 // TODO(dcarney): remove before cutover | 701 V8_INLINE(void MarkPartiallyDependent()); |
| 688 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); | 702 |
| 703 // TODO(dcarney): deprecate |
| 704 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)) { |
| 705 MarkPartiallyDependent(); |
| 706 } |
| 689 | 707 |
| 690 V8_INLINE(bool IsIndependent() const); | 708 V8_INLINE(bool IsIndependent() const); |
| 691 | 709 |
| 692 // TODO(dcarney): remove before cutover | 710 // TODO(dcarney): deprecate |
| 693 V8_INLINE(bool IsIndependent(Isolate* isolate) const); | 711 V8_INLINE(bool IsIndependent(Isolate* isolate) const) { |
| 712 return IsIndependent(); |
| 713 } |
| 694 | 714 |
| 715 /** Checks if the handle holds the only reference to an object. */ |
| 695 V8_INLINE(bool IsNearDeath() const); | 716 V8_INLINE(bool IsNearDeath() const); |
| 696 | 717 |
| 697 /** Checks if the handle holds the only reference to an object. */ | 718 // TODO(dcarney): deprecate |
| 698 // TODO(dcarney): remove before cutover | 719 V8_INLINE(bool IsNearDeath(Isolate* isolate) const) { return IsNearDeath(); } |
| 699 V8_INLINE(bool IsNearDeath(Isolate* isolate) const); | |
| 700 | 720 |
| 721 /** Returns true if the handle's reference is weak. */ |
| 701 V8_INLINE(bool IsWeak() const); | 722 V8_INLINE(bool IsWeak() const); |
| 702 | 723 |
| 703 /** Returns true if the handle's reference is weak. */ | 724 // TODO(dcarney): deprecate |
| 704 // TODO(dcarney): remove before cutover | 725 V8_INLINE(bool IsWeak(Isolate* isolate) const) { return IsWeak(); } |
| 705 V8_INLINE(bool IsWeak(Isolate* isolate) const); | |
| 706 | |
| 707 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); | |
| 708 | 726 |
| 709 /** | 727 /** |
| 710 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface | 728 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface |
| 711 * description in v8-profiler.h for details. | 729 * description in v8-profiler.h for details. |
| 712 */ | 730 */ |
| 713 // TODO(dcarney): remove before cutover | 731 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); |
| 714 V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)); | |
| 715 | 732 |
| 716 V8_INLINE(uint16_t WrapperClassId() const); | 733 // TODO(dcarney): deprecate |
| 734 V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)) { |
| 735 SetWrapperClassId(class_id); |
| 736 } |
| 717 | 737 |
| 718 /** | 738 /** |
| 719 * Returns the class ID previously assigned to this handle or 0 if no class ID | 739 * Returns the class ID previously assigned to this handle or 0 if no class ID |
| 720 * was previously assigned. | 740 * was previously assigned. |
| 721 */ | 741 */ |
| 722 // TODO(dcarney): remove before cutover | 742 V8_INLINE(uint16_t WrapperClassId() const); |
| 723 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); | 743 |
| 744 // TODO(dcarney): deprecate |
| 745 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const) { |
| 746 return WrapperClassId(); |
| 747 } |
| 724 | 748 |
| 725 /** | 749 /** |
| 726 * Disposes the current contents of the handle and replaces it. | 750 * Disposes the current contents of the handle and replaces it. |
| 727 */ | 751 */ |
| 728 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); | 752 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); |
| 729 | 753 |
| 730 /** | 754 /** |
| 731 * Returns the underlying raw pointer and clears the handle. The caller is | 755 * Returns the underlying raw pointer and clears the handle. The caller is |
| 732 * responsible of eventually destroying the underlying object (by creating a | 756 * responsible of eventually destroying the underlying object (by creating a |
| 733 * Persistent handle which points to it and Disposing it). In the future, | 757 * Persistent handle which points to it and Disposing it). In the future, |
| (...skipping 3859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4593 */ | 4617 */ |
| 4594 static int ContextDisposedNotification(); | 4618 static int ContextDisposedNotification(); |
| 4595 | 4619 |
| 4596 private: | 4620 private: |
| 4597 V8(); | 4621 V8(); |
| 4598 | 4622 |
| 4599 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 4623 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
| 4600 internal::Object** handle); | 4624 internal::Object** handle); |
| 4601 static void DisposeGlobal(internal::Object** global_handle); | 4625 static void DisposeGlobal(internal::Object** global_handle); |
| 4602 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | 4626 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; |
| 4603 static void MakeWeak(internal::Isolate* isolate, | 4627 static void MakeWeak(internal::Object** global_handle, |
| 4604 internal::Object** global_handle, | |
| 4605 void* data, | 4628 void* data, |
| 4606 RevivableCallback weak_reference_callback, | 4629 RevivableCallback weak_reference_callback, |
| 4607 NearDeathCallback near_death_callback); | 4630 NearDeathCallback near_death_callback); |
| 4608 static void ClearWeak(internal::Isolate* isolate, | 4631 static void ClearWeak(internal::Object** global_handle); |
| 4609 internal::Object** global_handle); | |
| 4610 | 4632 |
| 4611 template <class T> friend class Handle; | 4633 template <class T> friend class Handle; |
| 4612 template <class T> friend class Local; | 4634 template <class T> friend class Local; |
| 4613 template <class T> friend class Persistent; | 4635 template <class T> friend class Persistent; |
| 4614 friend class Context; | 4636 friend class Context; |
| 4615 }; | 4637 }; |
| 4616 | 4638 |
| 4617 | 4639 |
| 4618 /** | 4640 /** |
| 4619 * An external exception handler. | 4641 * An external exception handler. |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5488 if (that == NULL) return Persistent<T>(); | 5510 if (that == NULL) return Persistent<T>(); |
| 5489 internal::Object** p = reinterpret_cast<internal::Object**>(that); | 5511 internal::Object** p = reinterpret_cast<internal::Object**>(that); |
| 5490 return Persistent<T>(reinterpret_cast<T*>( | 5512 return Persistent<T>(reinterpret_cast<T*>( |
| 5491 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), | 5513 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), |
| 5492 p))); | 5514 p))); |
| 5493 } | 5515 } |
| 5494 | 5516 |
| 5495 | 5517 |
| 5496 template <class T> | 5518 template <class T> |
| 5497 bool Persistent<T>::IsIndependent() const { | 5519 bool Persistent<T>::IsIndependent() const { |
| 5498 return IsIndependent(Isolate::GetCurrent()); | |
| 5499 } | |
| 5500 | |
| 5501 | |
| 5502 template <class T> | |
| 5503 bool Persistent<T>::IsIndependent(Isolate* isolate) const { | |
| 5504 typedef internal::Internals I; | 5520 typedef internal::Internals I; |
| 5505 if (this->IsEmpty()) return false; | 5521 if (this->IsEmpty()) return false; |
| 5506 if (!I::IsInitialized(isolate)) return false; | |
| 5507 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5522 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5508 I::kNodeIsIndependentShift); | 5523 I::kNodeIsIndependentShift); |
| 5509 } | 5524 } |
| 5510 | 5525 |
| 5511 | 5526 |
| 5512 template <class T> | 5527 template <class T> |
| 5513 bool Persistent<T>::IsNearDeath() const { | 5528 bool Persistent<T>::IsNearDeath() const { |
| 5514 return IsNearDeath(Isolate::GetCurrent()); | |
| 5515 } | |
| 5516 | |
| 5517 | |
| 5518 template <class T> | |
| 5519 bool Persistent<T>::IsNearDeath(Isolate* isolate) const { | |
| 5520 typedef internal::Internals I; | 5529 typedef internal::Internals I; |
| 5521 if (this->IsEmpty()) return false; | 5530 if (this->IsEmpty()) return false; |
| 5522 if (!I::IsInitialized(isolate)) return false; | |
| 5523 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == | 5531 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == |
| 5524 I::kNodeStateIsNearDeathValue; | 5532 I::kNodeStateIsNearDeathValue; |
| 5525 } | 5533 } |
| 5526 | 5534 |
| 5527 | 5535 |
| 5528 template <class T> | 5536 template <class T> |
| 5529 bool Persistent<T>::IsWeak() const { | 5537 bool Persistent<T>::IsWeak() const { |
| 5530 return IsWeak(Isolate::GetCurrent()); | |
| 5531 } | |
| 5532 | |
| 5533 | |
| 5534 template <class T> | |
| 5535 bool Persistent<T>::IsWeak(Isolate* isolate) const { | |
| 5536 typedef internal::Internals I; | 5538 typedef internal::Internals I; |
| 5537 if (this->IsEmpty()) return false; | 5539 if (this->IsEmpty()) return false; |
| 5538 if (!I::IsInitialized(isolate)) return false; | |
| 5539 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == | 5540 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == |
| 5540 I::kNodeStateIsWeakValue; | 5541 I::kNodeStateIsWeakValue; |
| 5541 } | 5542 } |
| 5542 | 5543 |
| 5543 | 5544 |
| 5544 template <class T> | 5545 template <class T> |
| 5545 void Persistent<T>::Dispose() { | 5546 void Persistent<T>::Dispose() { |
| 5546 if (this->IsEmpty()) return; | 5547 if (this->IsEmpty()) return; |
| 5547 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); | 5548 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); |
| 5548 #ifndef V8_USE_UNSAFE_HANDLES | 5549 #ifndef V8_USE_UNSAFE_HANDLES |
| 5549 val_ = 0; | 5550 val_ = 0; |
| 5550 #endif | 5551 #endif |
| 5551 } | 5552 } |
| 5552 | 5553 |
| 5553 | 5554 |
| 5554 template <class T> | 5555 template <class T> |
| 5555 void Persistent<T>::Dispose(Isolate* isolate) { | |
| 5556 Dispose(); | |
| 5557 } | |
| 5558 | |
| 5559 | |
| 5560 template <class T> | |
| 5561 template <typename S, typename P> | 5556 template <typename S, typename P> |
| 5562 void Persistent<T>::MakeWeak( | 5557 void Persistent<T>::MakeWeak( |
| 5563 Isolate* isolate, | |
| 5564 P* parameters, | 5558 P* parameters, |
| 5565 typename WeakReferenceCallbacks<S, P>::Revivable callback) { | 5559 typename WeakReferenceCallbacks<S, P>::Revivable callback) { |
| 5566 TYPE_CHECK(S, T); | 5560 TYPE_CHECK(S, T); |
| 5567 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; | 5561 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; |
| 5568 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), | 5562 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), |
| 5569 reinterpret_cast<internal::Object**>(this->val_), | |
| 5570 parameters, | 5563 parameters, |
| 5571 reinterpret_cast<Revivable>(callback), | 5564 reinterpret_cast<Revivable>(callback), |
| 5572 NULL); | 5565 NULL); |
| 5573 } | 5566 } |
| 5574 | 5567 |
| 5575 | 5568 |
| 5576 template <class T> | 5569 template <class T> |
| 5577 template <typename P> | 5570 template <typename P> |
| 5578 void Persistent<T>::MakeWeak( | 5571 void Persistent<T>::MakeWeak( |
| 5579 Isolate* isolate, | |
| 5580 P* parameters, | 5572 P* parameters, |
| 5581 typename WeakReferenceCallbacks<T, P>::Revivable callback) { | 5573 typename WeakReferenceCallbacks<T, P>::Revivable callback) { |
| 5582 MakeWeak<T, P>(isolate, parameters, callback); | 5574 MakeWeak<T, P>(parameters, callback); |
| 5583 } | 5575 } |
| 5584 | 5576 |
| 5585 | 5577 |
| 5586 template <class T> | 5578 template <class T> |
| 5587 void Persistent<T>::MakeWeak(Isolate* isolate, | 5579 void Persistent<T>::MakeWeak(Isolate* isolate, |
| 5588 void* parameters, | 5580 void* parameters, |
| 5589 NearDeathCallback callback) { | 5581 NearDeathCallback callback) { |
| 5590 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), | 5582 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), |
| 5591 reinterpret_cast<internal::Object**>(this->val_), | |
| 5592 parameters, | 5583 parameters, |
| 5593 NULL, | 5584 NULL, |
| 5594 callback); | 5585 callback); |
| 5595 } | 5586 } |
| 5596 | 5587 |
| 5588 |
| 5597 template <class T> | 5589 template <class T> |
| 5598 void Persistent<T>::ClearWeak() { | 5590 void Persistent<T>::ClearWeak() { |
| 5599 ClearWeak(Isolate::GetCurrent()); | 5591 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); |
| 5600 } | 5592 } |
| 5601 | 5593 |
| 5602 template <class T> | |
| 5603 void Persistent<T>::ClearWeak(Isolate* isolate) { | |
| 5604 V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate), | |
| 5605 reinterpret_cast<internal::Object**>(this->val_)); | |
| 5606 } | |
| 5607 | 5594 |
| 5608 template <class T> | 5595 template <class T> |
| 5609 void Persistent<T>::MarkIndependent() { | 5596 void Persistent<T>::MarkIndependent() { |
| 5610 MarkIndependent(Isolate::GetCurrent()); | |
| 5611 } | |
| 5612 | |
| 5613 template <class T> | |
| 5614 void Persistent<T>::MarkIndependent(Isolate* isolate) { | |
| 5615 typedef internal::Internals I; | 5597 typedef internal::Internals I; |
| 5616 if (this->IsEmpty()) return; | 5598 if (this->IsEmpty()) return; |
| 5617 if (!I::IsInitialized(isolate)) return; | |
| 5618 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5599 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5619 true, | 5600 true, |
| 5620 I::kNodeIsIndependentShift); | 5601 I::kNodeIsIndependentShift); |
| 5621 } | 5602 } |
| 5622 | 5603 |
| 5604 |
| 5623 template <class T> | 5605 template <class T> |
| 5624 void Persistent<T>::MarkPartiallyDependent() { | 5606 void Persistent<T>::MarkPartiallyDependent() { |
| 5625 MarkPartiallyDependent(Isolate::GetCurrent()); | |
| 5626 } | |
| 5627 | |
| 5628 template <class T> | |
| 5629 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { | |
| 5630 typedef internal::Internals I; | 5607 typedef internal::Internals I; |
| 5631 if (this->IsEmpty()) return; | 5608 if (this->IsEmpty()) return; |
| 5632 if (!I::IsInitialized(isolate)) return; | |
| 5633 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5609 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
| 5634 true, | 5610 true, |
| 5635 I::kNodeIsPartiallyDependentShift); | 5611 I::kNodeIsPartiallyDependentShift); |
| 5636 } | 5612 } |
| 5637 | 5613 |
| 5638 template <class T> | |
| 5639 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { | |
| 5640 SetWrapperClassId(Isolate::GetCurrent(), class_id); | |
| 5641 } | |
| 5642 | |
| 5643 | 5614 |
| 5644 template <class T> | 5615 template <class T> |
| 5645 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { | 5616 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { |
| 5646 Dispose(isolate); | 5617 Dispose(isolate); |
| 5647 #ifdef V8_USE_UNSAFE_HANDLES | 5618 #ifdef V8_USE_UNSAFE_HANDLES |
| 5648 *this = *New(isolate, other); | 5619 *this = *New(isolate, other); |
| 5649 #else | 5620 #else |
| 5650 if (other.IsEmpty()) { | 5621 if (other.IsEmpty()) { |
| 5651 this->val_ = NULL; | 5622 this->val_ = NULL; |
| 5652 return; | 5623 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5666 *this = Persistent<T>(); | 5637 *this = Persistent<T>(); |
| 5667 #else | 5638 #else |
| 5668 old = val_; | 5639 old = val_; |
| 5669 val_ = NULL; | 5640 val_ = NULL; |
| 5670 #endif | 5641 #endif |
| 5671 return old; | 5642 return old; |
| 5672 } | 5643 } |
| 5673 | 5644 |
| 5674 | 5645 |
| 5675 template <class T> | 5646 template <class T> |
| 5676 void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { | 5647 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
| 5677 typedef internal::Internals I; | 5648 typedef internal::Internals I; |
| 5678 if (this->IsEmpty()) return; | 5649 if (this->IsEmpty()) return; |
| 5679 if (!I::IsInitialized(isolate)) return; | |
| 5680 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5650 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
| 5681 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 5651 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 5682 *reinterpret_cast<uint16_t*>(addr) = class_id; | 5652 *reinterpret_cast<uint16_t*>(addr) = class_id; |
| 5683 } | 5653 } |
| 5684 | 5654 |
| 5655 |
| 5685 template <class T> | 5656 template <class T> |
| 5686 uint16_t Persistent<T>::WrapperClassId() const { | 5657 uint16_t Persistent<T>::WrapperClassId() const { |
| 5687 return WrapperClassId(Isolate::GetCurrent()); | |
| 5688 } | |
| 5689 | |
| 5690 template <class T> | |
| 5691 uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { | |
| 5692 typedef internal::Internals I; | 5658 typedef internal::Internals I; |
| 5693 if (this->IsEmpty()) return 0; | 5659 if (this->IsEmpty()) return 0; |
| 5694 if (!I::IsInitialized(isolate)) return 0; | |
| 5695 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5660 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
| 5696 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 5661 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 5697 return *reinterpret_cast<uint16_t*>(addr); | 5662 return *reinterpret_cast<uint16_t*>(addr); |
| 5698 } | 5663 } |
| 5699 | 5664 |
| 5700 | 5665 |
| 5701 template<typename T> | 5666 template<typename T> |
| 5702 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} | 5667 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} |
| 5703 | 5668 |
| 5704 template<typename T> | 5669 template<typename T> |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6343 | 6308 |
| 6344 | 6309 |
| 6345 } // namespace v8 | 6310 } // namespace v8 |
| 6346 | 6311 |
| 6347 | 6312 |
| 6348 #undef V8EXPORT | 6313 #undef V8EXPORT |
| 6349 #undef TYPE_CHECK | 6314 #undef TYPE_CHECK |
| 6350 | 6315 |
| 6351 | 6316 |
| 6352 #endif // V8_H_ | 6317 #endif // V8_H_ |
| OLD | NEW |