Commit 5b45f90a authored by mark.lam@apple.com's avatar mark.lam@apple.com

Fix 30% JSBench regression (caused by adding column numbers to stack traces).

https://bugs.webkit.org/show_bug.cgi?id=118481.

Reviewed by Mark Hahnenberg and Geoffrey Garen.

Source/JavaScriptCore: 

Previously, we already capture ExpressionRangeInfo that provides a divot for
each bytecode that can potentially throw an exception (and therefore generate
a stack trace). On first attempt to compute column numbers, we then do a walk
of the source string to record all line start positions in a table associated
with the SourceProvider. The column number can then be computed as
    divot - lineStartFor(bytecodeOffset).

The computation of this lineStarts table is the source of the 30% JSBench
performance regression.

The new code now records lineStarts as the lexer and parser scans the source
code. These lineStarts are then used to compute the column number for the
given divot, and stored in the ExpressionRangeInfo. Similarly, we also capture
the line number at the divot point and store that in the ExpressionRangeInfo.
Hence, to look up line and column numbers, we now lookup the ExpressionRangeInfo
for the bytecodeOffset, and then compute the line and column from the values
stored in the expression info.

The strategy:
1. We want to minimize perturbations to the lexer and parser. Specifically,
   the changes added should not change how it scans code, and generate bytecode.
2. We regard the divot as the source character position we are interested
   in. As such, we'll capture line and lineStart (for column) at the point
   when we capture the divot information. This ensures that the 3 values are
   consistent.

How the change is done:
1. Change the lexer to track lineStarts.
2. Change the parser to capture line and lineStarts at the point of capturing
   divots.
3. Change the parser and associated code to plumb these values all the way to
   the point that the correspoinding ExpressionRangeInfo is emitted.
4. Propagate and record SourceCode firstLine and firstLineColumnOffset to the
   the necessary places so that we can add them as needed when reifying
   UnlinkedCodeBlocks into CodeBlocks.
5. Compress the line and column number values in the ExpressionRangeInfo. In
   practice, we seldom have both large line and column numbers. Hence, we can
   encode both in an uint32_t most of the time. For the times when we encounter
   both large line and column numbers, we have a fallback to store the "fat"
   position info.
6. Emit an ExpressionRangeInfo for UnaryOp nodes to get more line and column
   number coverage.
7. Change the interpreter to use the new way of computing line and column.
8. Delete old line and column computation code that is now unused.

Misc details:
- the old lexer was tracking both a startOffset and charPosition where
  charPosition equals startOffset - SourceCode.startOffset. We now use
  startOffset exclusively throughout the system for consistency.
  All offset values (including lineStart) are relative to the start of the
  SourceProvider string. These values will only be converted to be relative
  to the SourceCode.startOffset at the very last minute i.e. when the divot
  is stored into the ExpressionRangeInfo.

  This change to use the same offset system everywhere reduces confusion
  from having to convert back and forth between the 2 systems. It also
  enables a lot of assertions to be used.

- Also fixed some bugs in the choice of divot positions to use. For example,
  both Eval and Function expressions previously used column numbers from
  the start of the expression but used the line number at the end of the
  expression. This is now fixed to use either the start or end positions
  as appropriate, but not a mix of line and columns from both.

- Why use ints instead of unsigneds for offsets and lineStarts inside the
  lexer and parser?
  Some tests (e.g. fast/js/call-base-resolution.html and
  fast/js/eval-cross-window.html) has shown that lineStart offsets can be
  prior to the SourceCode.startOffset. Keeping the lexer offsets as ints
  simplifies computations and makes it easier to maintain the assertions
  that (startOffset >= lineStartOffset).

  However, column and line numbers are always unsigned when we publish
  them to the ExpressionRangeInfo. The ints are only used inside the
  lexer and parser ... well, and bytecode generator.

- For all cases, lineStart is always captured where the divot is captured.
  However, some sputnik conformance tests have shown that we cannot honor
  line breaks for assignment statements like the following:

      eval("x\u000A*=\u000A-1;");

  In this case, the lineStart is expected to be captured at the start of
  the assignment expression instead of at the divot point in the middle.
  The assignment expression is the only special case for this.

This patch has been tested against the full layout tests both with release
and debug builds with no regression.

* API/JSContextRef.cpp:
(JSContextCreateBacktrace):
  - Updated to use the new StackFrame::computeLineAndColumn().
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
  - Added m_firstLineColumnOffset initialization.
  - Plumbed the firstLineColumnOffset into the SourceCode.
  - Initialized column for op_debug using the new way.
(JSC::CodeBlock::lineNumberForBytecodeOffset):
  - Changed to compute line number using the ExpressionRangeInfo.
(JSC::CodeBlock::columnNumberForBytecodeOffset): Added
  - Changed to compute column number using the ExpressionRangeInfo.
(JSC::CodeBlock::expressionRangeForBytecodeOffset):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::firstLineColumnOffset):
(JSC::GlobalCodeBlock::GlobalCodeBlock):
  - Plumbed firstLineColumnOffset through to the super class.
(JSC::ProgramCodeBlock::ProgramCodeBlock):
  - Plumbed firstLineColumnOffset through to the super class.
(JSC::EvalCodeBlock::EvalCodeBlock):
  - Plumbed firstLineColumnOffset through to the super class.
    But for EvalCodeBlocks, the firstLineColumnOffset is always 1
    because we're starting with a new source string with no start
    offset.
