Changeset 264750 in webkit
- Timestamp:
- Jul 23, 2020, 1:25:12 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/microbenchmarks/destructuring-array-literal.js (added)
-
JSTests/microbenchmarks/function-dot-apply-array-literal.js (added)
-
JSTests/stress/apply-second-argument-must-be-array-like.js (modified) (2 diffs)
-
JSTests/stress/destructuring-assignment-syntax.js (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/parser/NodeConstructors.h (modified) (3 diffs)
-
Source/JavaScriptCore/parser/Nodes.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r264703 r264750 1 2020-07-23 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Remove ArrayNode::m_optional 4 https://bugs.webkit.org/show_bug.cgi?id=214294 5 6 Reviewed by Darin Adler. 7 8 * microbenchmarks/destructuring-array-literal.js: Added. 9 * microbenchmarks/function-dot-apply-array-literal.js: Added. 10 * stress/apply-second-argument-must-be-array-like.js: 11 * stress/destructuring-assignment-syntax.js: 12 1 13 2020-07-22 Angelos Oikonomopoulos <angelos@igalia.com> 2 14 -
trunk/JSTests/stress/apply-second-argument-must-be-array-like.js
r203790 r264750 19 19 } 20 20 21 function shouldNotThrow(expr) {22 let testFunc = new Function(expr);23 for (let i = 0; i < 10000; i++) {24 let error;25 try {26 testFunc();27 } catch (e) {28 error = e;29 }30 assert(!error);31 }32 }33 34 21 function foo() { } 35 22 … … 43 30 shouldThrow("foo.apply(undefined, Symbol())"); 44 31 45 shouldNotThrow("foo.apply(undefined, undefined)"); 46 shouldNotThrow("foo.apply(undefined, null)"); 47 shouldNotThrow("foo.apply(undefined, {})"); 48 shouldNotThrow("foo.apply(undefined, [])"); 49 shouldNotThrow("foo.apply(undefined, function(){})"); 32 function bar() { 33 return arguments.length; 34 } 35 36 for (let i = 0; i < 10000; i++) { 37 new Function(` 38 assert(bar.apply(undefined, undefined) === 0); 39 assert(bar.apply(undefined, null) === 0); 40 assert(bar.apply(undefined, {}) === 0); 41 assert(bar.apply(undefined, []) === 0); 42 assert(bar.apply(undefined, function() {}) === 0); 43 `)(); 44 } -
trunk/JSTests/stress/destructuring-assignment-syntax.js
r231142 r264750 22 22 throw new Error("Bad error: " + String(error)); 23 23 } 24 25 testSyntax("[] = []"); 26 testSyntax("[] = [,]"); 27 testSyntax("[,] = [,]"); 28 testSyntax("[,] = []"); 24 29 25 30 testSyntax("({ a: this.a } = {})"); -
trunk/Source/JavaScriptCore/ChangeLog
r264748 r264750 1 2020-07-23 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Remove ArrayNode::m_optional 4 https://bugs.webkit.org/show_bug.cgi?id=214294 5 6 Reviewed by Darin Adler. 7 8 m_optional, which dates back to KJS era, means "is this an array with optional trailing comma, 9 with elision, or an empty array". It was used by ArrayNode::streamTo() to preserve a trailing 10 comma when converting array node to source string, as well as in few other places, 11 before ECMA-262 clarified trailing comma in array literals [1]. 12 13 Currently, m_optional is used only by ArrayNode::isSimpleArray(), along with m_elision. 14 Checking m_elision is enough since trailing comma doesn't add extra `undefined` element. 15 16 This patch completely removes m_optional, speeding up destructuring and function.apply() 17 with empty arrays and arrays with trailing commas by ~55% and a factor of 11 respectively. 18 Reflect.apply() optimization (https://webkit.org/b/190668) will also benefit from this change. 19 20 Also, this change converts isSpreadExpression() check to an ASSERT (was enabled by r196323). 21 22 [1]: https://tc39.es/ecma262/#sec-array-initializer 23 24 * bytecompiler/NodesCodegen.cpp: 25 (JSC::ArrayNode::isSimpleArray const): 26 (JSC::ArrayNode::toArgumentList const): 27 (JSC::ArrayNode::emitDirectBinding): 28 * parser/NodeConstructors.h: 29 (JSC::ArrayNode::ArrayNode): 30 * parser/Nodes.h: 31 1 32 2020-07-23 Alexey Shvayka <shvaikalesh@gmail.com> 2 33 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r264748 r264750 507 507 bool ArrayNode::isSimpleArray() const 508 508 { 509 if (m_elision || m_optional)509 if (m_elision) 510 510 return false; 511 511 for (ElementNode* ptr = m_element; ptr; ptr = ptr->next()) { … … 520 520 ArgumentListNode* ArrayNode::toArgumentList(ParserArena& parserArena, int lineNumber, int startPosition) const 521 521 { 522 ASSERT(!m_elision && !m_optional);522 ASSERT(!m_elision); 523 523 ElementNode* ptr = m_element; 524 524 if (!ptr) … … 5104 5104 for (; elementNodes; elementNodes = elementNodes->next()) { 5105 5105 ExpressionNode* value = elementNodes->value(); 5106 if (value->isSpreadExpression()) 5107 return nullptr; 5106 ASSERT(!value->isSpreadExpression()); 5108 5107 elements.append(value); 5109 5108 } -
trunk/Source/JavaScriptCore/parser/NodeConstructors.h
r262613 r264750 227 227 , m_element(nullptr) 228 228 , m_elision(elision) 229 , m_optional(true)230 229 { 231 230 } … … 235 234 , m_element(element) 236 235 , m_elision(0) 237 , m_optional(false)238 236 { 239 237 } … … 243 241 , m_element(element) 244 242 , m_elision(elision) 245 , m_optional(true)246 243 { 247 244 } -
trunk/Source/JavaScriptCore/parser/Nodes.h
r264304 r264750 717 717 ElementNode* m_element; 718 718 int m_elision; 719 bool m_optional;720 719 }; 721 720
Note:
See TracChangeset
for help on using the changeset viewer.