Changeset 200824 in webkit
- Timestamp:
- May 13, 2016 1:22:21 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r200821 r200824 1 2016-05-13 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 Assertion failure for super() call in arrow function default parameters 4 https://bugs.webkit.org/show_bug.cgi?id=157079 5 6 Reviewed by Saam Barati. 7 8 * js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt: 9 * js/arrowfunction-lexical-bind-this-expected.txt: 10 * js/arrowfunction-supercall-expected.txt: 11 * js/arrowfunction-superproperty-expected.txt: 12 * js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js: 13 * js/script-tests/arrowfunction-lexical-bind-this.js: 14 * js/script-tests/arrowfunction-supercall.js: 15 * js/script-tests/arrowfunction-superproperty.js: 16 1 17 2016-05-12 Sergio Villar Senin <svillar@igalia.com> 2 18 -
trunk/LayoutTests/js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt
r195581 r200824 23 23 PASS foo(10, 11, 12).next().value()[1] is 11 24 24 PASS foo(10, 11, 12).next().value()[2] is 12 25 PASS (function (a, b, c) { return (a = arguments) => {return a;}; })('1-1', '2-2', '3-3')()[1] is '2-2' 25 26 PASS successfullyParsed is true 26 27 -
trunk/LayoutTests/js/arrowfunction-lexical-bind-this-expected.txt
r198978 r200824 20 20 PASS fooObject.arr() is internal_value_1 21 21 PASS fooObject._id is internal_value_2 22 PASS boo.call(o1) is o1 22 PASS boo.call(expected) is expected 23 PASS (function () { return (a = this)=>{return a;}; }).call(expected)() is expected 23 24 PASS successfullyParsed is true 24 25 -
trunk/LayoutTests/js/arrowfunction-supercall-expected.txt
r193766 r200824 22 22 PASS indexOfarrowInChildConstructorInStackError > -1 && errorStack.indexOf('arrowInChildConstructor', indexOfarrowInChildConstructorInStackError + 1) === -1 is true 23 23 PASS indexOfChildClassInStackError > -1 && errorStack.indexOf('ChildClass', indexOfChildClassInStackError + 1) === -1 is true 24 PASS (new class extends A { constructor() { ((a = super())=>{})() } }).id is value 25 PASS (new class extends A { constructor() { ((a = this)=>{ return a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 26 PASS (new class extends A { constructor() { ((a = this, b=super())=>{ return a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 27 PASS (new class extends A { constructor() { ((a = new.target)=>{ return a; })(); super(); } }) did not throw exception. 28 PASS (new class extends A { constructor() { ((a = new.target, b=super())=>{ return a; })() } }) did not throw exception. 24 29 PASS successfullyParsed is true 25 30 -
trunk/LayoutTests/js/arrowfunction-superproperty-expected.txt
r198714 r200824 13 13 PASS (new F()).genGetParentValue().next().value is expectedValue 14 14 PASS (new F()).genGetParentValueDeepArrow().next().value is expectedValue 15 PASS (new class extends A { constructor() { ((a = super(), b = super.getValue())=>{ this.id = b; })() } }).id is expectedValue 16 PASS (new class extends A { constructor() { ((a = super(), b = new.target)=>{ this.newTarget = b; })(); expectedNewTarget = new.target;} }).newTarget is expectedNewTarget 17 PASS (new class extends A { constructor() { ((a = super.getValue())=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 18 PASS (new class extends A { constructor() { ((a = super.getValue(), b=super())=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 19 PASS (new class extends F { constructor() { ((a = super.prop)=>{ return a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 20 PASS (new class extends F { constructor() { ((a = super.prop, b=super())=>{ return a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 21 PASS (new class extends F { constructor() { ((a = (super.prop = "value"))=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 22 PASS (new class extends F { constructor() { ((a = (super.prop = "value"), b=super())=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 23 PASS (new class extends F { constructor() { ((a = super.genGetParentValue().next().value)=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 24 PASS (new class extends F { constructor() { ((a = super.genGetParentValue().next().value, b=super())=>{ this.id = a; })() } }) threw exception ReferenceError: Cannot access uninitialized variable.. 15 25 PASS successfullyParsed is true 16 26 -
trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js
r195581 r200824 146 146 shouldBe("foo(10, 11, 12).next().value()[1]", "11"); 147 147 shouldBe("foo(10, 11, 12).next().value()[2]", "12"); 148 shouldBe("(function (a, b, c) { return (a = arguments) => {return a;}; })('1-1', '2-2', '3-3')()[1]", "'2-2'"); 148 149 149 150 var successfullyParsed = true; -
trunk/LayoutTests/js/script-tests/arrowfunction-lexical-bind-this.js
r198978 r200824 108 108 } 109 109 110 let o1= {'this': 20};110 let expected = {'this': 20}; 111 111 112 shouldBe('boo.call(o1)', 'o1'); 112 shouldBe('boo.call(expected)', 'expected'); 113 shouldBe('(function () { return (a = this)=>{return a;}; }).call(expected)()', 'expected'); 113 114 114 115 var successfullyParsed = true; -
trunk/LayoutTests/js/script-tests/arrowfunction-supercall.js
r193766 r200824 149 149 shouldBeTrue("indexOfChildClassInStackError > -1 && errorStack.indexOf('ChildClass', indexOfChildClassInStackError + 1) === -1"); 150 150 151 shouldBe("(new class extends A { constructor() { ((a = super())=>{})() } }).id", "value"); 152 shouldThrow('(new class extends A { constructor() { ((a = this)=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 153 shouldThrow('(new class extends A { constructor() { ((a = this, b=super())=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 154 shouldNotThrow('(new class extends A { constructor() { ((a = new.target)=>{ return a; })(); super(); } })', '"ReferenceError: Cannot access uninitialized variable."'); 155 shouldNotThrow('(new class extends A { constructor() { ((a = new.target, b=super())=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 156 151 157 var successfullyParsed = true; -
trunk/LayoutTests/js/script-tests/arrowfunction-superproperty.js
r198714 r200824 93 93 shouldBe('(new F()).genGetParentValue().next().value', 'expectedValue'); 94 94 shouldBe('(new F()).genGetParentValueDeepArrow().next().value', 'expectedValue'); 95 shouldBe('(new class extends A { constructor() { ((a = super(), b = super.getValue())=>{ this.id = b; })() } }).id', 'expectedValue'); 96 var expectedNewTarget; 97 shouldBe('(new class extends A { constructor() { ((a = super(), b = new.target)=>{ this.newTarget = b; })(); expectedNewTarget = new.target;} }).newTarget', 'expectedNewTarget'); 98 shouldThrow('(new class extends A { constructor() { ((a = super.getValue())=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 99 shouldThrow('(new class extends A { constructor() { ((a = super.getValue(), b=super())=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 100 shouldThrow('(new class extends F { constructor() { ((a = super.prop)=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 101 shouldThrow('(new class extends F { constructor() { ((a = super.prop, b=super())=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 102 shouldThrow('(new class extends F { constructor() { ((a = (super.prop = "value"))=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 103 shouldThrow('(new class extends F { constructor() { ((a = (super.prop = "value"), b=super())=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 104 shouldThrow('(new class extends F { constructor() { ((a = super.genGetParentValue().next().value)=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 105 shouldThrow('(new class extends F { constructor() { ((a = super.genGetParentValue().next().value, b=super())=>{ this.id = a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 95 106 96 107 var successfullyParsed = true; -
trunk/Source/JavaScriptCore/ChangeLog
r200796 r200824 1 2016-05-13 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 Assertion failure for super() call in arrow function default parameters 4 https://bugs.webkit.org/show_bug.cgi?id=157079 5 6 Reviewed by Saam Barati. 7 8 Root of the issue that in arrow function we load bounded variables this/super/new.target just after 9 input parameters were initialized, and did not covered case of default values for 10 function parameters. 11 Current patch tried to fix issue and allow to load bounded variables earlier, before the input 12 parameters are assigned by default values. 13 14 * bytecompiler/BytecodeGenerator.cpp: 15 (JSC::BytecodeGenerator::BytecodeGenerator): 16 * tests/stress/arrowfunction-lexical-bind-this-2.js: 17 1 18 2016-05-12 Mark Lam <mark.lam@apple.com> 2 19 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r200586 r200824 558 558 } 559 559 560 // We need load |super| & |this| for arrow function before initializeDefaultParameterValuesAndSetupFunctionScopeStack 561 // if we have default parameter expression. Because |super| & |this| values can be used there 562 if (SourceParseMode::ArrowFunctionMode == parseMode && !isSimpleParameterList) { 563 if (functionNode->usesThis() || functionNode->usesSuperProperty()) 564 emitLoadThisFromArrowFunctionLexicalEnvironment(); 565 566 if (m_scopeNode->usesNewTarget() || m_scopeNode->usesSuperCall()) 567 emitLoadNewTargetFromArrowFunctionLexicalEnvironment(); 568 } 569 560 570 // All "addVar()"s needs to happen before "initializeDefaultParameterValuesAndSetupFunctionScopeStack()" is called 561 571 // because a function's default parameter ExpressionNodes will use temporary registers. … … 563 573 initializeDefaultParameterValuesAndSetupFunctionScopeStack(parameters, isSimpleParameterList, functionNode, functionSymbolTable, symbolTableConstantIndex, captures); 564 574 565 // Loading |this| inside an arrow function must be done after initializeDefaultParameterValuesAndSetupFunctionScopeStack()566 // because that function sets up the SymbolTable stack and emitLoadThisFromArrowFunctionLexicalEnvironment()567 // consults the SymbolTable stack568 if (SourceParseMode::ArrowFunctionMode == parseMode ) {575 // If we don't have default parameter expression, then loading |this| inside an arrow function must be done 576 // after initializeDefaultParameterValuesAndSetupFunctionScopeStack() because that function sets up the 577 // SymbolTable stack and emitLoadThisFromArrowFunctionLexicalEnvironment() consults the SymbolTable stack 578 if (SourceParseMode::ArrowFunctionMode == parseMode && isSimpleParameterList) { 569 579 if (functionNode->usesThis() || functionNode->usesSuperProperty()) 570 580 emitLoadThisFromArrowFunctionLexicalEnvironment(); -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-2.js
r194340 r200824 71 71 var fooObject = new foo(); 72 72 73 function fooDefault() { 74 let arr = (that = this) => { 75 var x = 123; 76 function bas() { 77 return x; 78 }; 79 that._id = '12345'; 80 return bas(); 81 }; 82 this.arr = arr; 83 }; 84 85 var fooDefaultObject = new fooDefault(); 86 73 87 for (var i=0; i < 10000; i++) { 74 88 testCase(fooObject.arr() === 123, true, "Error: this is not lexically binded inside of the arrow function #7"); 75 89 testCase(fooObject._id === '12345', true, "Error: this is not lexically binded inside of the arrow function #8"); 90 testCase(fooDefaultObject.arr() === 123, true, "Error: this is not lexically binded inside of the arrow function #7"); 91 testCase(fooDefaultObject._id === '12345', true, "Error: this is not lexically binded inside of the arrow function #8"); 76 92 }
Note: See TracChangeset
for help on using the changeset viewer.