From b5e3ebf85ff235a35135c8abf0d0f07b89e95258 Mon Sep 17 00:00:00 2001
From: test262-automation <test262-automation@bocoup.com>
Date: Wed, 14 Nov 2018 18:59:46 +0000
Subject: [PATCH] [javascriptcore-test262-automation] Changes from
 https://github.com/webkit/webkit.git at sha 38e0e5eed1 on Wed Nov 14 2018
 18:57:07 GMT+0000 (Coordinated Universal Time)

---
 .../stress/big-int-out-of-memory-tests.js     | 63 -------------------
 .../javascriptcore/stress/regress-191563.js   | 22 +++++++
 .../javascriptcore/stress/regress-191579.js   | 26 ++++++++
 ...ler-log-should-defer-pending-exceptions.js | 26 ++++++++
 4 files changed, 74 insertions(+), 63 deletions(-)
 delete mode 100644 implementation-contributed/javascriptcore/stress/big-int-out-of-memory-tests.js
 create mode 100644 implementation-contributed/javascriptcore/stress/regress-191563.js
 create mode 100644 implementation-contributed/javascriptcore/stress/regress-191579.js
 create mode 100644 implementation-contributed/javascriptcore/stress/type-profiler-log-should-defer-pending-exceptions.js

diff --git a/implementation-contributed/javascriptcore/stress/big-int-out-of-memory-tests.js b/implementation-contributed/javascriptcore/stress/big-int-out-of-memory-tests.js
deleted file mode 100644
index ac39387ba1..0000000000
--- a/implementation-contributed/javascriptcore/stress/big-int-out-of-memory-tests.js
+++ /dev/null
@@ -1,63 +0,0 @@
-//@ runDefault("--useBigInt=true", "--useDFGJIT=false")
-
-function assert(a, message) {
-    if (!a)
-        throw new Error(message);
-}
-
-function lshift(y) {
-    let out = 1n;
-    for (let i = 0; i < y; i++) {
-        out *= 2n;
-    }
-
-    return out;
-}
-
-let a = lshift(16384 * 63);
-for (let i = 0; i < 256; i++) {
-    a *= 18446744073709551615n;
-}
-
-try {
-    let b = a + 1n;
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
-try {
-    let b = a - (-1n);
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
-try {
-    let b = a * (-1n);
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
-try {
-    let b = a / a;
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
-try {
-    let b = -a & -1n;
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
-try {
-    let b = a ^ -1n;
-    assert(false, "Should throw OutOfMemoryError, but executed without exception");
-} catch(e) {
-    assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
-}
-
diff --git a/implementation-contributed/javascriptcore/stress/regress-191563.js b/implementation-contributed/javascriptcore/stress/regress-191563.js
new file mode 100644
index 0000000000..5937d59721
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/regress-191563.js
@@ -0,0 +1,22 @@
+//@ skip if $memoryLimited
+
+function foo(str, count) {
+    while (str.length < count) {
+        try {
+           str += str;
+        } catch (e) {}
+    }
+    return str.substring();
+}
+var x = foo("1", 1 << 20);
+var y = foo("$1", 1 << 16);
+
+var exception;
+try {
+    var __v_6623 = x.replace(/(.+)/g, y);
+} catch (e) {
+    exception = e;
+}
+
+if (exception != "Error: Out of memory")
+    throw "FAILED";
diff --git a/implementation-contributed/javascriptcore/stress/regress-191579.js b/implementation-contributed/javascriptcore/stress/regress-191579.js
new file mode 100644
index 0000000000..388e5a10da
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/regress-191579.js
@@ -0,0 +1,26 @@
+//@ requireOptions("--maxPerThreadStackUsage=400000", "--useTypeProfiler=true", "--exceptionStackTraceLimit=1", "--defaultErrorStackTraceLimit=1")
+
+// This test passes if it does not crash.
+
+var count = 0;
+
+function bar() {
+    new foo();
+};
+
+function foo() {
+    if (count++ > 2000)
+        return;
+    let proxy = new Proxy({}, {
+        set: function() {
+            bar();
+        }
+    });
+    try {
+        Reflect.set(proxy);
+        foo();
+    } catch (e) {
+    }
+}
+
+bar();
diff --git a/implementation-contributed/javascriptcore/stress/type-profiler-log-should-defer-pending-exceptions.js b/implementation-contributed/javascriptcore/stress/type-profiler-log-should-defer-pending-exceptions.js
new file mode 100644
index 0000000000..07640366f3
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/type-profiler-log-should-defer-pending-exceptions.js
@@ -0,0 +1,26 @@
+//@ runDefault("--thresholdForOptimizeAfterWarmUp=0", "--useTypeProfiler=true")
+
+function foo() {
+    try {
+        throw 42;
+    } catch(e) {
+        if (e !== 42)
+            throw new Error("Bad!")
+    }
+}
+
+function test(_a) {
+    if (_a === 0) {
+        foo();
+    } 
+}
+
+function bar() {
+    test(Intl.NumberFormat());
+    test(Intl.NumberFormat());
+    test(0);
+}
+
+for (let i=0; i<200; i++) {
+    bar()
+}
-- 
GitLab