]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/generational-opaque-roots.js
1 // Tests that opaque roots behave correctly during young generation collections
3 // Create the primary Root.
5 // This secondary root is for allocating a second Element without overriding
6 // the primary Root's Element.
7 var otherRoot
= new Root();
9 // Run an Eden collection so that the Root will be in the old gen (and won't be rescanned).
12 // Create a new Element and set a custom property on it.
13 var elem
= new Element(root
);
14 elem
.customProperty
= "hello";
16 // Make the Element unreachable except through the ephemeron with the Root.
19 // Create another Element so that we process the weak handles in block of the original Element.
20 var test
= new Element(otherRoot
);
22 // Run another Eden collection to process the weak handles in the Element's block. If opaque roots
23 // are cleared then we'll think that the original Element is dead because the Root won't be in the
24 // set of opaque roots.
27 // Check if the primary Root's Element exists and has our custom property.
28 var elem
= getElement(root
);
29 if (elem
.customProperty
!= "hello")
30 throw new Error("bad value of customProperty: " + elem
.customProperty
);