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

Add tracking of endColumn for Executables.

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

1. Fixed computation of columns to take into account the startColumn from
   <script> tags. Previously, we were only computing the column relative
   to the char after the <script> tag. Now, the column number that JSC
   computes is always the column number you'll see when viewing the source
   in a text editor (assuming the first column position is 1, not 0).

2. Previously, unlinkedExecutables kept the a base-1 startColumn for
   ProgramExecutables and EvalExecutables, but uses base-0 columns for
   FunctionExecutables. This has been fixed so that they all use base-0
   columns. When the executable gets linked, the column is adjusted into
   a base-1 value.

3. In the UnlinkedFunctionExecutable, renamed m_functionStartOffset to
   m_unlinkedFunctionNameStart because it actually points to the start
   column in the name part of the function declaration.

   Similarly, renamed m_functionStartColumn to m_unlinkedBodyStartColumn
   because it points to the first character in the function body. This is
   usually '{' except for functions created from "global code" which
   excludes its braces. See FunctionExecutable::fromGlobalCode().

       The exclusion of braces for the global code case is needed so that
   computed start and end columns will more readily map to what a JS
   developer would expect them to be. Otherwise, the first column of the
   function source will not be 1 (includes prepended characters added in
   constructFunctionSkippingEvalEnabledCheck()).

   Also, similarly, a m_unlinkedBodyEndColumn has been added to track the
   end column of the UnlinkedFunctionExecutable.

4. For unlinked executables, end column values are either:
   a. Relative to the start of the last line if (last line != first line).
   b. Relative to the start column position if (last line == first line).

   The second case is needed so that we can add an appropriate adjustment
   to the end column value (just like we do for the start column) when we
   link the executable.

5. This is not new to this patch, but it worth noting that the lineCount
   values used through this patch has the following meaning:
   - a lineCount of 0 means the source for this code block is on 1 line.
   - a lineCount of N means there are N + l lines of source.

   This interpretation is janky, but was present before this patch. We can
   clean that up later in another patch.


* JavaScriptCore.xcodeproj/project.pbxproj:
- In order to implement WebCore::Internals::parserMetaData(), we need to
  move some seemingly unrelated header files from the Project section to
  the Private section so that they can be #include'd by the forwarding
  CodeBlock.h from WebCore.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::sourceCodeForTools):
(JSC::CodeBlock::CodeBlock):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
- m_isFromGlobalCode is needed to support the exclusion of the open brace /
  prepended code for functions created from "global code".
(JSC::UnlinkedFunctionExecutable::link):
(JSC::UnlinkedFunctionExecutable::fromGlobalCode):
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::create):
(JSC::UnlinkedFunctionExecutable::unlinkedFunctionNameStart):
(JSC::UnlinkedFunctionExecutable::unlinkedBodyStartColumn):
(JSC::UnlinkedFunctionExecutable::unlinkedBodyEndColumn):
(JSC::UnlinkedFunctionExecutable::recordParse):
(JSC::UnlinkedCodeBlock::recordParse):
(JSC::UnlinkedCodeBlock::endColumn):
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionBodyNode::emitBytecode):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionBody):
(JSC::ASTBuilder::setFunctionNameStart):
* parser/Lexer.cpp:
(JSC::::shiftLineTerminator):
- Removed an unused SourceCode Lexer<T>::sourceCode() function.
* parser/Lexer.h:
(JSC::Lexer::positionBeforeLastNewline):
(JSC::Lexer::prevTerminator):
- Added tracking of m_positionBeforeLastNewline in the Lexer to enable us
  to exclude the close brace / appended code for functions created from "global
  code".
* parser/Nodes.cpp:
(JSC::ProgramNode::ProgramNode):
(JSC::ProgramNode::create):
(JSC::EvalNode::EvalNode):
(JSC::EvalNode::create):
(JSC::FunctionBodyNode::FunctionBodyNode):
(JSC::FunctionBodyNode::create):
(JSC::FunctionBodyNode::setEndPosition):
- setEndPosition() is needed to fixed up the end position so that we can
  exclude the close brace / appended code for functions created from "global
  code".
* parser/Nodes.h:
(JSC::ProgramNode::startColumn):
(JSC::ProgramNode::endColumn):
(JSC::EvalNode::startColumn):
(JSC::EvalNode::endColumn):
(JSC::FunctionBodyNode::setFunctionNameStart):
(JSC::FunctionBodyNode::functionNameStart):
(JSC::FunctionBodyNode::endColumn):
* parser/Parser.cpp:
(JSC::::parseFunctionBody):
(JSC::::parseFunctionInfo):
* parser/Parser.h:
(JSC::Parser::positionBeforeLastNewline):
(JSC::::parse):
- Subtracted 1 from startColumn here to keep the node column values consistently
  base-0. See note 2 above.
