Changeset 156497 in webkit


Ignore:
Timestamp:
Sep 26, 2013 2:27:00 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r156464 and r156480.
http://trac.webkit.org/changeset/156464
http://trac.webkit.org/changeset/156480
https://bugs.webkit.org/show_bug.cgi?id=121981

Leaking too much and killi
ng buildbot. (Requested by xenon on
#webkit).

Source/JavaScriptCore:

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedFunctionExecutable::paramString):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::emitExpressionInfo):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ForInNode::emitBytecode):
(JSC::FuncExprNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFormalParameterList):
(JSC::ASTBuilder::createForInLoop):
(JSC::ASTBuilder::addVar):

  • parser/NodeConstructors.h:

(JSC::CommaNode::CommaNode):
(JSC::ParameterNode::ParameterNode):
(JSC::ForInNode::ForInNode):

  • parser/Nodes.cpp:

(JSC::FunctionParameters::create):
(JSC::FunctionParameters::FunctionParameters):
(JSC::FunctionParameters::~FunctionParameters):

  • parser/Nodes.h:

(JSC::CommaNode::append):
(JSC::ParameterNode::ident):
(JSC::FunctionParameters::at):
(JSC::FunctionParameters::identifiers):

  • parser/Parser.cpp:

(JSC::::Parser):
(JSC::::parseVarDeclaration):
(JSC::::parseVarDeclarationList):
(JSC::::parseForStatement):
(JSC::::parseFormalParameters):
(JSC::::parseAssignmentExpression):

  • parser/Parser.h:

(JSC::Scope::declareParameter):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createFormalParameterList):
(JSC::SyntaxChecker::createForInLoop):
(JSC::SyntaxChecker::operatorStackPop):

  • runtime/JSONObject.cpp:
  • runtime/JSONObject.h:

LayoutTests:

  • js/destructuring-assignment-expected.txt: Removed.
  • js/destructuring-assignment.html: Removed.
  • js/mozilla/strict/13.1-expected.txt:
  • js/mozilla/strict/regress-532254-expected.txt:
  • js/mozilla/strict/script-tests/13.1.js:
  • js/regress/destructuring-arguments-expected.txt: Removed.
  • js/regress/destructuring-arguments-length-expected.txt: Removed.
  • js/regress/destructuring-arguments-length.html: Removed.
  • js/regress/destructuring-arguments.html: Removed.
  • js/regress/destructuring-swap-expected.txt: Removed.
  • js/regress/destructuring-swap.html: Removed.
  • js/regress/script-tests/destructuring-arguments-length.js: Removed.
  • js/regress/script-tests/destructuring-arguments.js: Removed.
  • js/regress/script-tests/destructuring-swap.js: Removed.
  • js/script-tests/destructuring-assignment.js: Removed.
  • sputnik/Conformance/13_Function_Definition/S13_A5.html:
