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

Side by Side Diff: include/v8.h

Issue 2474163002: [api] Remove EmbedderReachableReferenceReporter (Closed)
Patch Set: Remove old api Created 4 years, 1 month 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 | include/v8-util.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 // 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 457
458 // kParameter will pass a void* parameter back to the callback, kInternalFields 458 // kParameter will pass a void* parameter back to the callback, kInternalFields
459 // will pass the first two internal fields back to the callback, kFinalizer 459 // will pass the first two internal fields back to the callback, kFinalizer
460 // will pass a void* parameter back, but is invoked before the object is 460 // will pass a void* parameter back, but is invoked before the object is
461 // actually collected, so it can be resurrected. In the last case, it is not 461 // actually collected, so it can be resurrected. In the last case, it is not
462 // possible to request a second pass callback. 462 // possible to request a second pass callback.
463 enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer }; 463 enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
464 464
465 /** 465 /**
466 * A reporter class that embedder will use to report reachable references found
467 * by EmbedderHeapTracer.
468 */
469 class V8_EXPORT EmbedderReachableReferenceReporter {
470 public:
471 virtual void ReportExternalReference(Value* object) = 0;
472 virtual ~EmbedderReachableReferenceReporter() = default;
473 };
474
475 /**
476 * An object reference that is independent of any handle scope. Where 466 * An object reference that is independent of any handle scope. Where
477 * a Local handle only lives as long as the HandleScope in which it was 467 * a Local handle only lives as long as the HandleScope in which it was
478 * allocated, a PersistentBase handle remains valid until it is explicitly 468 * allocated, a PersistentBase handle remains valid until it is explicitly
479 * disposed. 469 * disposed.
480 * 470 *
481 * A persistent handle contains a reference to a storage cell within 471 * A persistent handle contains a reference to a storage cell within
482 * the v8 engine which holds an object value and which is updated by 472 * the v8 engine which holds an object value and which is updated by
483 * the garbage collector whenever the object is moved. A new storage 473 * the garbage collector whenever the object is moved. A new storage
484 * cell can be created using the constructor or PersistentBase::Reset and 474 * cell can be created using the constructor or PersistentBase::Reset and
485 * existing handles can be disposed using PersistentBase::Reset. 475 * existing handles can be disposed using PersistentBase::Reset.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 */ 552 */
563 V8_INLINE void SetWeak(); 553 V8_INLINE void SetWeak();
564 554
565 template<typename P> 555 template<typename P>
566 V8_INLINE P* ClearWeak(); 556 V8_INLINE P* ClearWeak();
567 557
568 // TODO(dcarney): remove this. 558 // TODO(dcarney): remove this.
569 V8_INLINE void ClearWeak() { ClearWeak<void>(); } 559 V8_INLINE void ClearWeak() { ClearWeak<void>(); }
570 560
571 /** 561 /**
572 * Deprecated.
573 * TODO(hlopko): remove once migration to reporter is finished.
574 */
575 V8_INLINE void RegisterExternalReference(Isolate* isolate) const {}
576
577 /**
578 * Allows the embedder to tell the v8 garbage collector that a certain object 562 * Allows the embedder to tell the v8 garbage collector that a certain object
579 * is alive. Only allowed when the embedder is asked to trace its heap by 563 * is alive. Only allowed when the embedder is asked to trace its heap by
580 * EmbedderHeapTracer. 564 * EmbedderHeapTracer.
581 */ 565 */
582 V8_INLINE void RegisterExternalReference( 566 V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
583 EmbedderReachableReferenceReporter* reporter) const;
584 567
585 /** 568 /**
586 * Marks the reference to this object independent. Garbage collector is free 569 * Marks the reference to this object independent. Garbage collector is free
587 * to ignore any object groups containing this object. Weak callback for an 570 * to ignore any object groups containing this object. Weak callback for an
588 * independent handle should not assume that it will be preceded by a global 571 * independent handle should not assume that it will be preceded by a global
589 * GC prologue callback or followed by a global GC epilogue callback. 572 * GC prologue callback or followed by a global GC epilogue callback.
590 */ 573 */
591 V8_INLINE void MarkIndependent(); 574 V8_INLINE void MarkIndependent();
592 575
593 /** 576 /**
(...skipping 5568 matching lines...) Expand 10 before | Expand all | Expand 10 after
6162 * Memory pressure level for the MemoryPressureNotification. 6145 * Memory pressure level for the MemoryPressureNotification.
6163 * kNone hints V8 that there is no memory pressure. 6146 * kNone hints V8 that there is no memory pressure.
6164 * kModerate hints V8 to speed up incremental garbage collection at the cost of 6147 * kModerate hints V8 to speed up incremental garbage collection at the cost of
6165 * of higher latency due to garbage collection pauses. 6148 * of higher latency due to garbage collection pauses.
6166 * kCritical hints V8 to free memory as soon as possible. Garbage collection 6149 * kCritical hints V8 to free memory as soon as possible. Garbage collection
6167 * pauses at this level will be large. 6150 * pauses at this level will be large.
6168 */ 6151 */
6169 enum class MemoryPressureLevel { kNone, kModerate, kCritical }; 6152 enum class MemoryPressureLevel { kNone, kModerate, kCritical };
6170 6153
6171 /** 6154 /**
6172 * Interface for tracing through the embedder heap. During the v8 garbage 6155 * Interface for tracing through the embedder heap. During a v8 garbage
6173 * collection, v8 collects hidden fields of all potential wrappers, and at the 6156 * collection, v8 collects hidden fields of all potential wrappers, and at the
6174 * end of its marking phase iterates the collection and asks the embedder to 6157 * end of its marking phase iterates the collection and asks the embedder to
6175 * trace through its heap and use reporter to report each js object reachable 6158 * trace through its heap and use reporter to report each JavaScript object
6176 * from any of the given wrappers. 6159 * reachable from any of the given wrappers.
6177 * 6160 *
6178 * Before the first call to the TraceWrappersFrom function TracePrologue will be 6161 * Before the first call to the TraceWrappersFrom function TracePrologue will be
6179 * called. When the garbage collection cycle is finished, TraceEpilogue will be 6162 * called. When the garbage collection cycle is finished, TraceEpilogue will be
6180 * called. 6163 * called.
6181 */ 6164 */
6182 class V8_EXPORT EmbedderHeapTracer { 6165 class V8_EXPORT EmbedderHeapTracer {
6183 public: 6166 public:
6184 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; 6167 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
6185 6168
6186 struct AdvanceTracingActions { 6169 struct AdvanceTracingActions {
6187 explicit AdvanceTracingActions(ForceCompletionAction force_completion_) 6170 explicit AdvanceTracingActions(ForceCompletionAction force_completion_)
6188 : force_completion(force_completion_) {} 6171 : force_completion(force_completion_) {}
6189 6172
6190 ForceCompletionAction force_completion; 6173 ForceCompletionAction force_completion;
6191 }; 6174 };
6192 6175
6193 /** 6176 /**
6194 * V8 will call this method with internal fields of found wrappers. The 6177 * Called by v8 to register internal fields of found wrappers.
6195 * embedder is expected to store them in its marking deque and trace 6178 *
6196 * reachable wrappers from them when called through |AdvanceTracing|. 6179 * The embedder is expected to store them somewhere and trace reachable
6180 * wrappers from them when called through |AdvanceTracing|.
6197 */ 6181 */
6198 virtual void RegisterV8References( 6182 virtual void RegisterV8References(
6199 const std::vector<std::pair<void*, void*> >& internal_fields) = 0; 6183 const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
6200 6184
6201 /** 6185 /**
6202 * Deprecated. 6186 * Called at the beginning of a GC cycle.
6203 * TODO(hlopko) Remove once the migration to reporter is finished.
6204 */ 6187 */
6205 virtual void TracePrologue() {} 6188 virtual void TracePrologue() = 0;
6206 6189
6207 /** 6190 /**
6208 * V8 will call this method at the beginning of a GC cycle. Embedder is 6191 * Called to to make a tracing step in the embedder.
6209 * expected to use EmbedderReachableReferenceReporter for reporting all 6192 *
6210 * reachable v8 objects. 6193 * The embedder is expected to trace its heap starting from wrappers reported
6211 */ 6194 * by RegisterV8References method, and report back all reachable wrappers.
6212 virtual void TracePrologue(EmbedderReachableReferenceReporter* reporter) {} 6195 * Furthermore, the embedder is expected to stop tracing by the given
6213 6196 * deadline.
6214 /**
6215 * Embedder is expected to trace its heap starting from wrappers reported by
6216 * RegisterV8References method, and use reporter for all reachable wrappers.
6217 * Embedder is expected to stop tracing by the given deadline.
6218 * 6197 *
6219 * Returns true if there is still work to do. 6198 * Returns true if there is still work to do.
6220 */ 6199 */
6221 virtual bool AdvanceTracing(double deadline_in_ms, 6200 virtual bool AdvanceTracing(double deadline_in_ms,
6222 AdvanceTracingActions actions) = 0; 6201 AdvanceTracingActions actions) = 0;
6223 6202
6224 /** 6203 /**
6225 * V8 will call this method at the end of a GC cycle. 6204 * Called at the end of a GC cycle.
6226 * 6205 *
6227 * Note that allocation is *not* allowed within |TraceEpilogue|. 6206 * Note that allocation is *not* allowed within |TraceEpilogue|.
6228 */ 6207 */
6229 virtual void TraceEpilogue() = 0; 6208 virtual void TraceEpilogue() = 0;
6230 6209
6231 /** 6210 /**
6232 * Let embedder know v8 entered final marking pause (no more incremental steps 6211 * Called upon entering the final marking pause. No more incremental marking
6233 * will follow). 6212 * steps will follow this call.
6234 */ 6213 */
6235 virtual void EnterFinalPause() {} 6214 virtual void EnterFinalPause() = 0;
6236 6215
6237 /** 6216 /**
6238 * Throw away all intermediate data and reset to the initial state. 6217 * Called when tracing is aborted.
6218 *
6219 * The embedder is expected to throw away all intermediate data and reset to
6220 * the initial state.
6239 */ 6221 */
6240 virtual void AbortTracing() {} 6222 virtual void AbortTracing() = 0;
6241 6223
6242 /** 6224 /**
6243 * Returns the number of wrappers that are still to be traced by the embedder. 6225 * Returns the number of wrappers that are still to be traced by the embedder.
6244 */ 6226 */
6245 virtual size_t NumberOfWrappersToTrace() { return 0; } 6227 virtual size_t NumberOfWrappersToTrace() { return 0; }
6246 6228
6247 protected: 6229 protected:
6248 virtual ~EmbedderHeapTracer() = default; 6230 virtual ~EmbedderHeapTracer() = default;
6249 }; 6231 };
6250 6232
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
7543 // Must be 1 or -1. 7525 // Must be 1 or -1.
7544 int internal_field_index2, 7526 int internal_field_index2,
7545 WeakCallbackInfo<void>::Callback weak_callback); 7527 WeakCallbackInfo<void>::Callback weak_callback);
7546 static void MakeWeak(internal::Object*** location_addr); 7528 static void MakeWeak(internal::Object*** location_addr);
7547 static void* ClearWeak(internal::Object** location); 7529 static void* ClearWeak(internal::Object** location);
7548 static void Eternalize(Isolate* isolate, 7530 static void Eternalize(Isolate* isolate,
7549 Value* handle, 7531 Value* handle,
7550 int* index); 7532 int* index);
7551 static Local<Value> GetEternal(Isolate* isolate, int index); 7533 static Local<Value> GetEternal(Isolate* isolate, int index);
7552 7534
7535 static void RegisterExternallyReferencedObject(internal::Object** object,
7536 internal::Isolate* isolate);
7537
7553 template <class K, class V, class T> 7538 template <class K, class V, class T>
7554 friend class PersistentValueMapBase; 7539 friend class PersistentValueMapBase;
7555 7540
7556 static void FromJustIsNothing(); 7541 static void FromJustIsNothing();
7557 static void ToLocalEmpty(); 7542 static void ToLocalEmpty();
7558 static void InternalFieldOutOfBounds(int index); 7543 static void InternalFieldOutOfBounds(int index);
7559 template <class T> friend class Local; 7544 template <class T> friend class Local;
7560 template <class T> 7545 template <class T>
7561 friend class MaybeLocal; 7546 friend class MaybeLocal;
7562 template <class T> 7547 template <class T>
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
8613 } 8598 }
8614 8599
8615 template <class T> 8600 template <class T>
8616 template <typename P> 8601 template <typename P>
8617 P* PersistentBase<T>::ClearWeak() { 8602 P* PersistentBase<T>::ClearWeak() {
8618 return reinterpret_cast<P*>( 8603 return reinterpret_cast<P*>(
8619 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); 8604 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
8620 } 8605 }
8621 8606
8622 template <class T> 8607 template <class T>
8623 void PersistentBase<T>::RegisterExternalReference( 8608 void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
8624 EmbedderReachableReferenceReporter* reporter) const {
8625 if (IsEmpty()) return; 8609 if (IsEmpty()) return;
8626 reporter->ReportExternalReference(this->val_); 8610 V8::RegisterExternallyReferencedObject(
8611 reinterpret_cast<internal::Object**>(this->val_),
8612 reinterpret_cast<internal::Isolate*>(isolate));
8627 } 8613 }
8628 8614
8629 template <class T> 8615 template <class T>
8630 void PersistentBase<T>::MarkIndependent() { 8616 void PersistentBase<T>::MarkIndependent() {
8631 typedef internal::Internals I; 8617 typedef internal::Internals I;
8632 if (this->IsEmpty()) return; 8618 if (this->IsEmpty()) return;
8633 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), 8619 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
8634 true, 8620 true,
8635 I::kNodeIsIndependentShift); 8621 I::kNodeIsIndependentShift);
8636 } 8622 }
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
9705 */ 9691 */
9706 9692
9707 9693
9708 } // namespace v8 9694 } // namespace v8
9709 9695
9710 9696
9711 #undef TYPE_CHECK 9697 #undef TYPE_CHECK
9712 9698
9713 9699
9714 #endif // INCLUDE_V8_H_ 9700 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | include/v8-util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698