From df1fc484ea7a9dd2a13fed76129af3bd2b72bc19 Mon Sep 17 00:00:00 2001 From: test262-automation Date: Mon, 30 Jul 2018 18:04:02 +0000 Subject: [PATCH] [javascriptcore-test262-automation] Changes from https://github.com/webkit/webkit.git at sha 00228d3ccc on Mon Jul 30 2018 18:01:10 GMT+0000 (Coordinated Universal Time) --- ...ray-profile-should-record-copy-on-write.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 implementation-contributed/javascriptcore/stress/array-profile-should-record-copy-on-write.js diff --git a/implementation-contributed/javascriptcore/stress/array-profile-should-record-copy-on-write.js b/implementation-contributed/javascriptcore/stress/array-profile-should-record-copy-on-write.js new file mode 100644 index 0000000000..0de63e9230 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/array-profile-should-record-copy-on-write.js @@ -0,0 +1,39 @@ +function shouldBe(actual, expected) +{ + if (actual !== expected) + throw new Error('bad value: ' + actual); +} +noInline(shouldBe); + +function test1(array) +{ + for (var i = 0; i < 5; ++i) { + array[0] = array[0] + 1; + } + return array; +} +noInline(test1); + +function test2(array) +{ + for (var i = 0; i < 5; ++i) { + array[0] = array[0] + 1; + } + return array; +} +noInline(test2); + +function test3(array) +{ + for (var i = 0; i < 5; ++i) { + array[0] = array[0] + 1; + } + return array; +} +noInline(test3); + +for (var i = 0; i < 1e5; ++i) { + shouldBe(String(test1([0, 1, 2, 3, 4])), `5,1,2,3,4`); + shouldBe(String(test2([0.1, 1.1, 2.1, 3.1, 4.1])), `5.1,1.1,2.1,3.1,4.1`); + shouldBe(String(test3(['C', 'o', 'c', 'o', 'a'])), `C11111,o,c,o,a`); +}