(JSC::parse):
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createFunctionBody):
(JSC::SyntaxChecker::setFunctionNameStart):
* runtime/CodeCache.cpp:
(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getProgramCodeBlock):
(JSC::CodeCache::getEvalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
* runtime/CodeCache.h:
* runtime/Executable.cpp:
(JSC::ScriptExecutable::newCodeBlockFor):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::ProgramExecutable::initializeGlobalProperties):
(JSC::FunctionExecutable::fromGlobalCode):
* runtime/Executable.h:
(JSC::ExecutableBase::isEvalExecutable):
(JSC::ExecutableBase::isProgramExecutable):
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::ScriptExecutable::endColumn):
(JSC::ScriptExecutable::recordParse):
(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::bodyIncludesBraces):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/FunctionPrototype.cpp:
(JSC::insertSemicolonIfNeeded):
(JSC::functionProtoFuncToString):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::createProgramCodeBlock):
(JSC::JSGlobalObject::createEvalCodeBlock):

Source/WebCore: 

Test: js/dom/script-start-end-locations.html

* ForwardingHeaders/bytecode: Added.
* ForwardingHeaders/bytecode/CodeBlock.h: Added.
* WebCore.exp.in:
* testing/Internals.cpp:
(WebCore::GetCallerCodeBlockFunctor::GetCallerCodeBlockFunctor):
(WebCore::GetCallerCodeBlockFunctor::operator()):
(WebCore::GetCallerCodeBlockFunctor::codeBlock):
(WebCore::Internals::parserMetaData):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit: 

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
- Added an exported symbol to make the Win32 build happy. The Win64 symbol
  is currently a copy of the Win32 one. It'll need to be updated if the
  mangled symbol is different for Win64.

LayoutTests: 

* fast/events/window-onerror2-expected.txt:
* inspector-protocol/debugger/setBreakpoint-actions-expected.txt:
* js/dom/script-start-end-locations-expected.txt: Added.
* js/dom/script-start-end-locations.html: Added.
* js/dom/script-tests/script-start-end-locations.js: Added.
* js/dom/stack-trace-expected.txt:
* js/dom/stack-trace.html:
- Changed tabs to spaces. The tabs were making it hard to visually confirm
  the exected column values for 2 functions.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6d6b4408