(JSC::FunctionCodeBlock::FunctionCodeBlock):
  - Plumbed firstLineColumnOffset through to the super class.

* bytecode/ExpressionRangeInfo.h:
  - Added modes for encoding line and column into a single 30-bit
    unsigned. The encoding is in 1 of 3 modes:
    1. FatLineMode: 22-bit line, 8-bit column
    2. FatColumnMode: 8-bit line, 22-bit column
    3. FatLineAndColumnMode: 32-bit line, 32-bit column
(JSC::ExpressionRangeInfo::encodeFatLineMode): Added.
  - Encodes line and column into the 30-bit position using FatLine mode.
(JSC::ExpressionRangeInfo::encodeFatColumnMode): Added.
  - Encodes line and column into the 30-bit position using FatColumn mode.
(JSC::ExpressionRangeInfo::decodeFatLineMode): Added.
  - Decodes the FatLine mode 30-bit position into line and column.
(JSC::ExpressionRangeInfo::decodeFatColumnMode): Added.
  - Decodes the FatColumn mode 30-bit position into line and column.

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
  - Plumbed startColumn through.
(JSC::UnlinkedFunctionExecutable::link):
  - Plumbed startColumn through.
(JSC::UnlinkedCodeBlock::lineNumberForBytecodeOffset):
  - Computes a line number using the new way.
(JSC::UnlinkedCodeBlock::expressionRangeForBytecodeOffset):
  - Added decoding of line and column.
  - Added handling of the case when we do not find a fitting expression
    range info for a specified bytecodeOffset. This only happens if the
    bytecodeOffset is below the first expression range info. In that
    case, we'll use the first expression range info entry.
(JSC::UnlinkedCodeBlock::addExpressionInfo):
  - Added encoding of line and column.

* bytecode/UnlinkedCodeBlock.h:
  - Added m_expressionInfoFatPositions in RareData.
(JSC::UnlinkedFunctionExecutable::functionStartColumn):
(JSC::UnlinkedCodeBlock::shrinkToFit):
  - Removed obsoleted m_lineInfo.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitCall): Plumbed line and lineStart through.
(JSC::BytecodeGenerator::emitCallEval): Plumbed line and lineStart through.
(JSC::BytecodeGenerator::emitCallVarargs): Plumbed line and lineStart through.
(JSC::BytecodeGenerator::emitConstruct): Plumbed line and lineStart through.
(JSC::BytecodeGenerator::emitDebugHook): Plumbed lineStart through.
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::emitNode):
(JSC::BytecodeGenerator::emitNodeInConditionContext):
  - Removed obsoleted m_lineInfo.
(JSC::BytecodeGenerator::emitExpressionInfo):
  - Plumbed line and lineStart through.
  - Compute the line and column to be added to the expression range info.
* bytecompiler/NodesCodegen.cpp:
(JSC::ThrowableExpressionData::emitThrowReferenceError):
(JSC::ResolveNode::emitBytecode):
(JSC::ArrayNode::toArgumentList):
(JSC::BracketAccessorNode::emitBytecode):
(JSC::DotAccessorNode::emitBytecode):
(JSC::NewExprNode::emitBytecode):
(JSC::EvalFunctionCallNode::emitBytecode):
(JSC::FunctionCallValueNode::emitBytecode):
(JSC::FunctionCallResolveNode::emitBytecode):
(JSC::FunctionCallBracketNode::emitBytecode):
(JSC::FunctionCallDotNode::emitBytecode):
(JSC::CallFunctionCallDotNode::emitBytecode):
(JSC::ApplyFunctionCallDotNode::emitBytecode):
(JSC::PostfixNode::emitResolve):
(JSC::PostfixNode::emitBracket):
(JSC::PostfixNode::emitDot):
(JSC::DeleteResolveNode::emitBytecode):
(JSC::DeleteBracketNode::emitBytecode):
(JSC::DeleteDotNode::emitBytecode):
(JSC::PrefixNode::emitResolve):
(JSC::PrefixNode::emitBracket):
(JSC::PrefixNode::emitDot):
  - Plumbed line and lineStart through the above as needed.

(JSC::UnaryOpNode::emitBytecode):
  - Added emission of an ExpressionRangeInfo for the UnaryOp node.

(JSC::BinaryOpNode::emitStrcat):
(JSC::ThrowableBinaryOpNode::emitBytecode):
(JSC::InstanceOfNode::emitBytecode):
(JSC::emitReadModifyAssignment):
(JSC::ReadModifyResolveNode::emitBytecode):
(JSC::AssignResolveNode::emitBytecode):
(JSC::AssignDotNode::emitBytecode):
(JSC::ReadModifyDotNode::emitBytecode):
(JSC::AssignBracketNode::emitBytecode):
(JSC::ReadModifyBracketNode::emitBytecode):
  - Plumbed line and lineStart through the above as needed.

(JSC::ConstStatementNode::emitBytecode):
(JSC::EmptyStatementNode::emitBytecode):
(JSC::DebuggerStatementNode::emitBytecode):
(JSC::ExprStatementNode::emitBytecode):
(JSC::VarStatementNode::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):
  - Plumbed line and lineStart through the above as needed.

* interpreter/Interpreter.cpp:
(JSC::appendSourceToError):
  - Added line and column arguments for expressionRangeForBytecodeOffset().
(JSC::StackFrame::computeLineAndColumn):
  - Replaces StackFrame::line() and StackFrame::column().
(JSC::StackFrame::expressionInfo):
  - Added line and column arguments.
