[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 <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59194}
This commit is contained in:
Michael Lippautz 2019-01-29 20:23:02 +01:00 committed by Commit Bot
parent a1cde8fb34
commit 06193b0b79
2 changed files with 36 additions and 12 deletions

View File

@ -555,9 +555,10 @@ template <class T> class PersistentBase {
* independent handle should not assume that it will be preceded by a global
* GC prologue callback or followed by a global GC epilogue callback.
*/
V8_DEPRECATE_SOON(
"Objects are always considered independent. "
"Use MarkActive to avoid collecting otherwise dead weak handles.",
V8_DEPRECATED(
"Weak objects are always considered independent. "
"Use TracedGlobal when trying to use EmbedderHeapTracer. "
"Use a strong handle when trying to keep an object alive.",
V8_INLINE void MarkIndependent());
/**
@ -567,15 +568,13 @@ template <class T> class PersistentBase {
*
* This bit is cleared after the each garbage collection pass.
*/
V8_INLINE void MarkActive();
V8_DEPRECATE_SOON("Use TracedGlobal.", V8_INLINE void MarkActive());
V8_DEPRECATE_SOON("See MarkIndependent.",
V8_INLINE bool IsIndependent() const);
V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
/** Checks if the handle holds the only reference to an object. */
V8_DEPRECATE_SOON(
"Garbage collection internal state should not be relied on.",
V8_INLINE bool IsNearDeath() const);
V8_DEPRECATED("Garbage collection internal state should not be relied on.",
V8_INLINE bool IsNearDeath() const);
/** Returns true if the handle's reference is weak. */
V8_INLINE bool IsWeak() const;
@ -8444,7 +8443,7 @@ class V8_EXPORT Isolate {
* garbage collection but is free to visit an arbitrary superset of these
* objects.
*/
V8_DEPRECATE_SOON(
V8_DEPRECATED(
"Use VisitHandlesWithClassIds",
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor));

View File

@ -344,7 +344,16 @@ TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesScavenge) {
CcTest::InitializeVM();
WeakHandleTest(
CcTest::isolate(), &ConstructJSApiObject,
[](FlagAndPersistent* fp) { fp->handle.MarkActive(); },
[](FlagAndPersistent* fp) {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
fp->handle.MarkActive();
#if __clang__
#pragma clang diagnostic pop
#endif
},
[]() { InvokeScavenge(); }, SurvivalMode::kSurvives);
}
@ -352,7 +361,16 @@ TEST(WeakHandleToActiveUnmodifiedJSApiObjectDiesOnMarkCompact) {
CcTest::InitializeVM();
WeakHandleTest(
CcTest::isolate(), &ConstructJSApiObject,
[](FlagAndPersistent* fp) { fp->handle.MarkActive(); },
[](FlagAndPersistent* fp) {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
fp->handle.MarkActive();
#if __clang__
#pragma clang diagnostic pop
#endif
},
[]() { InvokeMarkSweep(); }, SurvivalMode::kDies);
}
@ -361,7 +379,14 @@ TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) {
WeakHandleTest(
CcTest::isolate(), &ConstructJSApiObject,
[](FlagAndPersistent* fp) {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
fp->handle.MarkActive();
#if __clang__
#pragma clang diagnostic pop
#endif
v8::Local<v8::Object> handle =
v8::Local<v8::Object>::New(CcTest::isolate(), fp->handle);
USE(handle);