<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[195581] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195581">195581</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-25 21:43:11 -0800 (Mon, 25 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments"
https://bugs.webkit.org/show_bug.cgi?id=145132
Patch by Skachkov Oleksandr <gskachkov@gmail.com> on 2016-01-25
Reviewed by Saam Barati.
Source/JavaScriptCore:
Added support of ES6 arrow function specific feature, lexical bind of arguments.
http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions-runtime-semantics-evaluation
'arguments' variable in arrow function must resolve to a binding in a lexically enclosing environment.
In srict mode it points to arguments object, and in non-stric mode it points to arguments object or varible
with name 'arguments' if it was declared.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* parser/Parser.h:
(JSC::Scope::Scope):
(JSC::Scope::setSourceParseMode):
(JSC::Scope::isArrowFunction):
(JSC::Scope::collectFreeVariables):
(JSC::Scope::setIsArrowFunction):
* tests/es6.yaml:
* tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js: Added.
* tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js: Added.
* tests/stress/arrowfunction-lexical-bind-arguments-strict.js: Added.
Source/WebInspectorUI:
Current patch is implementing lexical bind of arguments, so in this callback we need
to return to ordinary function.
* UserInterface/Base/Object.js:
(WebInspector.Object.singleFireEventListener.let.wrappedCallback):
(WebInspector.Object.singleFireEventListener):
LayoutTests:
* js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt: Added.
* js/arrowfunction-lexical-bind-arguments-non-strict.html: Added.
* js/arrowfunction-lexical-bind-arguments-strict-expected.txt: Added.
* js/arrowfunction-lexical-bind-arguments-strict.html: Added.
* js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js: Added.
* js/script-tests/arrowfunction-lexical-bind-arguments-strict.js: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseObjectjs">trunk/Source/WebInspectorUI/UserInterface/Base/Object.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsarrowfunctionlexicalbindargumentsnonstrictexpectedtxt">trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionlexicalbindargumentsnonstricthtml">trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionlexicalbindargumentsstrictexpectedtxt">trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionlexicalbindargumentsstricthtml">trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionlexicalbindargumentsnonstrictjs">trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionlexicalbindargumentsstrictjs">trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-strict.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsnonstrict1js">trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsnonstrict2js">trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsstrictjs">trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-strict.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/LayoutTests/ChangeLog        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-01-25 Skachkov Oleksandr <gskachkov@gmail.com>
+
+ [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments"
+ https://bugs.webkit.org/show_bug.cgi?id=145132
+
+ Reviewed by Saam Barati.
+
+ * js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt: Added.
+ * js/arrowfunction-lexical-bind-arguments-non-strict.html: Added.
+ * js/arrowfunction-lexical-bind-arguments-strict-expected.txt: Added.
+ * js/arrowfunction-lexical-bind-arguments-strict.html: Added.
+ * js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js: Added.
+ * js/script-tests/arrowfunction-lexical-bind-arguments-strict.js: Added.
+
</ins><span class="cx"> 2016-01-25 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Give the layout test results file a <title> showing the date and time the tests were run
</span></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionlexicalbindargumentsnonstrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+Tests for ES6 arrow function lexical bind of arguments
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS arr.length is 2
+PASS arr[0] is "ABC"
+PASS arr[1] is "DEF"
+PASS typeof arr[2] is "undefined"
+PASS afFactory1('AB', 'CD', 'EF')('G', 'H') is "AB-CD-EF-G-H"
+PASS (new afFactory2('P1', 'Q2', 'R3')).func('A4', 'B5') is "P1_Q2_R3_A4_B5"
+PASS (new afFactory3('PQ', 'RS', 'TU')).func('VW', 'XY')('Z', 'A') is "PQ_RS_TU_VW_XY_Z_A"
+PASS af5.func('VW', 'XY')('Z', '') is "GH_IJ_KL_VW_XY_Z_"
+PASS objInternal.method('H') is "ABC-H"
+PASS (() => arguments)() is arguments
+PASS func_with_eval("abc", "def")("xyz")[0] is "abc"
+PASS func_with_eval("abc", "def")("xyz")[1] is "def"
+PASS af_block_scope('A', 'B')('C') is 'branch-1'
+PASS af_function_scope(true, 'D', 'E')('F') is 'af_function_scope'
+PASS af_mixed_scope(true, 'G', 'H')('I') is 'local-scope'
+PASS test() is 40000
+PASS foo(10, 11, 12).next().value()[0] is 10
+PASS foo(10, 11, 12).next().value()[1] is 11
+PASS foo(10, 11, 12).next().value()[2] is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionlexicalbindargumentsnonstricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict.html (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict.html        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/arrowfunction-lexical-bind-arguments-non-strict.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionlexicalbindargumentsstrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict-expected.txt (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict-expected.txt        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Tests for ES6 arrow function lexical bind of arguments
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS arr.length is 2
+PASS arr[0] is "ABC"
+PASS arr[1] is "DEF"
+PASS typeof arr[2] is "undefined"
+PASS afFactory1('AB', 'CD', 'EF')('G', 'H') is "AB-CD-EF-G-H"
+PASS (new afFactory2('P1', 'Q2', 'R3')).func('A4', 'B5') is "P1_Q2_R3_A4_B5"
+PASS (new afFactory3('PQ', 'RS', 'TU')).func('VW', 'XY')('Z', 'A') is "PQ_RS_TU_VW_XY_Z_A"
+PASS af5.func('VW', 'XY')('Z', '') is "GH_IJ_KL_VW_XY_Z_"
+PASS objInternal.method('H') is "ABC-H"
+PASS arr_nesting()()().id is "data"
+PASS func_with_eval("abc", "def")("xyz")[0] is "abc"
+PASS func_with_eval("abc", "def")("xyz")[1] is "def"
+PASS test() is 40000
+PASS foo(10, 11, 12).next().value()[0] is 10
+PASS foo(10, 11, 12).next().value()[1] is 11
+PASS foo(10, 11, 12).next().value()[2] is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionlexicalbindargumentsstricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict.html (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-strict.html        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/arrowfunction-lexical-bind-arguments-strict.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionlexicalbindargumentsnonstrictjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,149 @@
</span><ins>+description('Tests for ES6 arrow function lexical bind of arguments');
+
+function afFactory0() {
+ return a => arguments;
+}
+var af0 = afFactory0('ABC', 'DEF');
+
+var arr = af0(0);
+
+shouldBe('arr.length', '2');
+shouldBe('arr[0]','"ABC"');
+shouldBe('arr[1]','"DEF"');
+shouldBe('typeof arr[2]','"undefined"');
+
+function afFactory1(x, y, z) {
+ return (a, b) => arguments[0] + '-' + arguments[1] + '-' + arguments[2] + '-' + a + '-' + b;
+}
+
+shouldBe("afFactory1('AB', 'CD', 'EF')('G', 'H')", '"AB-CD-EF-G-H"');
+
+var afFactory2 = function () {
+ this.func = (a, b) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b;
+};
+
+shouldBe("(new afFactory2('P1', 'Q2', 'R3')).func('A4', 'B5')", '"P1_Q2_R3_A4_B5"');
+
+var afFactory3 = function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+};
+
+shouldBe("(new afFactory3('PQ', 'RS', 'TU')).func('VW', 'XY')('Z', 'A')", '"PQ_RS_TU_VW_XY_Z_A"');
+
+var afNested = function () {
+ return function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+ };
+};
+
+var afInternal = new afNested('AB', 'CD', 'EF');
+var af5 = new afInternal('GH', 'IJ', 'KL');
+shouldBe("af5.func('VW', 'XY')('Z', '')", '"GH_IJ_KL_VW_XY_Z_"');
+
+var objFactory = function () {
+ return {
+ name : 'nested',
+ method : (index) => arguments[0] + '-' + index
+ };
+};
+
+var objInternal = objFactory('ABC', 'DEF');
+shouldBe("objInternal.method('H')", '"ABC-H"');
+
+shouldBe("(() => arguments)()", "arguments")
+
+var func_with_eval = function (a, b) { return () => eval('arguments') }
+
+shouldBe('func_with_eval("abc", "def")("xyz")[0]', '"abc"');
+shouldBe('func_with_eval("abc", "def")("xyz")[1]', '"def"');
+
+var af_function_scope = function (first, x, y) {
+ let arr;
+ var arguments = 'af_function_scope';
+ if (first) {
+ arr = () => arguments;
+ } else {
+ arr = () => arguments;
+ }
+ return arr;
+};
+
+var af_mixed_scope = function (first, x, y) {
+ let arr;
+ var arguments = 'af_mixed_scope';
+ if (first) {
+ let arguments = 'local-scope';
+ arr = () => arguments;
+ } else {
+ let arguments = 'local-scope-2';
+ arr = () => arguments;
+ }
+ return arr;
+};
+
+var af_block_scope = function (x, y) {
+ let arr;
+ if (true) {
+ let arguments = 'branch-1';
+ arr = () => arguments;
+ } else {
+ let arguments = 'branch-2';
+ arr = () => arguments;
+ }
+ return arr;
+};
+
+shouldBe("af_block_scope('A', 'B')('C')", "'branch-1'");
+shouldBe("af_function_scope(true, 'D', 'E')('F')", "'af_function_scope'");
+shouldBe("af_mixed_scope(true, 'G', 'H')('I')", "'local-scope'");
+
+class A {
+ constructor() {
+ this.list = [];
+ }
+};
+
+class B extends A {
+ addObj(obj) {
+ this.list.push(obj);
+ this.result = 0;
+ }
+ runAll() {
+ for (let i = 0; i < this.list.length; i++) {
+ this.result += this.list[i].operand(1);
+ }
+ }
+};
+
+function test() {
+ let b = new B();
+
+ function runTest () {
+ b.addObj({ operand : (value) => value + value });
+ b.addObj({ operand : (value) => value + value });
+ }
+
+ for (var i = 0; i < 10000; i++) {
+ runTest();
+ }
+
+ b.runAll();
+
+ return b.result;
+}
+
+test();
+
+shouldBe("test()", "40000");
+
+function* foo(a, b, c) {
+ yield () => arguments;
+}
+
+foo(10, 11, 12).next().value()[0];
+
+shouldBe("foo(10, 11, 12).next().value()[0]", "10");
+shouldBe("foo(10, 11, 12).next().value()[1]", "11");
+shouldBe("foo(10, 11, 12).next().value()[2]", "12");
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionlexicalbindargumentsstrictjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-strict.js (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-strict.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-strict.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+"use strict";
+description('Tests for ES6 arrow function lexical bind of arguments');
+
+function afFactory0() {
+ return a => arguments;
+}
+var af0 = afFactory0('ABC', 'DEF');
+
+var arr = af0(0);
+
+shouldBe('arr.length', '2');
+shouldBe('arr[0]','"ABC"');
+shouldBe('arr[1]','"DEF"');
+shouldBe('typeof arr[2]','"undefined"');
+
+function afFactory1(x, y, z) {
+ return (a, b) => arguments[0] + '-' + arguments[1] + '-' + arguments[2] + '-' + a + '-' + b;
+}
+
+shouldBe("afFactory1('AB', 'CD', 'EF')('G', 'H')", '"AB-CD-EF-G-H"');
+
+var afFactory2 = function () {
+ this.func = (a, b) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b;
+};
+
+shouldBe("(new afFactory2('P1', 'Q2', 'R3')).func('A4', 'B5')", '"P1_Q2_R3_A4_B5"');
+
+var afFactory3 = function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+};
+
+shouldBe("(new afFactory3('PQ', 'RS', 'TU')).func('VW', 'XY')('Z', 'A')", '"PQ_RS_TU_VW_XY_Z_A"');
+
+var afNested = function () {
+ return function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+ };
+};
+
+var afInternal = new afNested('AB', 'CD', 'EF');
+var af5 = new afInternal('GH', 'IJ', 'KL');
+shouldBe("af5.func('VW', 'XY')('Z', '')", '"GH_IJ_KL_VW_XY_Z_"');
+
+var objFactory = function () {
+ return {
+ name : 'nested',
+ method : (index) => arguments[0] + '-' + index
+ };
+};
+
+var objInternal = objFactory('ABC', 'DEF');
+shouldBe("objInternal.method('H')", '"ABC-H"');
+
+var obj = function (value) {
+ this.id = value;
+};
+
+var arr_nesting = () => () => () => new obj('data');
+
+shouldBe("arr_nesting()()().id", '"data"');
+
+var func_with_eval = function (a, b) { return () => eval('arguments') }
+
+shouldBe('func_with_eval("abc", "def")("xyz")[0]', '"abc"');
+shouldBe('func_with_eval("abc", "def")("xyz")[1]', '"def"');
+
+class A {
+ constructor() {
+ this.list = [];
+ }
+};
+
+class B extends A {
+ addObj(obj) {
+ this.list.push(obj);
+ this.result = 0;
+ }
+ runAll() {
+ for (let i = 0; i < this.list.length; i++) {
+ this.result += this.list[i].operand(1);
+ }
+ }
+};
+
+function test() {
+ let b = new B();
+
+ function runTest () {
+ b.addObj({ operand : (value) => value + value });
+ b.addObj({ operand : (value) => value + value });
+ }
+
+ for (var i = 0; i < 10000; i++) {
+ runTest();
+ }
+
+ b.runAll();
+
+ return b.result;
+}
+
+test();
+
+shouldBe("test()", "40000");
+
+function* foo(a, b, c) {
+ yield () => arguments;
+}
+
+foo(10, 11, 12).next().value()[0];
+
+shouldBe("foo(10, 11, 12).next().value()[0]", "10");
+shouldBe("foo(10, 11, 12).next().value()[1]", "11");
+shouldBe("foo(10, 11, 12).next().value()[2]", "12");
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-01-25 Skachkov Oleksandr <gskachkov@gmail.com>
+
+ [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments"
+ https://bugs.webkit.org/show_bug.cgi?id=145132
+
+ Reviewed by Saam Barati.
+
+ Added support of ES6 arrow function specific feature, lexical bind of arguments.
+ http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions-runtime-semantics-evaluation
+ 'arguments' variable in arrow function must resolve to a binding in a lexically enclosing environment.
+ In srict mode it points to arguments object, and in non-stric mode it points to arguments object or varible
+ with name 'arguments' if it was declared.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ * parser/Parser.h:
+ (JSC::Scope::Scope):
+ (JSC::Scope::setSourceParseMode):
+ (JSC::Scope::isArrowFunction):
+ (JSC::Scope::collectFreeVariables):
+ (JSC::Scope::setIsArrowFunction):
+ * tests/es6.yaml:
+ * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js: Added.
+ * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js: Added.
+ * tests/stress/arrowfunction-lexical-bind-arguments-strict.js: Added.
+
</ins><span class="cx"> 2016-01-25 Benjamin Poulain <bpoulain@apple.com>
</span><span class="cx">
</span><span class="cx"> [JSC] We should never use x18 on iOS ARM64
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -243,7 +243,7 @@
</span><span class="cx"> bool shouldCaptureSomeOfTheThings = m_shouldEmitDebugHooks || m_codeBlock->needsFullScopeChain() || containsArrowOrEvalButNotInArrowBlock;
</span><span class="cx">
</span><span class="cx"> bool shouldCaptureAllOfTheThings = m_shouldEmitDebugHooks || codeBlock->usesEval();
</span><del>- bool needsArguments = functionNode->usesArguments() || codeBlock->usesEval();
</del><ins>+ bool needsArguments = (functionNode->usesArguments() || codeBlock->usesEval() || (functionNode->usesArrowFunction() && !codeBlock->isArrowFunction()));
</ins><span class="cx">
</span><span class="cx"> // Generator never provides "arguments". "arguments" reference will be resolved in an upper generator function scope.
</span><span class="cx"> if (parseMode == SourceParseMode::GeneratorBodyMode)
</span><span class="lines">@@ -508,10 +508,12 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
- if (!haveParameterNamedArguments) {
</del><ins>+
+ // Do not create arguments variable in case of Arrow function. Value will be loaded from parent scope
+ if (!haveParameterNamedArguments && !m_codeBlock->isArrowFunction()) {
</ins><span class="cx"> createVariable(
</span><span class="cx"> propertyNames().arguments, varKind(propertyNames().arguments.impl()), functionSymbolTable);
</span><ins>+
</ins><span class="cx"> m_needToInitializeArguments = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -170,6 +170,7 @@
</span><span class="cx"> , m_strictMode(strictMode)
</span><span class="cx"> , m_isFunction(isFunction)
</span><span class="cx"> , m_isGenerator(isGenerator)
</span><ins>+ , m_isArrowFunction(false)
</ins><span class="cx"> , m_isLexicalScope(false)
</span><span class="cx"> , m_isFunctionBoundary(false)
</span><span class="cx"> , m_isValidStrictMode(true)
</span><span class="lines">@@ -191,6 +192,7 @@
</span><span class="cx"> , m_strictMode(rhs.m_strictMode)
</span><span class="cx"> , m_isFunction(rhs.m_isFunction)
</span><span class="cx"> , m_isGenerator(rhs.m_isGenerator)
</span><ins>+ , m_isArrowFunction(rhs.m_isArrowFunction)
</ins><span class="cx"> , m_isLexicalScope(rhs.m_isLexicalScope)
</span><span class="cx"> , m_isFunctionBoundary(rhs.m_isFunctionBoundary)
</span><span class="cx"> , m_isValidStrictMode(rhs.m_isValidStrictMode)
</span><span class="lines">@@ -257,10 +259,13 @@
</span><span class="cx"> case SourceParseMode::GetterMode:
</span><span class="cx"> case SourceParseMode::SetterMode:
</span><span class="cx"> case SourceParseMode::MethodMode:
</span><del>- case SourceParseMode::ArrowFunctionMode:
</del><span class="cx"> setIsFunction();
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case SourceParseMode::ArrowFunctionMode:
+ setIsArrowFunction();
+ break;
+
</ins><span class="cx"> case SourceParseMode::ProgramMode:
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -446,6 +451,7 @@
</span><span class="cx">
</span><span class="cx"> void setNeedsFullActivation() { m_needsFullActivation = true; }
</span><span class="cx"> bool needsFullActivation() const { return m_needsFullActivation; }
</span><ins>+ bool isArrowFunction() { return m_isArrowFunction; }
</ins><span class="cx">
</span><span class="cx"> bool hasDirectSuper() { return m_hasDirectSuper; }
</span><span class="cx"> void setHasDirectSuper() { m_hasDirectSuper = true; }
</span><span class="lines">@@ -464,7 +470,7 @@
</span><span class="cx"> continue;
</span><span class="cx">
</span><span class="cx"> // "arguments" reference should be resolved at function boudary.
</span><del>- if (nestedScope->isFunctionBoundary() && nestedScope->hasArguments() && impl == m_vm->propertyNames->arguments.impl())
</del><ins>+ if (nestedScope->isFunctionBoundary() && nestedScope->hasArguments() && impl == m_vm->propertyNames->arguments.impl() && !nestedScope->isArrowFunction())
</ins><span class="cx"> continue;
</span><span class="cx">
</span><span class="cx"> m_usedVariables.add(impl);
</span><span class="lines">@@ -580,6 +586,12 @@
</span><span class="cx"> m_isGenerator = true;
</span><span class="cx"> m_hasArguments = false;
</span><span class="cx"> }
</span><ins>+
+ void setIsArrowFunction()
+ {
+ setIsFunction();
+ m_isArrowFunction = true;
+ }
</ins><span class="cx">
</span><span class="cx"> void setIsModule()
</span><span class="cx"> {
</span><span class="lines">@@ -597,6 +609,7 @@
</span><span class="cx"> bool m_strictMode : 1;
</span><span class="cx"> bool m_isFunction : 1;
</span><span class="cx"> bool m_isGenerator : 1;
</span><ins>+ bool m_isArrowFunction : 1;
</ins><span class="cx"> bool m_isLexicalScope : 1;
</span><span class="cx"> bool m_isFunctionBoundary : 1;
</span><span class="cx"> bool m_isValidStrictMode : 1;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -745,7 +745,7 @@
</span><span class="cx"> - path: es6/Array_static_methods_Array[Symbol.species].js
</span><span class="cx"> cmd: runES6 :normal
</span><span class="cx"> - path: es6/arrow_functions_lexical_arguments_binding.js
</span><del>- cmd: runES6 :fail
</del><ins>+ cmd: runES6 :normal
</ins><span class="cx"> - path: es6/arrow_functions_lexical_new.target_binding.js
</span><span class="cx"> cmd: runES6 :normal
</span><span class="cx"> - path: es6/arrow_functions_lexical_super_binding.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsnonstrict1js"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,207 @@
</span><ins>+var testCase = function (actual, expected, message) {
+ if (actual !== expected) {
+ throw message + ". Expected '" + expected + "', but was '" + actual + "'";
+ }
+};
+
+var txtMsg = 'Error: arguments is not lexically binded inside of the arrow function ';
+
+function afFactory0() {
+ return a => arguments;
+}
+
+var af0 = afFactory0('ABC', 'DEF');
+
+noInline(af0);
+
+for (var i=0; i<10000; i++) {
+ var arr = af0(i);
+
+ testCase(arr.length, 2, txtMsg + "#1");
+ testCase(arr[0],'ABC', txtMsg + "#2");
+ testCase(arr[1],'DEF', txtMsg + "#3");
+ testCase(typeof arr[2], 'undefined', txtMsg + "#4");
+}
+
+
+function afFactory() {
+ return a => arguments[0];
+}
+
+var af = afFactory(12);
+
+noInline(af);
+
+for (var i=0; i<10000; i++) {
+ testCase(af(6), 12, txtMsg + "#5");
+}
+
+function afFactory1(x, y, z) {
+ return (a, b) => arguments[0] + '-' + arguments[1] + '-' + arguments[2] + '-' + a + '-' + b;
+}
+
+var af1 = afFactory1('AB', 'CD', 'EF');
+
+noInline(af1);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af1('G', i), 'AB-CD-EF-G-' + i, txtMsg + "#5");
+}
+
+var af2 = (x, y) => arguments[0] + '-' + x + y;
+
+noInline(af2);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af2('ABC', i), 'undefined-ABC' + i, txtMsg + "#6");
+}
+
+var af3 = () => arguments;
+noInline(af3);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(typeof af3('ABC', i), 'object', txtMsg + "#7");
+ testCase(typeof af3('ABC', i)[0], 'undefined', txtMsg + "#8");
+}
+
+var afFactory4 = function () {
+ this.func = (a, b) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b;
+};
+
+var af4 = new afFactory4('P1', 'Q2', 'R3');
+noInline(af4);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af4.func('EF', i), 'P1_Q2_R3_EF_' + i, txtMsg + "#9");
+}
+
+var afFactory5 = function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+};
+
+var af5 = new afFactory5('PQ', 'RS', 'TU');
+noInline(af5);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af5.func('VW', 'XY')('Z',i), 'PQ_RS_TU_VW_XY_Z_' + i, txtMsg + "#9");
+}
+
+var afNested = function () {
+ return function () {
+ this.func = (a, b) => (c, d) => arguments[0] + '_' + arguments[1] + '_' + arguments[2] + '_' + a + '_' + b + '_' + c + '_' + d;
+ };
+};
+
+var afInternal = new afNested('AB', 'CD', 'EF');
+var af6 = new afInternal('GH', 'IJ', 'KL');
+noInline(af6);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af6.func('VW', 'XY')('Z',i), 'GH_IJ_KL_VW_XY_Z_' + i, txtMsg + "#9");
+}
+
+var obj = {
+ name : 'id',
+ method : (index) => arguments[0] + '-' + index
+};
+
+noInline(obj.method);
+
+for (var i = 0; i < 10000; i++) {
+ testCase(obj.method(i), 'undefined-' + i, txtMsg + "#10");
+}
+
+var objFactory = function () {
+ return {
+ name : 'nested',
+ method : (index) => arguments[0] + '-' + index
+ };
+};
+
+var objInternal = objFactory('ABC', 'DEF');
+
+for (var i = 0; i < 10000; i++) {
+ testCase(objInternal.method(i), 'ABC-' + i, txtMsg + "#11");
+}
+
+var af_block_scope = function (first, x, y) {
+ let arr;
+ if (first) {
+ let arguments = 'branch-1';
+ arr = () => arguments;
+ } else {
+ let arguments = 'branch-2';
+ arr = () => {
+ if (true) {
+ let arguments = 'internal-arrow-block-scope';
+ return arguments;
+ }
+ };
+ }
+ return arr;
+};
+
+var af_function_scope = function (first, x, y) {
+ let arr;
+ var arguments = 'af_function_scope';
+ if (first) {
+ arr = () => arguments;
+ } else {
+ arr = () => {
+ var arguments = 'internal-arrow-scope';
+ return arguments;
+ };
+ }
+ return arr;
+};
+
+var af_mixed_scope = function (first, x, y) {
+ let arr;
+ var arguments = 'af_mixed_scope';
+ if (first) {
+ let arguments = 'local-scope';
+ arr = () => arguments;
+ } else {
+ let arguments = 'local-scope-2';
+ arr = () => {
+ let arguments = 'internal-arrow-scope';
+ return arguments;
+ };
+ }
+ return arr;
+};
+
+for (var i = 0; i < 10000; i++) {
+ testCase(af_block_scope(true, 'A', 'B')('C'), 'branch-1', txtMsg + "#12");
+ testCase(af_block_scope(false, 'A', 'B')('C'), 'internal-arrow-block-scope', txtMsg + "#12");
+ testCase(af_function_scope(true, 'D', 'E')('F'), 'af_function_scope', txtMsg + "#13");
+ testCase(af_function_scope(false, 'D', 'E')('F'), 'internal-arrow-scope', txtMsg + "#13");
+ testCase(af_mixed_scope(true, 'G', 'H')('I'), 'local-scope', txtMsg + "#14");
+ testCase(af_mixed_scope(false, 'G', 'H')('I'), 'internal-arrow-scope', txtMsg + "#14");
+}
+
+function foo() {
+ var x = (p) => eval(p);
+ return x;
+}
+
+var foo_arr = foo('A', 'B');
+
+for (var i = 0; i < 10000; i++) {
+ testCase(foo_arr('arguments[0]'), 'A', txtMsg + "#15");
+ testCase(foo_arr('arguments[1]'), 'B', txtMsg + "#16");
+}
+
+function boo() {
+ return () => {
+ return () => {
+ return function () {
+ return () => arguments;
+ }
+ }
+ }
+}
+
+for (var i = 0; i < 10000; i++) {
+ testCase(boo('A' + i)('B' + i)('D' + i)('E' + i)('G' + i)[0], 'E' + i, txtMsg + "#17");
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsnonstrict2js"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+var testCase = function (actual, expected, message) {
+ if (actual !== expected) {
+ throw message + ". Expected '" + expected + "', but was '" + actual + "'";
+ }
+};
+
+var txtMsg = 'Error: arguments is not lexically binded inside of the arrow function ';
+var text_value = 'function_global_scope';
+var arguments = text_value;
+
+var arr = a => arguments;
+
+noInline(arr);
+
+for (let i=0; i<10000; i++) {
+ let value = arr(i);
+
+ testCase(value, text_value, txtMsg + "#1");
+}
+
+function afFactory0() {
+ return a => arguments;
+}
+
+var af0 = afFactory0('ABC', 'DEF');
+
+noInline(af0);
+
+for (var i=0; i<10000; i++) {
+ var arr = af0(i);
+
+ testCase(arr.length, 2, txtMsg + "#2");
+ testCase(arr[0],'ABC', txtMsg + "#3");
+ testCase(arr[1],'DEF', txtMsg + "#4");
+ testCase(typeof arr[2], 'undefined', txtMsg + "#5");
+}
+
+var innerUseStrict = function () {
+ 'use strict';
+ var createArrow = function (a, b, c) {
+ return (x, y) => arguments[0] + arguments[1] + arguments[2] + x + y;
+ };
+
+ let af = createArrow('A', 'B', 'C');
+ noInline(af);
+
+ for (var i=0; i<10000; i++) {
+ let arr = af('D', 'E');
+ testCase(arr, 'ABCDE', txtMsg + "#6");
+ }
+};
+
+innerUseStrict();
+
+var obj = function (value) {
+ this.id = value;
+};
+
+var arr_nesting = () => () => () => new obj('data');
+
+for (var i=0; i<10000; i++) {
+ testCase(arr_nesting()()().id, 'data');
+}
+
+class A {
+ constructor() {
+ this.list = [];
+ }
+};
+
+class B extends A {
+ addObj(obj) {
+ this.list.push(obj);
+ this.result = 0;
+ }
+ runAll() {
+ for (let i = 0; i < this.list.length; i++) {
+ this.result += this.list[i].operand(1);
+ }
+ }
+};
+
+function test() {
+ let b = new B();
+
+ function runTest () {
+ b.addObj({ operand : (value) => value + value });
+ b.addObj({ operand : (value) => value + value });
+ }
+
+ for (var i = 0; i < 10000; i++) {
+ runTest();
+ }
+
+ b.runAll();
+
+ testCase(b.result, 40000, txtMsg + "#7");
+}
+
+test();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarrowfunctionlexicalbindargumentsstrictjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-strict.js (0 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-strict.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-arguments-strict.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+'use strict'
+var testCase = function (actual, expected, message) {
+ if (actual !== expected) {
+ throw message + ". Expected '" + expected + "', but was '" + actual + "'";
+ }
+};
+
+var txtMsg = 'Error: arguments is not lexically binded inside of the arrow function in strict mode';
+var text_value = 'function_global_scope';
+
+var arr = (error) => {
+ if (error)
+ return arguments;
+ else
+ return 'no-error';
+};
+
+noInline(arr);
+
+for (let i=0; i<10000; i++) {
+ let value = arr(true);
+ let isArray = typeof value === 'array';
+ testCase(isArray, false, txtMsg + "#1");
+}
+
+function afFactory0() {
+ return a => arguments;
+}
+
+var af0 = afFactory0('ABC', 'DEF');
+
+noInline(af0);
+
+for (var i=0; i<10000; i++) {
+ let args = af0(i);
+
+ testCase(args.length, 2, txtMsg + "#2");
+ testCase(args[0], 'ABC', txtMsg + "#3");
+ testCase(args[1], 'DEF', txtMsg + "#4");
+ testCase(typeof args[2], 'undefined', txtMsg + "#5");
+}
+
+for (var i=0; i<10000; i++) {
+ let args = af0.call(this, i);
+
+ testCase(args.length, 2, txtMsg + "#2");
+ testCase(args[0], 'ABC', txtMsg + "#3");
+ testCase(args[1], 'DEF', txtMsg + "#4");
+ testCase(typeof args[2], 'undefined', txtMsg + "#5");
+}
+
+for (var i=0; i<10000; i++) {
+ var args = af0.apply(this, [i]);
+
+ testCase(args.length, 2, txtMsg + "#2");
+ testCase(args[0], 'ABC', txtMsg + "#3");
+ testCase(args[1], 'DEF', txtMsg + "#4");
+ testCase(typeof args[2], 'undefined', txtMsg + "#5");
+}
+
+var innerUseStrict = function () {
+ var createArrow = function (a, b, c) {
+ return (x, y) => arguments[0] + arguments[1] + arguments[2] + x + y;
+ };
+
+ let af = createArrow('A', 'B', 'C');
+ noInline(af);
+
+ for (var i=0; i<10000; i++) {
+ let args = af('D', 'E');
+ testCase(args, 'ABCDE', txtMsg + "#6");
+ }
+};
+
+innerUseStrict();
+
+var obj = function (value) {
+ this.id = value;
+};
+
+var arr_nesting = () => () => () => new obj('data');
+
+for (var i=0; i<10000; i++) {
+ testCase(arr_nesting()()().id, 'data');
+}
+
+function foo() {
+ var x = (p) => eval(p);
+ return x;
+}
+
+var foo_arr = foo('A', 'B');
+
+for (var i = 0; i < 10000; i++) {
+ testCase(foo_arr('arguments[0]'), 'A', txtMsg + "#15");
+ testCase(foo_arr('arguments[1]'), 'B', txtMsg + "#16");
+}
+
+function boo() {
+ return () => {
+ return () => {
+ return function () {
+ return () => arguments;
+ }
+ }
+ }
+}
+
+for (var i = 0; i < 10000; i++) {
+ testCase(boo('A' + i)('B' + i)('D' + i)('E' + i)('G' + i)[0], 'E' + i, txtMsg + "#17");
+}
+
+class A {
+ constructor() {
+ this.list = [];
+ }
+};
+
+class B extends A {
+ addObj(obj) {
+ this.list.push(obj);
+ this.result = 0;
+ }
+ runAll() {
+ for (let i = 0; i < this.list.length; i++) {
+ this.result += this.list[i].operand(1);
+ }
+ }
+};
+
+function test() {
+ let b = new B();
+
+ function runTest () {
+ b.addObj({ operand : (value) => value + value });
+ b.addObj({ operand : (value) => value + value });
+ }
+
+ for (var i = 0; i < 10000; i++) {
+ runTest();
+ }
+
+ b.runAll();
+
+ testCase(b.result, 40000, txtMsg + "#18");
+}
+
+test();
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-01-25 Skachkov Oleksandr <gskachkov@gmail.com>
+
+ [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments"
+ https://bugs.webkit.org/show_bug.cgi?id=145132
+
+ Reviewed by Saam Barati.
+
+ Current patch is implementing lexical bind of arguments, so in this callback we need
+ to return to ordinary function.
+
+ * UserInterface/Base/Object.js:
+ (WebInspector.Object.singleFireEventListener.let.wrappedCallback):
+ (WebInspector.Object.singleFireEventListener):
+
</ins><span class="cx"> 2016-01-25 Saam barati <sbarati@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Have top-level ScriptTimelineDataGridNode events show sample counts
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseObjectjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Object.js (195580 => 195581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Object.js        2016-01-26 05:41:44 UTC (rev 195580)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Object.js        2016-01-26 05:43:11 UTC (rev 195581)
</span><span class="lines">@@ -58,10 +58,10 @@
</span><span class="cx">
</span><span class="cx"> static singleFireEventListener(eventType, listener, thisObject)
</span><span class="cx"> {
</span><del>- let wrappedCallback = () => {
</del><ins>+ let wrappedCallback = function() {
</ins><span class="cx"> this.removeEventListener(eventType, wrappedCallback, null);
</span><span class="cx"> listener.apply(thisObject, arguments);
</span><del>- };
</del><ins>+ }.bind(this);
</ins><span class="cx">
</span><span class="cx"> this.addEventListener(eventType, wrappedCallback, null);
</span><span class="cx"> return wrappedCallback;
</span></span></pre>
</div>
</div>
</body>
</html>