Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: test/cctest/test-weaksets.cc

Issue 2655533004: [tests] Fix use-after-scope errors related to weak refs (Closed)
Patch Set: typo Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 103 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
104 104
105 // Force a full GC. 105 // Force a full GC.
106 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 106 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
107 CHECK_EQ(0, NumberOfWeakCalls); 107 CHECK_EQ(0, NumberOfWeakCalls);
108 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 108 CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
109 CHECK_EQ( 109 CHECK_EQ(
110 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 110 0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
111 111
112 // Make the global reference to the key weak. 112 // Make the global reference to the key weak.
113 { 113 std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
114 HandleScope scope(isolate); 114 GlobalHandles::MakeWeak(
115 std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); 115 key.location(), reinterpret_cast<void*>(&handle_and_id),
116 GlobalHandles::MakeWeak( 116 &WeakPointerCallback, v8::WeakCallbackType::kParameter);
117 key.location(), reinterpret_cast<void*>(&handle_and_id),
118 &WeakPointerCallback, v8::WeakCallbackType::kParameter);
119 }
120 CHECK(global_handles->IsWeak(key.location())); 117 CHECK(global_handles->IsWeak(key.location()));
121 118
122 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 119 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
123 CHECK_EQ(1, NumberOfWeakCalls); 120 CHECK_EQ(1, NumberOfWeakCalls);
124 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); 121 CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements());
125 CHECK_EQ( 122 CHECK_EQ(
126 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); 123 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
127 } 124 }
128 125
129 126
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 JSWeakCollection::Set(weakset, keys[i], smi, hash); 235 JSWeakCollection::Set(weakset, keys[i], smi, hash);
239 } 236 }
240 237
241 // Force compacting garbage collection. The subsequent collections are used 238 // Force compacting garbage collection. The subsequent collections are used
242 // to verify that key references were actually updated. 239 // to verify that key references were actually updated.
243 CHECK(FLAG_always_compact); 240 CHECK(FLAG_always_compact);
244 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 241 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
245 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 242 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
246 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 243 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
247 } 244 }
OLDNEW
« no previous file with comments | « test/cctest/test-weakmaps.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698