Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: include/v8.h

Issue 1026283004: fix disposal of phantom handles in GlobalValueMap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/v8-util.h » ('j') | test/cctest/test-api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 V8_INLINE Local<T> Get(Isolate* isolate); 464 V8_INLINE Local<T> Get(Isolate* isolate);
465 V8_INLINE bool IsEmpty() { return index_ == kInitialValue; } 465 V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
466 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle); 466 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
467 467
468 private: 468 private:
469 static const int kInitialValue = -1; 469 static const int kInitialValue = -1;
470 int index_; 470 int index_;
471 }; 471 };
472 472
473 473
474 static const int kInternalFieldsInWeakCallback = 2;
475
476
474 template <typename T> 477 template <typename T>
475 class WeakCallbackInfo { 478 class WeakCallbackInfo {
476 public: 479 public:
477 typedef void (*Callback)(const WeakCallbackInfo<T>& data); 480 typedef void (*Callback)(const WeakCallbackInfo<T>& data);
478 481
479 WeakCallbackInfo(Isolate* isolate, T* parameter, void* internal_field1, 482 WeakCallbackInfo(Isolate* isolate, T* parameter, void* internal_field1,
480 void* internal_field2) 483 void* internal_field2)
481 : isolate_(isolate), 484 : isolate_(isolate), parameter_(parameter) {
482 parameter_(parameter), 485 internal_fields_[0] = internal_field1;
483 internal_field1_(internal_field1), 486 internal_fields_[1] = internal_field2;
484 internal_field2_(internal_field2) {} 487 }
485 488
486 V8_INLINE Isolate* GetIsolate() const { return isolate_; } 489 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
487 V8_INLINE T* GetParameter() const { return parameter_; } 490 V8_INLINE T* GetParameter() const { return parameter_; }
488 V8_INLINE void* GetInternalField1() const { return internal_field1_; } 491 V8_INLINE void* GetInternalField(int index) const;
489 V8_INLINE void* GetInternalField2() const { return internal_field2_; } 492
493 V8_INLINE V8_DEPRECATE_SOON("use indexed version",
494 void* GetInternalField1()) const {
495 return internal_fields_[0];
496 }
497 V8_INLINE V8_DEPRECATE_SOON("use indexed version",
498 void* GetInternalField2()) const {
499 return internal_fields_[1];
500 }
490 501
491 private: 502 private:
492 Isolate* isolate_; 503 Isolate* isolate_;
493 T* parameter_; 504 T* parameter_;
494 void* internal_field1_; 505 void* internal_fields_[2];
495 void* internal_field2_;
496 }; 506 };
497 507
498 508
499 template <class T, class P> 509 template <class T, class P>
500 class WeakCallbackData { 510 class WeakCallbackData {
501 public: 511 public:
502 typedef void (*Callback)(const WeakCallbackData<T, P>& data); 512 typedef void (*Callback)(const WeakCallbackData<T, P>& data);
503 513
504 WeakCallbackData(Isolate* isolate, P* parameter, Local<T> handle) 514 WeakCallbackData(Isolate* isolate, P* parameter, Local<T> handle)
505 : isolate_(isolate), parameter_(parameter), handle_(handle) {} 515 : isolate_(isolate), parameter_(parameter), handle_(handle) {}
(...skipping 5461 matching lines...) Expand 10 before | Expand all | Expand 10 after
5967 int internal_field_index2, 5977 int internal_field_index2,
5968 WeakCallbackInfo<void>::Callback weak_callback); 5978 WeakCallbackInfo<void>::Callback weak_callback);
5969 static void* ClearWeak(internal::Object** global_handle); 5979 static void* ClearWeak(internal::Object** global_handle);
5970 static void Eternalize(Isolate* isolate, 5980 static void Eternalize(Isolate* isolate,
5971 Value* handle, 5981 Value* handle,
5972 int* index); 5982 int* index);
5973 static Local<Value> GetEternal(Isolate* isolate, int index); 5983 static Local<Value> GetEternal(Isolate* isolate, int index);
5974 5984
5975 static void CheckIsJust(bool is_just); 5985 static void CheckIsJust(bool is_just);
5976 static void ToLocalEmpty(); 5986 static void ToLocalEmpty();
5987 static void InternalFieldOutOfBounds(int index);
5977 5988
5978 template <class T> friend class Handle; 5989 template <class T> friend class Handle;
5979 template <class T> friend class Local; 5990 template <class T> friend class Local;
5980 template <class T> 5991 template <class T>
5981 friend class MaybeLocal; 5992 friend class MaybeLocal;
5982 template <class T> 5993 template <class T>
5983 friend class Maybe; 5994 friend class Maybe;
5984 template <class T> friend class Eternal; 5995 template <class T> friend class Eternal;
5985 template <class T> friend class PersistentBase; 5996 template <class T> friend class PersistentBase;
5986 template <class T, class M> friend class Persistent; 5997 template <class T, class M> friend class Persistent;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
6826 template <class T> 6837 template <class T>
6827 Local<T> MaybeLocal<T>::ToLocalChecked() { 6838 Local<T> MaybeLocal<T>::ToLocalChecked() {
6828 #ifdef V8_ENABLE_CHECKS 6839 #ifdef V8_ENABLE_CHECKS
6829 if (val_ == nullptr) V8::ToLocalEmpty(); 6840 if (val_ == nullptr) V8::ToLocalEmpty();
6830 #endif 6841 #endif
6831 return Local<T>(val_); 6842 return Local<T>(val_);
6832 } 6843 }
6833 6844
6834 6845
6835 template <class T> 6846 template <class T>
6847 void* WeakCallbackInfo<T>::GetInternalField(int index) const {
6848 #ifdef V8_ENABLE_CHECKS
6849 if (index < 0 || index >= kInternalFieldsInWeakCallback) {
6850 V8::InternalFieldOutOfBounds(index);
6851 }
6852 #endif
6853 return internal_fields_[index];
6854 }
6855
6856
6857 template <class T>
6836 T* PersistentBase<T>::New(Isolate* isolate, T* that) { 6858 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
6837 if (that == NULL) return NULL; 6859 if (that == NULL) return NULL;
6838 internal::Object** p = reinterpret_cast<internal::Object**>(that); 6860 internal::Object** p = reinterpret_cast<internal::Object**>(that);
6839 return reinterpret_cast<T*>( 6861 return reinterpret_cast<T*>(
6840 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), 6862 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
6841 p)); 6863 p));
6842 } 6864 }
6843 6865
6844 6866
6845 template <class T, class M> 6867 template <class T, class M>
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
7975 */ 7997 */
7976 7998
7977 7999
7978 } // namespace v8 8000 } // namespace v8
7979 8001
7980 8002
7981 #undef TYPE_CHECK 8003 #undef TYPE_CHECK
7982 8004
7983 8005
7984 #endif // V8_H_ 8006 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | include/v8-util.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698