Commit 96315d16 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[api] Mark old method for tracing as soon deprecated

Users should switch to TracedGlobal and the newly added methods of
v8::EmbedderHeapTracer.

Bug: chromium:923361, v8:8562
Change-Id: I3e5ed5785a0a49c0b65c7b1d1d103e568dd3e938
Reviewed-on: https://chromium-review.googlesource.com/c/1445752
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59297}
parent 327fd140
...@@ -547,7 +547,9 @@ template <class T> class PersistentBase { ...@@ -547,7 +547,9 @@ template <class T> class PersistentBase {
* is alive. Only allowed when the embedder is asked to trace its heap by * is alive. Only allowed when the embedder is asked to trace its heap by
* EmbedderHeapTracer. * EmbedderHeapTracer.
*/ */
V8_INLINE void RegisterExternalReference(Isolate* isolate) const; V8_DEPRECATE_SOON(
"Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
V8_INLINE void RegisterExternalReference(Isolate* isolate) const);
/** /**
* Marks the reference to this object independent. Garbage collector is free * Marks the reference to this object independent. Garbage collector is free
......
...@@ -41,7 +41,7 @@ v8::Local<v8::Object> ConstructTraceableJSApiObject( ...@@ -41,7 +41,7 @@ v8::Local<v8::Object> ConstructTraceableJSApiObject(
class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer { class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
public: public:
explicit TestEmbedderHeapTracer(v8::Isolate* isolate) : isolate_(isolate) {} TestEmbedderHeapTracer() = default;
void RegisterV8References( void RegisterV8References(
const std::vector<std::pair<void*, void*>>& embedder_fields) final { const std::vector<std::pair<void*, void*>>& embedder_fields) final {
...@@ -49,13 +49,13 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer { ...@@ -49,13 +49,13 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
embedder_fields.begin(), embedder_fields.end()); embedder_fields.begin(), embedder_fields.end());
} }
void AddReferenceForTracing(v8::Persistent<v8::Object>* persistent) { void AddReferenceForTracing(v8::TracedGlobal<v8::Object>* global) {
to_register_with_v8_.push_back(persistent); to_register_with_v8_.push_back(global);
} }
bool AdvanceTracing(double deadline_in_ms) final { bool AdvanceTracing(double deadline_in_ms) final {
for (auto persistent : to_register_with_v8_) { for (auto global : to_register_with_v8_) {
persistent->RegisterExternalReference(isolate_); RegisterEmbedderReference(global->As<v8::Value>());
} }
to_register_with_v8_.clear(); to_register_with_v8_.clear();
return true; return true;
...@@ -83,9 +83,8 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer { ...@@ -83,9 +83,8 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
} }
private: private:
v8::Isolate* const isolate_;
std::vector<std::pair<void*, void*>> registered_from_v8_; std::vector<std::pair<void*, void*>> registered_from_v8_;
std::vector<v8::Persistent<v8::Object>*> to_register_with_v8_; std::vector<v8::TracedGlobal<v8::Object>*> to_register_with_v8_;
bool consider_traced_global_as_root_ = true; bool consider_traced_global_as_root_ = true;
}; };
...@@ -113,7 +112,7 @@ TEST(V8RegisteringEmbedderReference) { ...@@ -113,7 +112,7 @@ TEST(V8RegisteringEmbedderReference) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
...@@ -133,19 +132,18 @@ TEST(EmbedderRegisteringV8Reference) { ...@@ -133,19 +132,18 @@ TEST(EmbedderRegisteringV8Reference) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
v8::Persistent<v8::Object> g; v8::TracedGlobal<v8::Object> g;
{ {
v8::HandleScope inner_scope(isolate); v8::HandleScope inner_scope(isolate);
v8::Local<v8::Object> o = v8::Local<v8::Object> o =
v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate)); v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate));
g.Reset(isolate, o); g.Reset(isolate, o);
g.SetWeak();
} }
tracer.AddReferenceForTracing(&g); tracer.AddReferenceForTracing(&g);
CcTest::CollectGarbage(i::OLD_SPACE); CcTest::CollectGarbage(i::OLD_SPACE);
...@@ -167,7 +165,7 @@ TEST(TracingInRevivedSubgraph) { ...@@ -167,7 +165,7 @@ TEST(TracingInRevivedSubgraph) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
...@@ -195,7 +193,7 @@ TEST(TracingInEphemerons) { ...@@ -195,7 +193,7 @@ TEST(TracingInEphemerons) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
...@@ -226,7 +224,7 @@ TEST(FinalizeTracingIsNoopWhenNotMarking) { ...@@ -226,7 +224,7 @@ TEST(FinalizeTracingIsNoopWhenNotMarking) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
Isolate* i_isolate = CcTest::i_isolate(); Isolate* i_isolate = CcTest::i_isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
// Finalize a potentially running garbage collection. // Finalize a potentially running garbage collection.
...@@ -245,7 +243,7 @@ TEST(FinalizeTracingWhenMarking) { ...@@ -245,7 +243,7 @@ TEST(FinalizeTracingWhenMarking) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
Isolate* i_isolate = CcTest::i_isolate(); Isolate* i_isolate = CcTest::i_isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
// Finalize a potentially running garbage collection. // Finalize a potentially running garbage collection.
...@@ -270,7 +268,7 @@ TEST(GarbageCollectionForTesting) { ...@@ -270,7 +268,7 @@ TEST(GarbageCollectionForTesting) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
Isolate* i_isolate = CcTest::i_isolate(); Isolate* i_isolate = CcTest::i_isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
int saved_gc_counter = i_isolate->heap()->gc_count(); int saved_gc_counter = i_isolate->heap()->gc_count();
...@@ -400,7 +398,7 @@ TEST(TracedGlobalToUnmodifiedJSObjectSurvivesScavengeWhenExcludedFromRoots) { ...@@ -400,7 +398,7 @@ TEST(TracedGlobalToUnmodifiedJSObjectSurvivesScavengeWhenExcludedFromRoots) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
tracer.ConsiderTracedGlobalAsRoot(false); tracer.ConsiderTracedGlobalAsRoot(false);
TracedGlobalTest( TracedGlobalTest(
...@@ -413,7 +411,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectSurvivesScavengePerDefault) { ...@@ -413,7 +411,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectSurvivesScavengePerDefault) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
tracer.ConsiderTracedGlobalAsRoot(true); tracer.ConsiderTracedGlobalAsRoot(true);
TracedGlobalTest( TracedGlobalTest(
...@@ -426,7 +424,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectDiesOnScavengeWhenExcludedFromRoots) { ...@@ -426,7 +424,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectDiesOnScavengeWhenExcludedFromRoots) {
ManualGCScope manual_gc; ManualGCScope manual_gc;
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
tracer.ConsiderTracedGlobalAsRoot(false); tracer.ConsiderTracedGlobalAsRoot(false);
TracedGlobalTest( TracedGlobalTest(
...@@ -440,7 +438,7 @@ TEST(TracedGlobalWrapperClassId) { ...@@ -440,7 +438,7 @@ TEST(TracedGlobalWrapperClassId) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::TracedGlobal<v8::Object> traced; v8::TracedGlobal<v8::Object> traced;
...@@ -475,7 +473,7 @@ TEST(TracedGlobalIteration) { ...@@ -475,7 +473,7 @@ TEST(TracedGlobalIteration) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
TestEmbedderHeapTracer tracer(isolate); TestEmbedderHeapTracer tracer;
TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer);
v8::TracedGlobal<v8::Object> traced; v8::TracedGlobal<v8::Object> traced;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment