diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/String/ropes.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/String/ropes.js')
-rw-r--r-- | js/src/tests/non262/String/ropes.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/non262/String/ropes.js b/js/src/tests/non262/String/ropes.js new file mode 100644 index 0000000000..b8e99dacb9 --- /dev/null +++ b/js/src/tests/non262/String/ropes.js @@ -0,0 +1,58 @@ +print("Stress test of ropes"); + +if (typeof newRope === "undefined") { + var newRope = SpecialPowers.Cu.getJSTestingFunctions().newRope; +} +if (typeof ensureLinearString === "undefined") { + var ensureLinearString = SpecialPowers.Cu.getJSTestingFunctions().ensureLinearString; +} + +function createRopes() { + const ropes = {}; + + let j = 88; + function advance() { + // This is totally made up and probably stupid. + j = ((((j * 7) >> 2) + j) + (j << 3)) | 0; + return j; + } + + function randomBalancedRope(height) { + if (height == 0) + return "s" + j; + + const left = randomBalancedRope(height - 1); + advance(); + const right = randomBalancedRope(height - 1); + advance(); + return newRope(left, right, {nursery:(j & 1)}); + } + + // Construct a fairly big random rope first. If we did it later, then the + // chances of it all ending up tenured are higher. + ropes.balanced = randomBalancedRope(10); + + ropes.simple = newRope("a", "b"); + ropes.simple_tenured = newRope("a", "b", {nursery:false}); + ropes.tenured_nursery = newRope("a", newRope("b", "c", {nursery:true}), {nursery:false}); + ropes.nursery_tenured = newRope("a", newRope("b", "c", {nursery:false}), {nursery:true}); + + return ropes; +} + +const ropes = createRopes(); + +// Flatten them all. +for (const [name, rope] of Object.entries(ropes)) + ensureLinearString(rope); + +// GC with them all live. +let ropes2 = createRopes(); +gc(); + +// GC with them all dead. +ropes2 = null; +gc(); + +if (typeof reportCompare === "function") + reportCompare(true, true); |