Add test for ic with side effects
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 20:31:00 +0000 (20:31 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 20:31:00 +0000 (20:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179268

Reviewed by Saam Barati.

* stress/put-inline-cache-side-effects.js: Added.
(let.i.of.objs.keys):
(f):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224425 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/stress/put-inline-cache-side-effects.js [new file with mode: 0644]

index 8b8c907..b4c9fb4 100644 (file)
@@ -1,3 +1,14 @@
+2017-11-03  Keith Miller  <keith_miller@apple.com>
+
+        Add test for ic with side effects
+        https://bugs.webkit.org/show_bug.cgi?id=179268
+
+        Reviewed by Saam Barati.
+
+        * stress/put-inline-cache-side-effects.js: Added.
+        (let.i.of.objs.keys):
+        (f):
+
 2017-11-03  Mark Lam  <mark.lam@apple.com>
 
         CachedCall (and its clients) needs overflow checks.
diff --git a/JSTests/stress/put-inline-cache-side-effects.js b/JSTests/stress/put-inline-cache-side-effects.js
new file mode 100644 (file)
index 0000000..ea9fa1c
--- /dev/null
@@ -0,0 +1,30 @@
+let objs = new Array(1000);
+for (let i of objs.keys()) {
+    let o = {};
+    // Make the object an uncacheable dictionary.
+    o.foo = 1;
+    delete o.foo;
+    objs[i] = o;
+}
+
+function f(o) {
+    o.foo = 42;
+}
+
+for (let obj of objs) {
+    let setter = new Function(`
+        Object.defineProperty(this, "foo", {
+            writable: true,
+            configurable: true,
+            value: null
+        });
+        let o = Object.create(this);
+        // Need eval to get a new IC to flatten obj.
+        let str = "for (let i = 0; i < 1000; i++) o.foo";
+        eval(str);
+    `);
+
+    obj.__defineSetter__("foo", setter);
+    f(obj);
+    f(obj);
+}