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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 */ | 382 */ |
383 inline void Dispose(); | 383 inline void Dispose(); |
384 | 384 |
385 /** | 385 /** |
386 * Make the reference to this object weak. When only weak handles | 386 * Make the reference to this object weak. When only weak handles |
387 * refer to the object, the garbage collector will perform a | 387 * refer to the object, the garbage collector will perform a |
388 * callback to the given V8::WeakReferenceCallback function, passing | 388 * callback to the given V8::WeakReferenceCallback function, passing |
389 * it the object reference and the given parameters. | 389 * it the object reference and the given parameters. |
390 */ | 390 */ |
391 inline void MakeWeak(void* parameters, WeakReferenceCallback callback); | 391 inline void MakeWeak(void* parameters, WeakReferenceCallback callback); |
| 392 inline void MakeWeak(Isolate* isolate, void* parameters, |
| 393 WeakReferenceCallback callback); |
392 | 394 |
393 /** Clears the weak reference to this object. */ | 395 /** Clears the weak reference to this object. */ |
394 inline void ClearWeak(); | 396 inline void ClearWeak(); |
395 | 397 |
396 /** | 398 /** |
397 * Marks the reference to this object independent. Garbage collector | 399 * Marks the reference to this object independent. Garbage collector |
398 * is free to ignore any object groups containing this object. | 400 * is free to ignore any object groups containing this object. |
399 * Weak callback for an independent handle should not | 401 * Weak callback for an independent handle should not |
400 * assume that it will be preceded by a global GC prologue callback | 402 * assume that it will be preceded by a global GC prologue callback |
401 * or followed by a global GC epilogue callback. | 403 * or followed by a global GC epilogue callback. |
402 */ | 404 */ |
403 inline void MarkIndependent(); | 405 inline void MarkIndependent(); |
404 | 406 |
405 /** Returns true if this handle was previously marked as independent. */ | 407 /** Returns true if this handle was previously marked as independent. */ |
406 inline bool IsIndependent() const; | 408 inline bool IsIndependent() const; |
407 | 409 |
408 /** Checks if the handle holds the only reference to an object. */ | 410 /** Checks if the handle holds the only reference to an object. */ |
409 inline bool IsNearDeath() const; | 411 inline bool IsNearDeath() const; |
410 | 412 |
411 /** Returns true if the handle's reference is weak. */ | 413 /** Returns true if the handle's reference is weak. */ |
412 inline bool IsWeak() const; | 414 inline bool IsWeak() const; |
| 415 inline bool IsWeak(Isolate* isolate) const; |
413 | 416 |
414 /** | 417 /** |
415 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo | 418 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo |
416 * interface description in v8-profiler.h for details. | 419 * interface description in v8-profiler.h for details. |
417 */ | 420 */ |
418 inline void SetWrapperClassId(uint16_t class_id); | 421 inline void SetWrapperClassId(uint16_t class_id); |
419 | 422 |
420 /** | 423 /** |
421 * Returns the class ID previously assigned to this handle or 0 if no class | 424 * Returns the class ID previously assigned to this handle or 0 if no class |
422 * ID was previously assigned. | 425 * ID was previously assigned. |
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3253 * object in the group is alive, all objects in the group are alive. | 3256 * object in the group is alive, all objects in the group are alive. |
3254 * After each garbage collection, object groups are removed. It is | 3257 * After each garbage collection, object groups are removed. It is |
3255 * intended to be used in the before-garbage-collection callback | 3258 * intended to be used in the before-garbage-collection callback |
3256 * function, for instance to simulate DOM tree connections among JS | 3259 * function, for instance to simulate DOM tree connections among JS |
3257 * wrapper objects. | 3260 * wrapper objects. |
3258 * See v8-profiler.h for RetainedObjectInfo interface description. | 3261 * See v8-profiler.h for RetainedObjectInfo interface description. |
3259 */ | 3262 */ |
3260 static void AddObjectGroup(Persistent<Value>* objects, | 3263 static void AddObjectGroup(Persistent<Value>* objects, |
3261 size_t length, | 3264 size_t length, |
3262 RetainedObjectInfo* info = NULL); | 3265 RetainedObjectInfo* info = NULL); |
| 3266 static void AddObjectGroup(Isolate* isolate, |
| 3267 Persistent<Value>* objects, |
| 3268 size_t length, |
| 3269 RetainedObjectInfo* info = NULL); |
3263 | 3270 |
3264 /** | 3271 /** |
3265 * Allows the host application to declare implicit references between | 3272 * Allows the host application to declare implicit references between |
3266 * the objects: if |parent| is alive, all |children| are alive too. | 3273 * the objects: if |parent| is alive, all |children| are alive too. |
3267 * After each garbage collection, all implicit references | 3274 * After each garbage collection, all implicit references |
3268 * are removed. It is intended to be used in the before-garbage-collection | 3275 * are removed. It is intended to be used in the before-garbage-collection |
3269 * callback function. | 3276 * callback function. |
3270 */ | 3277 */ |
3271 static void AddImplicitReferences(Persistent<Object> parent, | 3278 static void AddImplicitReferences(Persistent<Object> parent, |
3272 Persistent<Value>* children, | 3279 Persistent<Value>* children, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3484 static int ContextDisposedNotification(); | 3491 static int ContextDisposedNotification(); |
3485 | 3492 |
3486 private: | 3493 private: |
3487 V8(); | 3494 V8(); |
3488 | 3495 |
3489 static internal::Object** GlobalizeReference(internal::Object** handle); | 3496 static internal::Object** GlobalizeReference(internal::Object** handle); |
3490 static void DisposeGlobal(internal::Object** global_handle); | 3497 static void DisposeGlobal(internal::Object** global_handle); |
3491 static void MakeWeak(internal::Object** global_handle, | 3498 static void MakeWeak(internal::Object** global_handle, |
3492 void* data, | 3499 void* data, |
3493 WeakReferenceCallback); | 3500 WeakReferenceCallback); |
| 3501 static void MakeWeak(internal::Isolate* isolate, |
| 3502 internal::Object** global_handle, |
| 3503 void* data, |
| 3504 WeakReferenceCallback); |
3494 static void ClearWeak(internal::Object** global_handle); | 3505 static void ClearWeak(internal::Object** global_handle); |
3495 static void MarkIndependent(internal::Object** global_handle); | 3506 static void MarkIndependent(internal::Object** global_handle); |
3496 static bool IsGlobalIndependent(internal::Object** global_handle); | 3507 static bool IsGlobalIndependent(internal::Object** global_handle); |
3497 static bool IsGlobalNearDeath(internal::Object** global_handle); | 3508 static bool IsGlobalNearDeath(internal::Object** global_handle); |
3498 static bool IsGlobalWeak(internal::Object** global_handle); | 3509 static bool IsGlobalWeak(internal::Object** global_handle); |
| 3510 static bool IsGlobalWeak(internal::Isolate* isolate, |
| 3511 internal::Object** global_handle); |
3499 static void SetWrapperClassId(internal::Object** global_handle, | 3512 static void SetWrapperClassId(internal::Object** global_handle, |
3500 uint16_t class_id); | 3513 uint16_t class_id); |
3501 static uint16_t GetWrapperClassId(internal::Object** global_handle); | 3514 static uint16_t GetWrapperClassId(internal::Object** global_handle); |
3502 | 3515 |
3503 template <class T> friend class Handle; | 3516 template <class T> friend class Handle; |
3504 template <class T> friend class Local; | 3517 template <class T> friend class Local; |
3505 template <class T> friend class Persistent; | 3518 template <class T> friend class Persistent; |
3506 friend class Context; | 3519 friend class Context; |
3507 }; | 3520 }; |
3508 | 3521 |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4230 | 4243 |
4231 | 4244 |
4232 template <class T> | 4245 template <class T> |
4233 bool Persistent<T>::IsWeak() const { | 4246 bool Persistent<T>::IsWeak() const { |
4234 if (this->IsEmpty()) return false; | 4247 if (this->IsEmpty()) return false; |
4235 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); | 4248 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); |
4236 } | 4249 } |
4237 | 4250 |
4238 | 4251 |
4239 template <class T> | 4252 template <class T> |
| 4253 bool Persistent<T>::IsWeak(Isolate* isolate) const { |
| 4254 if (this->IsEmpty()) return false; |
| 4255 return V8::IsGlobalWeak(reinterpret_cast<internal::Isolate*>(isolate), |
| 4256 reinterpret_cast<internal::Object**>(**this)); |
| 4257 } |
| 4258 |
| 4259 |
| 4260 template <class T> |
4240 void Persistent<T>::Dispose() { | 4261 void Persistent<T>::Dispose() { |
4241 if (this->IsEmpty()) return; | 4262 if (this->IsEmpty()) return; |
4242 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); | 4263 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); |
4243 } | 4264 } |
4244 | 4265 |
4245 | 4266 |
4246 template <class T> | 4267 template <class T> |
4247 Persistent<T>::Persistent() : Handle<T>() { } | 4268 Persistent<T>::Persistent() : Handle<T>() { } |
4248 | 4269 |
4249 template <class T> | 4270 template <class T> |
4250 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { | 4271 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { |
4251 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), | 4272 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), |
4252 parameters, | 4273 parameters, |
4253 callback); | 4274 callback); |
4254 } | 4275 } |
4255 | 4276 |
4256 template <class T> | 4277 template <class T> |
| 4278 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, |
| 4279 WeakReferenceCallback callback) { |
| 4280 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), |
| 4281 reinterpret_cast<internal::Object**>(**this), |
| 4282 parameters, |
| 4283 callback); |
| 4284 } |
| 4285 |
| 4286 template <class T> |
4257 void Persistent<T>::ClearWeak() { | 4287 void Persistent<T>::ClearWeak() { |
4258 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); | 4288 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); |
4259 } | 4289 } |
4260 | 4290 |
4261 template <class T> | 4291 template <class T> |
4262 void Persistent<T>::MarkIndependent() { | 4292 void Persistent<T>::MarkIndependent() { |
4263 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | 4293 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); |
4264 } | 4294 } |
4265 | 4295 |
4266 template <class T> | 4296 template <class T> |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4696 | 4726 |
4697 | 4727 |
4698 } // namespace v8 | 4728 } // namespace v8 |
4699 | 4729 |
4700 | 4730 |
4701 #undef V8EXPORT | 4731 #undef V8EXPORT |
4702 #undef TYPE_CHECK | 4732 #undef TYPE_CHECK |
4703 | 4733 |
4704 | 4734 |
4705 #endif // V8_H_ | 4735 #endif // V8_H_ |
OLD | NEW |