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

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: 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') | src/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 // 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 /** 145 /**
146 * A weak reference callback function. 146 * A weak reference callback function.
147 * 147 *
148 * This callback should either explicitly invoke Dispose on |object| if 148 * This callback should either explicitly invoke Dispose on |object| if
149 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. 149 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak.
150 * 150 *
151 * \param object the weak global object to be reclaimed by the garbage collector 151 * \param object the weak global object to be reclaimed by the garbage collector
152 * \param parameter the value passed in when making the weak global object 152 * \param parameter the value passed in when making the weak global object
153 */ 153 */
154 typedef void (*WeakReferenceCallback)(Persistent<Value> object, 154 typedef void (*WeakReferenceCallback)(Persistent<Value> object,
Sven Panne 2013/01/18 08:08:12 We should add a remark here that this kind of call
haraken 2013/01/22 00:27:37 Done.
155 void* parameter); 155 void* parameter);
156 typedef void (*WeakenedReferenceCallback)(Isolate* isolate,
Sven Panne 2013/01/18 08:08:12 Hmmm, I'm not totally happy with that name. We sho
haraken 2013/01/22 00:27:37 For now I changed the name to WeakHandleCallback.
157 Persistent<Value> object,
158 void* parameter);
156 159
157 160
158 // --- Handles --- 161 // --- Handles ---
159 162
160 #define TYPE_CHECK(T, S) \ 163 #define TYPE_CHECK(T, S) \
161 while (false) { \ 164 while (false) { \
162 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ 165 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
163 } 166 }
164 167
165 /** 168 /**
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 */ 403 */
401 V8_INLINE(void Dispose()); 404 V8_INLINE(void Dispose());
402 V8_INLINE(void Dispose(Isolate* isolate)); 405 V8_INLINE(void Dispose(Isolate* isolate));
403 406
404 /** 407 /**
405 * Make the reference to this object weak. When only weak handles 408 * Make the reference to this object weak. When only weak handles
406 * refer to the object, the garbage collector will perform a 409 * refer to the object, the garbage collector will perform a
407 * callback to the given V8::WeakReferenceCallback function, passing 410 * callback to the given V8::WeakReferenceCallback function, passing
408 * it the object reference and the given parameters. 411 * it the object reference and the given parameters.
409 */ 412 */
410 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback)); 413 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback));
Sven Panne 2013/01/18 08:08:12 Add a TODO comment that this should be deprecated
haraken 2013/01/22 00:27:37 Done.
411 V8_INLINE(void MakeWeak(Isolate* isolate, 414 V8_INLINE(void MakeWeak(Isolate* isolate,
412 void* parameters, 415 void* parameters,
413 WeakReferenceCallback callback)); 416 WeakReferenceCallback callback));
417 V8_INLINE(void Weaken(Isolate* isolate,
Sven Panne 2013/01/18 08:08:12 As discussed offline, the 3-arg MakeWeak is brand-
haraken 2013/01/22 00:27:37 Done.
418 void* parameters,
419 WeakenedReferenceCallback callback));
414 420
415 /** Clears the weak reference to this object. */ 421 /** Clears the weak reference to this object. */
416 V8_INLINE(void ClearWeak()); 422 V8_INLINE(void ClearWeak());
417 423
418 /** 424 /**
419 * Marks the reference to this object independent. Garbage collector 425 * Marks the reference to this object independent. Garbage collector
420 * is free to ignore any object groups containing this object. 426 * is free to ignore any object groups containing this object.
421 * Weak callback for an independent handle should not 427 * Weak callback for an independent handle should not
422 * assume that it will be preceded by a global GC prologue callback 428 * assume that it will be preceded by a global GC prologue callback
423 * or followed by a global GC epilogue callback. 429 * or followed by a global GC epilogue callback.
(...skipping 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 static void DisposeGlobal(internal::Object** global_handle); 3526 static void DisposeGlobal(internal::Object** global_handle);
3521 static void DisposeGlobal(internal::Isolate* isolate, 3527 static void DisposeGlobal(internal::Isolate* isolate,
3522 internal::Object** global_handle); 3528 internal::Object** global_handle);
3523 static void MakeWeak(internal::Object** global_handle, 3529 static void MakeWeak(internal::Object** global_handle,
3524 void* data, 3530 void* data,
3525 WeakReferenceCallback); 3531 WeakReferenceCallback);
3526 static void MakeWeak(internal::Isolate* isolate, 3532 static void MakeWeak(internal::Isolate* isolate,
3527 internal::Object** global_handle, 3533 internal::Object** global_handle,
3528 void* data, 3534 void* data,
3529 WeakReferenceCallback); 3535 WeakReferenceCallback);
3536 static void WeakenGlobal(internal::Isolate* isolate,
Sven Panne 2013/01/18 08:08:12 see above
haraken 2013/01/22 00:27:37 Done.
3537 internal::Object** global_handle,
3538 void* data,
3539 WeakenedReferenceCallback);
3530 static void ClearWeak(internal::Object** global_handle); 3540 static void ClearWeak(internal::Object** global_handle);
3531 static void MarkIndependent(internal::Object** global_handle); 3541 static void MarkIndependent(internal::Object** global_handle);
3532 static void MarkIndependent(internal::Isolate* isolate, 3542 static void MarkIndependent(internal::Isolate* isolate,
3533 internal::Object** global_handle); 3543 internal::Object** global_handle);
3534 static void MarkPartiallyDependent(internal::Object** global_handle); 3544 static void MarkPartiallyDependent(internal::Object** global_handle);
3535 static void MarkPartiallyDependent(internal::Isolate* isolate, 3545 static void MarkPartiallyDependent(internal::Isolate* isolate,
3536 internal::Object** global_handle); 3546 internal::Object** global_handle);
3537 static bool IsGlobalIndependent(internal::Object** global_handle); 3547 static bool IsGlobalIndependent(internal::Object** global_handle);
3538 static bool IsGlobalIndependent(internal::Isolate* isolate, 3548 static bool IsGlobalIndependent(internal::Isolate* isolate,
3539 internal::Object** global_handle); 3549 internal::Object** global_handle);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 template <class T> 4374 template <class T>
4365 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, 4375 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters,
4366 WeakReferenceCallback callback) { 4376 WeakReferenceCallback callback) {
4367 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), 4377 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4368 reinterpret_cast<internal::Object**>(**this), 4378 reinterpret_cast<internal::Object**>(**this),
4369 parameters, 4379 parameters,
4370 callback); 4380 callback);
4371 } 4381 }
4372 4382
4373 template <class T> 4383 template <class T>
4384 void Persistent<T>::Weaken(Isolate* isolate, void* parameters,
Sven Panne 2013/01/18 08:08:12 see above
haraken 2013/01/22 00:27:37 Done.
4385 WeakenedReferenceCallback callback) {
4386 V8::WeakenGlobal(reinterpret_cast<internal::Isolate*>(isolate),
4387 reinterpret_cast<internal::Object**>(**this),
4388 parameters,
4389 callback);
4390 }
4391
4392 template <class T>
4374 void Persistent<T>::ClearWeak() { 4393 void Persistent<T>::ClearWeak() {
4375 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); 4394 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
4376 } 4395 }
4377 4396
4378 template <class T> 4397 template <class T>
4379 void Persistent<T>::MarkIndependent() { 4398 void Persistent<T>::MarkIndependent() {
4380 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); 4399 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
4381 } 4400 }
4382 4401
4383 template <class T> 4402 template <class T>
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
4836 4855
4837 4856
4838 } // namespace v8 4857 } // namespace v8
4839 4858
4840 4859
4841 #undef V8EXPORT 4860 #undef V8EXPORT
4842 #undef TYPE_CHECK 4861 #undef TYPE_CHECK
4843 4862
4844 4863
4845 #endif // V8_H_ 4864 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698