Ignore:
Timestamp:
Aug 18, 2014, 12:11:41 PM (11 years ago)
Author:
[email protected]
Message:

The parser should generate AST nodes the var declarations with no initializers
https://bugs.webkit.org/show_bug.cgi?id=135545

Patch by Saam Barati <[email protected]> on 2014-08-18
Reviewed by Geoffrey Garen.

Currently, JSC's parser ignores variable declarations
that have no assignment initializer value because all
variables are implicitly assigned to undefined. But,
type profiling needs an AST node to be generated for these
empty variable declarations because it needs to be able to
profile their text locations and to see that their type
is undefined.

  • bytecompiler/NodesCodegen.cpp:

(JSC::EmptyVarExpression::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createVarStatement):
(JSC::ASTBuilder::createEmptyVarExpression):

  • parser/NodeConstructors.h:

(JSC::EmptyVarExpression::EmptyVarExpression):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseVarDeclarationList):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createEmptyVarExpression):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r172614 r172717  
    17831783}
    17841784
     1785// ------------------------------ EmptyVarExpression ----------------------------
     1786
     1787RegisterID* EmptyVarExpression::emitBytecode(BytecodeGenerator& generator, RegisterID*)
     1788{
     1789    if (!generator.isProfilingTypesWithHighFidelity())
     1790        return nullptr;
     1791
     1792    if (Local local = generator.local(m_ident))
     1793        generator.emitProfileTypesWithHighFidelity(local.get(), ProfileTypesBytecodeHasGlobalID, nullptr);
     1794    else {
     1795        RefPtr<RegisterID> scope = generator.emitResolveScope(generator.newTemporary(), m_ident);
     1796        RefPtr<RegisterID> value = generator.emitGetFromScope(generator.newTemporary(), scope.get(), m_ident, DoNotThrowIfNotFound);
     1797        generator.emitProfileTypesWithHighFidelity(value.get(), ProfileTypesBytecodeGetFromScope, &m_ident);
     1798    }
     1799
     1800    generator.emitHighFidelityTypeProfilingExpressionInfo(position(), JSTextPosition(-1, position().offset + m_ident.length(), -1));
     1801
     1802    // It's safe to return null here because this node will always be a child node of VarStatementNode which ignores our return value.
     1803    return nullptr;
     1804}
     1805
    17851806// ------------------------------ IfElseNode ---------------------------------------
    17861807
Note: See TracChangeset for help on using the changeset viewer.