Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: include/v8.h

Issue 1298113003: [api,heap] Fix external GC callbacks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Got rid of too many V8::Type vs Isolate::Type casts Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/heap/heap.cc » ('J')
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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 4933 matching lines...) Expand 10 before | Expand all | Expand 10 after
4944 4944
4945 /** 4945 /**
4946 * Callback to check if code generation from strings is allowed. See 4946 * Callback to check if code generation from strings is allowed. See
4947 * Context::AllowCodeGenerationFromStrings. 4947 * Context::AllowCodeGenerationFromStrings.
4948 */ 4948 */
4949 typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context); 4949 typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context);
4950 4950
4951 // --- Garbage Collection Callbacks --- 4951 // --- Garbage Collection Callbacks ---
4952 4952
4953 /** 4953 /**
4954 * Applications can register callback functions which will be called 4954 * Applications can register callback functions which will be called before and
4955 * before and after a garbage collection. Allocations are not 4955 * after certain garbage collection operations. Allocations are not allowed in
4956 * allowed in the callback functions, you therefore cannot manipulate 4956 * the callback functions, you therefore cannot manipulate objects (set or
4957 * objects (set or delete properties for example) since it is possible 4957 * delete properties for example) since it is possible such operations will
4958 * such operations will result in the allocation of objects. 4958 * result in the allocation of objects.
4959 */ 4959 */
4960 enum GCType { 4960 enum GCType {
4961 kGCTypeScavenge = 1 << 0, 4961 kGCTypeScavenge = 1 << 0,
4962 kGCTypeMarkSweepCompact = 1 << 1, 4962 kGCTypeMarkSweepCompact = 1 << 1,
4963 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact 4963 kGCTypeIncrementalMarking = 1 << 2,
4964 kGCTypeProcessWeakCallbacks = 1 << 3,
4965 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact |
4966 kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks
4964 }; 4967 };
4965 4968
4966 enum GCCallbackFlags { 4969 enum GCCallbackFlags {
4967 kNoGCCallbackFlags = 0, 4970 kNoGCCallbackFlags = 0,
4968 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1, 4971 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
4969 kGCCallbackFlagForced = 1 << 2, 4972 kGCCallbackFlagForced = 1 << 2,
4970 kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3 4973 kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3
4971 }; 4974 };
4972 4975
4973 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); 4976 V8_DEPRECATE_SOON("Use GCCallBack instead",
4974 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); 4977 typedef void (*GCPrologueCallback)(GCType type,
4978 GCCallbackFlags flags));
4979 V8_DEPRECATE_SOON("Use GCCallBack instead",
4980 typedef void (*GCEpilogueCallback)(GCType type,
4981 GCCallbackFlags flags));
4982 typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
4975 4983
4976 typedef void (*InterruptCallback)(Isolate* isolate, void* data); 4984 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
4977 4985
4978 4986
4979 /** 4987 /**
4980 * Collection of V8 heap information. 4988 * Collection of V8 heap information.
4981 * 4989 *
4982 * Instances of this class can be passed to v8::V8::HeapStatistics to 4990 * Instances of this class can be passed to v8::V8::HeapStatistics to
4983 * get heap statistics from V8. 4991 * get heap statistics from V8.
4984 */ 4992 */
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
5540 5548
5541 /** 5549 /**
5542 * Allows the host application to declare implicit references from an object 5550 * Allows the host application to declare implicit references from an object
5543 * to another object. If the parent object is alive, the child object is alive 5551 * to another object. If the parent object is alive, the child object is alive
5544 * too. After each garbage collection, all implicit references are removed. It 5552 * too. After each garbage collection, all implicit references are removed. It
5545 * is intended to be used in the before-garbage-collection callback function. 5553 * is intended to be used in the before-garbage-collection callback function.
5546 */ 5554 */
5547 template<typename T, typename S> 5555 template<typename T, typename S>
5548 void SetReference(const Persistent<T>& parent, const Persistent<S>& child); 5556 void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
5549 5557
5550 typedef void (*GCPrologueCallback)(Isolate* isolate, 5558 V8_DEPRECATE_SOON("Use GCCallBack instead",
5551 GCType type, 5559 typedef void (*GCPrologueCallback)(Isolate* isolate,
5552 GCCallbackFlags flags); 5560 GCType type,
5553 typedef void (*GCEpilogueCallback)(Isolate* isolate, 5561 GCCallbackFlags flags));
5554 GCType type, 5562 V8_DEPRECATE_SOON("Use GCCallBack instead",
5555 GCCallbackFlags flags); 5563 typedef void (*GCEpilogueCallback)(Isolate* isolate,
5564 GCType type,
5565 GCCallbackFlags flags));
5566 typedef void (*GCCallback)(Isolate* isolate, GCType type,
5567 GCCallbackFlags flags);
5556 5568
5557 /** 5569 /**
5558 * Enables the host application to receive a notification before a 5570 * Enables the host application to receive a notification before a
5559 * garbage collection. Allocations are allowed in the callback function, 5571 * garbage collection. Allocations are allowed in the callback function,
5560 * but the callback is not re-entrant: if the allocation inside it will 5572 * but the callback is not re-entrant: if the allocation inside it will
5561 * trigger the garbage collection, the callback won't be called again. 5573 * trigger the garbage collection, the callback won't be called again.
5562 * It is possible to specify the GCType filter for your callback. But it is 5574 * It is possible to specify the GCType filter for your callback. But it is
5563 * not possible to register the same callback function two times with 5575 * not possible to register the same callback function two times with
5564 * different GCType filters. 5576 * different GCType filters.
5565 */ 5577 */
5566 void AddGCPrologueCallback( 5578 void AddGCPrologueCallback(GCCallback callback,
5567 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); 5579 GCType gc_type_filter = kGCTypeAll);
5568 5580
5569 /** 5581 /**
5570 * This function removes callback which was installed by 5582 * This function removes callback which was installed by
5571 * AddGCPrologueCallback function. 5583 * AddGCPrologueCallback function.
5572 */ 5584 */
5573 void RemoveGCPrologueCallback(GCPrologueCallback callback); 5585 void RemoveGCPrologueCallback(GCCallback callback);
5574 5586
5575 /** 5587 /**
5576 * Enables the host application to receive a notification after a 5588 * Enables the host application to receive a notification after a
5577 * garbage collection. Allocations are allowed in the callback function, 5589 * garbage collection. Allocations are allowed in the callback function,
5578 * but the callback is not re-entrant: if the allocation inside it will 5590 * but the callback is not re-entrant: if the allocation inside it will
5579 * trigger the garbage collection, the callback won't be called again. 5591 * trigger the garbage collection, the callback won't be called again.
5580 * It is possible to specify the GCType filter for your callback. But it is 5592 * It is possible to specify the GCType filter for your callback. But it is
5581 * not possible to register the same callback function two times with 5593 * not possible to register the same callback function two times with
5582 * different GCType filters. 5594 * different GCType filters.
5583 */ 5595 */
5584 void AddGCEpilogueCallback( 5596 void AddGCEpilogueCallback(GCCallback callback,
5585 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); 5597 GCType gc_type_filter = kGCTypeAll);
5586 5598
5587 /** 5599 /**
5588 * This function removes callback which was installed by 5600 * This function removes callback which was installed by
5589 * AddGCEpilogueCallback function. 5601 * AddGCEpilogueCallback function.
5590 */ 5602 */
5591 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); 5603 void RemoveGCEpilogueCallback(GCCallback callback);
5592
5593 5604
5594 /** 5605 /**
5595 * Forcefully terminate the current thread of JavaScript execution 5606 * Forcefully terminate the current thread of JavaScript execution
5596 * in the given isolate. 5607 * in the given isolate.
5597 * 5608 *
5598 * This method can be used by any thread even if that thread has not 5609 * This method can be used by any thread even if that thread has not
5599 * acquired the V8 lock with a Locker object. 5610 * acquired the V8 lock with a Locker object.
5600 */ 5611 */
5601 void TerminateExecution(); 5612 void TerminateExecution();
5602 5613
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
6039 * garbage collection. Allocations are not allowed in the 6050 * garbage collection. Allocations are not allowed in the
6040 * callback function, you therefore cannot manipulate objects (set 6051 * callback function, you therefore cannot manipulate objects (set
6041 * or delete properties for example) since it is possible such 6052 * or delete properties for example) since it is possible such
6042 * operations will result in the allocation of objects. It is possible 6053 * operations will result in the allocation of objects. It is possible
6043 * to specify the GCType filter for your callback. But it is not possible to 6054 * to specify the GCType filter for your callback. But it is not possible to
6044 * register the same callback function two times with different 6055 * register the same callback function two times with different
6045 * GCType filters. 6056 * GCType filters.
6046 */ 6057 */
6047 static V8_DEPRECATE_SOON( 6058 static V8_DEPRECATE_SOON(
6048 "Use isolate version", 6059 "Use isolate version",
6049 void AddGCPrologueCallback(GCPrologueCallback callback, 6060 void AddGCPrologueCallback(GCCallback callback,
6050 GCType gc_type_filter = kGCTypeAll)); 6061 GCType gc_type_filter = kGCTypeAll));
6051 6062
6052 /** 6063 /**
6053 * This function removes callback which was installed by 6064 * This function removes callback which was installed by
6054 * AddGCPrologueCallback function. 6065 * AddGCPrologueCallback function.
6055 */ 6066 */
6056 V8_INLINE static V8_DEPRECATE_SOON( 6067 V8_INLINE static V8_DEPRECATE_SOON(
6057 "Use isolate version", 6068 "Use isolate version",
6058 void RemoveGCPrologueCallback(GCPrologueCallback callback)); 6069 void RemoveGCPrologueCallback(GCCallback callback));
6059 6070
6060 /** 6071 /**
6061 * Enables the host application to receive a notification after a 6072 * Enables the host application to receive a notification after a
6062 * garbage collection. Allocations are not allowed in the 6073 * garbage collection. Allocations are not allowed in the
6063 * callback function, you therefore cannot manipulate objects (set 6074 * callback function, you therefore cannot manipulate objects (set
6064 * or delete properties for example) since it is possible such 6075 * or delete properties for example) since it is possible such
6065 * operations will result in the allocation of objects. It is possible 6076 * operations will result in the allocation of objects. It is possible
6066 * to specify the GCType filter for your callback. But it is not possible to 6077 * to specify the GCType filter for your callback. But it is not possible to
6067 * register the same callback function two times with different 6078 * register the same callback function two times with different
6068 * GCType filters. 6079 * GCType filters.
6069 */ 6080 */
6070 static V8_DEPRECATE_SOON( 6081 static V8_DEPRECATE_SOON(
6071 "Use isolate version", 6082 "Use isolate version",
6072 void AddGCEpilogueCallback(GCEpilogueCallback callback, 6083 void AddGCEpilogueCallback(GCCallback callback,
6073 GCType gc_type_filter = kGCTypeAll)); 6084 GCType gc_type_filter = kGCTypeAll));
6074 6085
6075 /** 6086 /**
6076 * This function removes callback which was installed by 6087 * This function removes callback which was installed by
6077 * AddGCEpilogueCallback function. 6088 * AddGCEpilogueCallback function.
6078 */ 6089 */
6079 V8_INLINE static V8_DEPRECATE_SOON( 6090 V8_INLINE static V8_DEPRECATE_SOON(
6080 "Use isolate version", 6091 "Use isolate version",
6081 void RemoveGCEpilogueCallback(GCEpilogueCallback callback)); 6092 void RemoveGCEpilogueCallback(GCCallback callback));
6082 6093
6083 /** 6094 /**
6084 * Enables the host application to provide a mechanism to be notified 6095 * Enables the host application to provide a mechanism to be notified
6085 * and perform custom logging when V8 Allocates Executable Memory. 6096 * and perform custom logging when V8 Allocates Executable Memory.
6086 */ 6097 */
6087 V8_INLINE static V8_DEPRECATE_SOON( 6098 V8_INLINE static V8_DEPRECATE_SOON(
6088 "Use isolate version", 6099 "Use isolate version",
6089 void AddMemoryAllocationCallback(MemoryAllocationCallback callback, 6100 void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
6090 ObjectSpace space, 6101 ObjectSpace space,
6091 AllocationAction action)); 6102 AllocationAction action));
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
8250 options); 8261 options);
8251 } 8262 }
8252 8263
8253 8264
8254 void V8::SetFatalErrorHandler(FatalErrorCallback callback) { 8265 void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
8255 Isolate* isolate = Isolate::GetCurrent(); 8266 Isolate* isolate = Isolate::GetCurrent();
8256 isolate->SetFatalErrorHandler(callback); 8267 isolate->SetFatalErrorHandler(callback);
8257 } 8268 }
8258 8269
8259 8270
8260 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) { 8271 void V8::RemoveGCPrologueCallback(GCCallback callback) {
8261 Isolate* isolate = Isolate::GetCurrent(); 8272 Isolate* isolate = Isolate::GetCurrent();
8262 isolate->RemoveGCPrologueCallback( 8273 isolate->RemoveGCPrologueCallback(
8263 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback)); 8274 reinterpret_cast<v8::Isolate::GCCallback>(callback));
8264 } 8275 }
8265 8276
8266 8277
8267 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { 8278 void V8::RemoveGCEpilogueCallback(GCCallback callback) {
8268 Isolate* isolate = Isolate::GetCurrent(); 8279 Isolate* isolate = Isolate::GetCurrent();
8269 isolate->RemoveGCEpilogueCallback( 8280 isolate->RemoveGCEpilogueCallback(
8270 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback)); 8281 reinterpret_cast<v8::Isolate::GCCallback>(callback));
8271 } 8282 }
8272 8283
8273 8284
8274 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback, 8285 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
8275 ObjectSpace space, 8286 ObjectSpace space,
8276 AllocationAction action) { 8287 AllocationAction action) {
8277 Isolate* isolate = Isolate::GetCurrent(); 8288 Isolate* isolate = Isolate::GetCurrent();
8278 isolate->AddMemoryAllocationCallback(callback, space, action); 8289 isolate->AddMemoryAllocationCallback(callback, space, action);
8279 } 8290 }
8280 8291
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
8336 */ 8347 */
8337 8348
8338 8349
8339 } // namespace v8 8350 } // namespace v8
8340 8351
8341 8352
8342 #undef TYPE_CHECK 8353 #undef TYPE_CHECK
8343 8354
8344 8355
8345 #endif // V8_H_ 8356 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/heap/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698