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. If the objects | |
3154 * of the object group are alive, the children are alive too. After each | |
3155 * garbage collection, all implicit references are removed. It is intended to | |
3156 * be used in the before-garbage-collection callback function. | |
3157 */ | |
3158 void AddImplicitReference(UniqueId id, | |
yurys
2013/04/22 14:39:54
Method name is a bit confusing. May be SetReferenc
marja
2013/04/23 12:00:05
Done.
| |
3159 const Persistent<Value>& object); | |
3160 | |
3113 private: | 3161 private: |
3114 Isolate(); | 3162 Isolate(); |
3115 Isolate(const Isolate&); | 3163 Isolate(const Isolate&); |
3116 ~Isolate(); | 3164 ~Isolate(); |
3117 Isolate& operator=(const Isolate&); | 3165 Isolate& operator=(const Isolate&); |
3118 void* operator new(size_t size); | 3166 void* operator new(size_t size); |
3119 void operator delete(void*, size_t); | 3167 void operator delete(void*, size_t); |
3120 }; | 3168 }; |
3121 | 3169 |
3122 | 3170 |
(...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. | 3555 * object in the group is alive, all objects in the group are alive. |
3508 * After each garbage collection, object groups are removed. It is | 3556 * After each garbage collection, object groups are removed. It is |
3509 * intended to be used in the before-garbage-collection callback | 3557 * intended to be used in the before-garbage-collection callback |
3510 * function, for instance to simulate DOM tree connections among JS | 3558 * function, for instance to simulate DOM tree connections among JS |
3511 * wrapper objects. Object groups for all dependent handles need to | 3559 * wrapper objects. Object groups for all dependent handles need to |
3512 * be provided for kGCTypeMarkSweepCompact collections, for all other | 3560 * be provided for kGCTypeMarkSweepCompact collections, for all other |
3513 * garbage collection types it is sufficient to provide object groups | 3561 * garbage collection types it is sufficient to provide object groups |
3514 * for partially dependent handles only. | 3562 * for partially dependent handles only. |
3515 * See v8-profiler.h for RetainedObjectInfo interface description. | 3563 * See v8-profiler.h for RetainedObjectInfo interface description. |
3516 */ | 3564 */ |
3565 // TODO(marja): deprecate AddObjectGroup. Use Isolate::SetObjectGroupId and | |
3566 // HeapProfiler::SetRetainedObjectInfo instead. | |
3517 static void AddObjectGroup(Persistent<Value>* objects, | 3567 static void AddObjectGroup(Persistent<Value>* objects, |
3518 size_t length, | 3568 size_t length, |
3519 RetainedObjectInfo* info = NULL); | 3569 RetainedObjectInfo* info = NULL); |
3520 static void AddObjectGroup(Isolate* isolate, | 3570 static void AddObjectGroup(Isolate* isolate, |
3521 Persistent<Value>* objects, | 3571 Persistent<Value>* objects, |
3522 size_t length, | 3572 size_t length, |
3523 RetainedObjectInfo* info = NULL); | 3573 RetainedObjectInfo* info = NULL); |
3524 | 3574 |
3525 /** | 3575 /** |
3526 * Allows the host application to declare implicit references between | 3576 * Allows the host application to declare implicit references between |
3527 * the objects: if |parent| is alive, all |children| are alive too. | 3577 * the objects: if |parent| is alive, all |children| are alive too. |
3528 * After each garbage collection, all implicit references | 3578 * After each garbage collection, all implicit references |
3529 * are removed. It is intended to be used in the before-garbage-collection | 3579 * are removed. It is intended to be used in the before-garbage-collection |
3530 * callback function. | 3580 * callback function. |
3531 */ | 3581 */ |
3582 // TODO(marja): Deprecate AddImplicitReferences. Use | |
3583 // Isolate::AddImplicitReference instead. | |
3532 static void AddImplicitReferences(Persistent<Object> parent, | 3584 static void AddImplicitReferences(Persistent<Object> parent, |
3533 Persistent<Value>* children, | 3585 Persistent<Value>* children, |
3534 size_t length); | 3586 size_t length); |
3535 | 3587 |
3536 /** | 3588 /** |
3537 * Initializes from snapshot if possible. Otherwise, attempts to | 3589 * Initializes from snapshot if possible. Otherwise, attempts to |
3538 * initialize from scratch. This function is called implicitly if | 3590 * initialize from scratch. This function is called implicitly if |
3539 * you use the API without calling it first. | 3591 * you use the API without calling it first. |
3540 */ | 3592 */ |
3541 static bool Initialize(); | 3593 static bool Initialize(); |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5137 | 5189 |
5138 | 5190 |
5139 } // namespace v8 | 5191 } // namespace v8 |
5140 | 5192 |
5141 | 5193 |
5142 #undef V8EXPORT | 5194 #undef V8EXPORT |
5143 #undef TYPE_CHECK | 5195 #undef TYPE_CHECK |
5144 | 5196 |
5145 | 5197 |
5146 #endif // V8_H_ | 5198 #endif // V8_H_ |
OLD | NEW |