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

Side by Side Diff: include/v8.h

Issue 260017: Implemented really weak handles. (Closed)
Patch Set: Fix typo. Created 11 years, 2 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 | src/api.cc » ('j') | src/global-handles.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 inline void Dispose(); 382 inline void Dispose();
383 383
384 /** 384 /**
385 * Make the reference to this object weak. When only weak handles 385 * Make the reference to this object weak. When only weak handles
386 * refer to the object, the garbage collector will perform a 386 * refer to the object, the garbage collector will perform a
387 * callback to the given V8::WeakReferenceCallback function, passing 387 * callback to the given V8::WeakReferenceCallback function, passing
388 * it the object reference and the given parameters. 388 * it the object reference and the given parameters.
389 */ 389 */
390 inline void MakeWeak(void* parameters, WeakReferenceCallback callback); 390 inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
391 391
392 /** Clears the weak reference to this object.*/ 392 /**
393 * Similar to the above function except that when the callback is
394 * invoked for a really weak handle the object may have been
395 * collected already. Accessing the object in the callback is not
396 * allowed. The embedder can only use the data that is stored in
397 * the handle itself.
398 */
399 inline void MakeReallyWeak(void* parameters, WeakReferenceCallback callback);
Christian Plesner Hansen 2009/10/06 13:47:21 I think we need to find a more informative name.
400
401 /**
402 * Clears weak status of this handle. Clearing status in weak
403 * callback is not allowed for really weak handles since the object
404 * may have been collected already.
405 */
393 inline void ClearWeak(); 406 inline void ClearWeak();
394 407
395 /** 408 /**
396 *Checks if the handle holds the only reference to an object. 409 * Checks if the handle holds the only reference to an object.
397 */ 410 */
398 inline bool IsNearDeath() const; 411 inline bool IsNearDeath() const;
399 412
400 /** 413 /**
401 * Returns true if the handle's reference is weak. 414 * Returns true if the handle's reference is weak or really weak.
402 */ 415 */
403 inline bool IsWeak() const; 416 inline bool IsWeak() const;
404 417
405 private: 418 private:
406 friend class ImplementationUtilities; 419 friend class ImplementationUtilities;
407 friend class ObjectTemplate; 420 friend class ObjectTemplate;
408 }; 421 };
409 422
410 423
411 /** 424 /**
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 static void LowMemoryNotification(); 2375 static void LowMemoryNotification();
2363 2376
2364 private: 2377 private:
2365 V8(); 2378 V8();
2366 2379
2367 static internal::Object** GlobalizeReference(internal::Object** handle); 2380 static internal::Object** GlobalizeReference(internal::Object** handle);
2368 static void DisposeGlobal(internal::Object** global_handle); 2381 static void DisposeGlobal(internal::Object** global_handle);
2369 static void MakeWeak(internal::Object** global_handle, 2382 static void MakeWeak(internal::Object** global_handle,
2370 void* data, 2383 void* data,
2371 WeakReferenceCallback); 2384 WeakReferenceCallback);
2385 static void MakeReallyWeak(internal::Object** global_handle,
2386 void* data,
2387 WeakReferenceCallback);
2372 static void ClearWeak(internal::Object** global_handle); 2388 static void ClearWeak(internal::Object** global_handle);
2373 static bool IsGlobalNearDeath(internal::Object** global_handle); 2389 static bool IsGlobalNearDeath(internal::Object** global_handle);
2374 static bool IsGlobalWeak(internal::Object** global_handle); 2390 static bool IsGlobalWeak(internal::Object** global_handle);
2375 2391
2376 template <class T> friend class Handle; 2392 template <class T> friend class Handle;
2377 template <class T> friend class Local; 2393 template <class T> friend class Local;
2378 template <class T> friend class Persistent; 2394 template <class T> friend class Persistent;
2379 friend class Context; 2395 friend class Context;
2380 }; 2396 };
2381 2397
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 Persistent<T>::Persistent() : Handle<T>() { } 2845 Persistent<T>::Persistent() : Handle<T>() { }
2830 2846
2831 template <class T> 2847 template <class T>
2832 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { 2848 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
2833 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), 2849 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this),
2834 parameters, 2850 parameters,
2835 callback); 2851 callback);
2836 } 2852 }
2837 2853
2838 template <class T> 2854 template <class T>
2855 void Persistent<T>::MakeReallyWeak(void* parameters,
2856 WeakReferenceCallback callback) {
2857 V8::MakeReallyWeak(reinterpret_cast<internal::Object**>(**this),
2858 parameters,
2859 callback);
2860 }
2861
2862 template <class T>
2839 void Persistent<T>::ClearWeak() { 2863 void Persistent<T>::ClearWeak() {
2840 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); 2864 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
2841 } 2865 }
2842 2866
2843 Local<Value> Arguments::operator[](int i) const { 2867 Local<Value> Arguments::operator[](int i) const {
2844 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); 2868 if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
2845 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); 2869 return Local<Value>(reinterpret_cast<Value*>(values_ - i));
2846 } 2870 }
2847 2871
2848 2872
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 3126
3103 } // namespace v8 3127 } // namespace v8
3104 3128
3105 3129
3106 #undef V8EXPORT 3130 #undef V8EXPORT
3107 #undef V8EXPORT_INLINE 3131 #undef V8EXPORT_INLINE
3108 #undef TYPE_CHECK 3132 #undef TYPE_CHECK
3109 3133
3110 3134
3111 #endif // V8_H_ 3135 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698