2013-11-19 Mark Lam <mark.lam@apple.com>
Add tracking of endColumn for Executables.
https://bugs.webkit.org/show_bug.cgi?id=124245.
Reviewed by Geoffrey Garen.
* fast/events/window-onerror2-expected.txt:
* inspector-protocol/debugger/setBreakpoint-actions-expected.txt:
* js/dom/script-start-end-locations-expected.txt: Added.
* js/dom/script-start-end-locations.html: Added.
* js/dom/script-tests/script-start-end-locations.js: Added.
* js/dom/stack-trace-expected.txt:
* js/dom/stack-trace.html:
- Changed tabs to spaces. The tabs were making it hard to visually confirm
the exected column values for 2 functions.
2013-11-15 Jer Noble <jer.noble@apple.com>
[MSE] Support fastSeek() in MediaSource.
......
Test that uncaught exceptions will be reported to the window.onerror handler. Bug 8519.
Main frame window.onerror: Error: Inline script exception at window-onerror2.html, line: 34, column: 47
Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 150
Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 66
Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html, line: 29, column: 47
......@@ -14,11 +14,11 @@ inside breakpointActions a:(2) b:(12)
inside breakpointActions a:(2) b:([object Object])
Running breakpointActions to triggering the breakpoint actions
inside breakpointActions a:(12) b:([object Object])
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:1"}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:2"}
PASS: Console Message: {"source":"console-api","level":"log","text":"eval-action","location":"???:1:26","parameters":[{"type":"string"},{"type":"number"},{"type":"object"}]}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:1"}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:2"}
inside breakpointActions a:(100) b:([object HTMLBodyElement])
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:1"}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:2"}
PASS: Console Message: {"source":"console-api","level":"log","text":"eval-action","location":"???:1:26","parameters":[{"type":"string"},{"type":"number"},{"type":"object","subtype":"node"}]}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:1"}
PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:2"}
program { 7:9 - 19:1 }
program { 21:9 - 21:50 }
program { 21:68 - 21:109 }
program { 23:9 - 23:50 }
program { 23:68 - 23:109 }
program { 25:9 - 26:1 }
program { 27:13 - 28:1 }
function "hf1" { 30:24 - 30:38 }
function "hf2" { 31:28 - 31:42 }
function "hf3" { 32:32 - 32:46 }
function "hf4" { 34:24 - 36:9 }
function "hf5" { 37:28 - 39:9 }
function "hf6" { 40:32 - 42:9 }
function "hf7" { 45:16 - 47:5 }
function "hf8" { 49:35 - 49:45 }
function "hf9" { 49:97 - 49:107 }
program { 1:1 - 474:1 }
On first line:
function "f0" { 1:115 - 1:266 }
function "f0a" { 1:142 - 1:257 }
function "f0b" { 1:170 - 1:248 }
eval { 1:1 - 1:56 }
function "x0" { 1:298 - 1:476 }
function "x0a" { 1:330 - 1:466 }
function "x0b" { 1:364 - 1:456 }
eval { 1:1 - 1:56 }
Functions Declarations in a function:
function "f1" { 9:22 - 9:113 }
eval { 1:1 - 1:56 }
function "f2" { 12:22 - 16:5 }
function "f2a" { 14:24 - 14:116 }
eval { 1:1 - 1:56 }
function "f3" { 19:22 - 31:5 }
function "f3a" { 21:24 - 29:9 }
function "f3b" { 23:28 - 27:13 }
eval { 1:1 - 1:56 }
function "f4" { 34:22 - 34:71 }
function "f4a" { 34:49 - 34:50 }
function "f5" { 36:22 - 36:151 }
function "f5a" { 36:49 - 36:141 }
eval { 1:1 - 1:56 }
function "f6" { 38:22 - 38:189 }
function "f6a" { 38:49 - 38:179 }
function "f6b" { 38:77 - 38:169 }
eval { 1:1 - 1:56 }
Indented Functions Declarations in a function:
function "fi1" { 43:27 - 43:119 }
eval { 1:1 - 1:56 }
function "fi2" { 46:27 - 50:9 }
function "fi2a" { 48:29 - 48:122 }
eval { 1:1 - 1:56 }
function "fi3" { 53:27 - 65:9 }
function "fi3a" { 55:29 - 63:13 }
function "fi3b" { 57:33 - 61:17 }
eval { 1:1 - 1:56 }
function "fi4" { 68:27 - 68:80 }
function "fi4a" { 68:56 - 68:57 }
function "fi5" { 70:27 - 70:160 }
function "fi5a" { 70:56 - 70:149 }
eval { 1:1 - 1:56 }
function "fi6" { 72:27 - 72:201 }
function "fi6a" { 72:56 - 72:190 }
function "fi6b" { 72:86 - 72:179 }
eval { 1:1 - 1:56 }
Functions Expressions in a function:
function "x1" { 77:28 - 77:119 }
eval { 1:1 - 1:56 }
function "x2" { 80:28 - 84:5 }
function "x2a" { 82:30 - 82:122 }
eval { 1:1 - 1:56 }
function "x3" { 87:28 - 99:5 }
function "x3a" { 89:30 - 97:9 }
function "x3b" { 91:34 - 95:13 }
eval { 1:1 - 1:56 }
function "x4" { 102:28 - 102:83 }
function "x4a" { 102:61 - 102:62 }
function "x5" { 104:28 - 104:163 }
function "x5a" { 104:61 - 104:153 }
eval { 1:1 - 1:56 }
function "x6" { 106:28 - 106:207 }
function "x6a" { 106:61 - 106:197 }
function "x6b" { 106:95 - 106:187 }
eval { 1:1 - 1:56 }
Indented Functions Expressions in a function:
function "xi1" { 111:33 - 111:125 }
eval { 1:1 - 1:56 }
function "xi2" { 114:33 - 118:9 }
function "xi2a" { 116:35 - 116:128 }
eval { 1:1 - 1:56 }
function "xi3" { 121:33 - 133:9 }
function "xi3a" { 123:35 - 131:13 }
function "xi3b" { 125:39 - 129:17 }
eval { 1:1 - 1:56 }
function "xi4" { 136:33 - 136:92 }
function "xi4a" { 136:68 - 136:69 }
function "xi5" { 138:33 - 138:172 }
function "xi5a" { 138:68 - 138:161 }
eval { 1:1 - 1:56 }
function "xi6" { 140:33 - 140:219 }
function "xi6a" { 140:68 - 140:208 }
function "xi6b" { 140:104 - 140:197 }
eval { 1:1 - 1:56 }
Anonymous Function Declaration in a function:
function "" { 146:58 - 151:5 }
eval { 1:1 - 1:56 }
Global eval:
eval { 1:1 - 1:56 }
Global Functions Declarations:
function "gf1" { 161:19 - 161:111 }
eval { 1:1 - 1:56 }
function "gf2" { 164:19 - 168:1 }
function "gf2a" { 166:21 - 166:114 }
eval { 1:1 - 1:56 }
function "gf3" { 171:19 - 183:1 }
function "gf3a" { 173:21 - 181:5 }
function "gf3b" { 175:25 - 179:9 }
eval { 1:1 - 1:56 }
function "gf4" { 186:19 - 186:72 }
function "gf4a" { 186:48 - 186:49 }
function "gf5" { 188:19 - 188:152 }
function "gf5a" { 188:48 - 188:141 }
eval { 1:1 - 1:56 }
function "gf6" { 190:19 - 190:193 }
function "gf6a" { 190:48 - 190:182 }
function "gf6b" { 190:78 - 190:171 }
eval { 1:1 - 1:56 }
Indented Global Functions Declarations:
function "gfi1" { 195:24 - 195:117 }
eval { 1:1 - 1:56 }
function "gfi2" { 198:24 - 202:5 }
function "gfi2a" { 200:26 - 200:120 }
eval { 1:1 - 1:56 }
function "gfi3" { 205:24 - 217:5 }
function "gfi3a" { 207:26 - 215:9 }
function "gfi3b" { 209:30 - 213:13 }
eval { 1:1 - 1:56 }
function "gfi4" { 220:24 - 220:81 }
function "gfi4a" { 220:55 - 220:56 }
function "gfi5" { 222:24 - 222:161 }
function "gfi5a" { 222:55 - 222:149 }
eval { 1:1 - 1:56 }
function "gfi6" { 224:24 - 224:205 }
function "gfi6a" { 224:55 - 224:193 }
function "gfi6b" { 224:87 - 224:181 }
eval { 1:1 - 1:56 }
Global Functions Expressions:
function "gx1" { 229:25 - 229:117 }
eval { 1:1 - 1:56 }
function "gx2" { 232:25 - 236:1 }
function "gx2a" { 234:27 - 234:120 }
eval { 1:1 - 1:56 }
function "gx3" { 239:25 - 251:1 }
function "gx3a" { 241:27 - 249:5 }
function "gx3b" { 243:31 - 247:9 }
eval { 1:1 - 1:56 }
function "gx4" { 254:25 - 254:84 }
function "gx4a" { 254:60 - 254:61 }
function "gx5" { 256:25 - 256:164 }
function "gx5a" { 256:60 - 256:153 }
eval { 1:1 - 1:56 }
function "gx6" { 258:25 - 258:211 }
function "gx6a" { 258:60 - 258:200 }
function "gx6b" { 258:96 - 258:189 }
eval { 1:1 - 1:56 }
Indented Functions Declarations:
function "gxi1" { 263:30 - 263:123 }
eval { 1:1 - 1:56 }
function "gxi2" { 266:30 - 270:5 }
function "gxi2a" { 268:32 - 268:126 }
eval { 1:1 - 1:56 }
function "gxi3" { 273:30 - 285:5 }
function "gxi3a" { 275:32 - 283:9 }
function "gxi3b" { 277:36 - 281:13 }
eval { 1:1 - 1:56 }
function "gxi4" { 288:30 - 288:93 }
function "gxi4a" { 288:67 - 288:68 }
function "gxi5" { 290:30 - 290:173 }
function "gxi5a" { 290:67 - 290:161 }
eval { 1:1 - 1:56 }
function "gxi6" { 292:30 - 292:223 }
function "gxi6a" { 292:67 - 292:211 }
function "gxi6b" { 292:105 - 292:199 }
eval { 1:1 - 1:56 }
Anonymous Global Function Declarations:
function "" { 299:56 - 304:1 }
eval { 1:1 - 1:56 }
Function Declarations in an eval:
eval { 1:1 - 16:7 }
function "ef1" { 3:20 - 14:5 }
function "ef1a" { 5:25 - 12:9 }
function "ef1b" { 7:29 - 10:13 }
eval { 1:1 - 1:56 }
eval { 1:1 - 1:225 }
function "ef2" { 1:59 - 1:217 }
function "ef2a" { 1:88 - 1:207 }
function "ef2b" { 1:118 - 1:197 }
eval { 1:1 - 1:56 }
eval { 1:1 - 17:8 }
function "efi1" { 4:21 - 15:5 }
function "efi1a" { 6:26 - 13:9 }
function "efi1b" { 8:30 - 11:13 }
eval { 1:1 - 1:56 }
eval { 1:1 - 1:234 }
function "efi2" { 1:60 - 1:225 }
function "efi2a" { 1:91 - 1:214 }
function "efi2b" { 1:123 - 1:203 }
eval { 1:1 - 1:56 }
Function Expressions in an eval:
eval { 1:1 - 16:7 }
function "ex1" { 3:26 - 14:5 }
function "ex1a" { 5:31 - 12:9 }
function "ex1b" { 7:35 - 10:13 }
eval { 1:1 - 1:56 }
eval { 1:1 - 1:246 }
function "ex2" { 1:65 - 1:237 }
function "ex2a" { 1:100 - 1:226 }
function "ex2b" { 1:136 - 1:215 }
eval { 1:1 - 1:56 }
eval { 1:1 - 17:8 }
function "exi1" { 4:27 - 15:5 }
function "exi1a" { 6:32 - 13:9 }
function "exi1b" { 8:36 - 11:13 }
eval { 1:1 - 1:56 }
eval { 1:1 - 1:255 }
function "exi2" { 1:66 - 1:245 }
function "exi2a" { 1:103 - 1:233 }
function "exi2b" { 1:141 - 1:221 }
eval { 1:1 - 1:56 }
new Function Object:
function "" { 1:1 - 1:228 }
function "nf1a" { 1:60 - 1:219 }
function "nf1b" { 1:90 - 1:209 }
function "nf1c" { 1:120 - 1:199 }
eval { 1:1 - 1:56 }
function "" { 1:1 - 17:8 }
function "nf2a" { 4:21 - 15:5 }
function "nf2b" { 6:25 - 13:9 }
function "nf2c" { 8:29 - 11:13 }
eval { 1:1 - 1:56 }
function "" { 1:1 - 1:228 }
function "nf1a" { 1:60 - 1:219 }
function "nf1b" { 1:90 - 1:209 }
function "nf1c" { 1:120 - 1:199 }
eval { 1:1 - 1:56 }
function "" { 1:1 - 1:237 }
function "nfi1a" { 1:61 - 1:227 }
function "nfi1b" { 1:93 - 1:216 }
function "nfi1c" { 1:125 - 1:205 }
eval { 1:1 - 1:56 }
function "" { 1:1 - 17:8 }
function "nf2a" { 4:21 - 15:5 }
function "nf2b" { 6:25 - 13:9 }
function "nf2c" { 8:29 - 11:13 }
eval { 1:1 - 1:56 }
function "" { 1:1 - 17:9 }
function "nfi2a" { 4:22 - 15:5 }
function "nfi2b" { 6:26 - 13:9 }
function "nfi2c" { 8:30 - 11:13 }
eval { 1:1 - 1:56 }
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
// Convenience function so that script-tests/script-start-end-locations.js
// can be less verbose for cases where we have a function whose bounds we
// want to dump.
function dump(func) {
debug(window.internals.parserMetaData(func));
}
debug(window.internals.parserMetaData());
var dummy = 5;
</script>
<script>debug(window.internals.parserMetaData());</script> <script>debug(window.internals.parserMetaData());</script>
<script>debug(window.internals.parserMetaData());</script> <script>debug(window.internals.parserMetaData());</script>
<script>debug(window.internals.parserMetaData());
</script>
<script>debug(window.internals.parserMetaData());
</script>
<script>function hf1() { dummy += 5; } hf1(); dump(hf1);</script>
<script>function hf2() { dummy += 5; } hf2(); dump(hf2); </script>
<script>function hf3() { dummy += 5; } hf3(); dump(hf3); </script>
<script>function hf4() {
dummy += 5;
} hf4(); dump(hf4);</script>
<script>function hf5() {
dummy += 5;
} hf5(); dump(hf5);</script>
<script>function hf6() {
dummy += 5;
} hf6(); dump(hf6);</script>
<script>
function hf7() {
dummy += 5;
} hf7(); dump(hf7);</script>
<script>var v = 1; function hf8() { v += 5; } hf8(); dump(hf8);</script> <script>function hf9() { v += 5; } hf9(); dump(hf9); debug("");</script>
<script src="script-tests/script-start-end-locations.js"></script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
This diff is collapsed.
......@@ -38,13 +38,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
2 global code at stack-trace.js:47:18
--> Stack Trace:
0 htmlInner at stack-trace.html:10:39
0 htmlInner at stack-trace.html:10:51
1 scripterInner at stack-trace.js:32:37
2 global code at stack-trace.js:49:20
--> Stack Trace:
0 htmlInner at stack-trace.html:10:39
1 htmlOuter at stack-trace.html:11:33
0 htmlInner at stack-trace.html:10:51
1 htmlOuter at stack-trace.html:11:45
2 scripterOuter at stack-trace.js:33:37
3 global code at stack-trace.js:50:20
......
......@@ -5,10 +5,10 @@
</head>
<body>
<p id="description"></p>
<p id="console"></p>
<script>function htmlInner() { throw new Error("Error in HTML"); }</script>
<script>function htmlOuter() { htmlInner(); }</script>
<script src="script-tests/stack-trace.js"></script>
<p id="description"></p>
<p id="console"></p>
<script>function htmlInner() { throw new Error("Error in HTML"); }</script>
<script>function htmlOuter() { htmlInner(); }</script>
<script src="script-tests/stack-trace.js"></script>
</body>
</html>
2013-11-19 Mark Lam <mark.lam@apple.com>
Add tracking of endColumn for Executables.
https://bugs.webkit.org/show_bug.cgi?id=124245.
Reviewed by Geoffrey Garen.
1. Fixed computation of columns to take into account the startColumn from
<script> tags. Previously, we were only computing the column relative
to the char after the <script> tag. Now, the column number that JSC
computes is always the column number you'll see when viewing the source
in a text editor (assuming the first column position is 1, not 0).
2. Previously, unlinkedExecutables kept the a base-1 startColumn for
ProgramExecutables and EvalExecutables, but uses base-0 columns for
FunctionExecutables. This has been fixed so that they all use base-0
columns. When the executable gets linked, the column is adjusted into
a base-1 value.
3. In the UnlinkedFunctionExecutable, renamed m_functionStartOffset to
m_unlinkedFunctionNameStart because it actually points to the start
column in the name part of the function declaration.
Similarly, renamed m_functionStartColumn to m_unlinkedBodyStartColumn
because it points to the first character in the function body. This is
usually '{' except for functions created from "global code" which
excludes its braces. See FunctionExecutable::fromGlobalCode().
The exclusion of braces for the global code case is needed so that
computed start and end columns will more readily map to what a JS
developer would expect them to be. Otherwise, the first column of the
function source will not be 1 (includes prepended characters added in
constructFunctionSkippingEvalEnabledCheck()).
Also, similarly, a m_unlinkedBodyEndColumn has been added to track the
end column of the UnlinkedFunctionExecutable.
4. For unlinked executables, end column values are either:
a. Relative to the start of the last line if (last line != first line).
b. Relative to the start column position if (last line == first line).
The second case is needed so that we can add an appropriate adjustment
to the end column value (just like we do for the start column) when we
link the executable.
5. This is not new to this patch, but it worth noting that the lineCount
values used through this patch has the following meaning:
- a lineCount of 0 means the source for this code block is on 1 line.
- a lineCount of N means there are N + l lines of source.
This interpretation is janky, but was present before this patch. We can
clean that up later in another patch.
* JavaScriptCore.xcodeproj/project.pbxproj:
- In order to implement WebCore::Internals::parserMetaData(), we need to
move some seemingly unrelated header files from the Project section to
the Private section so that they can be #include'd by the forwarding
CodeBlock.h from WebCore.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::sourceCodeForTools):
(JSC::CodeBlock::CodeBlock):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
- m_isFromGlobalCode is needed to support the exclusion of the open brace /
prepended code for functions created from "global code".
(JSC::UnlinkedFunctionExecutable::link):
(JSC::UnlinkedFunctionExecutable::fromGlobalCode):
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::create):
(JSC::UnlinkedFunctionExecutable::unlinkedFunctionNameStart):
(JSC::UnlinkedFunctionExecutable::unlinkedBodyStartColumn):
(JSC::UnlinkedFunctionExecutable::unlinkedBodyEndColumn):
(JSC::UnlinkedFunctionExecutable::recordParse):
(JSC::UnlinkedCodeBlock::recordParse):
(JSC::UnlinkedCodeBlock::endColumn):
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionBodyNode::emitBytecode):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionBody):
(JSC::ASTBuilder::setFunctionNameStart):
* parser/Lexer.cpp:
(JSC::::shiftLineTerminator):
- Removed an unused SourceCode Lexer<T>::sourceCode() function.
* parser/Lexer.h:
(JSC::Lexer::positionBeforeLastNewline):
(JSC::Lexer::prevTerminator):
- Added tracking of m_positionBeforeLastNewline in the Lexer to enable us
to exclude the close brace / appended code for functions created from "global
code".
* parser/Nodes.cpp:
(JSC::ProgramNode::ProgramNode):
(JSC::ProgramNode::create):
(JSC::EvalNode::EvalNode):
(JSC::EvalNode::create):
(JSC::FunctionBodyNode::FunctionBodyNode):
(JSC::FunctionBodyNode::create):
(JSC::FunctionBodyNode::setEndPosition):
- setEndPosition() is needed to fixed up the end position so that we can
exclude the close brace / appended code for functions created from "global
code".
* parser/Nodes.h:
(JSC::ProgramNode::startColumn):
(JSC::ProgramNode::endColumn):
(JSC::EvalNode::startColumn):
(JSC::EvalNode::endColumn):
(JSC::FunctionBodyNode::setFunctionNameStart):
(JSC::FunctionBodyNode::functionNameStart):
(JSC::FunctionBodyNode::endColumn):
* parser/Parser.cpp:
(JSC::::parseFunctionBody):
(JSC::::parseFunctionInfo):
* parser/Parser.h:
(JSC::Parser::positionBeforeLastNewline):
(JSC::::parse):
- Subtracted 1 from startColumn here to keep the node column values consistently
base-0. See note 2 above.
(JSC::parse):
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createFunctionBody):
(JSC::SyntaxChecker::setFunctionNameStart):
* runtime/CodeCache.cpp:
(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getProgramCodeBlock):
(JSC::CodeCache::getEvalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
* runtime/CodeCache.h:
* runtime/Executable.cpp:
(JSC::ScriptExecutable::newCodeBlockFor):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::ProgramExecutable::initializeGlobalProperties):
(JSC::FunctionExecutable::fromGlobalCode):
* runtime/Executable.h:
(JSC::ExecutableBase::isEvalExecutable):
(JSC::ExecutableBase::isProgramExecutable):
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::ScriptExecutable::endColumn):
(JSC::ScriptExecutable::recordParse):
(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::bodyIncludesBraces):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/FunctionPrototype.cpp:
(JSC::insertSemicolonIfNeeded):
(JSC::functionProtoFuncToString):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::createProgramCodeBlock):
(JSC::JSGlobalObject::createEvalCodeBlock):
2013-11-19 Dean Jackson <dino@apple.com>
MarkedSpace::resumeAllocating needs to delay release
......
......@@ -117,7 +117,7 @@
0F24E54C17EE274900ABB217 /* JITOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F24E54517EE274900ABB217 /* JITOperations.cpp */; };
0F24E54D17EE274900ABB217 /* JITOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54617EE274900ABB217 /* JITOperations.h */; };
0F24E54E17EE274900ABB217 /* JITOperationWrappers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54717EE274900ABB217 /* JITOperationWrappers.h */; };
0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54817EE274900ABB217 /* TempRegisterSet.h */; };
0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54817EE274900ABB217 /* TempRegisterSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F24E55017EE274900ABB217 /* Repatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F24E54917EE274900ABB217 /* Repatch.cpp */; };
0F24E55117EE274900ABB217 /* Repatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54A17EE274900ABB217 /* Repatch.h */; };
0F24E55217EE274900ABB217 /* ScratchRegisterAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54B17EE274900ABB217 /* ScratchRegisterAllocator.h */; };
......@@ -1012,7 +1012,7 @@
A7BDAEC917F4EA1400F6140C /* ArrayIteratorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BDAEC317F4EA1400F6140C /* ArrayIteratorPrototype.h */; };
A7BDAECA17F4EA1400F6140C /* JSArrayIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BDAEC417F4EA1400F6140C /* JSArrayIterator.cpp */; };
A7BDAECB17F4EA1400F6140C /* JSArrayIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */; };
A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BFF3BF179868940002F462 /* DFGFiltrationResult.h */; };
A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BFF3BF179868940002F462 /* DFGFiltrationResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7C0C4AB167C08CD0017011D /* JSScriptRefPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7C0C4AD1681067E0017011D /* JSScriptRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C0C4AA167C08CD0017011D /* JSScriptRef.cpp */; };
A7C1E8E4112E72EF00A37F98 /* JITPropertyAccess32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C1E8C8112E701C00A37F98 /* JITPropertyAccess32_64.cpp */; };
......@@ -1222,9 +1222,9 @@
C2F0F2D116BAEEE900187C19 /* StructureRareData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2F0F2D016BAEEE900187C19 /* StructureRareData.cpp */; };
C2FC9BD316644DFB00810D33 /* CopiedBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FC9BD216644DFB00810D33 /* CopiedBlockInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
C2FCAE1017A9C24E0034C735 /* BytecodeBasicBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2FCAE0C17A9C24E0034C735 /* BytecodeBasicBlock.cpp */; };
C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0D17A9C24E0034C735 /* BytecodeBasicBlock.h */; };
C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0D17A9C24E0034C735 /* BytecodeBasicBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
C2FCAE1217A9C24E0034C735 /* BytecodeLivenessAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2FCAE0E17A9C24E0034C735 /* BytecodeLivenessAnalysis.cpp */; };
C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0F17A9C24E0034C735 /* BytecodeLivenessAnalysis.h */; };
C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0F17A9C24E0034C735 /* BytecodeLivenessAnalysis.h */; settings = {ATTRIBUTES = (Private, ); }; };
C2FE18A416BAEC4000AF3061 /* StructureRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FE18A316BAEC4000AF3061 /* StructureRareData.h */; settings = {ATTRIBUTES = (Private, ); }; };
DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */ = {isa = PBXBuildFile; fileRef = E124A8F50E555775003091F1 /* OpaqueJSString.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -4177,6 +4177,10 @@
86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */,
0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,
A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */,
C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */,
C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */,
0F8335B81639C1EA001443B5 /* ArrayAllocationProfile.h in Headers */,
FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */,
A7A8AF3517ADB5F3005AB174 /* ArrayBuffer.h in Headers */,
......@@ -4184,7 +4188,6 @@
A7A8AF3717ADB5F3005AB174 /* ArrayBufferView.h in Headers */,
BC18C3E60E16F5CD00B34460 /* ArrayConstructor.h in Headers */,
0FB7F39515ED8E4600F167B2 /* ArrayConventions.h in Headers */,
C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */,
A7BDAEC717F4EA1400F6140C /* ArrayIteratorConstructor.h in Headers */,
A7BDAEC917F4EA1400F6140C /* ArrayIteratorPrototype.h in Headers */,
0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
......@@ -4307,7 +4310,6 @@
A7986D5717A0BB1E00A95DD0 /* DFGEdgeUsesStructure.h in Headers */,
0FBC0AE81496C7C700D4FBDD /* DFGExitProfile.h in Headers */,
A78A9775179738B8009DF744 /* DFGFailedFinalizer.h in Headers */,
A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */,
A78A9777179738B8009DF744 /* DFGFinalizer.h in Headers */,
0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */,
0F9D339717FFC4E60073C2BC /* DFGFlushedAt.h in Headers */,
......@@ -4779,7 +4781,6 @@
A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */,
BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */,
C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */,
BC18C46A0E16F5CD00B34460 /* StringPrototype.h in Headers */,
142E313B134FF0A600AFADB5 /* Strong.h in Headers */,
145722861437E140005FDE26 /* StrongInlines.h in Headers */,
......@@ -4795,7 +4796,6 @@
C2DF44301707AC0100A5CA96 /* SuperRegion.h in Headers */,
BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */,
A784A26411D16622005776AC /* SyntaxChecker.h in Headers */,
0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,
0FA2C17C17D7CF84009D015F /* TestRunnerUtils.h in Headers */,
0F572D4F16879FDD00E57FBD /* ThunkGenerator.h in Headers */,
A7386556118697B400540279 /* ThunkGenerators.h in Headers */,
......
......@@ -114,7 +114,7 @@ CString CodeBlock::sourceCodeForTools() const
unsigned unlinkedStartOffset = unlinked->startOffset();
unsigned linkedStartOffset = executable->source().startOffset();
int delta = linkedStartOffset - unlinkedStartOffset;
unsigned rangeStart = delta + unlinked->functionStartOffset();
unsigned rangeStart = delta + unlinked->unlinkedFunctionNameStart();
unsigned rangeEnd = delta + unlinked->startOffset() + unlinked->sourceLength();