| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 template <class T> class Persistent; | 137 template <class T> class Persistent; |
| 138 | 138 |
| 139 namespace internal { | 139 namespace internal { |
| 140 class Arguments; | 140 class Arguments; |
| 141 class Heap; | 141 class Heap; |
| 142 class HeapObject; | 142 class HeapObject; |
| 143 class Isolate; | 143 class Isolate; |
| 144 class Object; | 144 class Object; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Generic-purpose unique identifier. | |
| 148 class UniqueId { | |
| 149 public: | |
| 150 explicit UniqueId(intptr_t data) | |
| 151 : data_(data) {} | |
| 152 | |
| 153 bool operator==(const UniqueId& other) const { | |
| 154 return data_ == other.data_; | |
| 155 } | |
| 156 | |
| 157 bool operator!=(const UniqueId& other) const { | |
| 158 return data_ != other.data_; | |
| 159 } | |
| 160 | |
| 161 bool operator<(const UniqueId& other) const { | |
| 162 return data_ < other.data_; | |
| 163 } | |
| 164 | |
| 165 private: | |
| 166 intptr_t data_; | |
| 167 }; | |
| 168 | |
| 169 | 147 |
| 170 // --- Weak Handles --- | 148 // --- Weak Handles --- |
| 171 | 149 |
| 172 | 150 |
| 173 /** | 151 /** |
| 174 * A weak reference callback function. | 152 * A weak reference callback function. |
| 175 * | 153 * |
| 176 * This callback should either explicitly invoke Dispose on |object| if | 154 * This callback should either explicitly invoke Dispose on |object| if |
| 177 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. | 155 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. |
| 178 * | 156 * |
| (...skipping 3350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3529 * object in the group is alive, all objects in the group are alive. | 3507 * object in the group is alive, all objects in the group are alive. |
| 3530 * After each garbage collection, object groups are removed. It is | 3508 * After each garbage collection, object groups are removed. It is |
| 3531 * intended to be used in the before-garbage-collection callback | 3509 * intended to be used in the before-garbage-collection callback |
| 3532 * function, for instance to simulate DOM tree connections among JS | 3510 * function, for instance to simulate DOM tree connections among JS |
| 3533 * wrapper objects. Object groups for all dependent handles need to | 3511 * wrapper objects. Object groups for all dependent handles need to |
| 3534 * be provided for kGCTypeMarkSweepCompact collections, for all other | 3512 * be provided for kGCTypeMarkSweepCompact collections, for all other |
| 3535 * garbage collection types it is sufficient to provide object groups | 3513 * garbage collection types it is sufficient to provide object groups |
| 3536 * for partially dependent handles only. | 3514 * for partially dependent handles only. |
| 3537 * See v8-profiler.h for RetainedObjectInfo interface description. | 3515 * See v8-profiler.h for RetainedObjectInfo interface description. |
| 3538 */ | 3516 */ |
| 3539 // TODO(marja): deprecate AddObjectGroup. Use SetObjectGroupID and | |
| 3540 // SetRetainedObjectInfo instead. | |
| 3541 static void AddObjectGroup(Persistent<Value>* objects, | 3517 static void AddObjectGroup(Persistent<Value>* objects, |
| 3542 size_t length, | 3518 size_t length, |
| 3543 RetainedObjectInfo* info = NULL); | 3519 RetainedObjectInfo* info = NULL); |
| 3544 static void AddObjectGroup(Isolate* isolate, | 3520 static void AddObjectGroup(Isolate* isolate, |
| 3545 Persistent<Value>* objects, | 3521 Persistent<Value>* objects, |
| 3546 size_t length, | 3522 size_t length, |
| 3547 RetainedObjectInfo* info = NULL); | 3523 RetainedObjectInfo* info = NULL); |
| 3548 | 3524 |
| 3549 static void SetObjectGroupId(Isolate* isolate, | |
| 3550 const Persistent<Value>& object, | |
| 3551 UniqueId id); | |
| 3552 | |
| 3553 static void SetRetainedObjectInfo(Isolate* isolate, | |
| 3554 UniqueId id, | |
| 3555 RetainedObjectInfo* info); | |
| 3556 | |
| 3557 /** | |
| 3558 * Sets a representative object to a group. Used in conjunction with implicit | |
| 3559 * references: If you're going to use AddImplicitReference with the group, you | |
| 3560 * need to set a representative object too. | |
| 3561 */ | |
| 3562 static void SetObjectGroupRepresentative(Isolate* isolate, | |
| 3563 UniqueId id, | |
| 3564 const Persistent<Object>& object); | |
| 3565 | |
| 3566 /** | 3525 /** |
| 3567 * Allows the host application to declare implicit references between | 3526 * Allows the host application to declare implicit references between |
| 3568 * the objects: if |parent| is alive, all |children| are alive too. | 3527 * the objects: if |parent| is alive, all |children| are alive too. |
| 3569 * After each garbage collection, all implicit references | 3528 * After each garbage collection, all implicit references |
| 3570 * are removed. It is intended to be used in the before-garbage-collection | 3529 * are removed. It is intended to be used in the before-garbage-collection |
| 3571 * callback function. | 3530 * callback function. |
| 3572 */ | 3531 */ |
| 3573 // TODO(marja): Deprecate AddImplicitReferences. Use | |
| 3574 // SetObjectGroupRepresentativeObject and AddImplicitReference instead. | |
| 3575 static void AddImplicitReferences(Persistent<Object> parent, | 3532 static void AddImplicitReferences(Persistent<Object> parent, |
| 3576 Persistent<Value>* children, | 3533 Persistent<Value>* children, |
| 3577 size_t length); | 3534 size_t length); |
| 3578 | 3535 |
| 3579 /** | 3536 /** |
| 3580 * Allows the host application to declare implicit references. If the | |
| 3581 * representative object of the object group (identified by id) is alive, the | |
| 3582 * children are alive too. After each garbage collection, all implicit | |
| 3583 * references are removed. It is intended to be used in the | |
| 3584 * before-garbage-collection callback function. | |
| 3585 */ | |
| 3586 static void AddImplicitReference(Isolate* isolate, | |
| 3587 UniqueId id, | |
| 3588 const Persistent<Value>& object); | |
| 3589 | |
| 3590 /** | |
| 3591 * Initializes from snapshot if possible. Otherwise, attempts to | 3537 * Initializes from snapshot if possible. Otherwise, attempts to |
| 3592 * initialize from scratch. This function is called implicitly if | 3538 * initialize from scratch. This function is called implicitly if |
| 3593 * you use the API without calling it first. | 3539 * you use the API without calling it first. |
| 3594 */ | 3540 */ |
| 3595 static bool Initialize(); | 3541 static bool Initialize(); |
| 3596 | 3542 |
| 3597 /** | 3543 /** |
| 3598 * Allows the host application to provide a callback which can be used | 3544 * Allows the host application to provide a callback which can be used |
| 3599 * as a source of entropy for random number generators. | 3545 * as a source of entropy for random number generators. |
| 3600 */ | 3546 */ |
| (...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5191 | 5137 |
| 5192 | 5138 |
| 5193 } // namespace v8 | 5139 } // namespace v8 |
| 5194 | 5140 |
| 5195 | 5141 |
| 5196 #undef V8EXPORT | 5142 #undef V8EXPORT |
| 5197 #undef TYPE_CHECK | 5143 #undef TYPE_CHECK |
| 5198 | 5144 |
| 5199 | 5145 |
| 5200 #endif // V8_H_ | 5146 #endif // V8_H_ |
| OLD | NEW |