Skip to content

Commit 06193b0

Browse files
mlippautzCommit Bot
authored andcommitted
[api] Move forward deprecations around Persistent handles
In future, weak handles will be considered as independent and MarkActive() will not be supported anymore. Users should switch to TracedGlobal, when relying on special cases for using handles with v8::EmbedderHeapTracer. Bug: chromium:923361, v8:8562 Change-Id: Ic6e01a1ab59a25c5fb0aa2ebfb8ddb02e454d72d Reviewed-on: https://chromium-review.googlesource.com/c/1443064 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#59194}
1 parent a1cde8f commit 06193b0

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

include/v8.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,10 @@ template <class T> class PersistentBase {
555555
* independent handle should not assume that it will be preceded by a global
556556
* GC prologue callback or followed by a global GC epilogue callback.
557557
*/
558-
V8_DEPRECATE_SOON(
559-
"Objects are always considered independent. "
560-
"Use MarkActive to avoid collecting otherwise dead weak handles.",
558+
V8_DEPRECATED(
559+
"Weak objects are always considered independent. "
560+
"Use TracedGlobal when trying to use EmbedderHeapTracer. "
561+
"Use a strong handle when trying to keep an object alive.",
561562
V8_INLINE void MarkIndependent());
562563

563564
/**
@@ -567,15 +568,13 @@ template <class T> class PersistentBase {
567568
*
568569
* This bit is cleared after the each garbage collection pass.
569570
*/
570-
V8_INLINE void MarkActive();
571+
V8_DEPRECATE_SOON("Use TracedGlobal.", V8_INLINE void MarkActive());
571572

572-
V8_DEPRECATE_SOON("See MarkIndependent.",
573-
V8_INLINE bool IsIndependent() const);
573+
V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
574574

575575
/** Checks if the handle holds the only reference to an object. */
576-
V8_DEPRECATE_SOON(
577-
"Garbage collection internal state should not be relied on.",
578-
V8_INLINE bool IsNearDeath() const);
576+
V8_DEPRECATED("Garbage collection internal state should not be relied on.",
577+
V8_INLINE bool IsNearDeath() const);
579578

580579
/** Returns true if the handle's reference is weak. */
581580
V8_INLINE bool IsWeak() const;
@@ -8444,7 +8443,7 @@ class V8_EXPORT Isolate {
84448443
* garbage collection but is free to visit an arbitrary superset of these
84458444
* objects.
84468445
*/
8447-
V8_DEPRECATE_SOON(
8446+
V8_DEPRECATED(
84488447
"Use VisitHandlesWithClassIds",
84498448
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor));
84508449

test/cctest/test-global-handles.cc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,33 @@ TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesScavenge) {
344344
CcTest::InitializeVM();
345345
WeakHandleTest(
346346
CcTest::isolate(), &ConstructJSApiObject,
347-
[](FlagAndPersistent* fp) { fp->handle.MarkActive(); },
347+
[](FlagAndPersistent* fp) {
348+
#if __clang__
349+
#pragma clang diagnostic push
350+
#pragma clang diagnostic ignored "-Wdeprecated"
351+
#endif
352+
fp->handle.MarkActive();
353+
#if __clang__
354+
#pragma clang diagnostic pop
355+
#endif
356+
},
348357
[]() { InvokeScavenge(); }, SurvivalMode::kSurvives);
349358
}
350359

351360
TEST(WeakHandleToActiveUnmodifiedJSApiObjectDiesOnMarkCompact) {
352361
CcTest::InitializeVM();
353362
WeakHandleTest(
354363
CcTest::isolate(), &ConstructJSApiObject,
355-
[](FlagAndPersistent* fp) { fp->handle.MarkActive(); },
364+
[](FlagAndPersistent* fp) {
365+
#if __clang__
366+
#pragma clang diagnostic push
367+
#pragma clang diagnostic ignored "-Wdeprecated"
368+
#endif
369+
fp->handle.MarkActive();
370+
#if __clang__
371+
#pragma clang diagnostic pop
372+
#endif
373+
},
356374
[]() { InvokeMarkSweep(); }, SurvivalMode::kDies);
357375
}
358376

@@ -361,7 +379,14 @@ TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) {
361379
WeakHandleTest(
362380
CcTest::isolate(), &ConstructJSApiObject,
363381
[](FlagAndPersistent* fp) {
382+
#if __clang__
383+
#pragma clang diagnostic push
384+
#pragma clang diagnostic ignored "-Wdeprecated"
385+
#endif
364386
fp->handle.MarkActive();
387+
#if __clang__
388+
#pragma clang diagnostic pop
389+
#endif
365390
v8::Local<v8::Object> handle =
366391
v8::Local<v8::Object>::New(CcTest::isolate(), fp->handle);
367392
USE(handle);

0 commit comments

Comments
 (0)