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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 147 |
| 148 /** |
| 149 * General purpose unique identifier. |
| 150 */ |
| 151 class UniqueId { |
| 152 public: |
| 153 explicit UniqueId(intptr_t data) |
| 154 : data_(data) {} |
| 155 |
| 156 bool operator==(const UniqueId& other) const { |
| 157 return data_ == other.data_; |
| 158 } |
| 159 |
| 160 bool operator!=(const UniqueId& other) const { |
| 161 return data_ != other.data_; |
| 162 } |
| 163 |
| 164 bool operator<(const UniqueId& other) const { |
| 165 return data_ < other.data_; |
| 166 } |
| 167 |
| 168 private: |
| 169 intptr_t data_; |
| 170 }; |
| 171 |
| 172 |
148 // --- Weak Handles --- | 173 // --- Weak Handles --- |
149 | 174 |
150 | 175 |
151 /** | 176 /** |
152 * A weak reference callback function. | 177 * A weak reference callback function. |
153 * | 178 * |
154 * This callback should either explicitly invoke Dispose on |object| if | 179 * This callback should either explicitly invoke Dispose on |object| if |
155 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. | 180 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. |
156 * | 181 * |
157 * \param object the weak global object to be reclaimed by the garbage collector | 182 * \param object the weak global object to be reclaimed by the garbage collector |
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3103 | 3128 |
3104 /** | 3129 /** |
3105 * Returns CPU profiler for this isolate. Will return NULL until the isolate | 3130 * Returns CPU profiler for this isolate. Will return NULL until the isolate |
3106 * is initialized. | 3131 * is initialized. |
3107 */ | 3132 */ |
3108 CpuProfiler* GetCpuProfiler(); | 3133 CpuProfiler* GetCpuProfiler(); |
3109 | 3134 |
3110 /** Returns the context that is on the top of the stack. */ | 3135 /** Returns the context that is on the top of the stack. */ |
3111 Local<Context> GetCurrentContext(); | 3136 Local<Context> GetCurrentContext(); |
3112 | 3137 |
| 3138 /** |
| 3139 * Allows the host application to group objects together. If one |
| 3140 * object in the group is alive, all objects in the group are alive. |
| 3141 * After each garbage collection, object groups are removed. It is |
| 3142 * intended to be used in the before-garbage-collection callback |
| 3143 * function, for instance to simulate DOM tree connections among JS |
| 3144 * wrapper objects. Object groups for all dependent handles need to |
| 3145 * be provided for kGCTypeMarkSweepCompact collections, for all other |
| 3146 * garbage collection types it is sufficient to provide object groups |
| 3147 * for partially dependent handles only. |
| 3148 */ |
| 3149 void SetObjectGroupId(const Persistent<Value>& object, |
| 3150 UniqueId id); |
| 3151 |
| 3152 /** |
| 3153 * Allows the host application to declare implicit references from an object |
| 3154 * group to an object. If the objects of the object group are alive, the child |
| 3155 * object is alive too. After each garbage collection, all implicit references |
| 3156 * are removed. It is intended to be used in the before-garbage-collection |
| 3157 * callback function. |
| 3158 */ |
| 3159 void SetReferenceFromGroup(UniqueId id, |
| 3160 const Persistent<Value>& child); |
| 3161 |
| 3162 /** |
| 3163 * Allows the host application to declare implicit references from an object |
| 3164 * to another object. If the parent object is alive, the child object is alive |
| 3165 * too. After each garbage collection, all implicit references are removed. It |
| 3166 * is intended to be used in the before-garbage-collection callback function. |
| 3167 */ |
| 3168 void SetReference(const Persistent<Object>& parent, |
| 3169 const Persistent<Value>& child); |
| 3170 |
3113 private: | 3171 private: |
3114 Isolate(); | 3172 Isolate(); |
3115 Isolate(const Isolate&); | 3173 Isolate(const Isolate&); |
3116 ~Isolate(); | 3174 ~Isolate(); |
3117 Isolate& operator=(const Isolate&); | 3175 Isolate& operator=(const Isolate&); |
3118 void* operator new(size_t size); | 3176 void* operator new(size_t size); |
3119 void operator delete(void*, size_t); | 3177 void operator delete(void*, size_t); |
3120 }; | 3178 }; |
3121 | 3179 |
3122 | 3180 |
(...skipping 384 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. | 3565 * object in the group is alive, all objects in the group are alive. |
3508 * After each garbage collection, object groups are removed. It is | 3566 * After each garbage collection, object groups are removed. It is |
3509 * intended to be used in the before-garbage-collection callback | 3567 * intended to be used in the before-garbage-collection callback |
3510 * function, for instance to simulate DOM tree connections among JS | 3568 * function, for instance to simulate DOM tree connections among JS |
3511 * wrapper objects. Object groups for all dependent handles need to | 3569 * wrapper objects. Object groups for all dependent handles need to |
3512 * be provided for kGCTypeMarkSweepCompact collections, for all other | 3570 * be provided for kGCTypeMarkSweepCompact collections, for all other |
3513 * garbage collection types it is sufficient to provide object groups | 3571 * garbage collection types it is sufficient to provide object groups |
3514 * for partially dependent handles only. | 3572 * for partially dependent handles only. |
3515 * See v8-profiler.h for RetainedObjectInfo interface description. | 3573 * See v8-profiler.h for RetainedObjectInfo interface description. |
3516 */ | 3574 */ |
| 3575 // TODO(marja): deprecate AddObjectGroup. Use Isolate::SetObjectGroupId and |
| 3576 // HeapProfiler::SetRetainedObjectInfo instead. |
3517 static void AddObjectGroup(Persistent<Value>* objects, | 3577 static void AddObjectGroup(Persistent<Value>* objects, |
3518 size_t length, | 3578 size_t length, |
3519 RetainedObjectInfo* info = NULL); | 3579 RetainedObjectInfo* info = NULL); |
3520 static void AddObjectGroup(Isolate* isolate, | 3580 static void AddObjectGroup(Isolate* isolate, |
3521 Persistent<Value>* objects, | 3581 Persistent<Value>* objects, |
3522 size_t length, | 3582 size_t length, |
3523 RetainedObjectInfo* info = NULL); | 3583 RetainedObjectInfo* info = NULL); |
3524 | 3584 |
3525 /** | 3585 /** |
3526 * Allows the host application to declare implicit references between | 3586 * Allows the host application to declare implicit references between |
3527 * the objects: if |parent| is alive, all |children| are alive too. | 3587 * the objects: if |parent| is alive, all |children| are alive too. |
3528 * After each garbage collection, all implicit references | 3588 * After each garbage collection, all implicit references |
3529 * are removed. It is intended to be used in the before-garbage-collection | 3589 * are removed. It is intended to be used in the before-garbage-collection |
3530 * callback function. | 3590 * callback function. |
3531 */ | 3591 */ |
| 3592 // TODO(marja): Deprecate AddImplicitReferences. Use |
| 3593 // Isolate::SetReferenceFromGroup instead. |
3532 static void AddImplicitReferences(Persistent<Object> parent, | 3594 static void AddImplicitReferences(Persistent<Object> parent, |
3533 Persistent<Value>* children, | 3595 Persistent<Value>* children, |
3534 size_t length); | 3596 size_t length); |
3535 | 3597 |
3536 /** | 3598 /** |
3537 * Initializes from snapshot if possible. Otherwise, attempts to | 3599 * Initializes from snapshot if possible. Otherwise, attempts to |
3538 * initialize from scratch. This function is called implicitly if | 3600 * initialize from scratch. This function is called implicitly if |
3539 * you use the API without calling it first. | 3601 * you use the API without calling it first. |
3540 */ | 3602 */ |
3541 static bool Initialize(); | 3603 static bool Initialize(); |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5137 | 5199 |
5138 | 5200 |
5139 } // namespace v8 | 5201 } // namespace v8 |
5140 | 5202 |
5141 | 5203 |
5142 #undef V8EXPORT | 5204 #undef V8EXPORT |
5143 #undef TYPE_CHECK | 5205 #undef TYPE_CHECK |
5144 | 5206 |
5145 | 5207 |
5146 #endif // V8_H_ | 5208 #endif // V8_H_ |
OLD | NEW |