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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 * was previously assigned. | 688 * was previously assigned. |
689 */ | 689 */ |
690 // TODO(dcarney): remove before cutover | 690 // TODO(dcarney): remove before cutover |
691 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); | 691 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); |
692 | 692 |
693 /** | 693 /** |
694 * Disposes the current contents of the handle and replaces it. | 694 * Disposes the current contents of the handle and replaces it. |
695 */ | 695 */ |
696 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); | 696 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); |
697 | 697 |
698 V8_INLINE(T* LeakPersistent()); | |
Sven Panne
2013/05/10 12:00:02
Please add a comment that it is necessary to re-wr
marja
2013/05/10 13:02:26
Done.
| |
699 | |
698 #ifndef V8_USE_UNSAFE_HANDLES | 700 #ifndef V8_USE_UNSAFE_HANDLES |
699 | 701 |
700 #ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | 702 #ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
701 | 703 |
702 private: | 704 private: |
703 #endif | 705 #endif |
704 // TODO(dcarney): make unlinkable before cutover | 706 // TODO(dcarney): make unlinkable before cutover |
705 V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} | 707 V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} |
706 // TODO(dcarney): make unlinkable before cutover | 708 // TODO(dcarney): make unlinkable before cutover |
707 V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | 709 V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT |
(...skipping 4669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5377 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | 5379 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), |
5378 true, | 5380 true, |
5379 I::kNodeIsPartiallyDependentShift); | 5381 I::kNodeIsPartiallyDependentShift); |
5380 } | 5382 } |
5381 | 5383 |
5382 template <class T> | 5384 template <class T> |
5383 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { | 5385 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
5384 SetWrapperClassId(Isolate::GetCurrent(), class_id); | 5386 SetWrapperClassId(Isolate::GetCurrent(), class_id); |
5385 } | 5387 } |
5386 | 5388 |
5389 | |
5387 template <class T> | 5390 template <class T> |
5388 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { | 5391 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { |
5389 Dispose(isolate); | 5392 Dispose(isolate); |
5390 #ifdef V8_USE_UNSAFE_HANDLES | 5393 #ifdef V8_USE_UNSAFE_HANDLES |
5391 *this = *New(isolate, other); | 5394 *this = *New(isolate, other); |
5392 #else | 5395 #else |
5393 if (other.IsEmpty()) { | 5396 if (other.IsEmpty()) { |
5394 this->val_ = NULL; | 5397 this->val_ = NULL; |
5395 return; | 5398 return; |
5396 } | 5399 } |
5397 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); | 5400 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); |
5398 this->val_ = reinterpret_cast<T*>( | 5401 this->val_ = reinterpret_cast<T*>( |
5399 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); | 5402 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); |
5400 #endif | 5403 #endif |
5401 } | 5404 } |
5402 | 5405 |
5406 | |
5407 template <class T> | |
5408 T* Persistent<T>::LeakPersistent() { | |
Sven Panne
2013/05/10 12:00:02
As discussed offline, we should better name it "Cl
marja
2013/05/10 13:02:26
Done.
| |
5409 T* old; | |
5410 #ifdef V8_USE_UNSAFE_HANDLES | |
5411 old = this->operator*(); | |
Sven Panne
2013/05/10 12:00:02
Can we use '*this' here? If not, a comment might b
marja
2013/05/10 13:02:26
"this" is not Persistent, but Persistent*, so "*th
| |
5412 *this = Persistent<T>(); | |
5413 #else | |
5414 old = val_; | |
5415 val_ = NULL; | |
5416 #endif | |
5417 return old; | |
5418 } | |
5419 | |
5420 | |
5403 template <class T> | 5421 template <class T> |
5404 void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { | 5422 void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { |
5405 typedef internal::Internals I; | 5423 typedef internal::Internals I; |
5406 if (this->IsEmpty()) return; | 5424 if (this->IsEmpty()) return; |
5407 if (!I::IsInitialized(isolate)) return; | 5425 if (!I::IsInitialized(isolate)) return; |
5408 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5426 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
5409 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 5427 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
5410 *reinterpret_cast<uint16_t*>(addr) = class_id; | 5428 *reinterpret_cast<uint16_t*>(addr) = class_id; |
5411 } | 5429 } |
5412 | 5430 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5964 | 5982 |
5965 | 5983 |
5966 } // namespace v8 | 5984 } // namespace v8 |
5967 | 5985 |
5968 | 5986 |
5969 #undef V8EXPORT | 5987 #undef V8EXPORT |
5970 #undef TYPE_CHECK | 5988 #undef TYPE_CHECK |
5971 | 5989 |
5972 | 5990 |
5973 #endif // V8_H_ | 5991 #endif // V8_H_ |
OLD | NEW |