Ignore:
Timestamp:
Mar 20, 2013, 2:09:38 AM (12 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Fix incorrect debugger column number value.
https://bugs.webkit.org/show_bug.cgi?id=112741.

Reviewed by Oliver Hunt.

  1. In lexer, parser, and debugger code, renamed column to charPosition.
  2. Convert the charPosition to the equivalent column number before passing it to the debugger.
  3. Changed ScopeNodes to take both a startLocation and an endLocation. This allows FunctionBodyNodes, ProgramNodes, and EvalNodess to emit correct debug hooks with correct starting line and column numbers.
  4. Fixed the Lexer to not reset the charPosition (previously columnNumber) in Lexer::lex().

(JSC::CodeBlock::dumpBytecode):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDebugHook):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::emitExpressionInfo):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ArrayNode::toArgumentList):
(JSC::ConstStatementNode::emitBytecode):
(JSC::EmptyStatementNode::emitBytecode):
(JSC::DebuggerStatementNode::emitBytecode):
(JSC::ExprStatementNode::emitBytecode):
(JSC::VarStatementNode::emitBytecode):
(JSC::IfNode::emitBytecode):
(JSC::IfElseNode::emitBytecode):
(JSC::DoWhileNode::emitBytecode):
(JSC::WhileNode::emitBytecode):
(JSC::ForNode::emitBytecode):
(JSC::ForInNode::emitBytecode):
(JSC::ContinueNode::emitBytecode):
(JSC::BreakNode::emitBytecode):
(JSC::ReturnNode::emitBytecode):
(JSC::WithNode::emitBytecode):
(JSC::SwitchNode::emitBytecode):
(JSC::LabelNode::emitBytecode):
(JSC::ThrowNode::emitBytecode):
(JSC::TryNode::emitBytecode):
(JSC::ProgramNode::emitBytecode):
(JSC::EvalNode::emitBytecode):
(JSC::FunctionBodyNode::emitBytecode):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::debug):

  • convert charPosition to column for the debugger.
  • interpreter/Interpreter.h:
  • jit/JITStubs.cpp:

(DEFINE_STUB_FUNCTION(void, op_debug)):

  • llint/LLIntSlowPaths.cpp:

(LLINT_SLOW_PATH_DECL(slow_op_debug)):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionExpr):
(JSC::ASTBuilder::createFunctionBody):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createFuncDeclStatement):
(JSC::ASTBuilder::createBlockStatement):
(JSC::ASTBuilder::createExprStatement):
(JSC::ASTBuilder::createIfStatement):
(JSC::ASTBuilder::createForLoop):
(JSC::ASTBuilder::createForInLoop):
(JSC::ASTBuilder::createVarStatement):
(JSC::ASTBuilder::createReturnStatement):
(JSC::ASTBuilder::createBreakStatement):
(JSC::ASTBuilder::createContinueStatement):
(JSC::ASTBuilder::createTryStatement):
(JSC::ASTBuilder::createSwitchStatement):
(JSC::ASTBuilder::createWhileStatement):
(JSC::ASTBuilder::createDoWhileStatement):
(JSC::ASTBuilder::createWithStatement):
(JSC::ASTBuilder::createThrowStatement):
(JSC::ASTBuilder::createDebugger):
(JSC::ASTBuilder::createConstStatement):

  • parser/Lexer.cpp:

(JSC::::setCode):
(JSC::::internalShift):
(JSC::::shift):
(JSC::::lex):

  • parser/Lexer.h:

(JSC::Lexer::currentCharPosition):
(Lexer):
(JSC::::lexExpectIdentifier):

  • parser/NodeConstructors.h:

(JSC::Node::Node):

  • parser/Nodes.cpp:

(JSC::StatementNode::setLoc):
(JSC::ScopeNode::ScopeNode):
(JSC::ProgramNode::ProgramNode):
(JSC::ProgramNode::create):
(JSC::EvalNode::EvalNode):
(JSC::EvalNode::create):
(JSC::FunctionBodyNode::FunctionBodyNode):
(JSC::FunctionBodyNode::create):

  • parser/Nodes.h:

(JSC::Node::charPosition):
(Node):
(StatementNode):
(JSC::StatementNode::lastLine):
(ScopeNode):
(JSC::ScopeNode::startLine):
(JSC::ScopeNode::startCharPosition):
(ProgramNode):
(EvalNode):
(FunctionBodyNode):

  • parser/Parser.cpp:

(JSC::::Parser):
(JSC::::parseFunctionBody):
(JSC::::parseFunctionInfo):

  • parser/Parser.h:

(JSC::::parse):

  • parser/ParserTokens.h:

(JSC::JSTokenLocation::JSTokenLocation):
(JSTokenLocation):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createFunctionBody):

Source/WTF: Introducing String::reverseFindLineTerminator().
https://bugs.webkit.org/show_bug.cgi?id=112741.

Reviewed by Oliver Hunt.

This is needed by the JSC debugger code for computing column numbers.

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::reverseFindLineTerminator):

  • wtf/text/StringImpl.h:

(StringImpl):
(WTF::reverseFindLineTerminator):

  • wtf/text/WTFString.h:

(WTF::String::reverseFindLineTerminator):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Nodes.cpp

    r140947 r146318  
    22*  Copyright (C) 1999-2002 Harri Porten ([email protected])
    33*  Copyright (C) 2001 Peter Kelly ([email protected])
    4 *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     4*  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
    55*  Copyright (C) 2007 Cameron Zwarich ([email protected])
    66*  Copyright (C) 2007 Maks Orlovich
     
    5353// ------------------------------ StatementNode --------------------------------
    5454
    55 void StatementNode::setLoc(int firstLine, int lastLine, int column)
     55void StatementNode::setLoc(int firstLine, int lastLine, int charPosition)
    5656{
    5757    m_lineNumber = firstLine;
    5858    m_lastLine = lastLine;
    59     m_columnNumber = column;
    60 }
    61 
    62 void StatementNode::setLoc(int firstLine, int lastLine)
    63 {
    64     m_lineNumber = firstLine;
    65     m_lastLine = lastLine;
    66     m_columnNumber = 0;
     59    m_charPosition = charPosition;
    6760}
    6861
     
    8477// ------------------------------ ScopeNode -----------------------------
    8578
    86 ScopeNode::ScopeNode(JSGlobalData* globalData, const JSTokenLocation& location, bool inStrictContext)
    87     : StatementNode(location)
     79ScopeNode::ScopeNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, bool inStrictContext)
     80    : StatementNode(endLocation)
    8881    , ParserArenaRefCounted(globalData)
     82    , m_startLineNumber(startLocation.line)
     83    , m_startCharPosition(startLocation.charPosition)
    8984    , m_features(inStrictContext ? StrictModeFeature : NoFeatures)
    9085    , m_numConstants(0)
     
    9388}
    9489
    95 ScopeNode::ScopeNode(JSGlobalData* globalData, const JSTokenLocation& location, const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, CodeFeatures features, int numConstants)
    96     : StatementNode(location)
     90ScopeNode::ScopeNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, CodeFeatures features, int numConstants)
     91    : StatementNode(endLocation)
    9792    , ParserArenaRefCounted(globalData)
     93    , m_startLineNumber(startLocation.line)
     94    , m_startCharPosition(startLocation.charPosition)
    9895    , m_features(features)
    9996    , m_source(source)
     
    116113// ------------------------------ ProgramNode -----------------------------
    117114
    118 inline ProgramNode::ProgramNode(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
    119     : ScopeNode(globalData, location, source, children, varStack, funcStack, capturedVariables, features, numConstants)
    120 {
    121 }
    122 
    123 PassRefPtr<ProgramNode> ProgramNode::create(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
    124 {
    125     RefPtr<ProgramNode> node = new ProgramNode(globalData, location, children, varStack, funcStack,  capturedVariables, source, features, numConstants);
     115inline ProgramNode::ProgramNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
     116    : ScopeNode(globalData, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants)
     117{
     118}
     119
     120PassRefPtr<ProgramNode> ProgramNode::create(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
     121{
     122    RefPtr<ProgramNode> node = new ProgramNode(globalData, startLocation, endLocation, children, varStack, funcStack,  capturedVariables, source, features, numConstants);
    126123
    127124    ASSERT(node->m_arena.last() == node);
     
    134131// ------------------------------ EvalNode -----------------------------
    135132
    136 inline EvalNode::EvalNode(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
    137     : ScopeNode(globalData, location, source, children, varStack, funcStack, capturedVariables, features, numConstants)
    138 {
    139 }
    140 
    141 PassRefPtr<EvalNode> EvalNode::create(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
    142 {
    143     RefPtr<EvalNode> node = new EvalNode(globalData, location, children, varStack, funcStack, capturedVariables, source, features, numConstants);
     133inline EvalNode::EvalNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
     134    : ScopeNode(globalData, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants)
     135{
     136}
     137
     138PassRefPtr<EvalNode> EvalNode::create(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
     139{
     140    RefPtr<EvalNode> node = new EvalNode(globalData, startLocation, endLocation, children, varStack, funcStack, capturedVariables, source, features, numConstants);
    144141
    145142    ASSERT(node->m_arena.last() == node);
     
    177174}
    178175
    179 inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, const JSTokenLocation& location, bool inStrictContext)
    180     : ScopeNode(globalData, location, inStrictContext)
    181 {
    182 }
    183 
    184 inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
    185     : ScopeNode(globalData, location, sourceCode, children, varStack, funcStack, capturedVariables, features, numConstants)
     176inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, bool inStrictContext)
     177    : ScopeNode(globalData, startLocation, endLocation, inStrictContext)
     178{
     179}
     180
     181inline FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
     182    : ScopeNode(globalData, startLocation, endLocation, sourceCode, children, varStack, funcStack, capturedVariables, features, numConstants)
    186183{
    187184}
     
    201198}
    202199
    203 FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData, const JSTokenLocation& location, bool inStrictContext)
    204 {
    205     return new FunctionBodyNode(globalData, location, inStrictContext);
    206 }
    207 
    208 PassRefPtr<FunctionBodyNode> FunctionBodyNode::create(JSGlobalData* globalData, const JSTokenLocation& location, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
    209 {
    210     RefPtr<FunctionBodyNode> node = new FunctionBodyNode(globalData, location, children, varStack, funcStack, capturedVariables, sourceCode, features, numConstants);
     200FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, bool inStrictContext)
     201{
     202    return new FunctionBodyNode(globalData, startLocation, endLocation, inStrictContext);
     203}
     204
     205PassRefPtr<FunctionBodyNode> FunctionBodyNode::create(JSGlobalData* globalData, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
     206{
     207    RefPtr<FunctionBodyNode> node = new FunctionBodyNode(globalData, startLocation, endLocation, children, varStack, funcStack, capturedVariables, sourceCode, features, numConstants);
    211208
    212209    ASSERT(node->m_arena.last() == node);
Note: See TracChangeset for help on using the changeset viewer.