(JSC::StackFrame::toString):
  - Changed to use the new StackFrame::computeLineAndColumn().
(JSC::Interpreter::getStackTrace):
  - Added the needed firstLineColumnOffset arg for the StackFrame.

* interpreter/Interpreter.h:
* parser/ASTBuilder.h:
(JSC::ASTBuilder::BinaryOpInfo::BinaryOpInfo):
(JSC::ASTBuilder::AssignmentInfo::AssignmentInfo):
(JSC::ASTBuilder::createResolve):
(JSC::ASTBuilder::createBracketAccess):
(JSC::ASTBuilder::createDotAccess):
(JSC::ASTBuilder::createRegExp):
(JSC::ASTBuilder::createNewExpr):
(JSC::ASTBuilder::createAssignResolve):
(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::createLabelStatement):
(JSC::ASTBuilder::createWithStatement):
(JSC::ASTBuilder::createThrowStatement):
(JSC::ASTBuilder::createDebugger):
(JSC::ASTBuilder::createConstStatement):
(JSC::ASTBuilder::appendBinaryExpressionInfo):
(JSC::ASTBuilder::appendUnaryToken):
(JSC::ASTBuilder::unaryTokenStackLastStart):
(JSC::ASTBuilder::unaryTokenStackLastLineStartPosition): Added.
(JSC::ASTBuilder::assignmentStackAppend):
(JSC::ASTBuilder::createAssignment):
(JSC::ASTBuilder::setExceptionLocation):
(JSC::ASTBuilder::makeDeleteNode):
(JSC::ASTBuilder::makeFunctionCallNode):
(JSC::ASTBuilder::makeBinaryNode):
(JSC::ASTBuilder::makeAssignNode):
(JSC::ASTBuilder::makePrefixNode):
(JSC::ASTBuilder::makePostfixNode):.
  - Plumbed line, lineStart, and startColumn through the above as needed.

* parser/Lexer.cpp:
(JSC::::currentSourcePtr):
(JSC::::setCode):
  - Added tracking for sourceoffset and lineStart.
(JSC::::internalShift):
(JSC::::parseIdentifier):
  - Added tracking for lineStart.
(JSC::::parseIdentifierSlowCase):
(JSC::::parseString):
  - Added tracking for lineStart.
(JSC::::parseStringSlowCase):
(JSC::::lex):
  - Added tracking for sourceoffset.
(JSC::::sourceCode):
* parser/Lexer.h:
(JSC::Lexer::currentOffset):
(JSC::Lexer::currentLineStartOffset):
(JSC::Lexer::setOffset):
  - Added tracking for lineStart.
(JSC::Lexer::offsetFromSourcePtr): Added. conversion function.
(JSC::Lexer::sourcePtrFromOffset): Added. conversion function.
(JSC::Lexer::setOffsetFromSourcePtr):
(JSC::::lexExpectIdentifier):
  - Added tracking for sourceoffset and lineStart.

* parser/NodeConstructors.h:
(JSC::Node::Node):
(JSC::ResolveNode::ResolveNode):
(JSC::EvalFunctionCallNode::EvalFunctionCallNode):
(JSC::FunctionCallValueNode::FunctionCallValueNode):
(JSC::FunctionCallResolveNode::FunctionCallResolveNode):
(JSC::FunctionCallBracketNode::FunctionCallBracketNode):
(JSC::FunctionCallDotNode::FunctionCallDotNode):
(JSC::CallFunctionCallDotNode::CallFunctionCallDotNode):
(JSC::ApplyFunctionCallDotNode::ApplyFunctionCallDotNode):
(JSC::PostfixNode::PostfixNode):
(JSC::DeleteResolveNode::DeleteResolveNode):
(JSC::DeleteBracketNode::DeleteBracketNode):
(JSC::DeleteDotNode::DeleteDotNode):
(JSC::PrefixNode::PrefixNode):
(JSC::ReadModifyResolveNode::ReadModifyResolveNode):
(JSC::ReadModifyBracketNode::ReadModifyBracketNode):
(JSC::AssignBracketNode::AssignBracketNode):
(JSC::AssignDotNode::AssignDotNode):
(JSC::ReadModifyDotNode::ReadModifyDotNode):
(JSC::AssignErrorNode::AssignErrorNode):
(JSC::WithNode::WithNode):
(JSC::ForInNode::ForInNode):
  - Plumbed line and lineStart through the above as needed.
* parser/Nodes.cpp:
(JSC::StatementNode::setLoc): Plumbed lineStart.
(JSC::ScopeNode::ScopeNode): Plumbed lineStart.
(JSC::ProgramNode::ProgramNode): Plumbed startColumn.
(JSC::ProgramNode::create): Plumbed startColumn.
(JSC::EvalNode::create):
(JSC::FunctionBodyNode::FunctionBodyNode): Plumbed startColumn.
(JSC::FunctionBodyNode::create): Plumbed startColumn.
* parser/Nodes.h:
(JSC::Node::startOffset):
(JSC::Node::lineStartOffset): Added.
(JSC::StatementNode::firstLine):
(JSC::StatementNode::lastLine):
(JSC::ThrowableExpressionData::ThrowableExpressionData):
(JSC::ThrowableExpressionData::setExceptionSourceCode):
(JSC::ThrowableExpressionData::divotStartOffset):
(JSC::ThrowableExpressionData::divotEndOffset):
(JSC::ThrowableExpressionData::divotLine):
(JSC::ThrowableExpressionData::divotLineStart):
(JSC::ThrowableSubExpressionData::ThrowableSubExpressionData):
(JSC::ThrowableSubExpressionData::setSubexpressionInfo):
(JSC::ThrowableSubExpressionData::subexpressionDivot):
(JSC::ThrowableSubExpressionData::subexpressionStartOffset):
(JSC::ThrowableSubExpressionData::subexpressionEndOffset):
(JSC::ThrowableSubExpressionData::subexpressionLine):
(JSC::ThrowableSubExpressionData::subexpressionLineStart):
(JSC::ThrowablePrefixedSubExpressionData::ThrowablePrefixedSubExpressionData):
(JSC::ThrowablePrefixedSubExpressionData::setSubexpressionInfo):
(JSC::ThrowablePrefixedSubExpressionData::subexpressionDivot):
(JSC::ThrowablePrefixedSubExpressionData::subexpressionStartOffset):
(JSC::ThrowablePrefixedSubExpressionData::subexpressionEndOffset):
(JSC::ThrowablePrefixedSubExpressionData::subexpressionLine):
(JSC::ThrowablePrefixedSubExpressionData::subexpressionLineStart):
(JSC::ScopeNode::startStartOffset):
(JSC::ScopeNode::startLineStartOffset):
(JSC::ProgramNode::startColumn):
(JSC::EvalNode::startColumn):
(JSC::FunctionBodyNode::startColumn):
  - Plumbed line and lineStart through the above as needed.
* parser/Parser.cpp:
(JSC::::Parser):
(JSC::::parseSourceElements):
(JSC::::parseVarDeclarationList):
(JSC::::parseConstDeclarationList):
(JSC::::parseForStatement):
(JSC::::parseBreakStatement):
(JSC::::parseContinueStatement):
(JSC::::parseReturnStatement):
(JSC::::parseThrowStatement):
(JSC::::parseWithStatement):
  - Plumbed line and lineStart through the above as needed.
(JSC::::parseFunctionBody):
  - Plumbed startColumn.
(JSC::::parseFunctionInfo):
(JSC::::parseFunctionDeclaration):
(JSC::LabelInfo::LabelInfo):
(JSC::::parseExpressionOrLabelStatement):
(JSC::::parseAssignmentExpression):
(JSC::::parseBinaryExpression):
(JSC::::parseProperty):
(JSC::::parseObjectLiteral):
(JSC::::parsePrimaryExpression):
(JSC::::parseMemberExpression):
(JSC::::parseUnaryExpression):
  - Plumbed line, lineStart, startColumn through the above as needed.
* parser/Parser.h:
(JSC::Parser::next):
(JSC::Parser::nextExpectIdentifier):
(JSC::Parser::tokenStart):
(JSC::Parser::tokenColumn):
(JSC::Parser::tokenEnd):
(JSC::Parser::tokenLineStart):
(JSC::Parser::lastTokenLine):
(JSC::Parser::lastTokenLineStart):
(JSC::::parse):
* parser/ParserTokens.h:
(JSC::JSTokenLocation::JSTokenLocation):
  - Plumbed lineStart.
(JSC::JSTokenLocation::lineStartPosition):
(JSC::JSTokenLocation::startPosition):
(JSC::JSTokenLocation::endPosition):
* parser/SourceCode.h:
(JSC::SourceCode::SourceCode):
(JSC::SourceCode::startColumn):
(JSC::makeSource):
(JSC::SourceCode::subExpression):
* parser/SourceProvider.cpp: delete old code.
* parser/SourceProvider.h: delete old code.
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::closeBraceToken):
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
  - Plumbed lineStart.
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::makeFunctionCallNode):
(JSC::SyntaxChecker::makeAssignNode):
(JSC::SyntaxChecker::makePrefixNode):
(JSC::SyntaxChecker::makePostfixNode):
(JSC::SyntaxChecker::makeDeleteNode):
(JSC::SyntaxChecker::createResolve):
(JSC::SyntaxChecker::createBracketAccess):
(JSC::SyntaxChecker::createDotAccess):
(JSC::SyntaxChecker::createRegExp):
(JSC::SyntaxChecker::createNewExpr):
(JSC::SyntaxChecker::createAssignResolve):
(JSC::SyntaxChecker::createFunctionExpr):
(JSC::SyntaxChecker::createFunctionBody):
(JSC::SyntaxChecker::createFuncDeclStatement):
(JSC::SyntaxChecker::createForInLoop):
(JSC::SyntaxChecker::createReturnStatement):
(JSC::SyntaxChecker::createBreakStatement):
(JSC::SyntaxChecker::createContinueStatement):
(JSC::SyntaxChecker::createWithStatement):
(JSC::SyntaxChecker::createLabelStatement):
(JSC::SyntaxChecker::createThrowStatement):
(JSC::SyntaxChecker::createGetterOrSetterProperty):
(JSC::SyntaxChecker::appendBinaryExpressionInfo):
(JSC::SyntaxChecker::operatorStackPop):
  - Made SyntaxChecker prototype changes to match ASTBuilder due to new
    args added for plumbing line, lineStart, and startColumn.
* runtime/CodeCache.cpp:
(JSC::CodeCache::generateBytecode):
(JSC::CodeCache::getCodeBlock):
  - Plumbed startColumn.
* runtime/Executable.cpp:
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::produceCodeBlockFor):
(JSC::FunctionExecutable::fromGlobalCode):
  - Plumbed startColumn.
