diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-12-05 16:41:55 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-12-06 12:52:07 +0100 |
commit | 1854ba04e9a68f062beb299dd6e1479279b26363 (patch) | |
tree | d5b2df9b8c1deb6388f7a728fca8e1c98c779abe /deps/v8/test/cctest/test-global-handles.cc | |
parent | b52c23b75f96e1c9d2c7b3a7e5619170d0a0d8e1 (diff) | |
download | node-new-1854ba04e9a68f062beb299dd6e1479279b26363.tar.gz |
deps: update V8 to 6.3.292.46
PR-URL: https://github.com/nodejs/node/pull/16271
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/test/cctest/test-global-handles.cc')
-rw-r--r-- | deps/v8/test/cctest/test-global-handles.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/test-global-handles.cc b/deps/v8/test/cctest/test-global-handles.cc index 4550618de6..d3e229530f 100644 --- a/deps/v8/test/cctest/test-global-handles.cc +++ b/deps/v8/test/cctest/test-global-handles.cc @@ -185,5 +185,42 @@ TEST(PhatomHandlesWithoutCallbacks) { CHECK_EQ(0u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); } +namespace { + +void ResurrectingFinalizer( + const v8::WeakCallbackInfo<v8::Global<v8::Object>>& data) { + data.GetParameter()->ClearWeak(); +} + +} // namespace + +TEST(Regress772299) { + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + + v8::Global<v8::Object> g1, g2; + { + v8::HandleScope scope(isolate); + v8::Local<v8::Object> o1 = + v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate)); + v8::Local<v8::Object> o2 = + v8::Local<v8::Object>::New(isolate, v8::Object::New(isolate)); + o1->Set(isolate->GetCurrentContext(), v8_str("link"), o2).FromJust(); + g1.Reset(isolate, o1); + g2.Reset(isolate, o2); + // g1 will be finalized but resurrected. + g1.SetWeak(&g1, ResurrectingFinalizer, v8::WeakCallbackType::kFinalizer); + // g2 will be a phantom handle that should not be reset as g1 transitively + // keeps it alive. + g2.SetWeak(); + } + + CcTest::CollectAllAvailableGarbage(); + // Both, g1 and g2, should stay alive as the finalizer resurrects the root + // object that transitively keeps the other one alive. + CHECK(!g1.IsEmpty()); + CHECK(!g2.IsEmpty()); +} + } // namespace internal } // namespace v8 |