Commit 4a395137 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Test] Make collections-constructor-custom-iterator resilient to GCs.

The optimized code for TestSetWithCustomIterator holds a weak reference to the map
for the entries object. If this is collected by the GC then the optimized code deopts
which causes the test to fail. To prevent this, hold onto an entires object to keep
it's map alive.

Change-Id: I5796e74fc1d7c5061bf8c98f7a82fe582d6be76a
Reviewed-on: https://chromium-review.googlesource.com/c/1357043Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57978}
parent 298aefa6
......@@ -4,6 +4,8 @@
// Flags: --allow-natives-syntax --opt
var global;
function TestSetWithCustomIterator(ctor) {
const k1 = {};
const k2 = {};
......@@ -19,6 +21,9 @@ function TestSetWithCustomIterator(ctor) {
assertFalse(set.has(k1));
assertTrue(set.has(k2));
assertEquals(2, callCount);
// Keep entries alive to avoid collection of the weakly held map in optimized
// code which causes the code to deopt.
global = entries;
}
TestSetWithCustomIterator(Set);
TestSetWithCustomIterator(Set);
......@@ -49,6 +54,9 @@ function TestMapWithCustomIterator(ctor) {
assertFalse(map.has(k1));
assertEquals(2, map.get(k2));
assertEquals(2, callCount);
// Keep entries alive to avoid collection of the weakly held map in optimized
// code which causes the code to deopt.
global = entries;
}
TestMapWithCustomIterator(Map);
TestMapWithCustomIterator(Map);
......
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