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. | |
Michael Starzinger
2013/04/22 11:34:51
nit: Can we turn that into a Doxygen comment (i.e.
marja
2013/04/22 13:49:07
Done.
| |
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 | |
147 | 169 |
148 // --- Weak Handles --- | 170 // --- Weak Handles --- |
149 | 171 |
150 | 172 |
151 /** | 173 /** |
152 * A weak reference callback function. | 174 * A weak reference callback function. |
153 * | 175 * |
154 * This callback should either explicitly invoke Dispose on |object| if | 176 * This callback should either explicitly invoke Dispose on |object| if |
155 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. | 177 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. |
156 * | 178 * |
(...skipping 3350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3507 * object in the group is alive, all objects in the group are alive. | 3529 * object in the group is alive, all objects in the group are alive. |
3508 * After each garbage collection, object groups are removed. It is | 3530 * After each garbage collection, object groups are removed. It is |
3509 * intended to be used in the before-garbage-collection callback | 3531 * intended to be used in the before-garbage-collection callback |
3510 * function, for instance to simulate DOM tree connections among JS | 3532 * function, for instance to simulate DOM tree connections among JS |
3511 * wrapper objects. Object groups for all dependent handles need to | 3533 * wrapper objects. Object groups for all dependent handles need to |
3512 * be provided for kGCTypeMarkSweepCompact collections, for all other | 3534 * be provided for kGCTypeMarkSweepCompact collections, for all other |
3513 * garbage collection types it is sufficient to provide object groups | 3535 * garbage collection types it is sufficient to provide object groups |
3514 * for partially dependent handles only. | 3536 * for partially dependent handles only. |
3515 * See v8-profiler.h for RetainedObjectInfo interface description. | 3537 * See v8-profiler.h for RetainedObjectInfo interface description. |
3516 */ | 3538 */ |
3539 // TODO(marja): deprecate AddObjectGroup. Use SetObjectGroupId and | |
3540 // SetRetainedObjectInfo instead. | |
3517 static void AddObjectGroup(Persistent<Value>* objects, | 3541 static void AddObjectGroup(Persistent<Value>* objects, |
3518 size_t length, | 3542 size_t length, |
3519 RetainedObjectInfo* info = NULL); | 3543 RetainedObjectInfo* info = NULL); |
3520 static void AddObjectGroup(Isolate* isolate, | 3544 static void AddObjectGroup(Isolate* isolate, |
3521 Persistent<Value>* objects, | 3545 Persistent<Value>* objects, |
3522 size_t length, | 3546 size_t length, |
3523 RetainedObjectInfo* info = NULL); | 3547 RetainedObjectInfo* info = NULL); |
3524 | 3548 |
3549 static void SetObjectGroupId(Isolate* isolate, | |
yurys
2013/04/22 12:10:43
Since these methods are new why not make them inst
marja
2013/04/22 13:49:07
Done.
| |
3550 const Persistent<Value>& object, | |
3551 UniqueId id); | |
3552 | |
3553 static void SetRetainedObjectInfo(Isolate* isolate, | |
yurys
2013/04/22 12:05:46
As discussed offline, this method should be on v8:
marja
2013/04/22 13:49:07
Done.
| |
3554 UniqueId id, | |
3555 RetainedObjectInfo* info); | |
3556 | |
3525 /** | 3557 /** |
3526 * Allows the host application to declare implicit references between | 3558 * Allows the host application to declare implicit references between |
3527 * the objects: if |parent| is alive, all |children| are alive too. | 3559 * the objects: if |parent| is alive, all |children| are alive too. |
3528 * After each garbage collection, all implicit references | 3560 * After each garbage collection, all implicit references |
3529 * are removed. It is intended to be used in the before-garbage-collection | 3561 * are removed. It is intended to be used in the before-garbage-collection |
3530 * callback function. | 3562 * callback function. |
3531 */ | 3563 */ |
3564 // TODO(marja): Deprecate AddImplicitReferences. Use AddImplicitReference | |
3565 // instead. | |
3532 static void AddImplicitReferences(Persistent<Object> parent, | 3566 static void AddImplicitReferences(Persistent<Object> parent, |
3533 Persistent<Value>* children, | 3567 Persistent<Value>* children, |
3534 size_t length); | 3568 size_t length); |
3535 | 3569 |
3536 /** | 3570 /** |
3571 * Allows the host application to declare implicit references. If the | |
3572 * representative object of the object group (identified by id) is alive, the | |
3573 * children are alive too. After each garbage collection, all implicit | |
3574 * references are removed. It is intended to be used in the | |
3575 * before-garbage-collection callback function. | |
3576 */ | |
3577 static void AddImplicitReference(Isolate* isolate, | |
3578 UniqueId id, | |
3579 const Persistent<Value>& object); | |
3580 | |
3581 /** | |
3537 * Initializes from snapshot if possible. Otherwise, attempts to | 3582 * Initializes from snapshot if possible. Otherwise, attempts to |
3538 * initialize from scratch. This function is called implicitly if | 3583 * initialize from scratch. This function is called implicitly if |
3539 * you use the API without calling it first. | 3584 * you use the API without calling it first. |
3540 */ | 3585 */ |
3541 static bool Initialize(); | 3586 static bool Initialize(); |
3542 | 3587 |
3543 /** | 3588 /** |
3544 * Allows the host application to provide a callback which can be used | 3589 * Allows the host application to provide a callback which can be used |
3545 * as a source of entropy for random number generators. | 3590 * as a source of entropy for random number generators. |
3546 */ | 3591 */ |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5137 | 5182 |
5138 | 5183 |
5139 } // namespace v8 | 5184 } // namespace v8 |
5140 | 5185 |
5141 | 5186 |
5142 #undef V8EXPORT | 5187 #undef V8EXPORT |
5143 #undef TYPE_CHECK | 5188 #undef TYPE_CHECK |
5144 | 5189 |
5145 | 5190 |
5146 #endif // V8_H_ | 5191 #endif // V8_H_ |
OLD | NEW |