Chromium Code Reviews

Side by Side Diff: include/v8.h

Issue 14007008: New GC APIs, try 2. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Renaming. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | include/v8-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...)
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...)
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,
yurys 2013/04/23 15:25:15 I've just realized that this change will affect he
marja 2013/04/23 16:08:52 For implicit references which are not about event
3160 const Persistent<Value>& object);
3161
3113 private: 3162 private:
3114 Isolate(); 3163 Isolate();
3115 Isolate(const Isolate&); 3164 Isolate(const Isolate&);
3116 ~Isolate(); 3165 ~Isolate();
3117 Isolate& operator=(const Isolate&); 3166 Isolate& operator=(const Isolate&);
3118 void* operator new(size_t size); 3167 void* operator new(size_t size);
3119 void operator delete(void*, size_t); 3168 void operator delete(void*, size_t);
3120 }; 3169 };
3121 3170
3122 3171
(...skipping 384 matching lines...)
3507 * object in the group is alive, all objects in the group are alive. 3556 * object in the group is alive, all objects in the group are alive.
3508 * After each garbage collection, object groups are removed. It is 3557 * After each garbage collection, object groups are removed. It is
3509 * intended to be used in the before-garbage-collection callback 3558 * intended to be used in the before-garbage-collection callback
3510 * function, for instance to simulate DOM tree connections among JS 3559 * function, for instance to simulate DOM tree connections among JS
3511 * wrapper objects. Object groups for all dependent handles need to 3560 * wrapper objects. Object groups for all dependent handles need to
3512 * be provided for kGCTypeMarkSweepCompact collections, for all other 3561 * be provided for kGCTypeMarkSweepCompact collections, for all other
3513 * garbage collection types it is sufficient to provide object groups 3562 * garbage collection types it is sufficient to provide object groups
3514 * for partially dependent handles only. 3563 * for partially dependent handles only.
3515 * See v8-profiler.h for RetainedObjectInfo interface description. 3564 * See v8-profiler.h for RetainedObjectInfo interface description.
3516 */ 3565 */
3566 // TODO(marja): deprecate AddObjectGroup. Use Isolate::SetObjectGroupId and
3567 // HeapProfiler::SetRetainedObjectInfo instead.
3517 static void AddObjectGroup(Persistent<Value>* objects, 3568 static void AddObjectGroup(Persistent<Value>* objects,
3518 size_t length, 3569 size_t length,
3519 RetainedObjectInfo* info = NULL); 3570 RetainedObjectInfo* info = NULL);
3520 static void AddObjectGroup(Isolate* isolate, 3571 static void AddObjectGroup(Isolate* isolate,
3521 Persistent<Value>* objects, 3572 Persistent<Value>* objects,
3522 size_t length, 3573 size_t length,
3523 RetainedObjectInfo* info = NULL); 3574 RetainedObjectInfo* info = NULL);
3524 3575
3525 /** 3576 /**
3526 * Allows the host application to declare implicit references between 3577 * Allows the host application to declare implicit references between
3527 * the objects: if |parent| is alive, all |children| are alive too. 3578 * the objects: if |parent| is alive, all |children| are alive too.
3528 * After each garbage collection, all implicit references 3579 * After each garbage collection, all implicit references
3529 * are removed. It is intended to be used in the before-garbage-collection 3580 * are removed. It is intended to be used in the before-garbage-collection
3530 * callback function. 3581 * callback function.
3531 */ 3582 */
3583 // TODO(marja): Deprecate AddImplicitReferences. Use
3584 // Isolate::SetReferenceFromGroup instead.
3532 static void AddImplicitReferences(Persistent<Object> parent, 3585 static void AddImplicitReferences(Persistent<Object> parent,
3533 Persistent<Value>* children, 3586 Persistent<Value>* children,
3534 size_t length); 3587 size_t length);
3535 3588
3536 /** 3589 /**
3537 * Initializes from snapshot if possible. Otherwise, attempts to 3590 * Initializes from snapshot if possible. Otherwise, attempts to
3538 * initialize from scratch. This function is called implicitly if 3591 * initialize from scratch. This function is called implicitly if
3539 * you use the API without calling it first. 3592 * you use the API without calling it first.
3540 */ 3593 */
3541 static bool Initialize(); 3594 static bool Initialize();
(...skipping 1595 matching lines...)
5137 5190
5138 5191
5139 } // namespace v8 5192 } // namespace v8
5140 5193
5141 5194
5142 #undef V8EXPORT 5195 #undef V8EXPORT
5143 #undef TYPE_CHECK 5196 #undef TYPE_CHECK
5144 5197
5145 5198
5146 #endif // V8_H_ 5199 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | include/v8-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine