OLD | NEW |
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 5450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 * end of its marking phase iterates the collection and asks the embedder to | 5461 * end of its marking phase iterates the collection and asks the embedder to |
5462 * trace through its heap and call PersistentBase::RegisterExternalReference on | 5462 * trace through its heap and call PersistentBase::RegisterExternalReference on |
5463 * each js object reachable from any of the given wrappers. | 5463 * each js object reachable from any of the given wrappers. |
5464 * | 5464 * |
5465 * Before the first call to the TraceWrappersFrom function TracePrologue will be | 5465 * Before the first call to the TraceWrappersFrom function TracePrologue will be |
5466 * called. When the garbage collection cycle is finished, TraceEpilogue will be | 5466 * called. When the garbage collection cycle is finished, TraceEpilogue will be |
5467 * called. | 5467 * called. |
5468 */ | 5468 */ |
5469 class V8_EXPORT EmbedderHeapTracer { | 5469 class V8_EXPORT EmbedderHeapTracer { |
5470 public: | 5470 public: |
| 5471 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; |
| 5472 struct AdvanceTracingActions { |
| 5473 explicit AdvanceTracingActions(ForceCompletionAction force_completion_) |
| 5474 : force_completion(force_completion_) {} |
| 5475 |
| 5476 ForceCompletionAction force_completion; |
| 5477 }; |
| 5478 /** |
| 5479 * V8 will call this method with internal fields of found wrappers. |
| 5480 * Embedder is expected to store them in it's marking deque and trace |
| 5481 * reachable wrappers from them when asked by AdvanceTracing method. |
| 5482 */ |
| 5483 // TODO(hlopko): Make pure virtual after migration |
| 5484 virtual void RegisterV8References( |
| 5485 const std::vector<std::pair<void*, void*> >& internal_fields) {} |
| 5486 /** |
| 5487 * **Deprecated** |
| 5488 */ |
| 5489 // TODO(hlopko): Remove after migration |
| 5490 virtual void TraceWrappersFrom( |
| 5491 const std::vector<std::pair<void*, void*> >& internal_fields) {} |
5471 /** | 5492 /** |
5472 * V8 will call this method at the beginning of the gc cycle. | 5493 * V8 will call this method at the beginning of the gc cycle. |
5473 */ | 5494 */ |
5474 virtual void TracePrologue() = 0; | 5495 virtual void TracePrologue() = 0; |
5475 /** | 5496 /** |
5476 * V8 will call this method with internal fields of a potential wrappers. | 5497 * Embedder is expected to trace its heap starting from wrappers reported by |
5477 * Embedder is expected to trace its heap (synchronously) and call | 5498 * RegisterV8References method, and call |
5478 * PersistentBase::RegisterExternalReference() on all wrappers reachable from | 5499 * PersistentBase::RegisterExternalReference() on all reachable wrappers. |
5479 * any of the given wrappers. | 5500 * Embedder is expected to stop tracing by the given deadline. |
| 5501 * |
| 5502 * Returns true if there is still work to do. |
5480 */ | 5503 */ |
5481 virtual void TraceWrappersFrom( | 5504 // TODO(hlopko): Make pure virtual after migration |
5482 const std::vector<std::pair<void*, void*> >& internal_fields) = 0; | 5505 virtual bool AdvanceTracing(double deadline_in_ms, |
| 5506 AdvanceTracingActions actions) { |
| 5507 return false; |
| 5508 } |
5483 /** | 5509 /** |
5484 * V8 will call this method at the end of the gc cycle. Allocation is *not* | 5510 * V8 will call this method at the end of the gc cycle. Allocation is *not* |
5485 * allowed in the TraceEpilogue. | 5511 * allowed in the TraceEpilogue. |
5486 */ | 5512 */ |
5487 virtual void TraceEpilogue() = 0; | 5513 virtual void TraceEpilogue() = 0; |
5488 | 5514 |
5489 protected: | 5515 protected: |
5490 virtual ~EmbedderHeapTracer() = default; | 5516 virtual ~EmbedderHeapTracer() = default; |
5491 }; | 5517 }; |
5492 | 5518 |
(...skipping 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8803 */ | 8829 */ |
8804 | 8830 |
8805 | 8831 |
8806 } // namespace v8 | 8832 } // namespace v8 |
8807 | 8833 |
8808 | 8834 |
8809 #undef TYPE_CHECK | 8835 #undef TYPE_CHECK |
8810 | 8836 |
8811 | 8837 |
8812 #endif // INCLUDE_V8_H_ | 8838 #endif // INCLUDE_V8_H_ |
OLD | NEW |