Commit f392922b authored by mlippautz's avatar mlippautz Committed by Commit bot

[tests] Fix use-after-scope errors related to weak refs

BUG=v8:5887

Review-Url: https://codereview.chromium.org/2655533004
Cr-Commit-Position: refs/heads/master@{#42652}
parent 1cbb6903
...@@ -7570,13 +7570,14 @@ void InternalFieldCallback(bool global_gc) { ...@@ -7570,13 +7570,14 @@ void InternalFieldCallback(bool global_gc) {
Trivial* t1; Trivial* t1;
Trivial2* t2; Trivial2* t2;
instance_templ->SetInternalFieldCount(2); instance_templ->SetInternalFieldCount(2);
v8::Persistent<v8::Object> handle;
{ {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
Local<v8::Object> obj = templ->GetFunction(env.local()) Local<v8::Object> obj = templ->GetFunction(env.local())
.ToLocalChecked() .ToLocalChecked()
->NewInstance(env.local()) ->NewInstance(env.local())
.ToLocalChecked(); .ToLocalChecked();
v8::Persistent<v8::Object> handle(isolate, obj); handle.Reset(isolate, obj);
CHECK_EQ(2, obj->InternalFieldCount()); CHECK_EQ(2, obj->InternalFieldCount());
CHECK(obj->GetInternalField(0)->IsUndefined()); CHECK(obj->GetInternalField(0)->IsUndefined());
t1 = new Trivial(42); t1 = new Trivial(42);
......
...@@ -111,13 +111,10 @@ TEST(Weakness) { ...@@ -111,13 +111,10 @@ TEST(Weakness) {
0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
// Make the global reference to the key weak. // Make the global reference to the key weak.
{ std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
HandleScope scope(isolate); GlobalHandles::MakeWeak(
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); key.location(), reinterpret_cast<void*>(&handle_and_id),
GlobalHandles::MakeWeak( &WeakPointerCallback, v8::WeakCallbackType::kParameter);
key.location(), reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
}
CHECK(global_handles->IsWeak(key.location())); CHECK(global_handles->IsWeak(key.location()));
CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
......
...@@ -110,13 +110,10 @@ TEST(WeakSet_Weakness) { ...@@ -110,13 +110,10 @@ TEST(WeakSet_Weakness) {
0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
// Make the global reference to the key weak. // Make the global reference to the key weak.
{ std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
HandleScope scope(isolate); GlobalHandles::MakeWeak(
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); key.location(), reinterpret_cast<void*>(&handle_and_id),
GlobalHandles::MakeWeak( &WeakPointerCallback, v8::WeakCallbackType::kParameter);
key.location(), reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
}
CHECK(global_handles->IsWeak(key.location())); CHECK(global_handles->IsWeak(key.location()));
CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
......
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