]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/generational-opaque-roots.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / generational-opaque-roots.js
CommitLineData
81345200
A
1// Tests that opaque roots behave correctly during young generation collections
2
3// Create the primary Root.
4var root = new Root();
5// This secondary root is for allocating a second Element without overriding
6// the primary Root's Element.
7var otherRoot = new Root();
8
9// Run an Eden collection so that the Root will be in the old gen (and won't be rescanned).
10edenGC();
11
12// Create a new Element and set a custom property on it.
13var elem = new Element(root);
14elem.customProperty = "hello";
15
16// Make the Element unreachable except through the ephemeron with the Root.
17elem = null;
18
19// Create another Element so that we process the weak handles in block of the original Element.
20var test = new Element(otherRoot);
21
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.
25edenGC();
26
27// Check if the primary Root's Element exists and has our custom property.
28var elem = getElement(root);
29if (elem.customProperty != "hello")
30 throw new Error("bad value of customProperty: " + elem.customProperty);