michael@0: // |reftest| skip michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: Jason Orendorff michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: var summary = "Contention among threads enumerating properties"; michael@0: // Adapted from mozilla/js/src/xpconnect/tests/js/old/threads.js michael@0: michael@0: printStatus (summary); michael@0: michael@0: var LOOP_COUNT = 1000; michael@0: var THREAD_COUNT = 10; michael@0: michael@0: var foo; michael@0: var bar; michael@0: michael@0: function makeWorkerFn(id) { michael@0: return function() { michael@0: foo = id + 1; michael@0: bar[id] = {p: 0}; michael@0: var n, m; michael@0: for (n in bar) { michael@0: for (m in bar[n]) {} michael@0: } michael@0: for (n in parent({})) {} michael@0: }; michael@0: } michael@0: michael@0: function range(n) { michael@0: for (let i = 0; i < n; i++) michael@0: yield i; michael@0: } michael@0: michael@0: var expect; michael@0: var actual; michael@0: michael@0: expect = actual = 'No crash'; michael@0: if (typeof scatter == 'undefined') { michael@0: print('Test skipped. scatter not defined.'); michael@0: } else if (typeof parent === "undefined") { michael@0: print('Test skipped, no parent() function.'); michael@0: } else { michael@0: for (let i = 0; i < LOOP_COUNT; i++) { michael@0: foo = 0; michael@0: bar = new Array(THREAD_COUNT); michael@0: scatter([makeWorkerFn(j) for (j in range(THREAD_COUNT))]); michael@0: } michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary);