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

Side by Side Diff: include/v8.h

Issue 11959031: Add a new weak handle callback that passes an Isolate to an embedder (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Applied sven's comments Created 7 years, 11 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') | no next file with comments »
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 // 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // --- Weak Handles --- 145 // --- Weak Handles ---
146 146
147 147
148 /** 148 /**
149 * A weak reference callback function. 149 * A weak reference callback function.
150 * 150 *
151 * This callback should either explicitly invoke Dispose on |object| if 151 * This callback should either explicitly invoke Dispose on |object| if
152 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. 152 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak.
153 * 153 *
154 * \param isolate the current isolate
154 * \param object the weak global object to be reclaimed by the garbage collector 155 * \param object the weak global object to be reclaimed by the garbage collector
155 * \param parameter the value passed in when making the weak global object 156 * \param parameter the value passed in when making the weak global object
157 *
158 * WeakReferenceCallback is deprecated. Use WeakHandleCallback instead.
156 */ 159 */
157 typedef void (*WeakReferenceCallback)(Persistent<Value> object, 160 typedef void (*WeakReferenceCallback)(Persistent<Value> object,
158 void* parameter); 161 void* parameter);
162 typedef void (*WeakHandleCallback)(Isolate* isolate,
163 Persistent<Value> object,
164 void* parameter);
159 165
160 166
161 // --- Handles --- 167 // --- Handles ---
162 168
163 #define TYPE_CHECK(T, S) \ 169 #define TYPE_CHECK(T, S) \
164 while (false) { \ 170 while (false) { \
165 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ 171 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
166 } 172 }
167 173
168 /** 174 /**
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 * cell remain and IsEmpty will still return false. 408 * cell remain and IsEmpty will still return false.
403 */ 409 */
404 V8_INLINE(void Dispose()); 410 V8_INLINE(void Dispose());
405 V8_INLINE(void Dispose(Isolate* isolate)); 411 V8_INLINE(void Dispose(Isolate* isolate));
406 412
407 /** 413 /**
408 * Make the reference to this object weak. When only weak handles 414 * Make the reference to this object weak. When only weak handles
409 * refer to the object, the garbage collector will perform a 415 * refer to the object, the garbage collector will perform a
410 * callback to the given V8::WeakReferenceCallback function, passing 416 * callback to the given V8::WeakReferenceCallback function, passing
411 * it the object reference and the given parameters. 417 * it the object reference and the given parameters.
418 * The 2-arg MakeWeak is deprecated. The 3-arg MakeWeak should be used.
412 */ 419 */
413 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback)); 420 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback));
414 V8_INLINE(void MakeWeak(Isolate* isolate, 421 V8_INLINE(void MakeWeak(Isolate* isolate,
415 void* parameters, 422 void* parameters,
416 WeakReferenceCallback callback)); 423 WeakHandleCallback callback));
417 424
418 /** Clears the weak reference to this object. */ 425 /** Clears the weak reference to this object. */
419 V8_INLINE(void ClearWeak()); 426 V8_INLINE(void ClearWeak());
420 427
421 /** 428 /**
422 * Marks the reference to this object independent. Garbage collector 429 * Marks the reference to this object independent. Garbage collector
423 * is free to ignore any object groups containing this object. 430 * is free to ignore any object groups containing this object.
424 * Weak callback for an independent handle should not 431 * Weak callback for an independent handle should not
425 * assume that it will be preceded by a global GC prologue callback 432 * assume that it will be preceded by a global GC prologue callback
426 * or followed by a global GC epilogue callback. 433 * or followed by a global GC epilogue callback.
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 static internal::Object** GlobalizeReference(internal::Object** handle); 3529 static internal::Object** GlobalizeReference(internal::Object** handle);
3523 static void DisposeGlobal(internal::Object** global_handle); 3530 static void DisposeGlobal(internal::Object** global_handle);
3524 static void DisposeGlobal(internal::Isolate* isolate, 3531 static void DisposeGlobal(internal::Isolate* isolate,
3525 internal::Object** global_handle); 3532 internal::Object** global_handle);
3526 static void MakeWeak(internal::Object** global_handle, 3533 static void MakeWeak(internal::Object** global_handle,
3527 void* data, 3534 void* data,
3528 WeakReferenceCallback); 3535 WeakReferenceCallback);
3529 static void MakeWeak(internal::Isolate* isolate, 3536 static void MakeWeak(internal::Isolate* isolate,
3530 internal::Object** global_handle, 3537 internal::Object** global_handle,
3531 void* data, 3538 void* data,
3532 WeakReferenceCallback); 3539 WeakHandleCallback);
3533 static void ClearWeak(internal::Object** global_handle); 3540 static void ClearWeak(internal::Object** global_handle);
3534 static void MarkIndependent(internal::Object** global_handle); 3541 static void MarkIndependent(internal::Object** global_handle);
3535 static void MarkIndependent(internal::Isolate* isolate, 3542 static void MarkIndependent(internal::Isolate* isolate,
3536 internal::Object** global_handle); 3543 internal::Object** global_handle);
3537 static void MarkPartiallyDependent(internal::Object** global_handle); 3544 static void MarkPartiallyDependent(internal::Object** global_handle);
3538 static void MarkPartiallyDependent(internal::Isolate* isolate, 3545 static void MarkPartiallyDependent(internal::Isolate* isolate,
3539 internal::Object** global_handle); 3546 internal::Object** global_handle);
3540 static bool IsGlobalIndependent(internal::Object** global_handle); 3547 static bool IsGlobalIndependent(internal::Object** global_handle);
3541 static bool IsGlobalIndependent(internal::Isolate* isolate, 3548 static bool IsGlobalIndependent(internal::Isolate* isolate,
3542 internal::Object** global_handle); 3549 internal::Object** global_handle);
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 4376
4370 template <class T> 4377 template <class T>
4371 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { 4378 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
4372 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), 4379 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this),
4373 parameters, 4380 parameters,
4374 callback); 4381 callback);
4375 } 4382 }
4376 4383
4377 template <class T> 4384 template <class T>
4378 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, 4385 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters,
4379 WeakReferenceCallback callback) { 4386 WeakHandleCallback callback) {
4380 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), 4387 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4381 reinterpret_cast<internal::Object**>(**this), 4388 reinterpret_cast<internal::Object**>(**this),
4382 parameters, 4389 parameters,
4383 callback); 4390 callback);
4384 } 4391 }
4385 4392
4386 template <class T> 4393 template <class T>
4387 void Persistent<T>::ClearWeak() { 4394 void Persistent<T>::ClearWeak() {
4388 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); 4395 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
4389 } 4396 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4849 4856
4850 4857
4851 } // namespace v8 4858 } // namespace v8
4852 4859
4853 4860
4854 #undef V8EXPORT 4861 #undef V8EXPORT
4855 #undef TYPE_CHECK 4862 #undef TYPE_CHECK
4856 4863
4857 4864
4858 #endif // V8_H_ 4865 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698