* runtime/Executable.h:
(JSC::ScriptExecutable::startColumn):
(JSC::ScriptExecutable::recordParse):
(JSC::FunctionExecutable::create):
  - Plumbed startColumn.

Source/WebCore: 

Test: fast/js/line-column-numbers.html

Updated the bindings to use StackFrame::computeLineAndColumn(). The old
StackFrame::line() and StackFrame::column() has been removed. The new
algorithm always computes the 2 values together anyway. Hence it is more
efficient to return them as a pair instead of doing the same computation
twice for each half of the result.

* bindings/js/ScriptCallStackFactory.cpp:
(WebCore::createScriptCallStack):
(WebCore::createScriptCallStackFromException):
* bindings/js/ScriptSourceCode.h:
(WebCore::ScriptSourceCode::ScriptSourceCode):

LayoutTests: 

The fix now computes line and column numbers more accurately. As a result,
some of the test results need to be re-baselined. Among other fixes, one
major source of difference is that the old code was incorrectly computing
0-based column numbers. This has now been fixed to be 1-based.
Note: line numbers were always 1-based.

Also added a new test: fast/js/line-column-numbers.html, which tests line
and column numbers for source code in various configurations.

* editing/execCommand/outdent-blockquote-test1-expected.txt:
* editing/execCommand/outdent-blockquote-test2-expected.txt:
* editing/execCommand/outdent-blockquote-test3-expected.txt:
* editing/execCommand/outdent-blockquote-test4-expected.txt:
* editing/pasteboard/copy-paste-float-expected.txt:
* editing/pasteboard/paste-blockquote-before-blockquote-expected.txt:
* editing/pasteboard/paste-double-nested-blockquote-before-blockquote-expected.txt:
* fast/dom/Window/window-resize-contents-expected.txt:
* fast/events/remove-target-with-shadow-in-drag-expected.txt:
* fast/js/line-column-numbers-expected.txt: Added.
* fast/js/line-column-numbers.html: Added.
* fast/js/script-tests/line-column-numbers.js: Added.
(try.doThrow4b):
(doThrow5b.try.innerFunc):
(doThrow5b):
(doThrow6b.try.innerFunc):
(doThrow6b):
(catch):
(try.doThrow11b):
(try.doThrow14b):
* fast/js/stack-trace-expected.txt:
* inspector/console/console-url-line-column-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@152494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2d2050fd
2013-07-09 Mark Lam <mark.lam@apple.com>
Fix 30% JSBench regression (caused by adding column numbers to stack traces).
https://bugs.webkit.org/show_bug.cgi?id=118481.
Reviewed by Mark Hahnenberg and Geoffrey Garen.
The fix now computes line and column numbers more accurately. As a result,
some of the test results need to be re-baselined. Among other fixes, one
major source of difference is that the old code was incorrectly computing
0-based column numbers. This has now been fixed to be 1-based.
Note: line numbers were always 1-based.
Also added a new test: fast/js/line-column-numbers.html, which tests line
and column numbers for source code in various configurations.
* editing/execCommand/outdent-blockquote-test1-expected.txt:
* editing/execCommand/outdent-blockquote-test2-expected.txt:
* editing/execCommand/outdent-blockquote-test3-expected.txt:
* editing/execCommand/outdent-blockquote-test4-expected.txt:
* editing/pasteboard/copy-paste-float-expected.txt:
* editing/pasteboard/paste-blockquote-before-blockquote-expected.txt:
* editing/pasteboard/paste-double-nested-blockquote-before-blockquote-expected.txt:
* fast/dom/Window/window-resize-contents-expected.txt:
* fast/events/remove-target-with-shadow-in-drag-expected.txt:
* fast/js/line-column-numbers-expected.txt: Added.
* fast/js/line-column-numbers.html: Added.
* fast/js/script-tests/line-column-numbers.js: Added.
(try.doThrow4b):
(doThrow5b.try.innerFunc):
(doThrow5b):
(doThrow6b.try.innerFunc):
(doThrow6b):
(catch):
(try.doThrow11b):
(try.doThrow14b):
* fast/js/stack-trace-expected.txt:
* inspector/console/console-url-line-column-expected.txt:
2013-07-09 Zoltan Arvai <zarvai@inf.u-szeged.hu>
[Qt] Unreviewed gardening.
CONSOLE MESSAGE: line 14: SUCCESS: Nodes stayed in order after outdent.
CONSOLE MESSAGE: line 12: SUCCESS: Nodes stayed in order after outdent.
This test uses the execCommand to Outdent the text below. This test that nodes, with different relationships with blockquotes, stay in the correct order after an outdent.
A
......
CONSOLE MESSAGE: line 14: SUCCESS: Nodes stayed in order after outdent.
CONSOLE MESSAGE: line 12: SUCCESS: Nodes stayed in order after outdent.
This test uses the execCommand to Outdent the text below. This test that nodes, with different relationships with blockquotes, stay in the correct order after an outdent.
A
......
CONSOLE MESSAGE: line 14: SUCCESS: Nodes stayed in order after outdent.
CONSOLE MESSAGE: line 12: SUCCESS: Nodes stayed in order after outdent.
This test uses the execCommand to Outdent the text below. This test that nodes, with different relationships with blockquotes, stay in the correct order after an outdent.
A
......
CONSOLE MESSAGE: line 14: SUCCESS: Nodes stayed in order after outdent.
CONSOLE MESSAGE: line 12: SUCCESS: Nodes stayed in order after outdent.
This test uses the execCommand to Outdent the text below. This test that nodes, with different relationships with blockquotes, stay in the correct order after an outdent.
......
CONSOLE MESSAGE: line 20: SUCCESS: paste DID NOT keep float:left style.
CONSOLE MESSAGE: line 18: SUCCESS: paste DID NOT keep float:left style.
This test is to see if text within a floating block is put onto the paste board wihtout the float style.
First LI
......
CONSOLE MESSAGE: line 20: SUCCESS: pasting singleNestedNodeToCopy DID NOT keep the newline within the blockquote.
CONSOLE MESSAGE: line 18: SUCCESS: pasting singleNestedNodeToCopy DID NOT keep the newline within the blockquote.
This tests pasting a singly nested blockquote before, and outside of, another blockquote. This test does not work outside of DRT.
line 2
......
CONSOLE MESSAGE: line 20: SUCCESS: pasting doubleNestedNodeToCopy DID NOT keep the newline within the blockquote.
CONSOLE MESSAGE: line 18: SUCCESS: pasting doubleNestedNodeToCopy DID NOT keep the newline within the blockquote.
This tests pasting a doubly nested blockquote before, and outside of, another blockquote. This test does not work outside of DRT.
line 4
......
CONSOLE MESSAGE: line 19: Initial reference node dimensions 800 x 600
CONSOLE MESSAGE: line 18: Initial reference node dimensions 800 x 600
CONSOLE MESSAGE: line 20: Increasing window size by 10 x 10
CONSOLE MESSAGE: line 23: Post-resize reference node dimensions 800 x 600
CONSOLE MESSAGE: line 22: Post-resize reference node dimensions 800 x 600
This test checks that the yellow reference DOM node (which should be as big as the window) gets resized when the window is resized.
To avoid relayouts and repaints caused by DOM-based logging, it doesn't output anything. Please check the console for confirmation that the node dimensions increase by 10x10.
CONSOLE MESSAGE: line 35: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.
CONSOLE MESSAGE: line 35: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.
CONSOLE MESSAGE: line 34: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.
CONSOLE MESSAGE: line 34: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.
PASS. DRT didn't crash.
This test checks line and column numbers in stack traces for correctness.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
--> Case 1 Stack Trace:
0 global code at line-column-numbers.html:40:36
--> Case 2 Stack Trace:
0 global code at line-column-numbers.html:44:40
--> Case 3 Stack Trace:
0 global code at line-column-numbers.html:48:32
--> Case 3 Stack Trace:
0 global code at line-column-numbers.html:48:113
--> Case 4 Stack Trace:
0 doThrow4 at line-column-numbers.html:54:44
1 global code at line-column-numbers.html:55:13
--> Case 5 Stack Trace:
0 innerFunc at line-column-numbers.html:64:69
1 doThrow5 at line-column-numbers.html:64:82
2 global code at line-column-numbers.html:64:133
--> Case 6 Stack Trace:
0 innerFunc at line-column-numbers.html:70:69
1 doThrow6 at line-column-numbers.html:70:82
2 global code at line-column-numbers.html:70:133
--> Case 7 Stack Trace:
0 at line-column-numbers.html:75:51
1 global code at line-column-numbers.html:75:55
--> Case 8 Stack Trace:
0 at line-column-numbers.html:78:59
1 global code at line-column-numbers.html:78:63
--> Case 9 Stack Trace:
0 at line-column-numbers.html:82:55
1 global code at line-column-numbers.html:82:59
--> Case 9 Stack Trace:
0 at line-column-numbers.html:82:157
1 global code at line-column-numbers.html:82:161
--> Case 10 Stack Trace:
0 at line-column-numbers.html:89:26
1 global code at line-column-numbers.html:90:8
--> Case 11 Stack Trace:
0 at line-column-numbers.html:101:41
1 doThrow11 at line-column-numbers.html:101:45
2 global code at line-column-numbers.html:103:14
--> Case 12 Stack Trace:
0 at line-column-numbers.html:112:53
1 at line-column-numbers.html:112:57
2 global code at line-column-numbers.html:112:62
--> Case 13 Stack Trace:
0 at line-column-numbers.html:118:53
1 at line-column-numbers.html:118:57
2 global code at line-column-numbers.html:118:62
--> Case 14 Stack Trace:
0 at line-column-numbers.html:124:76
1 at line-column-numbers.html:124:80
2 doThrow14 at line-column-numbers.html:124:85
3 global code at line-column-numbers.html:124:99
--> Case 15 Stack Trace:
0 at eval code
1 eval at [native code]
2 global code at line-column-numbers.html:130:5
--> Case 16 Stack Trace:
0 at doThrow16
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.html:136:5
--> Case 17 Stack Trace:
0 at
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.html:149:5
--> Case 18 Stack Trace:
0 at
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.html:155:5
--> Case 1 Stack Trace:
0 global code at line-column-numbers.js:3:28
--> Case 2 Stack Trace:
0 global code at line-column-numbers.js:7:32
--> Case 3 Stack Trace:
0 global code at line-column-numbers.js:11:24
--> Case 3 Stack Trace:
0 global code at line-column-numbers.js:11:88
--> Case 4 Stack Trace:
0 doThrow4b at line-column-numbers.js:16:45
1 global code at line-column-numbers.js:17:14
--> Case 5 Stack Trace:
0 innerFunc at line-column-numbers.js:24:70
1 doThrow5b at line-column-numbers.js:24:83
2 global code at line-column-numbers.js:24:135
--> Case 6 Stack Trace:
0 innerFunc at line-column-numbers.js:28:70
1 doThrow6b at line-column-numbers.js:28:83
2 global code at line-column-numbers.js:28:135
--> Case 7 Stack Trace:
0 at line-column-numbers.js:32:43
1 global code at line-column-numbers.js:32:47
--> Case 8 Stack Trace:
0 at line-column-numbers.js:36:47
1 global code at line-column-numbers.js:36:51
--> Case 9 Stack Trace:
0 at line-column-numbers.js:40:39
1 global code at line-column-numbers.js:40:43
--> Case 9 Stack Trace:
0 at line-column-numbers.js:40:124
1 global code at line-column-numbers.js:40:128
--> Case 10 Stack Trace:
0 at line-column-numbers.js:46:26
1 global code at line-column-numbers.js:47:8
--> Case 11 Stack Trace:
0 at line-column-numbers.js:56:41
1 doThrow11b at line-column-numbers.js:56:45
2 global code at line-column-numbers.js:58:15
--> Case 12 Stack Trace:
0 at line-column-numbers.js:65:53
1 at line-column-numbers.js:65:57
2 global code at line-column-numbers.js:65:62
--> Case 13 Stack Trace:
0 at line-column-numbers.js:69:53
1 at line-column-numbers.js:69:57
2 global code at line-column-numbers.js:69:62
--> Case 14 Stack Trace:
0 at line-column-numbers.js:73:77
1 at line-column-numbers.js:73:81
2 doThrow14b at line-column-numbers.js:73:86
3 global code at line-column-numbers.js:73:101
--> Case 15 Stack Trace:
0 at eval code
1 eval at [native code]
2 global code at line-column-numbers.js:77:5
--> Case 16 Stack Trace:
0 at doThrow15b
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.js:81:5
--> Case 17 Stack Trace:
0 at
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.js:92:5
--> Case 18 Stack Trace:
0 at
1 at eval code
2 eval at [native code]
3 global code at line-column-numbers.js:96:5
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="resources/js-test-style.css">
<script src="resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<p id="console"></p>
<script>
if (!this.alert) {
debug = print;
description = print;
}
description(
'This test checks line and column numbers in stack traces for correctness.'
);
testId = 0;
function printStack(stackTrace) {
debug("--> Case " + testId + " Stack Trace:")
stackTrace = stackTrace.split("\n");
var length = Math.min(stackTrace.length, 100);
for (var i = 0; i < length; i++) {
var indexOfAt = stackTrace[i].indexOf('@')
var indexOfLastSlash = stackTrace[i].lastIndexOf('/');
if (indexOfLastSlash == -1)
indexOfLastSlash = indexOfAt
var functionName = stackTrace[i].substring(0, indexOfAt);
var fileName = stackTrace[i].substring(indexOfLastSlash + 1);
debug(" " + i + " " + functionName + " at " + fileName);
}
debug('');
}
</script>
<!-- Case 1: Throw and print stack: -->
<script>testId++;</script>
<script>try { throw new Error(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 2: Same program as Case 1 but indented. -->
<script>testId++;</script>
<script>try { throw new Error(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 3: Same program indented on the same line. -->
<script>testId++;</script>
<script>try { throw new Error(); } catch (e) { printStack(e.stack); }</script> <script>try { throw new Error(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 4: Throw inside a Function. -->
<script>testId++;</script>
<script>
try {
function doThrow4() { throw new Error(); }
doThrow4();
} catch(e) {
printStack(e.stack);
}
</script>
<!-- Case 5: Function wrapping a Function. -->
<script>testId++;</script>
<script>
function doThrow5() { try { function innerFunc() { throw new Error(); } innerFunc(); } catch (e) { printStack(e.stack); }}; doThrow5();
</script>
<!-- Case 6: Same inner function body as Case 5. -->
<script>testId++;</script>
<script>
function doThrow6() { try { function innerFunc() { throw new Error(); } innerFunc(); } catch (e) { printStack(e.stack); }}; doThrow6();
</script>
<!-- Case 7: Case 1 redone with a Function Expression. -->
<script>testId++;</script>
<script>try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 8: Case 2 redone with a Function Expression. -->
<script>testId++;</script>
<script>try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 9: Case 3 redone with a Function Expression. -->
<script>testId++;</script>
<script>try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }</script> <script>try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }</script>
<!-- Case 10: Function Expression as multiple lines. -->
<script>testId++;</script>
<script>
try {
(function () {
throw new Error();
})();
} catch(e) {
printStack(e.stack);
}
</script>
<!-- Case 11: Case 4 redone with a Function wrapping Function Expression. -->
<script>testId++;</script>
<script>
try {
function doThrow11() {
(function () { throw new Error(); })();
}
doThrow11();
} catch(e) {
printStack(e.stack);
}
</script>
<!-- Case 12: A Function Expression wrapping a Function Expression. -->
<script>testId++;</script>
<script>
try { (function () {(function () { throw new Error(); })();})(); } catch (e) { printStack(e.stack); }
</script>
<!-- Case 13: Same function body as Case 12. -->
<script>testId++;</script>
<script>
try { (function () {(function () { throw new Error(); })();})(); } catch (e) { printStack(e.stack); }
</script>
<!-- Case 14: Function Expression in a Function Expression in a Function. -->
<script>testId++;</script>
<script>
try { function doThrow14() {(function () { (function () { throw new Error(); })();})();} doThrow14(); } catch (e) { printStack(e.stack); }
</script>
<!-- Case 15: Throw in an Eval. -->
<script>testId++;</script>
<script>
eval("try { throw new Error(); } catch(e) { printStack(e.stack); }");
</script>
<!-- Case 16: Multiple lines in an Eval. -->
<script>testId++;</script>
<script>
eval("\n" +
"try {\n" +
" function doThrow16() {throw new Error();}\n" +
" doThrow16();\n" +
"} catch(e) {\n" +
" printStack(e.stack);\n" +
"}\n" +
"");
</script>
<!-- Case 17: Function Expression in an Eval. -->
<script>testId++;</script>
<script>
eval("try { (function () { throw new Error();})(); } catch(e) { printStack(e.stack); }");
</script>
<!-- Case 18: Multiple lines with a Function Expression in an Eval. -->
<script>testId++;</script>
<script>
eval("\n" +
"try {\n" +
" (function () { throw new Error();})();\n" +
"} catch(e) {\n" +
" printStack(e.stack);\n" +
"}\n" +
"");
</script>
<!-- Now do it all over with a loaded script file. -->
<script>testId = 0;</script>
<script src="script-tests/line-column-numbers.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
// Case 1: Throw and print stack:
testId++;
try { throw new Error(); } catch (e) { printStack(e.stack); }
// Case 2: Same program as Case 1 but indented.
testId++;
try { throw new Error(); } catch (e) { printStack(e.stack); }
// Case 3: Same program indented on the same line.
testId++;
try { throw new Error(); } catch (e) { printStack(e.stack); } try { throw new Error(); } catch (e) { printStack(e.stack); }
// Case 4: Stack with 2 function frames.
testId++;
try {
function doThrow4b() { throw new Error(); }
doThrow4b();
} catch(e) {
printStack(e.stack);
}
// Case 5: Function wrapping a Function.
testId++;
function doThrow5b() { try { function innerFunc() { throw new Error(); } innerFunc(); } catch (e) { printStack(e.stack); }}; doThrow5b();
// Case 6: Same inner function body as Case 5.
testId++;
function doThrow6b() { try { function innerFunc() { throw new Error(); } innerFunc(); } catch (e) { printStack(e.stack); }}; doThrow6b();
// Case 7: Case 1 redone with a Function Expression.
testId++;
try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }
// Case 8: Case 2 redone with a Function Expression.
testId++;
try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }
// Case 9: Case 3 redone with a Function Expression.
testId++;
try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); } try { (function () { throw new Error(); })(); } catch (e) { printStack(e.stack); }
// Case 10: Function Expression as multiple lines.
testId++;
try {
(function () {
throw new Error();
})();
} catch(e) {
printStack(e.stack);
}
// Case 11: Case 4 redone with a Function wrapping Function Expression.
testId++;
try {
function doThrow11b() {
(function () { throw new Error(); })();
}
doThrow11b();
} catch(e) {
printStack(e.stack);
}
// Case 12: A Function Expression wrapping a Function Expression.
testId++;
try { (function () {(function () { throw new Error(); })();})(); } catch (e) { printStack(e.stack); }
// Case 13: Same function body as Case 12.
testId++;
try { (function () {(function () { throw new Error(); })();})(); } catch (e) { printStack(e.stack); }
// Case 14: Function Expression in a Function Expression in a Function.
testId++;
try { function doThrow14b() {(function () { (function () { throw new Error(); })();})();} doThrow14b(); } catch (e) { printStack(e.stack); }
// Case 15: Throw in an Eval.
testId++;
eval("try { throw new Error(); } catch(e) { printStack(e.stack); }");
// Case 16: Multiple lines in an Eval.
testId++;
eval("\n" +
"try {\n" +
" function doThrow15b() { throw new Error(); }\n" +
" doThrow15b();\n" +
"} catch(e) {\n" +
" printStack(e.stack);\n" +
"}\n" +
"");
// Case 17: Function Expression in an Eval.
testId++;
eval("try { (function () { throw new Error(); })(); } catch(e) { printStack(e.stack); }");
// Case 18: Multiple lines with a Function Expression in an Eval.
testId++;
eval("\n" +
"try {\n" +
" (function () { throw new Error(); })();\n" +
"} catch(e) {\n" +
" printStack(e.stack);\n" +
"}\n" +
"");
successfullyParsed = true;
......@@ -8,12 +8,12 @@ CONSOLE MESSAGE: line 15: warn
CONSOLE MESSAGE: line 16: assert
Tests that url, line, and column properties are defined for console functions.
Message at location: console-url-line-column.html:9:15
Message at location: console-url-line-column.html:10:15
Message at location: console-url-line-column.html:11:15
Message at location: console-url-line-column.html:14:17
Message at location: console-url-line-column.html:14:39
Message at location: console-url-line-column.html:15:16
Message at location: console-url-line-column.html:15:38
Message at location: console-url-line-column.html:16:18
Message at location: console-url-line-column.html:9:16
Message at location: console-url-line-column.html:10:16
Message at location: console-url-line-column.html:11:16
Message at location: console-url-line-column.html:14:18
Message at location: console-url-line-column.html:14:40
Message at location: console-url-line-column.html:15:17
Message at location: console-url-line-column.html:15:39
Message at location: console-url-line-column.html:16:19
......@@ -237,7 +237,9 @@ JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize)
if (i)
break;