[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}
This commit is contained in:
parent
1cbb690366
commit
f392922b4a
@ -7570,13 +7570,14 @@ void InternalFieldCallback(bool global_gc) {
|
||||
Trivial* t1;
|
||||
Trivial2* t2;
|
||||
instance_templ->SetInternalFieldCount(2);
|
||||
v8::Persistent<v8::Object> handle;
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
Local<v8::Object> obj = templ->GetFunction(env.local())
|
||||
.ToLocalChecked()
|
||||
->NewInstance(env.local())
|
||||
.ToLocalChecked();
|
||||
v8::Persistent<v8::Object> handle(isolate, obj);
|
||||
handle.Reset(isolate, obj);
|
||||
CHECK_EQ(2, obj->InternalFieldCount());
|
||||
CHECK(obj->GetInternalField(0)->IsUndefined());
|
||||
t1 = new Trivial(42);
|
||||
|
@ -111,13 +111,10 @@ TEST(Weakness) {
|
||||
0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
|
||||
|
||||
// Make the global reference to the key weak.
|
||||
{
|
||||
HandleScope scope(isolate);
|
||||
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
|
||||
GlobalHandles::MakeWeak(
|
||||
key.location(), reinterpret_cast<void*>(&handle_and_id),
|
||||
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
|
||||
GlobalHandles::MakeWeak(
|
||||
key.location(), reinterpret_cast<void*>(&handle_and_id),
|
||||
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
|
||||
CHECK(global_handles->IsWeak(key.location()));
|
||||
|
||||
CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
|
||||
|
@ -110,13 +110,10 @@ TEST(WeakSet_Weakness) {
|
||||
0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
|
||||
|
||||
// Make the global reference to the key weak.
|
||||
{
|
||||
HandleScope scope(isolate);
|
||||
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
|
||||
GlobalHandles::MakeWeak(
|
||||
key.location(), reinterpret_cast<void*>(&handle_and_id),
|
||||
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
|
||||
GlobalHandles::MakeWeak(
|
||||
key.location(), reinterpret_cast<void*>(&handle_and_id),
|
||||
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
|
||||
CHECK(global_handles->IsWeak(key.location()));
|
||||
|
||||
CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
|
||||
|
Loading…
Reference in New Issue
Block a user