Skip to content

Commit f3b2976

Browse files
mlippautzCommit Bot
authored andcommitted
[api] Move forward deprecations in EmbedderHeapTracer and its references
- Move foward deprecations in EmbedderHeapTracer - Deprecate SetFinalizationCallback in v8::TraceReference Change-Id: Ic68402096ce8f5fe08521253836d3b19d73326ae Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863941 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Auto-Submit: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#64388}
1 parent df131db commit f3b2976

4 files changed

Lines changed: 43 additions & 35 deletions

File tree

include/v8.h

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -883,19 +883,6 @@ class TracedReferenceBase {
883883
*/
884884
V8_INLINE uint16_t WrapperClassId() const;
885885

886-
/**
887-
* Adds a finalization callback to the handle. The type of this callback is
888-
* similar to WeakCallbackType::kInternalFields, i.e., it will pass the
889-
* parameter and the first two internal fields of the object.
890-
*
891-
* The callback is then supposed to reset the handle in the callback. No
892-
* further V8 API may be called in this callback. In case additional work
893-
* involving V8 needs to be done, a second callback can be scheduled using
894-
* WeakCallbackInfo<void>::SetSecondPassCallback.
895-
*/
896-
V8_INLINE void SetFinalizationCallback(
897-
void* parameter, WeakCallbackInfo<void>::Callback callback);
898-
899886
template <class S>
900887
V8_INLINE TracedReferenceBase<S>& As() const {
901888
return reinterpret_cast<TracedReferenceBase<S>&>(
@@ -1033,6 +1020,19 @@ class TracedGlobal : public TracedReferenceBase<T> {
10331020
return reinterpret_cast<TracedGlobal<S>&>(
10341021
const_cast<TracedGlobal<T>&>(*this));
10351022
}
1023+
1024+
/**
1025+
* Adds a finalization callback to the handle. The type of this callback is
1026+
* similar to WeakCallbackType::kInternalFields, i.e., it will pass the
1027+
* parameter and the first two internal fields of the object.
1028+
*
1029+
* The callback is then supposed to reset the handle in the callback. No
1030+
* further V8 API may be called in this callback. In case additional work
1031+
* involving V8 needs to be done, a second callback can be scheduled using
1032+
* WeakCallbackInfo<void>::SetSecondPassCallback.
1033+
*/
1034+
V8_INLINE void SetFinalizationCallback(
1035+
void* parameter, WeakCallbackInfo<void>::Callback callback);
10361036
};
10371037

10381038
/**
@@ -1142,6 +1142,20 @@ class TracedReference : public TracedReferenceBase<T> {
11421142
return reinterpret_cast<TracedReference<S>&>(
11431143
const_cast<TracedReference<T>&>(*this));
11441144
}
1145+
1146+
/**
1147+
* Adds a finalization callback to the handle. The type of this callback is
1148+
* similar to WeakCallbackType::kInternalFields, i.e., it will pass the
1149+
* parameter and the first two internal fields of the object.
1150+
*
1151+
* The callback is then supposed to reset the handle in the callback. No
1152+
* further V8 API may be called in this callback. In case additional work
1153+
* involving V8 needs to be done, a second callback can be scheduled using
1154+
* WeakCallbackInfo<void>::SetSecondPassCallback.
1155+
*/
1156+
V8_DEPRECATE_SOON("Use TracedGlobal<> if callbacks are required.")
1157+
V8_INLINE void SetFinalizationCallback(
1158+
void* parameter, WeakCallbackInfo<void>::Callback callback);
11451159
};
11461160

11471161
/**
@@ -7618,7 +7632,7 @@ class V8_EXPORT EmbedderHeapTracer {
76187632
virtual void RegisterV8References(
76197633
const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
76207634

7621-
V8_DEPRECATE_SOON("Use version taking TracedReferenceBase<v8::Data> argument")
7635+
V8_DEPRECATED("Use version taking TracedReferenceBase<v8::Data> argument")
76227636
void RegisterEmbedderReference(const TracedReferenceBase<v8::Value>& ref);
76237637
void RegisterEmbedderReference(const TracedReferenceBase<v8::Data>& ref);
76247638

@@ -7652,8 +7666,7 @@ class V8_EXPORT EmbedderHeapTracer {
76527666
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
76537667
* garbage collections.
76547668
*/
7655-
V8_DEPRECATED("Use version with parameter.") virtual void TraceEpilogue() {}
7656-
virtual void TraceEpilogue(TraceSummary* trace_summary);
7669+
virtual void TraceEpilogue(TraceSummary* trace_summary) {}
76577670

76587671
/**
76597672
* Called upon entering the final marking pause. No more incremental marking
@@ -7704,8 +7717,7 @@ class V8_EXPORT EmbedderHeapTracer {
77047717
*/
77057718
virtual void ResetHandleInNonTracingGC(
77067719
const v8::TracedReference<v8::Value>& handle);
7707-
V8_DEPRECATE_SOON(
7708-
"Use TracedReference version when not requiring destructors.")
7720+
V8_DEPRECATED("Use TracedReference version when not requiring destructors.")
77097721
virtual void ResetHandleInNonTracingGC(
77107722
const v8::TracedGlobal<v8::Value>& handle);
77117723

@@ -10524,10 +10536,17 @@ uint16_t TracedReferenceBase<T>::WrapperClassId() const {
1052410536
}
1052510537

1052610538
template <class T>
10527-
void TracedReferenceBase<T>::SetFinalizationCallback(
10539+
void TracedGlobal<T>::SetFinalizationCallback(
10540+
void* parameter, typename WeakCallbackInfo<void>::Callback callback) {
10541+
V8::SetFinalizationCallbackTraced(
10542+
reinterpret_cast<internal::Address*>(this->val_), parameter, callback);
10543+
}
10544+
10545+
template <class T>
10546+
void TracedReference<T>::SetFinalizationCallback(
1052810547
void* parameter, typename WeakCallbackInfo<void>::Callback callback) {
10529-
V8::SetFinalizationCallbackTraced(reinterpret_cast<internal::Address*>(val_),
10530-
parameter, callback);
10548+
V8::SetFinalizationCallbackTraced(
10549+
reinterpret_cast<internal::Address*>(this->val_), parameter, callback);
1053110550
}
1053210551

1053310552
template <typename T>

src/api/api.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10503,17 +10503,6 @@ void Testing::DeoptimizeAll(Isolate* isolate) {
1050310503
i::Deoptimizer::DeoptimizeAll(i_isolate);
1050410504
}
1050510505

10506-
void EmbedderHeapTracer::TraceEpilogue(TraceSummary* trace_summary) {
10507-
#if __clang__
10508-
#pragma clang diagnostic push
10509-
#pragma clang diagnostic ignored "-Wdeprecated"
10510-
#endif
10511-
TraceEpilogue();
10512-
#if __clang__
10513-
#pragma clang diagnostic pop
10514-
#endif
10515-
}
10516-
1051710506
void EmbedderHeapTracer::FinalizeTracing() {
1051810507
if (isolate_) {
1051910508
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(isolate_);

test/cctest/heap/test-embedder-tracing.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
7878
}
7979
}
8080

81-
void TraceEpilogue() final {}
81+
void TraceEpilogue(TraceSummary*) final {}
8282
void EnterFinalPause(EmbedderStackState) final {}
8383

8484
bool IsRegisteredFromV8(void* first_field) const {
@@ -704,7 +704,7 @@ class EmptyEmbedderHeapTracer : public v8::EmbedderHeapTracer {
704704
bool AdvanceTracing(double deadline_in_ms) final { return true; }
705705
bool IsTracingDone() final { return true; }
706706
void TracePrologue(EmbedderHeapTracer::TraceFlags) final {}
707-
void TraceEpilogue() final {}
707+
void TraceEpilogue(TraceSummary*) final {}
708708
void EnterFinalPause(EmbedderStackState) final {}
709709
};
710710

test/cctest/test-global-handles.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
5050
bool AdvanceTracing(double deadline_in_ms) final { return true; }
5151
bool IsTracingDone() final { return true; }
5252
void TracePrologue(TraceFlags) final {}
53-
void TraceEpilogue() final {}
53+
void TraceEpilogue(TraceSummary*) final {}
5454
void EnterFinalPause(EmbedderStackState) final {}
5555

5656
bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle) final {

0 commit comments

Comments
 (0)