summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_5/GC
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/js1_5/GC')
-rw-r--r--js/src/tests/js1_5/GC/browser.js0
-rw-r--r--js/src/tests/js1_5/GC/regress-104584.js46
-rw-r--r--js/src/tests/js1_5/GC/regress-203278-2.js79
-rw-r--r--js/src/tests/js1_5/GC/regress-203278-3.js42
-rw-r--r--js/src/tests/js1_5/GC/regress-278725.js29
-rw-r--r--js/src/tests/js1_5/GC/regress-306788.js24
-rw-r--r--js/src/tests/js1_5/GC/regress-311497.js61
-rw-r--r--js/src/tests/js1_5/GC/regress-313276.js40
-rw-r--r--js/src/tests/js1_5/GC/regress-313479.js37
-rw-r--r--js/src/tests/js1_5/GC/regress-316885-01.js33
-rw-r--r--js/src/tests/js1_5/GC/regress-316885-02.js42
-rw-r--r--js/src/tests/js1_5/GC/regress-316885-03.js42
-rw-r--r--js/src/tests/js1_5/GC/regress-319980-01.js127
-rw-r--r--js/src/tests/js1_5/GC/regress-324278.js63
-rw-r--r--js/src/tests/js1_5/GC/regress-331719.js19
-rw-r--r--js/src/tests/js1_5/GC/regress-338653.js41
-rw-r--r--js/src/tests/js1_5/GC/regress-341877-01.js40
-rw-r--r--js/src/tests/js1_5/GC/regress-341877-02.js45
-rw-r--r--js/src/tests/js1_5/GC/regress-346794.js43
-rw-r--r--js/src/tests/js1_5/GC/regress-348532.js54
-rw-r--r--js/src/tests/js1_5/GC/regress-352606.js28
-rw-r--r--js/src/tests/js1_5/GC/regress-383269-01.js62
-rw-r--r--js/src/tests/js1_5/GC/regress-383269-02.js66
-rw-r--r--js/src/tests/js1_5/GC/regress-390078.js36
-rw-r--r--js/src/tests/js1_5/GC/regress-418128.js40
-rw-r--r--js/src/tests/js1_5/GC/regress-440558.js37
-rw-r--r--js/src/tests/js1_5/GC/shell.js0
27 files changed, 1176 insertions, 0 deletions
diff --git a/js/src/tests/js1_5/GC/browser.js b/js/src/tests/js1_5/GC/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/js1_5/GC/browser.js
diff --git a/js/src/tests/js1_5/GC/regress-104584.js b/js/src/tests/js1_5/GC/regress-104584.js
new file mode 100644
index 000000000..4148b6915
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-104584.js
@@ -0,0 +1,46 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Date: 14 October 2001
+ *
+ * SUMMARY: Regression test for Bugzilla bug 104584
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=104584
+ *
+ * Testing that we don't crash on this code. The idea is to
+ * call F,G WITHOUT providing an argument. This caused a crash
+ * on the second call to obj.toString() or print(obj) below -
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 104584;
+var summary = "Testing that we don't crash on this code -";
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+F();
+G();
+
+reportCompare('No Crash', 'No Crash', '');
+
+function F(obj)
+{
+ if(!obj)
+ obj = {};
+ obj.toString();
+ gc();
+ obj.toString();
+}
+
+
+function G(obj)
+{
+ if(!obj)
+ obj = {};
+ print(obj);
+ gc();
+ print(obj);
+}
diff --git a/js/src/tests/js1_5/GC/regress-203278-2.js b/js/src/tests/js1_5/GC/regress-203278-2.js
new file mode 100644
index 000000000..e2433f485
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-203278-2.js
@@ -0,0 +1,79 @@
+/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 203278;
+var summary = 'Don\'t crash in recursive js_MarkGCThing';
+var actual = 'FAIL';
+var expect = 'PASS';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+// Prepare array to test DeutschSchorrWaite implementation
+// and its reverse pointer scanning performance
+
+var a = new Array(1000 * 1000);
+
+var i = a.length;
+while (i-- != 0) {
+ switch (i % 11) {
+ case 0:
+ a[i] = { };
+ break;
+ case 1:
+ a[i] = { a: true, b: false, c: 0 };
+ break;
+ case 2:
+ a[i] = { 0: true, 1: {}, 2: false };
+ break;
+ case 3:
+ a[i] = { a: 1.2, b: "", c: [] };
+ break;
+ case 4:
+ a[i] = [ false ];
+ break;
+ case 6:
+ a[i] = [];
+ break;
+ case 7:
+ a[i] = false;
+ break;
+ case 8:
+ a[i] = "x";
+ break;
+ case 9:
+ a[i] = new String("x");
+ break;
+ case 10:
+ a[i] = 1.1;
+ break;
+ case 10:
+ a[i] = new Boolean();
+ break;
+ }
+}
+
+printStatus("DSF is prepared");
+
+// Prepare linked list that causes recursion during GC with
+// depth O(list size)
+// Note: pass "-S 500000" option to the shell to limit stack quota
+// available for recursion
+
+for (i = 0; i != 50*1000; ++i) {
+ a = [a, a, {}];
+ a = [a, {}, a];
+
+}
+
+printStatus("Linked list is prepared");
+
+gc();
+
+actual = 'PASS';
+
+reportCompare(expect, actual, summary);
+
diff --git a/js/src/tests/js1_5/GC/regress-203278-3.js b/js/src/tests/js1_5/GC/regress-203278-3.js
new file mode 100644
index 000000000..3ac6d4c91
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-203278-3.js
@@ -0,0 +1,42 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 203278;
+var summary = 'Don\'t crash in recursive js_MarkGCThing';
+var actual = 'FAIL';
+var expect = 'PASS';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+// Prepare array a to cause O(a.length^2) behaviour in the current
+// DeutschSchorrWaite implementation
+
+var a = new Array(1000 * 100);
+
+var i = a.length;
+while (i-- != 0)
+{
+ a[i] = {};
+}
+
+// Prepare linked list that causes recursion during GC with
+// depth O(list size)
+
+for (i = 0; i != 50*1000; ++i)
+{
+ a = [a, a.concat()];
+}
+
+if (typeof gc == 'function')
+{
+ gc();
+}
+
+actual = 'PASS';
+
+reportCompare(expect, actual, summary);
+
diff --git a/js/src/tests/js1_5/GC/regress-278725.js b/js/src/tests/js1_5/GC/regress-278725.js
new file mode 100644
index 000000000..47df5950f
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-278725.js
@@ -0,0 +1,29 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+// testcase by James Ross <silver@warwickcompsoc.co.uk>
+var BUGNUMBER = 278725;
+var summary = 'Don\'t Crash during GC';
+var actual = 'Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var results = [];
+for (var k = 0; k < 600000; k++) {
+ if (! (k %100000)) {
+ printStatus('hi');
+ if (0) {
+ results.length = 0;
+ gc();
+ }
+ }
+ results.push({});
+}
+
+actual = 'No Crash';
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-306788.js b/js/src/tests/js1_5/GC/regress-306788.js
new file mode 100644
index 000000000..d6e130679
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-306788.js
@@ -0,0 +1,24 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 306788;
+var summary = 'Do not crash sorting Arrays due to GC';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var array = new Array();
+
+for (var i = 0; i < 5000; i++)
+{
+ array[i] = new Array('1', '2', '3', '4', '5');
+}
+
+array.sort();
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-311497.js b/js/src/tests/js1_5/GC/regress-311497.js
new file mode 100644
index 000000000..21905a7fd
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-311497.js
@@ -0,0 +1,61 @@
+/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 311497;
+var summary = 'Root pivots in js_HeapSort';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+
+function force_gc()
+{
+ if (this.gc) gc();
+ for (var i = 0; i != 30000; ++i) {
+ var tmp = Math.sin(i);
+ tmp = null;
+ }
+}
+
+var array = new Array(10);
+for (var i = 0; i != array.length; ++i) {
+ array[i] = String.fromCharCode(i, i, i);
+}
+
+function cmp(a, b)
+{
+ for (var i = 0; i != array.length; ++i) {
+ array[i] = null;
+ }
+ force_gc();
+ return 0;
+}
+
+array.sort(cmp);
+
+// Verify that array contains either null or original strings
+
+var null_count = 0;
+var original_string_count = 0;
+for (var i = 0; i != array.length; ++i) {
+ var elem = array[i];
+ if (elem === null) {
+ ++null_count;
+ } else if (typeof elem == "string" && elem.length == 3) {
+ var code = elem.charCodeAt(0);
+ if (0 <= code && code < array.length) {
+ if (code === elem.charCodeAt(1) && code == elem.charCodeAt(2))
+ ++original_string_count;
+ }
+ }
+}
+
+var expect = array.length;
+var actual = null_count + original_string_count;
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-313276.js b/js/src/tests/js1_5/GC/regress-313276.js
new file mode 100644
index 000000000..7f622fa3f
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-313276.js
@@ -0,0 +1,40 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 313276;
+var summary = 'Root strings';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var obj = {
+ toString: function() {
+ return "*TEST*".substr(1, 4);
+ }
+};
+
+var TMP = 1e200;
+
+var likeZero = {
+ valueOf: function() {
+ if (typeof gc == "function") gc();
+ for (var i = 0; i != 40000; ++i) {
+ var tmp = 2 / TMP;
+ tmp = null;
+ }
+ return 0;
+ }
+}
+
+ expect = "TEST";
+actual = String.prototype.substr.call(obj, likeZero);
+
+printStatus("Substring length: "+actual.length);
+printStatus((expect === actual).toString());
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-313479.js b/js/src/tests/js1_5/GC/regress-313479.js
new file mode 100644
index 000000000..a13dba3ff
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-313479.js
@@ -0,0 +1,37 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 313479;
+var summary = 'Root access in jsnum.c';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var prepared_string = String(1);
+String(2); // To remove prepared_string from newborn
+
+var likeString = {
+ toString: function() {
+ var tmp = prepared_string;
+ prepared_string = null;
+ return tmp;
+ }
+};
+
+var likeNumber = {
+ valueOf: function() {
+ gc();
+ return 10;
+ }
+}
+
+ var expect = 1;
+var actual = parseInt(likeString, likeNumber);
+printStatus("expect="+expect+" actual="+actual);
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-316885-01.js b/js/src/tests/js1_5/GC/regress-316885-01.js
new file mode 100644
index 000000000..da814bbae
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-316885-01.js
@@ -0,0 +1,33 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 316885;
+var summary = 'Unrooted access in jsinterp.c';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var str_with_num = "0.1";
+
+var obj = {
+ get elem() {
+ return str_with_num;
+ },
+ set elem(value) {
+ gc();
+ }
+
+};
+
+expect = Number(str_with_num);
+actual = obj.elem++;
+
+gc();
+
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-316885-02.js b/js/src/tests/js1_5/GC/regress-316885-02.js
new file mode 100644
index 000000000..2cdda6006
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-316885-02.js
@@ -0,0 +1,42 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 316885;
+var summary = 'Unrooted access in jsinterp.c';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var str = "test";
+
+var lval = {
+ valueOf: function() {
+ return str+"1";
+ }
+};
+
+var ONE = 1;
+
+var rval = {
+ valueOf: function() {
+ // Make sure that the result of the previous lval.valueOf
+ // is not GC-rooted.
+ var tmp = "x"+lval;
+ if (typeof gc == "function")
+ gc();
+ for (var i = 0; i != 40000; ++i) {
+ tmp = 1e100 / ONE;
+ }
+ return str;
+ }
+};
+
+expect = (str+"1" > str);
+actual = (lval > rval);
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-316885-03.js b/js/src/tests/js1_5/GC/regress-316885-03.js
new file mode 100644
index 000000000..93f632e78
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-316885-03.js
@@ -0,0 +1,42 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 316885;
+var summary = 'Unrooted access in jsinterp.c';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var str = "test";
+
+var lval = {
+ valueOf: function() {
+ return str+"1";
+ }
+};
+
+var ONE = 1;
+
+var rval = {
+ valueOf: function() {
+ // Make sure that the result of the previous lval.valueOf
+ // is not GC-rooted.
+ var tmp = "x"+lval;
+ if (typeof gc == "function")
+ gc();
+ for (var i = 0; i != 40000; ++i) {
+ tmp = 1e100 / ONE;
+ }
+ return str;
+ }
+};
+
+expect = (str+"1")+str;
+actual = lval+rval;
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-319980-01.js b/js/src/tests/js1_5/GC/regress-319980-01.js
new file mode 100644
index 000000000..e9e696c8d
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-319980-01.js
@@ -0,0 +1,127 @@
+// |reftest| skip-if(!xulRuntime.shell) slow
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 319980;
+var summary = 'GC not called during non-fatal out of memory';
+var actual = '';
+var expect = 'Normal Exit';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+print ('This test should never fail explicitly. ' +
+ 'You must view the memory usage during the test. ' +
+ 'This test fails if memory usage for each subtest grows');
+
+var timeOut = 45 * 1000;
+var interval = 0.01 * 1000;
+var testFuncWatcherId;
+var testFuncTimerId;
+var maxTests = 5;
+var currTest = 0;
+
+if (typeof setTimeout == 'undefined')
+{
+ setTimeout = function() {};
+ clearTimeout = function() {};
+ actual = 'Normal Exit';
+ reportCompare(expect, actual, summary);
+}
+else
+{
+ // delay start until after js-test-driver-end runs.
+ // delay test driver end
+ gDelayTestDriverEnd = true;
+
+ setTimeout(testFuncWatcher, 1000);
+}
+
+function testFuncWatcher()
+{
+ a = null;
+
+ gc();
+
+ clearTimeout(testFuncTimerId);
+ testFuncWatcherId = testFuncTimerId = null;
+ if (currTest >= maxTests)
+ {
+ actual = 'Normal Exit';
+ reportCompare(expect, actual, summary);
+ printStatus('Test Completed');
+ gDelayTestDriverEnd = false;
+ jsTestDriverEnd();
+ return;
+ }
+ ++currTest;
+
+ print('Executing test ' + currTest + '\n');
+
+ testFuncWatcherId = setTimeout("testFuncWatcher()", timeOut);
+ testFuncTimerId = setTimeout(testFunc, interval);
+}
+
+
+var a;
+function testFunc()
+{
+
+ var i;
+
+ switch(currTest)
+ {
+ case 1:
+ a = new Array(100000);
+ for (i = 0; i < 100000; i++ )
+ {
+ a[i] = i;
+ }
+ break;
+
+ case 2:
+ a = new Array(100000);
+ for (i = 0; i < 100000; i++)
+ {
+ a[i] = new Number();
+ a[i] = i;
+ }
+ break;
+
+ case 3:
+ a = new String() ;
+ a = new Array(100000);
+ for ( i = 0; i < 100000; i++ )
+ {
+ a[i] = i;
+ }
+
+ break;
+
+ case 4:
+ a = new Array();
+ a[0] = new Array(100000);
+ for (i = 0; i < 100000; i++ )
+ {
+ a[0][i] = i;
+ }
+ break;
+
+ case 5:
+ a = new Array();
+ for (i = 0; i < 100000; i++ )
+ {
+ a[i] = i;
+ }
+ break;
+ }
+
+ if (testFuncTimerId)
+ {
+ testFuncTimerId = setTimeout(testFunc, interval);
+ }
+}
+
+
diff --git a/js/src/tests/js1_5/GC/regress-324278.js b/js/src/tests/js1_5/GC/regress-324278.js
new file mode 100644
index 000000000..56996994d
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-324278.js
@@ -0,0 +1,63 @@
+// |reftest| skip -- slow, obsoleted by 98409 fix
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 324278;
+var summary = 'GC without recursion';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+// Number to push native stack size beyond 10MB if GC recurses generating
+// segfault on Fedora Core / Ubuntu Linuxes where the stack size by default
+// is 10MB/8MB.
+var N = 100*1000;
+
+function build(N) {
+ // Exploit the fact that (in ES3), regexp literals are shared between
+ // function invocations. Thus we build the following chain:
+ // chainTop: function->regexp->function->regexp....->null
+ // to check how GC would deal with this chain.
+
+ var chainTop = null;
+ for (var i = 0; i != N; ++i) {
+ var f = Function('some_arg'+i, ' return /test/;');
+ var re = f();
+ re.previous = chainTop;
+ chainTop = f;
+ }
+ return chainTop;
+}
+
+function check(chainTop, N) {
+ for (var i = 0; i != N; ++i) {
+ var re = chainTop();
+ chainTop = re.previous;
+ }
+ if (chainTop !== null)
+ throw "Bad chainTop";
+
+}
+
+if (typeof gc != "function") {
+ gc = function() {
+ for (var i = 0; i != 50*1000; ++i) {
+ var tmp = new Object();
+ }
+ }
+}
+
+var chainTop = build(N);
+printStatus("BUILT");
+gc();
+check(chainTop, N);
+printStatus("CHECKED");
+chainTop = null;
+gc();
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-331719.js b/js/src/tests/js1_5/GC/regress-331719.js
new file mode 100644
index 000000000..3803b3d5c
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-331719.js
@@ -0,0 +1,19 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 331719;
+var summary = 'Problem with String.replace running with WAY_TOO_MUCH_GC';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+print('This test requires WAY_TOO_MUCH_GC');
+
+expect = 'No';
+actual = 'No'.replace(/\&\&/g, '&');
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-338653.js b/js/src/tests/js1_5/GC/regress-338653.js
new file mode 100644
index 000000000..17ef68de9
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-338653.js
@@ -0,0 +1,41 @@
+// |reftest| skip -- slow, killed on x86_64
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 338653;
+var summary = 'Force GC when JSRuntime.gcMallocBytes hits ' +
+ 'JSRuntime.gcMaxMallocBytes';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+print('This test should never fail explicitly. ' +
+ 'You must view the memory usage during the test. ' +
+ 'This test fails if the memory usage repeatedly spikes ' +
+ 'by several hundred megabytes.');
+
+function dosubst()
+{
+ var f = '0x';
+ var s = f;
+
+ for (var i = 0; i < 18; i++)
+ {
+ s += s;
+ }
+
+ var index = s.indexOf(f);
+ while (index != -1 && index < 10000) {
+ s = s.substr(0, index) + '1' + s.substr(index + f.length);
+ index = s.indexOf(f);
+ }
+
+}
+
+dosubst();
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-341877-01.js b/js/src/tests/js1_5/GC/regress-341877-01.js
new file mode 100644
index 000000000..6fc88f3ac
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-341877-01.js
@@ -0,0 +1,40 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 341877;
+var summary = 'GC hazard with for-in loop';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var obj = { };
+
+var prop = "xsomePropety".substr(1);
+
+obj.first = "first"
+
+ obj[prop] = 1;
+
+for (var elem in obj) {
+ var tmp = elem.toString();
+ delete obj[prop];
+ // ensure that prop is cut from all roots
+ prop = "xsomePropety".substr(2);
+ obj[prop] = 2;
+ delete obj[prop];
+ prop = null;
+ if (typeof gc == 'function')
+ gc();
+ for (var i = 0; i != 50000; ++i) {
+ var tmp = 1 / 3;
+ tmp /= 10;
+ }
+}
+
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-341877-02.js b/js/src/tests/js1_5/GC/regress-341877-02.js
new file mode 100644
index 000000000..b636ad693
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-341877-02.js
@@ -0,0 +1,45 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 341877;
+var summary = 'GC hazard with for-in loop';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var obj = { };
+
+var prop = "xsomePropety".substr(1);
+
+obj.first = "first"
+
+ obj[prop] = 1;
+
+for (var elem in obj) {
+ var tmp = elem.toString();
+ delete obj[prop];
+ // ensure that prop is cut from all roots
+ prop = "xsomePropety".substr(2);
+ obj[prop] = 2;
+ delete obj[prop];
+ prop = null;
+ if (typeof gc == 'function')
+ gc();
+ for (var i = 0; i != 50000; ++i) {
+ var tmp = 1 / 3;
+ tmp /= 10;
+ }
+ for (var i = 0; i != 1000; ++i) {
+ // Make string with 11 characters that would take
+ // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually
+ // malloc will ovewrite just freed atoms.
+ var tmp2 = Array(12).join(' ');
+ }
+}
+
+reportCompare(expect, actual, summary);
diff --git a/js/src/tests/js1_5/GC/regress-346794.js b/js/src/tests/js1_5/GC/regress-346794.js
new file mode 100644
index 000000000..a747642f1
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-346794.js
@@ -0,0 +1,43 @@
+// |reftest| skip -- slow, killed
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 346794;
+var summary = 'Do not crash';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ // either don't crash or run out of memory
+ expectExitCode(0);
+ expectExitCode(3);
+
+ function boo() {
+ s = '';
+ for (;;) {
+ try {
+ new RegExp(s + '[\\');
+ } catch(e) {}
+ s += 'q';
+ }
+ }
+
+ boo();
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-348532.js b/js/src/tests/js1_5/GC/regress-348532.js
new file mode 100644
index 000000000..cff651a63
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-348532.js
@@ -0,0 +1,54 @@
+// |reftest| skip-if(Android)
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 348532;
+var summary = 'Do not overflow int when constructing Error.stack';
+var actual = '';
+var expect = '';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ expectExitCode(0);
+ expectExitCode(3);
+ actual = 0;
+
+ // construct string of 1<<23 characters
+ var s = Array((1<<23)+1).join('x');
+
+ var recursionDepth = 0;
+ function err() {
+ try {
+ return err.apply(this, arguments);
+ } catch (e) {
+ if (!(e instanceof InternalError))
+ throw e;
+ }
+ return new Error();
+ }
+
+ // The full stack trace in error would include 64*4 copies of s exceeding
+ // 2^23 * 256 or 2^31 in length
+ var error = err(s,s,s,s);
+
+ print(error.stack.length);
+
+ expect = true;
+ actual = (error.stack.length > 0);
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-352606.js b/js/src/tests/js1_5/GC/regress-352606.js
new file mode 100644
index 000000000..b29c501fd
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-352606.js
@@ -0,0 +1,28 @@
+/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 352606;
+var summary = 'Do not crash involving post decrement';
+var actual = '';
+var expect = '';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ y = ({toString: gc}); new Function("y--;")()
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-383269-01.js b/js/src/tests/js1_5/GC/regress-383269-01.js
new file mode 100644
index 000000000..43f6a15fa
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-383269-01.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- unreliable - based on GC timing
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 383269;
+var summary = 'Leak related to arguments object';
+var actual = 'No Leak';
+var expect = 'No Leak';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ function generate_big_object_graph()
+ {
+ var root = {};
+ f(root, 17);
+ return root;
+ function f(parent, depth) {
+ if (depth == 0)
+ return;
+ --depth;
+ f(parent.a = {}, depth);
+ f(parent.b = {}, depth);
+ }
+ }
+
+ function outer() { var x = arguments; return function inner() { return x }; }
+
+ function timed_gc()
+ {
+ var t1 = Date.now();
+ gc();
+ return Date.now() - t1;
+ }
+
+ outer(1);
+ gc();
+ var base_time = timed_gc();
+
+ var f = outer(generate_big_object_graph());
+ f = null;
+ gc();
+ var time = timed_gc();
+
+ if (time > (base_time + 1) * 3)
+ actual = "generate_big_object_graph() leaked, base_gc_time="+base_time+", last_gc_time="+time;
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-383269-02.js b/js/src/tests/js1_5/GC/regress-383269-02.js
new file mode 100644
index 000000000..9ce0e44a0
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-383269-02.js
@@ -0,0 +1,66 @@
+// |reftest| skip -- unreliable - based on GC timing
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 383269;
+var summary = 'Leak related to arguments object';
+var actual = 'No Leak';
+var expect = 'No Leak';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ function generate_big_object_graph()
+ {
+ var root = {};
+ f(root, 17);
+ return root;
+ function f(parent, depth) {
+ if (depth == 0)
+ return;
+ --depth;
+ f(parent.a = {}, depth);
+ f(parent.b = {}, depth);
+ }
+ }
+
+ function f(obj) {
+ with (obj)
+ return arguments;
+ }
+
+ function timed_gc()
+ {
+ var t1 = Date.now();
+ gc();
+ return Date.now() - t1;
+ }
+
+ var x = f({});
+ x = null;
+ gc();
+ var base_time = timed_gc();
+
+ x = f(generate_big_object_graph());
+ x = null;
+ gc();
+ var time = timed_gc();
+
+ if (time > (base_time + 10) * 3)
+ actual = "generate_big_object_graph() leaked, base_gc_time="+base_time+", last_gc_time="+time;
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-390078.js b/js/src/tests/js1_5/GC/regress-390078.js
new file mode 100644
index 000000000..4a86d84ff
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-390078.js
@@ -0,0 +1,36 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 390078;
+var summary = 'GC hazard with JSstackFrame.argv[-1]';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ var a = new Array(10*1000);
+ a[0] = { toString: function() { gc(); return ".*9"; }};;
+ a[1] = "g";
+
+ for (var i = 0; i != 10*1000; ++i) {
+ String(new Number(123456789));
+ }
+
+ "".match.apply(123456789, a);
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-418128.js b/js/src/tests/js1_5/GC/regress-418128.js
new file mode 100644
index 000000000..0642e83dc
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-418128.js
@@ -0,0 +1,40 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 418128;
+var summary = 'GC hazard with ++/--';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ var obj = {};
+ var id = { toString: function() { return ""+Math.pow(2, 0.1); } }
+ obj[id] = { valueOf: unrooter };
+ print(obj[id]++);
+ gc();
+ print(uneval(obj));
+
+ function unrooter()
+ {
+ delete obj[id];
+ gc();
+ return 10;
+ }
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_5/GC/regress-440558.js b/js/src/tests/js1_5/GC/regress-440558.js
new file mode 100644
index 000000000..b36d01ba5
--- /dev/null
+++ b/js/src/tests/js1_5/GC/regress-440558.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(Android)
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 440558;
+var summary = 'Do not assert: *flagp != GCF_FINAL';
+var actual = 'No Crash';
+var expect = 'No Crash';
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ print('Note: this test requires that javascript.options.gczeal ' +
+ 'be set to 2 prior to the browser start');
+
+ m = function(a, b) {
+ if (++i < 10) {
+ }
+ };
+ e = function(a, b) {
+ };
+
+ reportCompare(expect, actual, summary);
+
+ exitFunc ('test');
+}
+
diff --git a/js/src/tests/js1_5/GC/shell.js b/js/src/tests/js1_5/GC/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/js1_5/GC/shell.js