⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 196323 in webkit


Ignore:
Timestamp:
Feb 9, 2016, 12:18:31 PM (11 years ago)
Author:
fpizlo@apple.com
Message:

Spread expressions are not fair game for direct binding
https://bugs.webkit.org/show_bug.cgi?id=154042
rdar://problem/24291413

Reviewed by Saam Barati.

Prior to this change we crashed on this:

var [x] = [...y];

Because NodesCodegen thinks that this is a direct binding. It's not, because we cannot
directly generate bytecode for "...y". This is a unique property of spread expressions, so
its sufficient to just bail out of direct binding if we see a spread expression. That's what
this patch does.

  • bytecompiler/NodesCodegen.cpp:

(JSC::ArrayPatternNode::emitDirectBinding):

  • tests/stress/spread-in-tail.js: Added.

(foo):
(catch):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196308 r196323  
     12016-02-09  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Spread expressions are not fair game for direct binding
     4        https://bugs.webkit.org/show_bug.cgi?id=154042
     5        rdar://problem/24291413
     6
     7        Reviewed by Saam Barati.
     8
     9        Prior to this change we crashed on this:
     10
     11            var [x] = [...y];
     12
     13        Because NodesCodegen thinks that this is a direct binding.  It's not, because we cannot
     14        directly generate bytecode for "...y".  This is a unique property of spread expressions, so
     15        its sufficient to just bail out of direct binding if we see a spread expression. That's what
     16        this patch does.
     17
     18        * bytecompiler/NodesCodegen.cpp:
     19        (JSC::ArrayPatternNode::emitDirectBinding):
     20        * tests/stress/spread-in-tail.js: Added.
     21        (foo):
     22        (catch):
     23
    1242016-02-09  Commit Queue  <commit-queue@webkit.org>
    225
     
    3962        runtimeTypeForValue should protect against seeing TDZ value
    4063        https://bugs.webkit.org/show_bug.cgi?id=154023
     64        rdar://problem/24291413
    4165
    4266        Reviewed by Michael Saboff.
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r196276 r196323  
    34323432{
    34333433    if (!rhs->isSimpleArray())
    3434         return 0;
     3434        return nullptr;
     3435
     3436    ElementNode* elementNodes = static_cast<ArrayNode*>(rhs)->elements();
     3437    Vector<ExpressionNode*> elements;
     3438    for (; elementNodes; elementNodes = elementNodes->next()) {
     3439        ExpressionNode* value = elementNodes->value();
     3440        if (value->isSpreadExpression())
     3441            return nullptr;
     3442        elements.append(value);
     3443    }
    34353444
    34363445    RefPtr<RegisterID> resultRegister;
    34373446    if (dst && dst != generator.ignoredResult())
    34383447        resultRegister = generator.emitNewArray(generator.newTemporary(), 0, 0);
    3439     ElementNode* elementNodes = static_cast<ArrayNode*>(rhs)->elements();
    3440     Vector<ExpressionNode*> elements;
    3441     for (; elementNodes; elementNodes = elementNodes->next())
    3442         elements.append(elementNodes->value());
    34433448    if (m_targetPatterns.size() != elements.size())
    3444         return 0;
     3449        return nullptr;
    34453450    Vector<RefPtr<RegisterID>> registers;
    34463451    registers.reserveCapacity(m_targetPatterns.size());
Note: See TracChangeset for help on using the changeset viewer.