Location:
trunk
Files:
12 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156495 r156497  
     12013-09-26  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r156464 and r156480.
     4        http://trac.webkit.org/changeset/156464
     5        http://trac.webkit.org/changeset/156480
     6        https://bugs.webkit.org/show_bug.cgi?id=121981
     7
     8        Leaking too much and killi
     9ng buildbot. (Requested by xenon on
     10        #webkit).
     11
     12        * js/destructuring-assignment-expected.txt: Removed.
     13        * js/destructuring-assignment.html: Removed.
     14        * js/mozilla/strict/13.1-expected.txt:
     15        * js/mozilla/strict/regress-532254-expected.txt:
     16        * js/mozilla/strict/script-tests/13.1.js:
     17        * js/regress/destructuring-arguments-expected.txt: Removed.
     18        * js/regress/destructuring-arguments-length-expected.txt: Removed.
     19        * js/regress/destructuring-arguments-length.html: Removed.
     20        * js/regress/destructuring-arguments.html: Removed.
     21        * js/regress/destructuring-swap-expected.txt: Removed.
     22        * js/regress/destructuring-swap.html: Removed.
     23        * js/regress/script-tests/destructuring-arguments-length.js: Removed.
     24        * js/regress/script-tests/destructuring-arguments.js: Removed.
     25        * js/regress/script-tests/destructuring-swap.js: Removed.
     26        * js/script-tests/destructuring-assignment.js: Removed.
     27        * sputnik/Conformance/13_Function_Definition/S13_A5.html:
     28
    1292013-09-26  Alexey Proskuryakov  <ap@apple.com>
    230
  • trunk/LayoutTests/js/mozilla/strict/13.1-expected.txt

    r156464 r156497  
    1111PASS !!Function("function f(a,b,c,d,e,f,g,h,d) {}") is true
    1212PASS true === true
    13 PASS !!Function("'use strict'; function f([x,y]) {}") is true
    14 PASS !!Function("function f([x,y]) {}") is true
     13PASS Function("'use strict'; function f([x,y]) {}") threw exception of type SyntaxError.
     14PASS Function("function f([x,y]) {}") threw exception of type SyntaxError.
    1515PASS true === true
    1616PASS Function("'use strict'; function f([x,x]){}") threw exception of type SyntaxError.
     
    3939PASS true === true
    4040PASS Function("'use strict'; function f([eval]){}") threw exception of type SyntaxError.
    41 PASS !!Function("function f([eval]){}") is true
     41PASS Function("function f([eval]){}") threw exception of type SyntaxError.
    4242PASS true === true
    4343PASS Function("'use strict'; function f({x:eval}){}") threw exception of type SyntaxError.
    44 PASS !!Function("function f({x:eval}){}") is true
     44PASS Function("function f({x:eval}){}") threw exception of type SyntaxError.
    4545PASS true === true
    4646PASS Function("'use strict'; function eval(){}") threw exception of type SyntaxError.
     
    6363PASS true === true
    6464PASS Function("'use strict'; (function f([eval]){})") threw exception of type SyntaxError.
    65 PASS !!Function("(function f([eval]){})") is true
     65PASS Function("(function f([eval]){})") threw exception of type SyntaxError.
    6666PASS true === true
    6767PASS Function("'use strict'; (function f({x:eval}){})") threw exception of type SyntaxError.
    68 PASS !!Function("(function f({x:eval}){})") is true
     68PASS Function("(function f({x:eval}){})") threw exception of type SyntaxError.
    6969PASS true === true
    7070PASS Function("'use strict'; (function eval(){})") threw exception of type SyntaxError.
     
    9999PASS true === true
    100100PASS Function("'use strict'; ({set x([eval]){}})") threw exception of type SyntaxError.
    101 PASS !!Function("({set x([eval]){}})") is true
     101PASS Function("({set x([eval]){}})") threw exception of type SyntaxError.
    102102PASS true === true
    103103PASS Function("'use strict'; ({set x({x:eval}){}})") threw exception of type SyntaxError.
    104 PASS !!Function("({set x({x:eval}){}})") is true
     104PASS Function("({set x({x:eval}){}})") threw exception of type SyntaxError.
    105105PASS true === true
    106106PASS Function("'use strict'; ({set x(eval){\"use strict\";}})") threw exception of type SyntaxError.
     
    117117PASS true === true
    118118PASS Function("'use strict'; function f([arguments]){}") threw exception of type SyntaxError.
    119 PASS !!Function("function f([arguments]){}") is true
     119PASS Function("function f([arguments]){}") threw exception of type SyntaxError.
    120120PASS true === true
    121121PASS Function("'use strict'; function f({x:arguments}){}") threw exception of type SyntaxError.
    122 PASS !!Function("function f({x:arguments}){}") is true
     122PASS Function("function f({x:arguments}){}") threw exception of type SyntaxError.
    123123PASS true === true
    124124PASS Function("'use strict'; function arguments(){}") threw exception of type SyntaxError.
     
    141141PASS true === true
    142142PASS Function("'use strict'; (function f([arguments]){})") threw exception of type SyntaxError.
    143 PASS !!Function("(function f([arguments]){})") is true
     143PASS Function("(function f([arguments]){})") threw exception of type SyntaxError.
    144144PASS true === true
    145145PASS Function("'use strict'; (function f({x:arguments}){})") threw exception of type SyntaxError.
    146 PASS !!Function("(function f({x:arguments}){})") is true
     146PASS Function("(function f({x:arguments}){})") threw exception of type SyntaxError.
    147147PASS true === true
    148148PASS Function("'use strict'; (function arguments(){})") threw exception of type SyntaxError.
     
    177177PASS true === true
    178178PASS Function("'use strict'; ({set x([arguments]){}})") threw exception of type SyntaxError.
    179 PASS !!Function("({set x([arguments]){}})") is true
     179PASS Function("({set x([arguments]){}})") threw exception of type SyntaxError.
    180180PASS true === true
    181181PASS Function("'use strict'; ({set x({x:arguments}){}})") threw exception of type SyntaxError.
    182 PASS !!Function("({set x({x:arguments}){}})") is true
     182PASS Function("({set x({x:arguments}){}})") threw exception of type SyntaxError.
    183183PASS true === true
    184184PASS Function("'use strict'; ({set x(arguments){\"use strict\";}})") threw exception of type SyntaxError.
  • trunk/LayoutTests/js/mozilla/strict/regress-532254-expected.txt

    r156464 r156497  
    11PASS Function("'use strict'; function f(eval,[x]){}") threw exception of type SyntaxError.
    2 PASS !!Function("function f(eval,[x]){}") is true
     2FAIL !!Function("function f(eval,[x]){}") should be true. Threw exception SyntaxError: Expected an identifier but found '[' instead
    33PASS true === true
    44 PASSED!
  • trunk/LayoutTests/js/mozilla/strict/script-tests/13.1.js

    r156464 r156497  
    4040// Destructuring is not valid ES5 syntax.
    4141assertEq(testLenientAndStrict('function f([x,y]) {}',
    42                               parsesSuccessfully,
    43                               parsesSuccessfully),
     42                              parseRaisesException(SyntaxError),
     43                              parseRaisesException(SyntaxError)),
    4444         true);
    4545assertEq(testLenientAndStrict('function f([x,x]){}',
     
    119119// Destructuring is not valid ES5 syntax.
    120120assertEq(testLenientAndStrict('function f([eval]){}',
    121                               parsesSuccessfully,
     121                              parseRaisesException(SyntaxError),
    122122                              parseRaisesException(SyntaxError)),
    123123         true);
    124124// Destructuring is not valid ES5 syntax.
    125125assertEq(testLenientAndStrict('function f({x:eval}){}',
    126                               parsesSuccessfully,
     126                              parseRaisesException(SyntaxError),
    127127                              parseRaisesException(SyntaxError)),
    128128         true);
     
    155155// Destructuring is not valid ES5 syntax.
    156156assertEq(testLenientAndStrict('(function f([eval]){})',
    157                               parsesSuccessfully,
     157                              parseRaisesException(SyntaxError),
    158158                              parseRaisesException(SyntaxError)),
    159159         true);
    160160// Destructuring is not valid ES5 syntax.
    161161assertEq(testLenientAndStrict('(function f({x:eval}){})',
    162                               parsesSuccessfully,
     162                              parseRaisesException(SyntaxError),
    163163                              parseRaisesException(SyntaxError)),
    164164         true);
     
    209209// Destructuring is not valid ES5 syntax.
    210210assertEq(testLenientAndStrict('({set x([eval]){}})',
    211                               parsesSuccessfully,
     211                              parseRaisesException(SyntaxError),
    212212                              parseRaisesException(SyntaxError)),
    213213         true);
    214214// Destructuring is not valid ES5 syntax.
    215215assertEq(testLenientAndStrict('({set x({x:eval}){}})',
    216                               parsesSuccessfully,
     216                              parseRaisesException(SyntaxError),
    217217                              parseRaisesException(SyntaxError)),
    218218         true);
     
    235235// Destructuring is not valid ES5 syntax.
    236236assertEq(testLenientAndStrict('function f([arguments]){}',
    237                               parsesSuccessfully,
     237                              parseRaisesException(SyntaxError),
    238238                              parseRaisesException(SyntaxError)),
    239239         true);
    240240// Destructuring is not valid ES5 syntax.
    241241assertEq(testLenientAndStrict('function f({x:arguments}){}',
    242                               parsesSuccessfully,
     242                              parseRaisesException(SyntaxError),
    243243                              parseRaisesException(SyntaxError)),
    244244         true);
     
    270270// Destructuring is not valid ES5 syntax.
    271271assertEq(testLenientAndStrict('(function f([arguments]){})',
    272                               parsesSuccessfully,
     272                              parseRaisesException(SyntaxError),
    273273                              parseRaisesException(SyntaxError)),
    274274         true);
    275275// Destructuring is not valid ES5 syntax.
    276276assertEq(testLenientAndStrict('(function f({x:arguments}){})',
    277                               parsesSuccessfully,
     277                              parseRaisesException(SyntaxError),
    278278                              parseRaisesException(SyntaxError)),
    279279         true);
     
    324324// Destructuring is not valid ES5 syntax.
    325325assertEq(testLenientAndStrict('({set x([arguments]){}})',
    326                               parsesSuccessfully,
     326                              parseRaisesException(SyntaxError),
    327327                              parseRaisesException(SyntaxError)),
    328328         true);
    329329// Destructuring is not valid ES5 syntax.
    330330assertEq(testLenientAndStrict('({set x({x:arguments}){}})',
    331                               parsesSuccessfully,
     331                              parseRaisesException(SyntaxError),
    332332                              parseRaisesException(SyntaxError)),
    333333         true);
  • trunk/LayoutTests/sputnik/Conformance/13_Function_Definition/S13_A5.html

    r156464 r156497  
    7777try{
    7878        eval("function __func([arg1, arg2, arg3]){return arguments.length;}");
     79        testFailed('#1: eval("function __func([arg1, arg2, arg3]){return arguments.length;}") lead to throwing exception');
    7980} catch(e){
    8081        if(!(e instanceof SyntaxError)){
  • trunk/Source/JavaScriptCore/ChangeLog

    r156494 r156497  
     12013-09-26  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r156464 and r156480.
     4        http://trac.webkit.org/changeset/156464
     5        http://trac.webkit.org/changeset/156480
     6        https://bugs.webkit.org/show_bug.cgi?id=121981
     7
     8        Leaking too much and killi
     9ng buildbot. (Requested by xenon on
     10        #webkit).
     11
     12        * bytecode/UnlinkedCodeBlock.cpp:
     13        (JSC::UnlinkedFunctionExecutable::paramString):
     14        * bytecompiler/BytecodeGenerator.cpp:
     15        (JSC::BytecodeGenerator::BytecodeGenerator):
     16        * bytecompiler/BytecodeGenerator.h:
     17        (JSC::BytecodeGenerator::emitExpressionInfo):
     18        * bytecompiler/NodesCodegen.cpp:
     19        (JSC::ForInNode::emitBytecode):
     20        (JSC::FuncExprNode::emitBytecode):
     21        * parser/ASTBuilder.h:
     22        (JSC::ASTBuilder::createFormalParameterList):
     23        (JSC::ASTBuilder::createForInLoop):
     24        (JSC::ASTBuilder::addVar):
     25        * parser/NodeConstructors.h:
     26        (JSC::CommaNode::CommaNode):
     27        (JSC::ParameterNode::ParameterNode):
     28        (JSC::ForInNode::ForInNode):
     29        * parser/Nodes.cpp:
     30        (JSC::FunctionParameters::create):
     31        (JSC::FunctionParameters::FunctionParameters):
     32        (JSC::FunctionParameters::~FunctionParameters):
     33        * parser/Nodes.h:
     34        (JSC::CommaNode::append):
     35        (JSC::ParameterNode::ident):
     36        (JSC::FunctionParameters::at):
     37        (JSC::FunctionParameters::identifiers):
     38        * parser/Parser.cpp:
     39        (JSC::::Parser):
     40        (JSC::::parseVarDeclaration):
     41        (JSC::::parseVarDeclarationList):
     42        (JSC::::parseForStatement):
     43        (JSC::::parseFormalParameters):
     44        (JSC::::parseAssignmentExpression):
     45        * parser/Parser.h:
     46        (JSC::Scope::declareParameter):
     47        * parser/SyntaxChecker.h:
     48        (JSC::SyntaxChecker::createFormalParameterList):
     49        (JSC::SyntaxChecker::createForInLoop):
     50        (JSC::SyntaxChecker::operatorStackPop):
     51        * runtime/JSONObject.cpp:
     52        * runtime/JSONObject.h:
     53
    1542013-09-26  Anders Carlsson  <andersca@apple.com>
    255
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r156482 r156497  
    184184        if (!builder.isEmpty())
    185185            builder.appendLiteral(", ");
    186         parameters.at(pos)->toString(builder);
     186        builder.append(parameters.at(pos).string());
    187187    }
    188188    return builder.toString();
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r156482 r156497  
    181181
    182182    for (size_t i = 0; i < varStack.size(); ++i)
    183         codeBlock->addVariableDeclaration(varStack[i].first, !!(varStack[i].second & DeclarationStacks::IsConstant));
     183        codeBlock->addVariableDeclaration(*varStack[i].first, !!(varStack[i].second & DeclarationStacks::IsConstant));
    184184
    185185}
     
    216216
    217217    m_symbolTable->setUsesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode());
    218     Vector<Identifier> boundParameterProperties;
    219     FunctionParameters& parameters = *functionBody->parameters();
    220     for (size_t i = 0; i < parameters.size(); i++) {
    221         auto pattern = parameters.at(i);
    222         if (pattern->isBindingNode())
    223             continue;
    224         pattern->collectBoundIdentifiers(boundParameterProperties);
    225         continue;
    226     }
    227218    m_symbolTable->setParameterCountIncludingThis(functionBody->parameters()->size() + 1);
    228219
     
    264255        for (size_t i = 0; i < parameters.size(); ++i) {
    265256            capturedArguments[i] = 0;
    266             auto pattern = parameters.at(i);
    267             if (!pattern->isBindingNode())
    268                 continue;
    269             const Identifier& ident = static_cast<const BindingNode*>(pattern)->boundProperty();
    270             if (!functionBody->captures(ident) && !shouldCaptureAllTheThings)
     257            if (!functionBody->captures(parameters.at(i)) && !shouldCaptureAllTheThings)
    271258                continue;
    272259            capturesAnyArgumentByName = true;
     
    313300        }
    314301        for (size_t i = 0; i < varStack.size(); ++i) {
    315             const Identifier& ident = varStack[i].first;
     302            const Identifier& ident = *varStack[i].first;
    316303            if (functionBody->captures(ident))
    317304                addVar(ident, varStack[i].second & DeclarationStacks::IsConstant);
     
    346333    m_lastLazyFunction = canLazilyCreateFunctions ? codeBlock->m_numVars : m_firstLazyFunction;
    347334    for (size_t i = 0; i < varStack.size(); ++i) {
    348         const Identifier& ident = varStack[i].first;
     335        const Identifier& ident = *varStack[i].first;
    349336        if (!functionBody->captures(ident))
    350337            addVar(ident, varStack[i].second & DeclarationStacks::IsConstant);
     
    354341        m_symbolTable->setCaptureEnd(localToOperand(codeBlock->m_numVars));
    355342
     343    FunctionParameters& parameters = *functionBody->parameters();
    356344    m_parameters.grow(parameters.size() + 1); // reserve space for "this"
    357345
     
    360348    m_thisRegister.setIndex(nextParameterIndex++);
    361349    m_codeBlock->addParameter();
    362     Vector<std::pair<RegisterID*, const DeconstructionPatternNode*>> deconstructedParameters;
     350   
    363351    for (size_t i = 0; i < parameters.size(); ++i, ++nextParameterIndex) {
    364352        int index = nextParameterIndex;
    365         auto pattern = parameters.at(i);
    366         if (!pattern->isBindingNode()) {
    367             m_codeBlock->addParameter();
    368             RegisterID& parameter = registerFor(index);
    369             parameter.setIndex(index);
    370             deconstructedParameters.append(make_pair(&parameter, pattern));
    371             continue;
    372         }
    373         auto simpleParameter = static_cast<const BindingNode*>(pattern);
    374353        if (capturedArguments.size() && capturedArguments[i]) {
    375             ASSERT((functionBody->hasCapturedVariables() && functionBody->captures(simpleParameter->boundProperty())) || shouldCaptureAllTheThings);
     354            ASSERT((functionBody->hasCapturedVariables() && functionBody->captures(parameters.at(i))) || shouldCaptureAllTheThings);
    376355            index = capturedArguments[i]->index();
    377356            RegisterID original(nextParameterIndex);
    378357            emitMove(capturedArguments[i], &original);
    379358        }
    380         addParameter(simpleParameter->boundProperty(), index);
     359        addParameter(parameters.at(i), index);
    381360    }
    382361    preserveLastVar();
     
    391370        instructions().append(kill(&m_thisRegister));
    392371        instructions().append(0);
    393     }
    394     for (size_t i = 0; i < deconstructedParameters.size(); i++) {
    395         auto& entry = deconstructedParameters[i];
    396         entry.second->emitBytecode(*this, entry.first);
    397372    }
    398373}
     
    440415    Vector<Identifier, 0, UnsafeVectorOverflow> variables;
    441416    variables.reserveCapacity(numVariables);
    442     for (size_t i = 0; i < numVariables; ++i) {
    443         ASSERT(varStack[i].first.impl()->isIdentifier());
    444         variables.append(varStack[i].first);
    445     }
     417    for (size_t i = 0; i < numVariables; ++i)
     418        variables.append(*varStack[i].first);
    446419    codeBlock->adoptVariables(variables);
    447420    preserveLastVar();
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r156482 r156497  
    287287            else
    288288                lineStart = 0;
    289 
    290             if (divotOffset < lineStart)
    291                 return;
    292 
     289            ASSERT(divotOffset >= lineStart);
    293290            unsigned column = divotOffset - lineStart;
    294291
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r156464 r156497  
    3636#include "JSGlobalObject.h"
    3737#include "JSNameScope.h"
    38 #include "JSONObject.h"
    3938#include "LabelScope.h"
    4039#include "Lexer.h"
     
    17151714        generator.emitExpressionInfo(assignNode->divot(), assignNode->divotStart(), assignNode->divotEnd());
    17161715        generator.emitPutById(base, ident, propertyName);
    1717     } else if (m_lexpr->isBracketAccessorNode()) {
     1716    } else {
     1717        ASSERT(m_lexpr->isBracketAccessorNode());
    17181718        BracketAccessorNode* assignNode = static_cast<BracketAccessorNode*>(m_lexpr);
    17191719        propertyName = generator.newTemporary();
     
    17241724        generator.emitExpressionInfo(assignNode->divot(), assignNode->divotStart(), assignNode->divotEnd());
    17251725        generator.emitPutByVal(base.get(), subscript, propertyName);
    1726     } else {
    1727         ASSERT(m_lexpr->isDeconstructionNode());
    1728         DeconstructingAssignmentNode* assignNode = static_cast<DeconstructingAssignmentNode*>(m_lexpr);
    1729         propertyName = generator.newTemporary();
    1730         RefPtr<RegisterID> protect(propertyName);
    1731         assignNode->bindings()->emitBytecode(generator, propertyName);
    1732     }
     1726    }   
    17331727
    17341728    generator.emitNode(dst, m_statement);
     
    21862180    return generator.emitNewFunctionExpression(generator.finalDestination(dst), this);
    21872181}
    2188    
    2189 // ------------------------------ DeconstructingAssignmentNode -----------------
    2190 RegisterID* DeconstructingAssignmentNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    2191 {
    2192     if (RegisterID* result = m_bindings->emitDirectBinding(generator, dst, m_initializer))
    2193         return result;
    2194     RefPtr<RegisterID> initializer = generator.tempDestination(dst);
    2195     generator.emitNode(initializer.get(), m_initializer);
    2196     m_bindings->emitBytecode(generator, initializer.get());
    2197     return generator.moveToDestinationIfNeeded(dst, initializer.get());
    2198 }
    2199 
    2200 DeconstructionPatternNode::~DeconstructionPatternNode()
    2201 {
    2202 }
    2203    
    2204 void ArrayPatternNode::emitBytecode(BytecodeGenerator& generator, RegisterID* rhs) const
    2205 {
    2206     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2207         auto target = m_targetPatterns[i];
    2208         if (!target)
    2209             continue;
    2210         RefPtr<RegisterID> temp = generator.newTemporary();
    2211         generator.emitLoad(temp.get(), jsNumber(i));
    2212         generator.emitGetByVal(temp.get(), rhs, temp.get());
    2213         target->emitBytecode(generator, temp.get());
    2214     }
    2215 }
    2216 
    2217 RegisterID* ArrayPatternNode::emitDirectBinding(BytecodeGenerator& generator, RegisterID* dst, ExpressionNode* rhs)
    2218 {
    2219     if (rhs->isResolveNode()
    2220         && generator.willResolveToArguments(static_cast<ResolveNode*>(rhs)->identifier())
    2221         && !generator.symbolTable().slowArguments()) {
    2222         for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2223             auto target = m_targetPatterns[i];
    2224             if (!target)
    2225                 continue;
    2226            
    2227             RefPtr<RegisterID> temp = generator.newTemporary();
    2228             generator.emitLoad(temp.get(), jsNumber(i));
    2229             generator.emitGetArgumentByVal(generator.finalDestination(dst), generator.uncheckedRegisterForArguments(), temp.get());
    2230             target->emitBytecode(generator, temp.get());
    2231         }
    2232     }
    2233     if (!rhs->isSimpleArray())
    2234         return 0;
    2235     ElementNode* elementNodes = static_cast<ArrayNode*>(rhs)->elements();
    2236     Vector<ExpressionNode*> elements;
    2237     for (; elementNodes; elementNodes = elementNodes->next())
    2238         elements.append(elementNodes->value());
    2239     if (m_targetPatterns.size() != elements.size())
    2240         return 0;
    2241     Vector<RefPtr<RegisterID>> registers;
    2242     registers.reserveCapacity(m_targetPatterns.size());
    2243     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2244         registers.uncheckedAppend(generator.newTemporary());
    2245         generator.emitNode(registers.last().get(), elements[i]);
    2246     }
    2247    
    2248     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2249         if (m_targetPatterns[i])
    2250             m_targetPatterns[i]->emitBytecode(generator, registers[i].get());
    2251     }
    2252     RefPtr<RegisterID> result = generator.finalDestination(dst);
    2253     return generator.emitLoad(result.get(), jsUndefined());
    2254 }
    2255 
    2256 void ArrayPatternNode::toString(StringBuilder& builder) const
    2257 {
    2258     builder.append('[');
    2259     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2260         if (!m_targetPatterns[i]) {
    2261             builder.append(',');
    2262             continue;
    2263         }
    2264         m_targetPatterns[i]->toString(builder);
    2265         if (i < m_targetPatterns.size() - 1)
    2266             builder.append(',');
    2267     }
    2268     builder.append(']');
    2269 }
    2270 
    2271 void ArrayPatternNode::collectBoundIdentifiers(Vector<Identifier>& identifiers) const
    2272 {
    2273     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2274         if (DeconstructionPatternNode* node = m_targetPatterns[i].get())
    2275             node->collectBoundIdentifiers(identifiers);
    2276     }
    2277 }
    2278 
    2279 void ObjectPatternNode::toString(StringBuilder& builder) const
    2280 {
    2281     builder.append('{');
    2282     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2283         if (m_targetPatterns[i].wasString) {
    2284             builder.append('"');
    2285             escapeStringToBuilder(builder, m_targetPatterns[i].propertyName.string());
    2286             builder.append('"');
    2287         } else
    2288             builder.append(m_targetPatterns[i].propertyName.string());
    2289         builder.append(":");
    2290         m_targetPatterns[i].pattern->toString(builder);
    2291         if (i < m_targetPatterns.size() - 1)
    2292             builder.append(',');
    2293     }
    2294     builder.append('}');
    2295 }
    2296    
    2297 void ObjectPatternNode::emitBytecode(BytecodeGenerator& generator, RegisterID* rhs) const
    2298 {
    2299     for (size_t i = 0; i < m_targetPatterns.size(); i++) {
    2300         auto& target = m_targetPatterns[i];
    2301         RefPtr<RegisterID> temp = generator.newTemporary();
    2302         generator.emitGetById(temp.get(), rhs, target.propertyName);
    2303         target.pattern->emitBytecode(generator, temp.get());
    2304     }
    2305 }
    2306 
    2307 void ObjectPatternNode::collectBoundIdentifiers(Vector<Identifier>& identifiers) const
    2308 {
    2309     for (size_t i = 0; i < m_targetPatterns.size(); i++)
    2310         m_targetPatterns[i].pattern->collectBoundIdentifiers(identifiers);
    2311 }
    2312 
    2313 void BindingNode::emitBytecode(BytecodeGenerator& generator, RegisterID* value) const
    2314 {
    2315     if (Local local = generator.local(m_boundProperty)) {
    2316         if (local.isReadOnly()) {
    2317             generator.emitReadOnlyExceptionIfNeeded();
    2318             return;
    2319         }
    2320         generator.emitMove(local.get(), value);
    2321         return;
    2322     }
    2323     if (generator.isStrictMode())
    2324         generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    2325     RegisterID* scope = generator.emitResolveScope(generator.newTemporary(), m_boundProperty);
    2326     generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    2327     generator.emitPutToScope(scope, m_boundProperty, value, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound);
    2328     return;
    2329 }
    2330 
    2331 void BindingNode::toString(StringBuilder& builder) const
    2332 {
    2333     builder.append(m_boundProperty.string());
    2334 }
    2335 
    2336 void BindingNode::collectBoundIdentifiers(Vector<Identifier>& identifiers) const
    2337 {
    2338     identifiers.append(m_boundProperty);
    2339 }
    23402182
    23412183} // namespace JSC
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r156464 r156497  
    9191    };
    9292
    93 
    9493    typedef SyntaxChecker FunctionBodyBuilder;
    9594
     
    109108    typedef ConstDeclNode* ConstDeclList;
    110109    typedef std::pair<ExpressionNode*, BinaryOpInfo> BinaryOperand;
    111     typedef RefPtr<DeconstructionPatternNode> DeconstructionPattern;
    112     typedef RefPtr<ArrayPatternNode> ArrayPattern;
    113     typedef RefPtr<ObjectPatternNode> ObjectPattern;
    114     typedef RefPtr<BindingNode> BindingPattern;
     110   
    115111    static const bool CreatesAST = true;
    116112    static const bool NeedsFreeVariableInfo = true;
     
    319315    ElementNode* createElementList(ElementNode* elems, int elisions, ExpressionNode* expr) { return new (m_vm) ElementNode(elems, elisions, expr); }
    320316
    321     ParameterNode* createFormalParameterList(DeconstructionPattern pattern) { return new (m_vm) ParameterNode(pattern); }
    322     ParameterNode* createFormalParameterList(ParameterNode* list, DeconstructionPattern pattern) { return new (m_vm) ParameterNode(list, pattern); }
     317    ParameterNode* createFormalParameterList(const Identifier& ident) { return new (m_vm) ParameterNode(ident); }
     318    ParameterNode* createFormalParameterList(ParameterNode* list, const Identifier& ident) { return new (m_vm) ParameterNode(list, ident); }
    323319
    324320    CaseClauseNode* createClause(ExpressionNode* expr, JSC::SourceElements* statements) { return new (m_vm) CaseClauseNode(expr, statements); }
     
    366362    }
    367363
     364    StatementNode* createForInLoop(const JSTokenLocation& location, const Identifier* ident, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end, int startLine, int endLine)
     365    {
     366        ForInNode* result = new (m_vm) ForInNode(m_vm, location, *ident, iter, statements, start);
     367        result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
     368        setExceptionLocation(result, start, divot + 1, end);
     369        return result;
     370    }
     371
    368372    StatementNode* createForInLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
    369373    {
    370374        ForInNode* result = new (m_vm) ForInNode(location, lhs, iter, statements);
    371         result->setLoc(start, end, location.startOffset, location.lineStartOffset);
    372         setExceptionLocation(result, eStart, eDivot, eEnd);
    373         return result;
    374     }
    375    
    376     StatementNode* createForInLoop(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
    377     {
    378         ForInNode* result = new (m_vm) ForInNode(m_vm, location, pattern.get(), iter, statements);
    379375        result->setLoc(start, end, location.startOffset, location.lineStartOffset);
    380376        setExceptionLocation(result, eStart, eDivot, eEnd);
     
    520516        if (m_vm->propertyNames->arguments == *ident)
    521517            usesArguments();
    522         ASSERT(ident->impl()->isIdentifier());
    523         m_scope.m_varDeclarations->data.append(std::make_pair(*ident, attrs));
     518        m_scope.m_varDeclarations->data.append(std::make_pair(ident, attrs));
    524519    }
    525520
     
    621616    bool isResolve(ExpressionNode* expr) const { return expr->isResolveNode(); }
    622617
    623     ExpressionNode* createDeconstructingAssignment(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* initializer)
    624     {
    625         return new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), initializer);
    626     }
    627    
    628     ArrayPattern createArrayPattern(const JSTokenLocation&)
    629     {
    630         return ArrayPatternNode::create(m_vm);
    631     }
    632    
    633     void appendArrayPatternSkipEntry(ArrayPattern node, const JSTokenLocation& location)
    634     {
    635         node->appendIndex(location, 0);
    636     }
    637 
    638     void appendArrayPatternEntry(ArrayPattern node, const JSTokenLocation& location, DeconstructionPattern pattern)
    639     {
    640         node->appendIndex(location, pattern.get());
    641     }
    642    
    643     ObjectPattern createObjectPattern(const JSTokenLocation&)
    644     {
    645         return ObjectPatternNode::create(m_vm);
    646     }
    647    
    648     void appendObjectPatternEntry(ObjectPattern node, const JSTokenLocation& location, bool wasString, const Identifier& identifier, DeconstructionPattern pattern)
    649     {
    650         node->appendEntry(location, identifier, wasString, pattern.get());
    651     }
    652    
    653     BindingPattern createBindingLocation(const JSTokenLocation&, const Identifier& boundProperty, const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end)
    654     {
    655         return BindingNode::create(m_vm, boundProperty, divot, start, end);
    656     }
    657    
    658618private:
    659619    struct Scope {
  • trunk/Source/JavaScriptCore/parser/NodeConstructors.h

    r156464 r156497  
    604604        : ExpressionNode(location)
    605605    {
    606         ASSERT(expr1);
    607         ASSERT(expr2);
    608606        m_expressions.append(expr1);
    609607        m_expressions.append(expr2);
     
    735733    }
    736734
    737     inline ParameterNode::ParameterNode(PassRefPtr<DeconstructionPatternNode> pattern)
    738         : m_pattern(pattern)
     735    inline ParameterNode::ParameterNode(const Identifier& ident)
     736        : m_ident(ident)
    739737        , m_next(0)
    740738    {
    741         ASSERT(m_pattern);
    742     }
    743 
    744     inline ParameterNode::ParameterNode(ParameterNode* l, PassRefPtr<DeconstructionPatternNode> pattern)
    745         : m_pattern(pattern)
     739    }
     740
     741    inline ParameterNode::ParameterNode(ParameterNode* l, const Identifier& ident)
     742        : m_ident(ident)
    746743        , m_next(0)
    747744    {
    748745        l->m_next = this;
    749         ASSERT(m_pattern);
    750         ASSERT(l->m_pattern);
    751746    }
    752747
     
    818813        , m_statement(statement)
    819814    {
    820         ASSERT(l);
    821     }
    822    
    823     inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
    824         : StatementNode(location)
    825         , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0))
     815    }
     816
     817    inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, const Identifier& ident, ExpressionNode* expr, StatementNode* statement, const JSTextPosition& divotStart)
     818        : StatementNode(location)
     819        , m_lexpr(new (vm) ResolveNode(location, ident, divotStart))
    826820        , m_expr(expr)
    827821        , m_statement(statement)
    828822    {
    829         ASSERT(pattern);
    830     }
    831    
    832     inline DeconstructionPatternNode::DeconstructionPatternNode(VM*)
    833     {
    834     }
    835 
    836     inline ArrayPatternNode::ArrayPatternNode(VM* vm)
    837         : DeconstructionPatternNode(vm)
    838     {
    839     }
    840    
    841     inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create(VM* vm)
    842     {
    843         return adoptRef(new ArrayPatternNode(vm));
    844     }
    845    
    846     inline ObjectPatternNode::ObjectPatternNode(VM* vm)
    847         : DeconstructionPatternNode(vm)
    848     {
    849     }
    850    
    851     inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create(VM* vm)
    852     {
    853         return adoptRef(new ObjectPatternNode(vm));
    854     }
    855 
    856     inline PassRefPtr<BindingNode> BindingNode::create(VM* vm, const Identifier& boundProperty, const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end)
    857     {
    858         return adoptRef(new BindingNode(vm, boundProperty, divot, start, end));
    859     }
    860    
    861     inline BindingNode::BindingNode(VM* vm, const Identifier& boundProperty, const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end)
    862         : DeconstructionPatternNode(vm)
    863         , ThrowableExpressionData(divot, start, end)
    864         , m_boundProperty(boundProperty)
    865     {
    866     }
    867    
    868     inline DeconstructingAssignmentNode::DeconstructingAssignmentNode(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> bindings, ExpressionNode* initializer)
    869         : ExpressionNode(location)
    870         , m_bindings(bindings)
    871         , m_initializer(initializer)
    872     {
    873     }
    874    
     823    }
     824
    875825} // namespace JSC
    876826
  • trunk/Source/JavaScriptCore/parser/Nodes.cpp

    r156464 r156497  
    158158        ++parameterCount;
    159159
    160     size_t objectSize = sizeof(FunctionParameters) - sizeof(void*) + sizeof(DeconstructionPatternNode*) * parameterCount;
     160    size_t objectSize = sizeof(FunctionParameters) - sizeof(void*) + sizeof(StringImpl*) * parameterCount;
    161161    void* slot = fastMalloc(objectSize);
    162162    return adoptRef(new (slot) FunctionParameters(firstParameter, parameterCount));
     
    167167{
    168168    unsigned i = 0;
    169     for (ParameterNode* parameter = firstParameter; parameter; parameter = parameter->nextParam()) {
    170         auto pattern = parameter->pattern();
    171         pattern->ref();
    172         patterns()[i++] = pattern;
    173     }
     169    for (ParameterNode* parameter = firstParameter; parameter; parameter = parameter->nextParam())
     170        new (&identifiers()[i++]) Identifier(parameter->ident());
    174171}
    175172
     
    177174{
    178175    for (unsigned i = 0; i < m_size; ++i)
    179         patterns()[i]->deref();
     176        identifiers()[i].~Identifier();
    180177}
    181178
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r156464 r156497  
    8181    namespace DeclarationStacks {
    8282        enum VarAttrs { IsConstant = 1, HasInitializer = 2 };
    83         typedef Vector<std::pair<Identifier, unsigned> > VarStack;
     83        typedef Vector<std::pair<const Identifier*, unsigned> > VarStack;
    8484        typedef Vector<FunctionBodyNode*> FunctionStack;
    8585    }
     
    155155        virtual bool isBracketAccessorNode() const { return false; }
    156156        virtual bool isDotAccessorNode() const { return false; }
    157         virtual bool isDeconstructionNode() const { return false; }
    158157        virtual bool isFuncExprNode() const { return false; }
    159158        virtual bool isCommaNode() const { return false; }
     
    463462        ArgumentListNode* toArgumentList(VM*, int, int) const;
    464463
    465         ElementNode* elements() const { ASSERT(isSimpleArray()); return m_element; }
    466464    private:
    467465        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
     
    10831081        using ParserArenaDeletable::operator new;
    10841082
    1085         void append(ExpressionNode* expr) { ASSERT(expr); m_expressions.append(expr); }
     1083        void append(ExpressionNode* expr) { m_expressions.append(expr); }
    10861084
    10871085    private:
     
    12411239        StatementNode* m_statement;
    12421240    };
    1243    
    1244     class DeconstructionPatternNode;
    12451241
    12461242    class ForInNode : public StatementNode, public ThrowableExpressionData {
    12471243    public:
    12481244        ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
    1249         ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
     1245        ForInNode(VM*, const JSTokenLocation&, const Identifier&, ExpressionNode*, StatementNode*, const JSTextPosition& divotStart);
    12501246
    12511247    private:
     
    13461342    class ParameterNode : public ParserArenaFreeable {
    13471343    public:
    1348         ParameterNode(PassRefPtr<DeconstructionPatternNode>);
    1349         ParameterNode(ParameterNode*, PassRefPtr<DeconstructionPatternNode>);
    1350 
    1351         DeconstructionPatternNode* pattern() const { return m_pattern.get(); }
     1344        ParameterNode(const Identifier&);
     1345        ParameterNode(ParameterNode*, const Identifier&);
     1346
     1347        const Identifier& ident() const { return m_ident; }
    13521348        ParameterNode* nextParam() const { return m_next; }
    13531349
    13541350    private:
    1355         RefPtr<DeconstructionPatternNode> m_pattern;
     1351        const Identifier& m_ident;
    13561352        ParameterNode* m_next;
    13571353    };
     
    14651461    class FunctionParameters : public RefCounted<FunctionParameters> {
    14661462        WTF_MAKE_FAST_ALLOCATED;
    1467         WTF_MAKE_NONCOPYABLE(FunctionParameters);
    14681463    public:
    14691464        static PassRefPtr<FunctionParameters> create(ParameterNode*);
     
    14711466
    14721467        unsigned size() const { return m_size; }
    1473         DeconstructionPatternNode* at(unsigned index) { ASSERT(index < m_size); return patterns()[index]; }
     1468        const Identifier& at(unsigned index) const { ASSERT(index < m_size); return identifiers()[index]; }
    14741469
    14751470    private:
    14761471        FunctionParameters(ParameterNode*, unsigned size);
    14771472
    1478         DeconstructionPatternNode** patterns() { return &m_storage; }
     1473        Identifier* identifiers() { return reinterpret_cast<Identifier*>(&m_storage); }
     1474        const Identifier* identifiers() const { return reinterpret_cast<const Identifier*>(&m_storage); }
    14791475
    14801476        unsigned m_size;
    1481         DeconstructionPatternNode* m_storage;
     1477        void* m_storage;
    14821478    };
    14831479
     
    15351531    };
    15361532
    1537     class DeconstructionPatternNode : public RefCounted<DeconstructionPatternNode> {
    1538         WTF_MAKE_NONCOPYABLE(DeconstructionPatternNode);
    1539         WTF_MAKE_FAST_ALLOCATED;
    1540 
    1541     public:
    1542         virtual void collectBoundIdentifiers(Vector<Identifier>&) const = 0;
    1543         virtual void emitBytecode(BytecodeGenerator&, RegisterID* source) const = 0;
    1544         virtual void toString(StringBuilder&) const = 0;
    1545 
    1546         virtual bool isBindingNode() const { return false; }
    1547         virtual RegisterID* emitDirectBinding(BytecodeGenerator&, RegisterID*, ExpressionNode*) { return 0; }
    1548        
    1549         virtual ~DeconstructionPatternNode() = 0;
    1550        
    1551     protected:
    1552         DeconstructionPatternNode(VM*);
    1553     };
    1554 
    1555     class ArrayPatternNode : public DeconstructionPatternNode {
    1556     public:
    1557         static PassRefPtr<ArrayPatternNode> create(VM*);
    1558         void appendIndex(const JSTokenLocation&, DeconstructionPatternNode* node)
    1559         {
    1560             m_targetPatterns.append(node);
    1561         }
    1562 
    1563     private:
    1564         ArrayPatternNode(VM*);
    1565         void collectBoundIdentifiers(Vector<Identifier>&) const;
    1566         void emitBytecode(BytecodeGenerator&, RegisterID*) const;
    1567         RegisterID* emitDirectBinding(BytecodeGenerator&, RegisterID* dst, ExpressionNode*);
    1568         void toString(StringBuilder&) const;
    1569 
    1570         Vector<RefPtr<DeconstructionPatternNode>> m_targetPatterns;
    1571     };
    1572    
    1573     class ObjectPatternNode : public DeconstructionPatternNode {
    1574     public:
    1575         static PassRefPtr<ObjectPatternNode> create(VM*);
    1576         void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DeconstructionPatternNode* pattern)
    1577         {
    1578             m_targetPatterns.append(Entry(identifier, wasString, pattern));
    1579         }
    1580        
    1581     private:
    1582         ObjectPatternNode(VM*);
    1583         void collectBoundIdentifiers(Vector<Identifier>&) const;
    1584         void emitBytecode(BytecodeGenerator&, RegisterID*) const;
    1585         void toString(StringBuilder&) const;
    1586         struct Entry {
    1587             Entry(const Identifier& propertyName, bool wasString, DeconstructionPatternNode* pattern)
    1588                 : propertyName(propertyName)
    1589                 , wasString(wasString)
    1590                 , pattern(pattern)
    1591             {
    1592             }
    1593             Identifier propertyName;
    1594             bool wasString;
    1595             RefPtr<DeconstructionPatternNode> pattern;
    1596         };
    1597         Vector<Entry> m_targetPatterns;
    1598     };
    1599 
    1600     class BindingNode : public DeconstructionPatternNode, ThrowableExpressionData {
    1601     public:
    1602         static PassRefPtr<BindingNode> create(VM*, const Identifier& boundProperty, const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end);
    1603         const Identifier& boundProperty() const { return m_boundProperty; }
    1604        
    1605     private:
    1606         BindingNode(VM*, const Identifier& boundProperty, const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end);
    1607 
    1608         void collectBoundIdentifiers(Vector<Identifier>&) const;
    1609         void emitBytecode(BytecodeGenerator&, RegisterID*) const;
    1610         void toString(StringBuilder&) const;
    1611        
    1612         virtual bool isBindingNode() const { return true; }
    1613        
    1614         Identifier m_boundProperty;
    1615     };
    1616 
    1617     class DeconstructingAssignmentNode : public ExpressionNode {
    1618     public:
    1619         DeconstructingAssignmentNode(const JSTokenLocation&, PassRefPtr<DeconstructionPatternNode>, ExpressionNode*);
    1620         DeconstructionPatternNode* bindings() { return m_bindings.get(); }
    1621 
    1622     private:
    1623         virtual bool isLocation() const { return true; }
    1624         virtual bool isDeconstructionNode() const { return true; }
    1625         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    1626 
    1627         RefPtr<DeconstructionPatternNode> m_bindings;
    1628         ExpressionNode* m_initializer;
    1629     };
    1630 
    16311533    class FuncDeclNode : public StatementNode {
    16321534    public:
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r156492 r156497  
    8585    m_token.m_location.endOffset = source.startOffset();
    8686    m_token.m_location.lineStartOffset = source.startOffset();
     87
    8788    m_functionCache = vm->addSourceProviderCache(source.provider());
    8889    ScopeRef scope = pushScope();
     
    9293        scope->setStrictMode();
    9394    if (parameters) {
    94         for (unsigned i = 0; i < parameters->size(); i++) {
    95             auto parameter = parameters->at(i);
    96             if (!parameter->isBindingNode())
    97                 continue;
    98             scope->declareParameter(&static_cast<BindingNode*>(parameter)->boundProperty());
    99         }
     95        for (unsigned i = 0; i < parameters->size(); i++)
     96            scope->declareParameter(&parameters->at(i));
    10097    }
    10198    if (!name.isNull())
     
    207204    int end = 0;
    208205    int scratch;
    209     TreeDeconstructionPattern scratch1 = 0;
     206    const Identifier* scratch1 = 0;
    210207    TreeExpression scratch2 = 0;
    211208    JSTextPosition scratch3;
     
    275272
    276273template <typename LexerType>
    277 template <class TreeBuilder> TreeExpression Parser<LexerType>::parseVarDeclarationList(TreeBuilder& context, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd)
     274template <class TreeBuilder> TreeExpression Parser<LexerType>::parseVarDeclarationList(TreeBuilder& context, int& declarations, const Identifier*& lastIdent, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd)
    278275{
    279276    TreeExpression varDecls = 0;
    280     const Identifier* lastIdent;
    281277    do {
    282         lastIdent = 0;
    283         lastPattern = 0;
     278        declarations++;
    284279        JSTokenLocation location(tokenLocation());
    285280        next();
    286         TreeExpression node = 0;
    287         declarations++;
    288         bool hasInitializer = false;
    289         if (match(IDENT)) {
    290             JSTextPosition varStart = tokenStartPosition();
    291             identStart = varStart;
    292             const Identifier* name = m_token.m_data.ident;
    293             lastIdent = name;
    294             next();
    295             hasInitializer = match(EQUAL);
    296             failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode.");
    297             context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
    298             if (hasInitializer) {
    299                 JSTextPosition varDivot = tokenStartPosition() + 1;
    300                 initStart = tokenStartPosition();
    301                 next(TreeBuilder::DontBuildStrings); // consume '='
    302                 TreeExpression initializer = parseAssignmentExpression(context);
    303                 initEnd = lastTokenEndPosition();
    304                 lastInitializer = initializer;
    305                 failIfFalse(initializer);
    306                
    307                 node = context.createAssignResolve(location, *name, initializer, varStart, varDivot, lastTokenEndPosition());
    308             }
    309         } else {
    310             lastIdent = 0;
    311             auto pattern = parseDeconstructionPattern<DeconstructToVariables>(context);
    312             failIfFalse(pattern);
    313             hasInitializer = match(EQUAL);
    314             lastPattern = pattern;
    315             if (hasInitializer) {
    316                 next(TreeBuilder::DontBuildStrings); // consume '='
    317                 TreeExpression rhs = parseExpression(context);
    318                 node = context.createDeconstructingAssignment(location, pattern, rhs);
    319             }
    320             ASSERT(node);
    321         }
    322        
     281        matchOrFail(IDENT);
     282       
     283        JSTextPosition varStart = tokenStartPosition();
     284        identStart = varStart;
     285        const Identifier* name = m_token.m_data.ident;
     286        lastIdent = name;
     287        next();
     288        bool hasInitializer = match(EQUAL);
     289        failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode.");
     290        context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
    323291        if (hasInitializer) {
     292            JSTextPosition varDivot = tokenStartPosition() + 1;
     293            initStart = tokenStartPosition();
     294            next(TreeBuilder::DontBuildStrings); // consume '='
     295            TreeExpression initializer = parseAssignmentExpression(context);
     296            initEnd = lastTokenEndPosition();
     297            lastInitializer = initializer;
     298            failIfFalse(initializer);
     299           
     300            TreeExpression node = context.createAssignResolve(location, *name, initializer, varStart, varDivot, lastTokenEndPosition());
    324301            if (!varDecls)
    325302                varDecls = node;
     
    328305        }
    329306    } while (match(COMMA));
    330     if (lastIdent)
    331         lastPattern = createBindingPattern<DeconstructToVariables>(context, *lastIdent, 0);
    332307    return varDecls;
    333 }
    334 
    335 template <typename LexerType>
    336 template <DeconstructionKind kind, class TreeBuilder> TreeDeconstructionPattern Parser<LexerType>::createBindingPattern(TreeBuilder& context, const Identifier& name, int depth)
    337 {
    338     ASSERT(!name.isEmpty());
    339     ASSERT(!name.isNull());
    340    
    341     ASSERT(name.impl()->isIdentifier());
    342     if (depth) {
    343         if (kind == DeconstructToVariables)
    344             failIfFalseIfStrictWithNameAndMessage(declareVariable(&name), "Cannot deconstruct to a variable named", name.impl(), ".");
    345         if (kind == DeconstructToParameters) {
    346             auto bindingResult = declareBoundParameter(&name);
    347             failIfFalseIfStrictWithNameAndMessage(bindingResult != Scope::StrictBindingFailed, "Cannot deconstruct to a parameter named", name.impl(), "in strict mode.");
    348             failIfFalseWithNameAndMessage(bindingResult != Scope::BindingFailed, "Cannot deconstruct to a parameter named", name.impl(), ".");
    349         }
    350         context.addVar(&name, kind == DeconstructToParameters ? 0 : DeclarationStacks::HasInitializer);
    351     } else {
    352         if (kind == DeconstructToVariables) {
    353             failIfFalseIfStrictWithNameAndMessage(declareVariable(&name), "Cannot declare a variable named", name.impl(), "in strict mode.");
    354             context.addVar(&name, DeclarationStacks::HasInitializer);
    355         }
    356        
    357         if (kind == DeconstructToParameters)
    358             failIfFalseIfStrictWithNameAndMessage(declareParameter(&name), "Cannot declare a parameter named", name.impl(), "in strict mode.");
    359     }
    360     return context.createBindingLocation(m_token.m_location, name, m_token.m_endPosition, m_token.m_startPosition, m_token.m_endPosition);
    361 }
    362 
    363 template <typename LexerType>
    364 template <DeconstructionKind kind, class TreeBuilder> TreeDeconstructionPattern Parser<LexerType>::parseDeconstructionPattern(TreeBuilder& context, int depth)
    365 {
    366     failIfStackOverflow();
    367     int nonLHSCount = m_nonLHSCount;
    368     TreeDeconstructionPattern pattern;
    369     switch (m_token.m_type) {
    370     case OPENBRACKET: {
    371         auto arrayPattern = context.createArrayPattern(m_token.m_location);
    372         next();
    373         do {
    374             while (match(COMMA)) {
    375                 context.appendArrayPatternSkipEntry(arrayPattern, m_token.m_location);
    376                 next();
    377             }
    378             failIfTrue(hasError());
    379             JSTokenLocation location = m_token.m_location;
    380             auto innerPattern = parseDeconstructionPattern<kind>(context, depth + 1);
    381             failIfFalse(innerPattern);
    382             context.appendArrayPatternEntry(arrayPattern, location, innerPattern);
    383         } while (consume(COMMA));
    384         consumeOrFail(CLOSEBRACKET);
    385         pattern = arrayPattern;
    386         break;
    387     }
    388     case OPENBRACE: {
    389         next();
    390         auto objectPattern = context.createObjectPattern(m_token.m_location);
    391         bool wasString = false;
    392         do {
    393             Identifier propertyName;
    394             TreeDeconstructionPattern innerPattern = 0;
    395             JSTokenLocation location = m_token.m_location;
    396             if (match(IDENT)) {
    397                 propertyName = *m_token.m_data.ident;
    398                 next();
    399                 if (consume(COLON))
    400                     innerPattern = parseDeconstructionPattern<kind>(context, depth + 1);
    401                 else
    402                     innerPattern = createBindingPattern<kind>(context, propertyName, depth);
    403             } else {
    404                 switch (m_token.m_type) {
    405                 case NUMBER:
    406                     propertyName = Identifier::from(m_vm, m_token.m_data.doubleValue);
    407                     break;
    408                 case STRING:
    409                     propertyName = *m_token.m_data.ident;
    410                     wasString = true;
    411                     break;
    412                 default:
    413                     failIfTrue(!(m_token.m_type & KeywordTokenFlag));
    414                     propertyName = *m_token.m_data.ident;
    415                     break;
    416                 }
    417                 next();
    418                 consumeOrFail(COLON);
    419                 innerPattern = parseDeconstructionPattern<kind>(context, depth + 1);
    420             }
    421             failIfFalse(innerPattern);
    422             context.appendObjectPatternEntry(objectPattern, location, wasString, propertyName, innerPattern);
    423         } while (consume(COMMA));
    424         consumeOrFail(CLOSEBRACE);
    425         pattern = objectPattern;
    426         break;
    427     }
    428 
    429     default: {
    430         matchOrFail(IDENT);
    431         pattern = createBindingPattern<kind>(context, *m_token.m_data.ident, depth);
    432         next();
    433         break;
    434     }
    435     }
    436     m_nonLHSCount = nonLHSCount;
    437     return pattern;
    438308}
    439309
     
    482352        /*
    483353         for (var IDENT in expression) statement
     354         for (var IDENT = expression in expression) statement
    484355         for (var varDeclarationList; expressionOpt; expressionOpt)
    485356         */
    486         TreeDeconstructionPattern forInTarget = 0;
     357        const Identifier* forInTarget = 0;
    487358        TreeExpression forInInitializer = 0;
    488359        m_allowsIn = false;
     
    499370        failIfFalse(declarations == 1);
    500371        failIfTrueWithMessage(forInInitializer, "Cannot use initialiser syntax in a for-in loop");
    501        
     372
    502373        // Handle for-in with var declaration
    503374        JSTextPosition inLocation = tokenStartPosition();
     
    516387        endLoop();
    517388        failIfFalse(statement);
     389       
    518390        return context.createForInLoop(location, forInTarget, expr, statement, declsStart, inLocation, exprEnd, startLine, endLine);
    519391    }
     
    901773template <class TreeBuilder> TreeFormalParameterList Parser<LexerType>::parseFormalParameters(TreeBuilder& context)
    902774{
    903     auto parameter = parseDeconstructionPattern<DeconstructToParameters>(context);
    904     failIfFalse(parameter);
    905     TreeFormalParameterList list = context.createFormalParameterList(parameter);
     775    matchOrFail(IDENT);
     776    failIfFalseIfStrictWithNameAndMessage(declareParameter(m_token.m_data.ident), "Cannot declare a parameter named", m_token.m_data.ident->impl(), " in strict mode");
     777    TreeFormalParameterList list = context.createFormalParameterList(*m_token.m_data.ident);
    906778    TreeFormalParameterList tail = list;
    907     while (consume(COMMA)) {
    908         parameter = parseDeconstructionPattern<DeconstructToParameters>(context);
    909         failIfFalse(parameter);
    910         tail = context.createFormalParameterList(tail, parameter);
     779    next();
     780    while (match(COMMA)) {
     781        next();
     782        matchOrFail(IDENT);
     783        const Identifier* ident = m_token.m_data.ident;
     784        failIfFalseIfStrictWithNameAndMessage(declareParameter(ident), "Cannot declare a parameter named", ident->impl(), "in strict mode");
     785        next();
     786        tail = context.createFormalParameterList(tail, *ident);
    911787    }
    912788    return list;
     
    12801156            m_lastIdentifier = 0;
    12811157        }
    1282         lhs = parseAssignmentExpression(context);
     1158        lhs = parseConditionalExpression(context);
    12831159        failIfFalse(lhs);
    12841160        if (initialNonLHSCount != m_nonLHSCount)
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r156480 r156497  
    7474#define TreeProperty typename TreeBuilder::Property
    7575#define TreePropertyList typename TreeBuilder::PropertyList
    76 #define TreeDeconstructionPattern typename TreeBuilder::DeconstructionPattern
    7776
    7877COMPILE_ASSERT(LastUntaggedToken < 64, LessThan64UntaggedTokens);
     
    8079enum SourceElementsMode { CheckForStrictMode, DontCheckForStrictMode };
    8180enum FunctionRequirements { FunctionNoRequirements, FunctionNeedsName };
    82 enum DeconstructionKind {
    83     DeconstructToVariables,
    84     DeconstructToParameters,
    85     DeconstructToExpressions
    86 };
    8781
    8882template <typename T> inline bool isEvalNode() { return false; }
     
    230224        return isValidStrictMode;
    231225    }
    232    
    233     enum BindingResult {
    234         BindingFailed,
    235         StrictBindingFailed,
    236         BindingSucceeded
    237     };
    238     BindingResult declareBoundParameter(const Identifier* ident)
    239     {
    240         bool isArguments = m_vm->propertyNames->arguments == *ident;
    241         bool newEntry = m_declaredVariables.add(ident->string().impl()).isNewEntry;
    242         bool isValidStrictMode = newEntry && m_vm->propertyNames->eval != *ident && !isArguments;
    243         m_isValidStrictMode = m_isValidStrictMode && isValidStrictMode;
    244    
    245         if (isArguments)
    246             m_shadowsArguments = true;
    247         if (!newEntry)
    248             return BindingFailed;
    249         return isValidStrictMode ? BindingSucceeded : StrictBindingFailed;
    250     }
    251 
    252226
    253227    void useVariable(const Identifier* ident, bool isEval)
     
    883857    bool isValidStrictMode() { return currentScope()->isValidStrictMode(); }
    884858    bool declareParameter(const Identifier* ident) { return currentScope()->declareParameter(ident); }
    885     Scope::BindingResult declareBoundParameter(const Identifier* ident) { return currentScope()->declareBoundParameter(ident); }
    886859    bool breakIsValid()
    887860    {
     
    954927    template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&);
    955928    template <class TreeBuilder> ALWAYS_INLINE TreeFormalParameterList parseFormalParameters(TreeBuilder&);
    956     template <class TreeBuilder> ALWAYS_INLINE TreeExpression parseVarDeclarationList(TreeBuilder&, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd);
    957     template <class TreeBuilder> ALWAYS_INLINE TreeConstDeclList parseConstDeclarationList(TreeBuilder&);
    958 
    959     template <DeconstructionKind, class TreeBuilder> ALWAYS_INLINE TreeDeconstructionPattern createBindingPattern(TreeBuilder&, const Identifier&, int depth);
    960     template <DeconstructionKind, class TreeBuilder> ALWAYS_INLINE TreeDeconstructionPattern parseDeconstructionPattern(TreeBuilder&, int depth = 0);
     929    template <class TreeBuilder> ALWAYS_INLINE TreeExpression parseVarDeclarationList(TreeBuilder&, int& declarations, const Identifier*& lastIdent, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd);
     930    template <class TreeBuilder> ALWAYS_INLINE TreeConstDeclList parseConstDeclarationList(TreeBuilder& context);
    961931    template <FunctionRequirements, bool nameIsInContainingScope, class TreeBuilder> bool parseFunctionInfo(TreeBuilder&, const Identifier*&, TreeFormalParameterList&, TreeFunctionBody&, unsigned& openBraceOffset, unsigned& closeBraceOffset, int& bodyStartLine, unsigned& bodyStartColumn);
    962932    ALWAYS_INLINE int isBinaryOperator(JSTokenType);
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r156464 r156497  
    112112    typedef int ConstDeclList;
    113113    typedef int BinaryOperand;
    114     typedef int DeconstructionPattern;
    115     typedef int ArrayPattern;
    116     typedef int ObjectPattern;
    117 
     114   
    118115    static const bool CreatesAST = false;
    119116    static const bool NeedsFreeVariableInfo = false;
     
    177174    int createElementList(int, int) { return 1; }
    178175    int createElementList(int, int, int) { return 1; }
    179     int createFormalParameterList(DeconstructionPattern) { return 1; }
    180     int createFormalParameterList(int, DeconstructionPattern) { return 1; }
     176    int createFormalParameterList(const Identifier&) { return 1; }
     177    int createFormalParameterList(int, const Identifier&) { return 1; }
    181178    int createClause(int, int) { return 1; }
    182179    int createClauseList(int) { return 1; }
     
    189186    int createIfStatement(const JSTokenLocation&, int, int, int, int, int) { return 1; }
    190187    int createForLoop(const JSTokenLocation&, int, int, int, int, int, int) { return 1; }
     188    int createForInLoop(const JSTokenLocation&, const Identifier*, int, int, int, int, int, int, int) { return 1; }
    191189    int createForInLoop(const JSTokenLocation&, int, int, int, int, int, int, int, int) { return 1; }
    192190    int createEmptyStatement(const JSTokenLocation&) { return 1; }
     
    253251    PropertyNode::Type getType(const Property& property) const { return property.type; }
    254252    bool isResolve(ExpressionType expr) const { return expr == ResolveExpr || expr == ResolveEvalExpr; }
    255     ExpressionType createDeconstructingAssignment(const JSTokenLocation&, int, ExpressionType)
    256     {
    257         return 1;
    258     }
    259    
    260     ArrayPattern createArrayPattern(const JSTokenLocation&)
    261     {
    262         return 1;
    263     }
    264     void appendArrayPatternSkipEntry(ArrayPattern, const JSTokenLocation&)
    265     {
    266     }
    267     void appendArrayPatternEntry(ArrayPattern, const JSTokenLocation&, DeconstructionPattern)
    268     {
    269     }
    270     ObjectPattern createObjectPattern(const JSTokenLocation&)
    271     {
    272         return 1;
    273     }
    274     void appendObjectPatternEntry(ArrayPattern, const JSTokenLocation&, bool, const Identifier&, DeconstructionPattern)
    275     {
    276     }
    277     DeconstructionPattern createBindingLocation(const JSTokenLocation&, const Identifier&, const JSTextPosition&, const JSTextPosition&, const JSTextPosition&)
    278     {
    279         return 1;
    280     }
     253   
    281254private:
    282255    int m_topBinaryExpr;
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r156464 r156497  
    303303    }
    304304}
    305 
    306 void escapeStringToBuilder(StringBuilder& builder, const String& message)
    307 {
    308     if (message.is8Bit())
    309         appendStringToStringBuilder(builder, message.characters8(), message.length());
    310     else
    311         appendStringToStringBuilder(builder, message.characters16(), message.length());
    312 }
    313 
     305   
    314306void Stringifier::appendQuotedString(StringBuilder& builder, const String& value)
    315307{
  • trunk/Source/JavaScriptCore/runtime/JSONObject.h

    r156464 r156497  
    6464    String JSONStringify(ExecState*, JSValue, unsigned indent);
    6565
    66     void escapeStringToBuilder(StringBuilder&, const String&);
    67    
    6866} // namespace JSC
    6967
Note: See TracChangeset for help on using the changeset viewer.