Changeset 159520 in webkit
- Timestamp:
- Nov 19, 2013 1:55:16 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r159519 r159520 1 2013-11-19 Mark Lam <mark.lam@apple.com> 2 3 Add tracking of endColumn for Executables. 4 https://bugs.webkit.org/show_bug.cgi?id=124245. 5 6 Reviewed by Geoffrey Garen. 7 8 * fast/events/window-onerror2-expected.txt: 9 * inspector-protocol/debugger/setBreakpoint-actions-expected.txt: 10 * js/dom/script-start-end-locations-expected.txt: Added. 11 * js/dom/script-start-end-locations.html: Added. 12 * js/dom/script-tests/script-start-end-locations.js: Added. 13 * js/dom/stack-trace-expected.txt: 14 * js/dom/stack-trace.html: 15 - Changed tabs to spaces. The tabs were making it hard to visually confirm 16 the exected column values for 2 functions. 17 1 18 2013-11-15 Jer Noble <jer.noble@apple.com> 2 19 -
trunk/LayoutTests/fast/events/window-onerror2-expected.txt
r153480 r159520 2 2 3 3 Main frame window.onerror: Error: Inline script exception at window-onerror2.html, line: 34, column: 47 4 Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 1504 Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 66 5 5 Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html, line: 29, column: 47 6 6 -
trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-actions-expected.txt
r155132 r159520 15 15 Running breakpointActions to triggering the breakpoint actions 16 16 inside breakpointActions a:(12) b:([object Object]) 17 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19: 1"}17 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:2"} 18 18 PASS: Console Message: {"source":"console-api","level":"log","text":"eval-action","location":"???:1:26","parameters":[{"type":"string"},{"type":"number"},{"type":"object"}]} 19 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19: 1"}19 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:2"} 20 20 inside breakpointActions a:(100) b:([object HTMLBodyElement]) 21 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19: 1"}21 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-before","location":"breakpoint.js:19:2"} 22 22 PASS: Console Message: {"source":"console-api","level":"log","text":"eval-action","location":"???:1:26","parameters":[{"type":"string"},{"type":"number"},{"type":"object","subtype":"node"}]} 23 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19: 1"}23 PASS: Console Message: {"source":"javascript","level":"log","text":"log-action-after","location":"breakpoint.js:19:2"} 24 24 -
trunk/LayoutTests/js/dom/stack-trace-expected.txt
r156066 r159520 39 39 40 40 --> Stack Trace: 41 0 htmlInner at stack-trace.html:10: 3941 0 htmlInner at stack-trace.html:10:51 42 42 1 scripterInner at stack-trace.js:32:37 43 43 2 global code at stack-trace.js:49:20 44 44 45 45 --> Stack Trace: 46 0 htmlInner at stack-trace.html:10: 3947 1 htmlOuter at stack-trace.html:11: 3346 0 htmlInner at stack-trace.html:10:51 47 1 htmlOuter at stack-trace.html:11:45 48 48 2 scripterOuter at stack-trace.js:33:37 49 49 3 global code at stack-trace.js:50:20 -
trunk/LayoutTests/js/dom/stack-trace.html
r156066 r159520 6 6 7 7 <body> 8 9 10 11 12 8 <p id="description"></p> 9 <p id="console"></p> 10 <script>function htmlInner() { throw new Error("Error in HTML"); }</script> 11 <script>function htmlOuter() { htmlInner(); }</script> 12 <script src="script-tests/stack-trace.js"></script> 13 13 </body> 14 14 </html> -
trunk/Source/JavaScriptCore/ChangeLog
r159515 r159520 1 2013-11-19 Mark Lam <mark.lam@apple.com> 2 3 Add tracking of endColumn for Executables. 4 https://bugs.webkit.org/show_bug.cgi?id=124245. 5 6 Reviewed by Geoffrey Garen. 7 8 1. Fixed computation of columns to take into account the startColumn from 9 <script> tags. Previously, we were only computing the column relative 10 to the char after the <script> tag. Now, the column number that JSC 11 computes is always the column number you'll see when viewing the source 12 in a text editor (assuming the first column position is 1, not 0). 13 14 2. Previously, unlinkedExecutables kept the a base-1 startColumn for 15 ProgramExecutables and EvalExecutables, but uses base-0 columns for 16 FunctionExecutables. This has been fixed so that they all use base-0 17 columns. When the executable gets linked, the column is adjusted into 18 a base-1 value. 19 20 3. In the UnlinkedFunctionExecutable, renamed m_functionStartOffset to 21 m_unlinkedFunctionNameStart because it actually points to the start 22 column in the name part of the function declaration. 23 24 Similarly, renamed m_functionStartColumn to m_unlinkedBodyStartColumn 25 because it points to the first character in the function body. This is 26 usually '{' except for functions created from "global code" which 27 excludes its braces. See FunctionExecutable::fromGlobalCode(). 28 29 The exclusion of braces for the global code case is needed so that 30 computed start and end columns will more readily map to what a JS 31 developer would expect them to be. Otherwise, the first column of the 32 function source will not be 1 (includes prepended characters added in 33 constructFunctionSkippingEvalEnabledCheck()). 34 35 Also, similarly, a m_unlinkedBodyEndColumn has been added to track the 36 end column of the UnlinkedFunctionExecutable. 37 38 4. For unlinked executables, end column values are either: 39 a. Relative to the start of the last line if (last line != first line). 40 b. Relative to the start column position if (last line == first line). 41 42 The second case is needed so that we can add an appropriate adjustment 43 to the end column value (just like we do for the start column) when we 44 link the executable. 45 46 5. This is not new to this patch, but it worth noting that the lineCount 47 values used through this patch has the following meaning: 48 - a lineCount of 0 means the source for this code block is on 1 line. 49 - a lineCount of N means there are N + l lines of source. 50 51 This interpretation is janky, but was present before this patch. We can 52 clean that up later in another patch. 53 54 55 * JavaScriptCore.xcodeproj/project.pbxproj: 56 - In order to implement WebCore::Internals::parserMetaData(), we need to 57 move some seemingly unrelated header files from the Project section to 58 the Private section so that they can be #include'd by the forwarding 59 CodeBlock.h from WebCore. 60 * bytecode/CodeBlock.cpp: 61 (JSC::CodeBlock::sourceCodeForTools): 62 (JSC::CodeBlock::CodeBlock): 63 * bytecode/UnlinkedCodeBlock.cpp: 64 (JSC::generateFunctionCodeBlock): 65 (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): 66 - m_isFromGlobalCode is needed to support the exclusion of the open brace / 67 prepended code for functions created from "global code". 68 (JSC::UnlinkedFunctionExecutable::link): 69 (JSC::UnlinkedFunctionExecutable::fromGlobalCode): 70 (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): 71 * bytecode/UnlinkedCodeBlock.h: 72 (JSC::UnlinkedFunctionExecutable::create): 73 (JSC::UnlinkedFunctionExecutable::unlinkedFunctionNameStart): 74 (JSC::UnlinkedFunctionExecutable::unlinkedBodyStartColumn): 75 (JSC::UnlinkedFunctionExecutable::unlinkedBodyEndColumn): 76 (JSC::UnlinkedFunctionExecutable::recordParse): 77 (JSC::UnlinkedCodeBlock::recordParse): 78 (JSC::UnlinkedCodeBlock::endColumn): 79 * bytecompiler/NodesCodegen.cpp: 80 (JSC::FunctionBodyNode::emitBytecode): 81 * parser/ASTBuilder.h: 82 (JSC::ASTBuilder::createFunctionBody): 83 (JSC::ASTBuilder::setFunctionNameStart): 84 * parser/Lexer.cpp: 85 (JSC::::shiftLineTerminator): 86 - Removed an unused SourceCode Lexer<T>::sourceCode() function. 87 * parser/Lexer.h: 88 (JSC::Lexer::positionBeforeLastNewline): 89 (JSC::Lexer::prevTerminator): 90 - Added tracking of m_positionBeforeLastNewline in the Lexer to enable us 91 to exclude the close brace / appended code for functions created from "global 92 code". 93 * parser/Nodes.cpp: 94 (JSC::ProgramNode::ProgramNode): 95 (JSC::ProgramNode::create): 96 (JSC::EvalNode::EvalNode): 97 (JSC::EvalNode::create): 98 (JSC::FunctionBodyNode::FunctionBodyNode): 99 (JSC::FunctionBodyNode::create): 100 (JSC::FunctionBodyNode::setEndPosition): 101 - setEndPosition() is needed to fixed up the end position so that we can 102 exclude the close brace / appended code for functions created from "global 103 code". 104 * parser/Nodes.h: 105 (JSC::ProgramNode::startColumn): 106 (JSC::ProgramNode::endColumn): 107 (JSC::EvalNode::startColumn): 108 (JSC::EvalNode::endColumn): 109 (JSC::FunctionBodyNode::setFunctionNameStart): 110 (JSC::FunctionBodyNode::functionNameStart): 111 (JSC::FunctionBodyNode::endColumn): 112 * parser/Parser.cpp: 113 (JSC::::parseFunctionBody): 114 (JSC::::parseFunctionInfo): 115 * parser/Parser.h: 116 (JSC::Parser::positionBeforeLastNewline): 117 (JSC::::parse): 118 - Subtracted 1 from startColumn here to keep the node column values consistently 119 base-0. See note 2 above. 120 (JSC::parse): 121 * parser/SourceProviderCacheItem.h: 122 (JSC::SourceProviderCacheItem::SourceProviderCacheItem): 123 * parser/SyntaxChecker.h: 124 (JSC::SyntaxChecker::createFunctionBody): 125 (JSC::SyntaxChecker::setFunctionNameStart): 126 * runtime/CodeCache.cpp: 127 (JSC::CodeCache::getGlobalCodeBlock): 128 (JSC::CodeCache::getProgramCodeBlock): 129 (JSC::CodeCache::getEvalCodeBlock): 130 (JSC::CodeCache::getFunctionExecutableFromGlobalCode): 131 * runtime/CodeCache.h: 132 * runtime/Executable.cpp: 133 (JSC::ScriptExecutable::newCodeBlockFor): 134 (JSC::FunctionExecutable::FunctionExecutable): 135 (JSC::ProgramExecutable::initializeGlobalProperties): 136 (JSC::FunctionExecutable::fromGlobalCode): 137 * runtime/Executable.h: 138 (JSC::ExecutableBase::isEvalExecutable): 139 (JSC::ExecutableBase::isProgramExecutable): 140 (JSC::ScriptExecutable::ScriptExecutable): 141 (JSC::ScriptExecutable::endColumn): 142 (JSC::ScriptExecutable::recordParse): 143 (JSC::FunctionExecutable::create): 144 (JSC::FunctionExecutable::bodyIncludesBraces): 145 * runtime/FunctionConstructor.cpp: 146 (JSC::constructFunctionSkippingEvalEnabledCheck): 147 * runtime/FunctionPrototype.cpp: 148 (JSC::insertSemicolonIfNeeded): 149 (JSC::functionProtoFuncToString): 150 * runtime/JSGlobalObject.cpp: 151 (JSC::JSGlobalObject::createProgramCodeBlock): 152 (JSC::JSGlobalObject::createEvalCodeBlock): 153 1 154 2013-11-19 Dean Jackson <dino@apple.com> 2 155 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r159394 r159520 118 118 0F24E54D17EE274900ABB217 /* JITOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54617EE274900ABB217 /* JITOperations.h */; }; 119 119 0F24E54E17EE274900ABB217 /* JITOperationWrappers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54717EE274900ABB217 /* JITOperationWrappers.h */; }; 120 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54817EE274900ABB217 /* TempRegisterSet.h */; };120 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54817EE274900ABB217 /* TempRegisterSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 121 121 0F24E55017EE274900ABB217 /* Repatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F24E54917EE274900ABB217 /* Repatch.cpp */; }; 122 122 0F24E55117EE274900ABB217 /* Repatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F24E54A17EE274900ABB217 /* Repatch.h */; }; … … 1013 1013 A7BDAECA17F4EA1400F6140C /* JSArrayIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BDAEC417F4EA1400F6140C /* JSArrayIterator.cpp */; }; 1014 1014 A7BDAECB17F4EA1400F6140C /* JSArrayIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */; }; 1015 A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BFF3BF179868940002F462 /* DFGFiltrationResult.h */; };1015 A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BFF3BF179868940002F462 /* DFGFiltrationResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1016 1016 A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7C0C4AB167C08CD0017011D /* JSScriptRefPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1017 1017 A7C0C4AD1681067E0017011D /* JSScriptRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C0C4AA167C08CD0017011D /* JSScriptRef.cpp */; }; … … 1223 1223 C2FC9BD316644DFB00810D33 /* CopiedBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FC9BD216644DFB00810D33 /* CopiedBlockInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1224 1224 C2FCAE1017A9C24E0034C735 /* BytecodeBasicBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2FCAE0C17A9C24E0034C735 /* BytecodeBasicBlock.cpp */; }; 1225 C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0D17A9C24E0034C735 /* BytecodeBasicBlock.h */; };1225 C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0D17A9C24E0034C735 /* BytecodeBasicBlock.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1226 1226 C2FCAE1217A9C24E0034C735 /* BytecodeLivenessAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2FCAE0E17A9C24E0034C735 /* BytecodeLivenessAnalysis.cpp */; }; 1227 C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0F17A9C24E0034C735 /* BytecodeLivenessAnalysis.h */; };1227 C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FCAE0F17A9C24E0034C735 /* BytecodeLivenessAnalysis.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1228 1228 C2FE18A416BAEC4000AF3061 /* StructureRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = C2FE18A316BAEC4000AF3061 /* StructureRareData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1229 1229 DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4178 4178 86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */, 4179 4179 65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */, 4180 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */, 4181 A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */, 4182 C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */, 4183 C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */, 4180 4184 0F8335B81639C1EA001443B5 /* ArrayAllocationProfile.h in Headers */, 4181 4185 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */, … … 4185 4189 BC18C3E60E16F5CD00B34460 /* ArrayConstructor.h in Headers */, 4186 4190 0FB7F39515ED8E4600F167B2 /* ArrayConventions.h in Headers */, 4187 C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */,4188 4191 A7BDAEC717F4EA1400F6140C /* ArrayIteratorConstructor.h in Headers */, 4189 4192 A7BDAEC917F4EA1400F6140C /* ArrayIteratorPrototype.h in Headers */, … … 4308 4311 0FBC0AE81496C7C700D4FBDD /* DFGExitProfile.h in Headers */, 4309 4312 A78A9775179738B8009DF744 /* DFGFailedFinalizer.h in Headers */, 4310 A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */,4311 4313 A78A9777179738B8009DF744 /* DFGFinalizer.h in Headers */, 4312 4314 0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */, … … 4780 4782 BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */, 4781 4783 BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */, 4782 C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */,4783 4784 BC18C46A0E16F5CD00B34460 /* StringPrototype.h in Headers */, 4784 4785 142E313B134FF0A600AFADB5 /* Strong.h in Headers */, … … 4796 4797 BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */, 4797 4798 A784A26411D16622005776AC /* SyntaxChecker.h in Headers */, 4798 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,4799 4799 0FA2C17C17D7CF84009D015F /* TestRunnerUtils.h in Headers */, 4800 4800 0F572D4F16879FDD00E57FBD /* ThunkGenerator.h in Headers */, -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r159462 r159520 115 115 unsigned linkedStartOffset = executable->source().startOffset(); 116 116 int delta = linkedStartOffset - unlinkedStartOffset; 117 unsigned rangeStart = delta + unlinked-> functionStartOffset();117 unsigned rangeStart = delta + unlinked->unlinkedFunctionNameStart(); 118 118 unsigned rangeEnd = delta + unlinked->startOffset() + unlinked->sourceLength(); 119 119 return toCString( … … 1639 1639 unsigned lineCount = unlinkedExecutable->lineCount(); 1640 1640 unsigned firstLine = ownerExecutable->lineNo() + unlinkedExecutable->firstLineOffset(); 1641 unsigned startColumn = unlinkedExecutable->functionStartColumn(); 1642 startColumn += (unlinkedExecutable->firstLineOffset() ? 1 : ownerExecutable->startColumn()); 1641 bool startColumnIsOnOwnerStartLine = !unlinkedExecutable->firstLineOffset(); 1642 unsigned startColumn = unlinkedExecutable->unlinkedBodyStartColumn() + (startColumnIsOnOwnerStartLine ? ownerExecutable->startColumn() : 1); 1643 bool endColumnIsOnStartLine = !lineCount; 1644 unsigned endColumn = unlinkedExecutable->unlinkedBodyEndColumn() + (endColumnIsOnStartLine ? startColumn : 1); 1643 1645 unsigned startOffset = sourceOffset + unlinkedExecutable->startOffset(); 1644 1646 unsigned sourceLength = unlinkedExecutable->sourceLength(); 1645 1647 SourceCode code(m_source, startOffset, startOffset + sourceLength, firstLine, startColumn); 1646 FunctionExecutable* executable = FunctionExecutable::create(*m_vm, code, unlinkedExecutable, firstLine, firstLine + lineCount, startColumn );1648 FunctionExecutable* executable = FunctionExecutable::create(*m_vm, code, unlinkedExecutable, firstLine, firstLine + lineCount, startColumn, endColumn); 1647 1649 m_functionDecls[i].set(*m_vm, ownerExecutable, executable); 1648 1650 } … … 1653 1655 unsigned lineCount = unlinkedExecutable->lineCount(); 1654 1656 unsigned firstLine = ownerExecutable->lineNo() + unlinkedExecutable->firstLineOffset(); 1655 unsigned startColumn = unlinkedExecutable->functionStartColumn(); 1656 startColumn += (unlinkedExecutable->firstLineOffset() ? 1 : ownerExecutable->startColumn()); 1657 bool startColumnIsOnOwnerStartLine = !unlinkedExecutable->firstLineOffset(); 1658 unsigned startColumn = unlinkedExecutable->unlinkedBodyStartColumn() + (startColumnIsOnOwnerStartLine ? ownerExecutable->startColumn() : 1); 1659 bool endColumnIsOnStartLine = !lineCount; 1660 unsigned endColumn = unlinkedExecutable->unlinkedBodyEndColumn() + (endColumnIsOnStartLine ? startColumn : 1); 1657 1661 unsigned startOffset = sourceOffset + unlinkedExecutable->startOffset(); 1658 1662 unsigned sourceLength = unlinkedExecutable->sourceLength(); 1659 1663 SourceCode code(m_source, startOffset, startOffset + sourceLength, firstLine, startColumn); 1660 FunctionExecutable* executable = FunctionExecutable::create(*m_vm, code, unlinkedExecutable, firstLine, firstLine + lineCount, startColumn );1664 FunctionExecutable* executable = FunctionExecutable::create(*m_vm, code, unlinkedExecutable, firstLine, firstLine + lineCount, startColumn, endColumn); 1661 1665 m_functionExprs[i].set(*m_vm, ownerExecutable, executable); 1662 1666 } -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r156785 r159520 60 60 body->setUsesArguments(); 61 61 body->finishParsing(executable->parameters(), executable->name(), executable->functionNameIsInScopeToggle()); 62 executable->recordParse(body->features(), body->hasCapturedVariables() , body->lineNo(), body->lastLine());62 executable->recordParse(body->features(), body->hasCapturedVariables()); 63 63 64 64 UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode, ExecutableInfo(body->needsActivation(), body->usesEval(), body->isStrictMode(), kind == CodeForConstruct)); … … 81 81 } 82 82 83 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, FunctionBodyNode* node )83 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, FunctionBodyNode* node, bool isFromGlobalCode) 84 84 : Base(*vm, structure) 85 85 , m_numCapturedVariables(node->capturedVariableCount()) … … 87 87 , m_isInStrictContext(node->isStrictMode()) 88 88 , m_hasCapturedVariables(node->hasCapturedVariables()) 89 , m_isFromGlobalCode(isFromGlobalCode) 89 90 , m_name(node->ident()) 90 91 , m_inferredName(node->inferredName()) … … 92 93 , m_firstLineOffset(node->firstLine() - source.firstLine()) 93 94 , m_lineCount(node->lastLine() - node->firstLine()) 94 , m_functionStartOffset(node->functionStart() - source.startOffset()) 95 , m_functionStartColumn(node->startColumn()) 95 , m_unlinkedFunctionNameStart(node->functionNameStart() - source.startOffset()) 96 , m_unlinkedBodyStartColumn(node->startColumn()) 97 , m_unlinkedBodyEndColumn(m_lineCount ? node->endColumn() : node->endColumn() - node->startColumn()) 96 98 , m_startOffset(node->source().startOffset() - source.startOffset()) 97 99 , m_sourceLength(node->source().length()) … … 124 126 unsigned firstLine = lineOffset + m_firstLineOffset; 125 127 unsigned startOffset = sourceOffset + m_startOffset; 126 unsigned startColumn = m_functionStartColumn + 1; // startColumn should start from 1, not 0. 128 bool startColumnIsOnFirstSourceLine = !m_firstLineOffset; 129 unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1); 130 bool endColumnIsOnStartLine = !m_lineCount; 131 unsigned endColumn = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? startColumn : 1); 127 132 SourceCode code(source.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn); 128 return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn );133 return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumn); 129 134 } 130 135 … … 132 137 { 133 138 ParserError error; 134 CodeCache* codeCache = exec->vm().codeCache(); 135 UnlinkedFunctionExecutable* executable = codeCache->getFunctionExecutableFromGlobalCode(exec->vm(), name, source, error); 139 VM& vm = exec->vm(); 140 CodeCache* codeCache = vm.codeCache(); 141 UnlinkedFunctionExecutable* executable = codeCache->getFunctionExecutableFromGlobalCode(vm, name, source, error); 136 142 137 143 if (exec->lexicalGlobalObject()->hasDebugger()) … … 205 211 , m_firstLine(0) 206 212 , m_lineCount(0) 213 , m_endColumn(UINT_MAX) 207 214 , m_features(0) 208 215 , m_codeType(codeType) -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r157653 r159520 84 84 friend class CodeCache; 85 85 typedef JSCell Base; 86 static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionBodyNode* node )87 { 88 UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap)) UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, node );86 static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionBodyNode* node, bool isFromGlobalCode = false) 87 { 88 UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap)) UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, node, isFromGlobalCode); 89 89 instance->finishCreation(*vm); 90 90 return instance; … … 104 104 unsigned firstLineOffset() const { return m_firstLineOffset; } 105 105 unsigned lineCount() const { return m_lineCount; } 106 unsigned functionStartOffset() const { return m_functionStartOffset; } 107 unsigned functionStartColumn() const { return m_functionStartColumn; } 106 unsigned unlinkedFunctionNameStart() const { return m_unlinkedFunctionNameStart; } 107 unsigned unlinkedBodyStartColumn() const { return m_unlinkedBodyStartColumn; } 108 unsigned unlinkedBodyEndColumn() const { return m_unlinkedBodyEndColumn; } 108 109 unsigned startOffset() const { return m_startOffset; } 109 110 unsigned sourceLength() { return m_sourceLength; } … … 127 128 FunctionParameters* parameters() { return m_parameters.get(); } 128 129 129 void recordParse(CodeFeatures features, bool hasCapturedVariables , int firstLine, int lastLine)130 void recordParse(CodeFeatures features, bool hasCapturedVariables) 130 131 { 131 132 m_features = features; 132 133 m_hasCapturedVariables = hasCapturedVariables; 133 m_lineCount = lastLine - firstLine;134 134 } 135 135 … … 144 144 145 145 private: 146 UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, FunctionBodyNode* );146 UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, FunctionBodyNode*, bool isFromGlobalCode); 147 147 WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForCall; 148 148 WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForConstruct; … … 152 152 bool m_isInStrictContext : 1; 153 153 bool m_hasCapturedVariables : 1; 154 bool m_isFromGlobalCode : 1; 154 155 155 156 Identifier m_name; … … 161 162 unsigned m_firstLineOffset; 162 163 unsigned m_lineCount; 163 unsigned m_functionStartOffset; 164 unsigned m_functionStartColumn; 164 unsigned m_unlinkedFunctionNameStart; 165 unsigned m_unlinkedBodyStartColumn; 166 unsigned m_unlinkedBodyEndColumn; 165 167 unsigned m_startOffset; 166 168 unsigned m_sourceLength; … … 187 189 static const unsigned StructureFlags = OverridesVisitChildren | JSCell::StructureFlags; 188 190 189 DECLARE_ INFO;191 DECLARE_EXPORT_INFO; 190 192 }; 191 193 … … 442 444 int& startOffset, int& endOffset, unsigned& line, unsigned& column); 443 445 444 void recordParse(CodeFeatures features, bool hasCapturedVariables, unsigned firstLine, unsigned lineCount )446 void recordParse(CodeFeatures features, bool hasCapturedVariables, unsigned firstLine, unsigned lineCount, unsigned endColumn) 445 447 { 446 448 m_features = features; … … 448 450 m_firstLine = firstLine; 449 451 m_lineCount = lineCount; 452 // For the UnlinkedCodeBlock, startColumn is always 0. 453 m_endColumn = endColumn; 450 454 } 451 455 … … 454 458 unsigned firstLine() const { return m_firstLine; } 455 459 unsigned lineCount() const { return m_lineCount; } 460 ALWAYS_INLINE unsigned startColumn() const { return 0; } 461 unsigned endColumn() const { return m_endColumn; } 456 462 457 463 protected: … … 493 499 unsigned m_firstLine; 494 500 unsigned m_lineCount; 501 unsigned m_endColumn; 495 502 496 503 CodeFeatures m_features; -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r159139 r159520 2255 2255 if (!returnNode) { 2256 2256 RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined()); 2257 ASSERT( (startOffset() - 1) >= lineStartOffset());2258 generator.emitDebugHook(WillLeaveCallFrame, lastLine(), startOffset() - 1, lineStartOffset());2257 ASSERT(startOffset() >= lineStartOffset()); 2258 generator.emitDebugHook(WillLeaveCallFrame, lastLine(), startOffset(), lineStartOffset()); 2259 2259 generator.emitReturn(r0); 2260 2260 return; -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r157724 r159520 284 284 } 285 285 286 FunctionBodyNode* createFunctionBody(const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, bool inStrictContext)287 { 288 return FunctionBodyNode::create(m_vm, startLocation, endLocation, startColumn, inStrictContext);289 } 290 291 void setFunction Start(FunctionBodyNode* body, int functionStart)292 { 293 body->setFunction Start(functionStart);286 FunctionBodyNode* createFunctionBody(const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, bool inStrictContext) 287 { 288 return FunctionBodyNode::create(m_vm, startLocation, endLocation, startColumn, endColumn, inStrictContext); 289 } 290 291 void setFunctionNameStart(FunctionBodyNode* body, int functionNameStart) 292 { 293 body->setFunctionNameStart(functionNameStart); 294 294 } 295 295 -
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r157836 r159520 619 619 ASSERT(isLineTerminator(m_current)); 620 620 621 m_positionBeforeLastNewline = currentPosition(); 621 622 T prev = m_current; 622 623 shift(); … … 1854 1855 } 1855 1856 1856 template <typename T>1857 SourceCode Lexer<T>::sourceCode(int openBrace, int closeBrace, int firstLine, unsigned startColumn)1858 {1859 ASSERT(m_source->provider()->source()[openBrace] == '{');1860 ASSERT(m_source->provider()->source()[closeBrace] == '}');1861 return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine, startColumn);1862 }1863 1864 1857 // Instantiate the two flavors of Lexer we need instead of putting most of this file in Lexer.h 1865 1858 template class Lexer<LChar>; -
trunk/Source/JavaScriptCore/parser/Lexer.h
r157836 r159520 96 96 return JSTextPosition(m_lineNumber, currentOffset(), currentLineStartOffset()); 97 97 } 98 JSTextPosition positionBeforeLastNewline() const { return m_positionBeforeLastNewline; } 98 99 void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; } 99 100 int lastLineNumber() const { return m_lastLineNumber; } 100 101 bool prevTerminator() const { return m_terminator; } 101 SourceCode sourceCode(int openBrace, int closeBrace, int firstLine, unsigned startColumn);102 102 bool scanRegExp(const Identifier*& pattern, const Identifier*& flags, UChar patternPrefix = 0); 103 103 bool skipRegExp(); … … 228 228 const T* m_codeStartPlusOffset; 229 229 const T* m_lineStart; 230 JSTextPosition m_positionBeforeLastNewline; 230 231 bool m_isReparsing; 231 232 bool m_atLineStart; -
trunk/Source/JavaScriptCore/parser/Nodes.cpp
r156785 r159520 115 115 // ------------------------------ ProgramNode ----------------------------- 116 116 117 inline ProgramNode::ProgramNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)117 inline ProgramNode::ProgramNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 118 118 : ScopeNode(vm, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants) 119 119 , m_startColumn(startColumn) 120 { 121 } 122 123 PassRefPtr<ProgramNode> ProgramNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 124 { 125 RefPtr<ProgramNode> node = new ProgramNode(vm, startLocation, endLocation, startColumn, children, varStack, funcStack, capturedVariables, source, features, numConstants); 120 , m_endColumn(endColumn) 121 { 122 } 123 124 PassRefPtr<ProgramNode> ProgramNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 125 { 126 RefPtr<ProgramNode> node = new ProgramNode(vm, startLocation, endLocation, startColumn, endColumn, children, varStack, funcStack, capturedVariables, source, features, numConstants); 126 127 127 128 ASSERT(node->m_arena.last() == node); … … 134 135 // ------------------------------ EvalNode ----------------------------- 135 136 136 inline EvalNode::EvalNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)137 inline EvalNode::EvalNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 137 138 : ScopeNode(vm, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants) 138 { 139 } 140 141 PassRefPtr<EvalNode> EvalNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 142 { 143 RefPtr<EvalNode> node = new EvalNode(vm, startLocation, endLocation, children, varStack, funcStack, capturedVariables, source, features, numConstants); 139 , m_endColumn(endColumn) 140 { 141 } 142 143 PassRefPtr<EvalNode> EvalNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants) 144 { 145 RefPtr<EvalNode> node = new EvalNode(vm, startLocation, endLocation, endColumn, children, varStack, funcStack, capturedVariables, source, features, numConstants); 144 146 145 147 ASSERT(node->m_arena.last() == node); … … 180 182 } 181 183 182 inline FunctionBodyNode::FunctionBodyNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, bool inStrictContext)184 inline FunctionBodyNode::FunctionBodyNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, bool inStrictContext) 183 185 : ScopeNode(vm, startLocation, endLocation, inStrictContext) 184 186 , m_startColumn(startColumn) 185 { 186 } 187 188 inline FunctionBodyNode::FunctionBodyNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants) 187 , m_endColumn(endColumn) 188 { 189 } 190 191 inline FunctionBodyNode::FunctionBodyNode(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants) 189 192 : ScopeNode(vm, startLocation, endLocation, sourceCode, children, varStack, funcStack, capturedVariables, features, numConstants) 190 193 , m_startColumn(startColumn) 194 , m_endColumn(endColumn) 191 195 { 192 196 } … … 206 210 } 207 211 208 FunctionBodyNode* FunctionBodyNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, bool inStrictContext)209 { 210 return new FunctionBodyNode(vm, startLocation, endLocation, startColumn, inStrictContext);211 } 212 213 PassRefPtr<FunctionBodyNode> FunctionBodyNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)214 { 215 RefPtr<FunctionBodyNode> node = new FunctionBodyNode(vm, startLocation, endLocation, startColumn, children, varStack, funcStack, capturedVariables, sourceCode, features, numConstants);212 FunctionBodyNode* FunctionBodyNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, bool inStrictContext) 213 { 214 return new FunctionBodyNode(vm, startLocation, endLocation, startColumn, endColumn, inStrictContext); 215 } 216 217 PassRefPtr<FunctionBodyNode> FunctionBodyNode::create(VM* vm, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants) 218 { 219 RefPtr<FunctionBodyNode> node = new FunctionBodyNode(vm, startLocation, endLocation, startColumn, endColumn , children, varStack, funcStack, capturedVariables, sourceCode, features, numConstants); 216 220 217 221 ASSERT(node->m_arena.last() == node); … … 222 226 } 223 227 228 void FunctionBodyNode::setEndPosition(JSTextPosition position) 229 { 230 m_lastLine = position.line; 231 m_endColumn = position.offset - position.lineStartOffset; 232 } 233 224 234 } // namespace JSC -
trunk/Source/JavaScriptCore/parser/Nodes.h
r158473 r159520 193 193 virtual bool isBlock() const { return false; } 194 194 195 pr ivate:195 protected: 196 196 int m_lastLine; 197 197 }; … … 1469 1469 public: 1470 1470 static const bool isFunctionNode = false; 1471 static PassRefPtr<ProgramNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1472 1473 unsigned startColumn() { return m_startColumn; } 1471 static PassRefPtr<ProgramNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1472 1473 unsigned startColumn() const { return m_startColumn; } 1474 unsigned endColumn() const { return m_endColumn; } 1474 1475 1475 1476 static const bool scopeIsFunction = false; 1476 1477 1477 1478 private: 1478 ProgramNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);1479 ProgramNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1479 1480 1480 1481 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) OVERRIDE; 1481 1482 1482 1483 unsigned m_startColumn; 1484 unsigned m_endColumn; 1483 1485 }; 1484 1486 … … 1486 1488 public: 1487 1489 static const bool isFunctionNode = false; 1488 static PassRefPtr<EvalNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1489 1490 unsigned startColumn() { return 1; } 1490 static PassRefPtr<EvalNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1491 1492 ALWAYS_INLINE unsigned startColumn() const { return 0; } 1493 unsigned endColumn() const { return m_endColumn; } 1491 1494 1492 1495 static const bool scopeIsFunction = false; 1493 1496 1494 1497 private: 1495 EvalNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1496 1497 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) OVERRIDE; 1498 EvalNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1499 1500 virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) OVERRIDE; 1501 1502 unsigned m_endColumn; 1498 1503 }; 1499 1504 … … 1520 1525 public: 1521 1526 static const bool isFunctionNode = true; 1522 static FunctionBodyNode* create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, bool isStrictMode);1523 static PassRefPtr<FunctionBodyNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);1527 static FunctionBodyNode* create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, bool isStrictMode); 1528 static PassRefPtr<FunctionBodyNode> create(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1524 1529 1525 1530 FunctionParameters* parameters() const { return m_parameters.get(); } … … 1538 1543 FunctionNameIsInScopeToggle functionNameIsInScopeToggle() { return m_functionNameIsInScopeToggle; } 1539 1544 1540 void setFunction Start(int functionStart) { m_functionStart = functionStart; }1541 int function Start() const { return m_functionStart; }1545 void setFunctionNameStart(int functionNameStart) { m_functionNameStart = functionNameStart; } 1546 int functionNameStart() const { return m_functionNameStart; } 1542 1547 unsigned startColumn() const { return m_startColumn; } 1548 unsigned endColumn() const { return m_endColumn; } 1549 1550 void setEndPosition(JSTextPosition); 1543 1551 1544 1552 static const bool scopeIsFunction = true; 1545 1553 1546 1554 private: 1547 FunctionBodyNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, bool inStrictContext);1548 FunctionBodyNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);1555 FunctionBodyNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, bool inStrictContext); 1556 FunctionBodyNode(VM*, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants); 1549 1557 1550 1558 Identifier m_ident; … … 1552 1560 FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle; 1553 1561 RefPtr<FunctionParameters> m_parameters; 1554 int m_function Start;1562 int m_functionNameStart; 1555 1563 unsigned m_startColumn; 1564 unsigned m_endColumn; 1556 1565 }; 1557 1566 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r159225 r159520 1163 1163 next(); 1164 1164 1165 if (match(CLOSEBRACE)) 1166 return context.createFunctionBody(startLocation, tokenLocation(), startColumn, strictMode()); 1165 if (match(CLOSEBRACE)) { 1166 unsigned endColumn = tokenColumn(); 1167 return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, strictMode()); 1168 } 1167 1169 DepthManager statementDepth(&m_statementDepth); 1168 1170 m_statementDepth = 0; 1169 1171 typename TreeBuilder::FunctionBodyBuilder bodyBuilder(const_cast<VM*>(m_vm), m_lexer.get()); 1170 1172 failIfFalse(parseSourceElements<CheckForStrictMode>(bodyBuilder), "Cannot parse body of this function"); 1171 return context.createFunctionBody(startLocation, tokenLocation(), startColumn, strictMode()); 1173 unsigned endColumn = tokenColumn(); 1174 return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, strictMode()); 1172 1175 } 1173 1176 … … 1191 1194 AutoPopScopeRef functionScope(this, pushScope()); 1192 1195 functionScope->setIsFunction(); 1193 int function Start = m_token.m_location.startOffset;1196 int functionNameStart = m_token.m_location.startOffset; 1194 1197 const Identifier* lastFunctionName = m_lastFunctionName; 1195 1198 m_lastFunctionName = nullptr; … … 1232 1235 endLocation.startOffset = cachedInfo->closeBraceOffset; 1233 1236 endLocation.lineStartOffset = cachedInfo->closeBraceLineStartOffset; 1237 1238 bool endColumnIsOnStartLine = (endLocation.line == bodyStartLine); 1234 1239 ASSERT(endLocation.startOffset >= endLocation.lineStartOffset); 1235 1236 body = context.createFunctionBody(startLocation, endLocation, bodyStartColumn, cachedInfo->strictMode); 1240 unsigned bodyEndColumn = endColumnIsOnStartLine ? 1241 endLocation.startOffset - m_token.m_data.lineStartOffset : 1242 endLocation.startOffset - endLocation.lineStartOffset; 1243 1244 body = context.createFunctionBody(startLocation, endLocation, bodyStartColumn, bodyEndColumn, cachedInfo->strictMode); 1237 1245 1238 1246 functionScope->restoreFromSourceProviderCache(cachedInfo); … … 1241 1249 closeBraceOffset = cachedInfo->closeBraceOffset; 1242 1250 1243 context.setFunction Start(body, functionStart);1251 context.setFunctionNameStart(body, functionNameStart); 1244 1252 m_token = cachedInfo->closeBraceToken(); 1245 1253 … … 1271 1279 if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) { 1272 1280 SourceProviderCacheItemCreationParameters parameters; 1273 parameters.function Start = functionStart;1281 parameters.functionNameStart = functionNameStart; 1274 1282 parameters.closeBraceLine = closeBraceLine; 1275 1283 parameters.closeBraceOffset = closeBraceOffset; … … 1279 1287 1280 1288 } 1281 context.setFunction Start(body, functionStart);1289 context.setFunctionNameStart(body, functionNameStart); 1282 1290 1283 1291 failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo), "Parser error"); -
trunk/Source/JavaScriptCore/parser/Parser.h
r159210 r159520 414 414 template <class ParsedNode> 415 415 PassRefPtr<ParsedNode> parse(ParserError&); 416 417 JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); } 416 418 417 419 private: … … 882 884 883 885 JSTokenLocation startLocation(tokenLocation()); 884 unsigned startColumn = m_source->startColumn(); 886 ASSERT(m_source->startColumn() > 0); 887 unsigned startColumn = m_source->startColumn() - 1; 885 888 886 889 String parseError = parseInner(); … … 901 904 if (m_sourceElements) { 902 905 JSTokenLocation endLocation; 903 endLocation.line = m_lexer->l astLineNumber();906 endLocation.line = m_lexer->lineNumber(); 904 907 endLocation.lineStartOffset = m_lexer->currentLineStartOffset(); 905 908 endLocation.startOffset = m_lexer->currentOffset(); 909 unsigned endColumn = endLocation.startOffset - endLocation.lineStartOffset; 906 910 result = ParsedNode::create(m_vm, 907 911 startLocation, 908 912 endLocation, 909 913 startColumn, 914 endColumn, 910 915 m_sourceElements, 911 916 m_varDeclarations ? &m_varDeclarations->data : 0, … … 915 920 m_features, 916 921 m_numConstants); 917 result->setLoc(m_source->firstLine(), m_l astTokenEndPosition.line, m_lexer->currentOffset(), m_lexer->currentLineStartOffset());922 result->setLoc(m_source->firstLine(), m_lexer->lineNumber(), m_lexer->currentOffset(), m_lexer->currentLineStartOffset()); 918 923 } else { 919 924 // We can never see a syntax error when reparsing a function, since we should have … … 945 950 946 951 template <class ParsedNode> 947 PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error )952 PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0) 948 953 { 949 954 SamplingRegion samplingRegion("Parsing"); … … 952 957 if (source.provider()->source().is8Bit()) { 953 958 Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode); 954 return parser.parse<ParsedNode>(error); 959 RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error); 960 if (positionBeforeLastNewline) 961 *positionBeforeLastNewline = parser.positionBeforeLastNewline(); 962 return result.release(); 955 963 } 956 964 Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode); 957 return parser.parse<ParsedNode>(error); 965 RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error); 966 if (positionBeforeLastNewline) 967 *positionBeforeLastNewline = parser.positionBeforeLastNewline(); 968 return result.release(); 958 969 } 959 970 -
trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h
r157653 r159520 35 35 36 36 struct SourceProviderCacheItemCreationParameters { 37 unsigned function Start;37 unsigned functionNameStart; 38 38 unsigned closeBraceLine; 39 39 unsigned closeBraceOffset; … … 71 71 } 72 72 73 unsigned function Start : 31;73 unsigned functionNameStart : 31; 74 74 bool needsFullActivation : 1; 75 75 … … 108 108 109 109 inline SourceProviderCacheItem::SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters& parameters) 110 : function Start(parameters.functionStart)110 : functionNameStart(parameters.functionNameStart) 111 111 , needsFullActivation(parameters.needsFullActivation) 112 112 , closeBraceLine(parameters.closeBraceLine) -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r157724 r159520 154 154 ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int) { return AssignmentExpr; } 155 155 ExpressionType createFunctionExpr(const JSTokenLocation&, const Identifier*, int, int, int, int, int, int, int) { return FunctionExpr; } 156 int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, bool) { return 1; }157 void setFunction Start(int, int) { }156 int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool) { return 1; } 157 void setFunctionNameStart(int, int) { } 158 158 int createArguments() { return 1; } 159 159 int createArguments(int) { return 1; } -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r153221 r159520 76 76 77 77 template <class UnlinkedCodeBlockType, class ExecutableType> 78 UnlinkedCodeBlockType* CodeCache::get CodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)78 UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) 79 79 { 80 80 SourceCodeKey key = SourceCodeKey(source, String(), CacheTypes<UnlinkedCodeBlockType>::codeType, strictness); … … 82 82 bool canCache = debuggerMode == DebuggerOff && profilerMode == ProfilerOff; 83 83 if (!addResult.isNewEntry && canCache) { 84 UnlinkedCodeBlockType* unlinkedCode = jsCast<UnlinkedCodeBlockType*>(addResult.iterator->value.cell.get()); 85 unsigned firstLine = source.firstLine() + unlinkedCode->firstLine(); 86 unsigned startColumn = source.firstLine() ? source.startColumn() : 0; 87 executable->recordParse(unlinkedCode->codeFeatures(), unlinkedCode->hasCapturedVariables(), firstLine, firstLine + unlinkedCode->lineCount(), startColumn); 88 return unlinkedCode; 84 UnlinkedCodeBlockType* unlinkedCodeBlock = jsCast<UnlinkedCodeBlockType*>(addResult.iterator->value.cell.get()); 85 unsigned firstLine = source.firstLine() + unlinkedCodeBlock->firstLine(); 86 unsigned lineCount = unlinkedCodeBlock->lineCount(); 87 unsigned startColumn = unlinkedCodeBlock->startColumn() + source.startColumn(); 88 bool endColumnIsOnStartLine = !lineCount; 89 unsigned endColumn = unlinkedCodeBlock->endColumn() + (endColumnIsOnStartLine ? startColumn : 1); 90 executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), firstLine, firstLine + lineCount, startColumn, endColumn); 91 return unlinkedCodeBlock; 89 92 } 90 93 … … 95 98 return 0; 96 99 } 97 executable->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->lineNo(), rootNode->lastLine(), rootNode->startColumn()); 100 unsigned lineCount = rootNode->lastLine() - rootNode->lineNo(); 101 unsigned startColumn = rootNode->startColumn() + 1; 102 bool endColumnIsOnStartLine = !lineCount; 103 unsigned unlinkedEndColumn = rootNode->endColumn(); 104 unsigned endColumn = unlinkedEndColumn + (endColumnIsOnStartLine ? startColumn : 1); 105 executable->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->lineNo(), rootNode->lastLine(), startColumn, endColumn); 98 106 99 UnlinkedCodeBlockType* unlinkedCode = UnlinkedCodeBlockType::create(&vm, executable->executableInfo()); 100 unlinkedCode->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->lineNo() - source.firstLine(), rootNode->lastLine() - rootNode->lineNo()); 101 OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(vm, rootNode.get(), unlinkedCode, debuggerMode, profilerMode))); 107 UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(&vm, executable->executableInfo()); 108 unlinkedCodeBlock->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->lineNo() - source.firstLine(), lineCount, unlinkedEndColumn); 109 110 OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(vm, rootNode.get(), unlinkedCodeBlock, debuggerMode, profilerMode))); 102 111 error = generator->generate(); 103 112 rootNode->destroyData(); … … 109 118 if (!canCache) { 110 119 m_sourceCode.remove(addResult.iterator); 111 return unlinkedCode ;120 return unlinkedCodeBlock; 112 121 } 113 122 114 addResult.iterator->value = SourceCodeValue(vm, unlinkedCode , m_sourceCode.age());115 return unlinkedCode ;123 addResult.iterator->value = SourceCodeValue(vm, unlinkedCodeBlock, m_sourceCode.age()); 124 return unlinkedCodeBlock; 116 125 } 117 126 118 127 UnlinkedProgramCodeBlock* CodeCache::getProgramCodeBlock(VM& vm, ProgramExecutable* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) 119 128 { 120 return get CodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, strictness, debuggerMode, profilerMode, error);129 return getGlobalCodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, strictness, debuggerMode, profilerMode, error); 121 130 } 122 131 123 132 UnlinkedEvalCodeBlock* CodeCache::getEvalCodeBlock(VM& vm, EvalExecutable* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) 124 133 { 125 return get CodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, strictness, debuggerMode, profilerMode, error);134 return getGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, strictness, debuggerMode, profilerMode, error); 126 135 } 127 136 … … 133 142 return jsCast<UnlinkedFunctionExecutable*>(addResult.iterator->value.cell.get()); 134 143 135 RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error); 144 JSTextPosition positionBeforeLastNewline; 145 RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error, &positionBeforeLastNewline); 136 146 if (!program) { 137 147 ASSERT(error.m_type != ParserError::ErrorNone); … … 148 158 RELEASE_ASSERT(funcExpr->isFuncExprNode()); 149 159 FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body(); 160 body->setEndPosition(positionBeforeLastNewline); 150 161 ASSERT(body); 151 162 ASSERT(body->ident().isNull()); 152 163 153 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, body );164 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, body, true); 154 165 functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string())); 155 166 -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r153221 r159520 254 254 255 255 template <class UnlinkedCodeBlockType, class ExecutableType> 256 UnlinkedCodeBlockType* get CodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);256 UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&); 257 257 258 258 CodeCacheMap m_sourceCode; -
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r158459 r159520 181 181 182 182 ASSERT(vm->heap.isDeferred()); 183 183 ASSERT(startColumn() != UINT_MAX); 184 ASSERT(endColumn() != UINT_MAX); 185 184 186 if (classInfo() == EvalExecutable::info()) { 185 187 EvalExecutable* executable = jsCast<EvalExecutable*>(this); … … 210 212 executable->m_unlinkedExecutable->codeBlockFor( 211 213 *vm, executable->m_source, kind, debuggerMode, profilerMode, error); 212 recordParse(executable->m_unlinkedExecutable->features(), executable->m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn() );214 recordParse(executable->m_unlinkedExecutable->features(), executable->m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn(), endColumn()); 213 215 if (!unlinkedCodeBlock) { 214 216 exception = vm->throwException( … … 363 365 const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionExecutable) }; 364 366 365 FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn )367 FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, bool bodyIncludesBraces) 366 368 : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext()) 367 369 , m_unlinkedExecutable(vm, this, unlinkedExecutable) 370 , m_bodyIncludesBraces(bodyIncludesBraces) 368 371 { 369 372 RELEASE_ASSERT(!source.isNull()); … … 371 374 m_firstLine = firstLine; 372 375 m_lastLine = lastLine; 376 ASSERT(startColumn != UINT_MAX); 377 ASSERT(endColumn != UINT_MAX); 373 378 m_startColumn = startColumn; 379 m_endColumn = endColumn; 374 380 } 375 381 … … 455 461 456 462 JSObject* exception = 0; 457 UnlinkedProgramCodeBlock* unlinkedCode = globalObject->createProgramCodeBlock(callFrame, this, &exception);463 UnlinkedProgramCodeBlock* unlinkedCodeBlock = globalObject->createProgramCodeBlock(callFrame, this, &exception); 458 464 if (exception) 459 465 return exception; 460 466 461 m_unlinkedProgramCodeBlock.set(vm, this, unlinkedCode );467 m_unlinkedProgramCodeBlock.set(vm, this, unlinkedCodeBlock); 462 468 463 469 BatchedTransitionOptimizer optimizer(vm, globalObject); 464 470 465 const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCode ->variableDeclarations();466 const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCode ->functionDeclarations();471 const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCodeBlock->variableDeclarations(); 472 const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCodeBlock->functionDeclarations(); 467 473 468 474 for (size_t i = 0; i < functionDeclarations.size(); ++i) { … … 565 571 FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& name, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception) 566 572 { 567 UnlinkedFunctionExecutable* unlinked Function= UnlinkedFunctionExecutable::fromGlobalCode(name, exec, debugger, source, exception);568 if (!unlinked Function)573 UnlinkedFunctionExecutable* unlinkedExecutable = UnlinkedFunctionExecutable::fromGlobalCode(name, exec, debugger, source, exception); 574 if (!unlinkedExecutable) 569 575 return 0; 570 unsigned firstLine = source.firstLine() + unlinkedFunction->firstLineOffset(); 571 unsigned startOffset = source.startOffset() + unlinkedFunction->startOffset(); 572 unsigned startColumn = source.startColumn(); 573 unsigned sourceLength = unlinkedFunction->sourceLength(); 574 SourceCode functionSource(source.provider(), startOffset, startOffset + sourceLength, firstLine, startColumn); 575 return FunctionExecutable::create(exec->vm(), functionSource, unlinkedFunction, firstLine, unlinkedFunction->lineCount(), startColumn); 576 unsigned lineCount = unlinkedExecutable->lineCount(); 577 unsigned firstLine = source.firstLine() + unlinkedExecutable->firstLineOffset(); 578 unsigned startOffset = source.startOffset() + unlinkedExecutable->startOffset(); 579 580 // We don't have any owner executable. The source string is effectively like a global 581 // string (like in the handling of eval). Hence, the startColumn is always 1. 582 unsigned startColumn = 1; 583 unsigned sourceLength = unlinkedExecutable->sourceLength(); 584 bool endColumnIsOnStartLine = !lineCount; 585 // The unlinkedBodyEndColumn is based-0. Hence, we need to add 1 to it. But if the 586 // endColumn is on the startLine, then we need to subtract back the adjustment for 587 // the open brace resulting in an adjustment of 0. 588 unsigned endColumnExcludingBraces = unlinkedExecutable->unlinkedBodyEndColumn() + (endColumnIsOnStartLine ? 0 : 1); 589 unsigned startOffsetExcludingOpenBrace = startOffset + 1; 590 unsigned endOffsetExcludingCloseBrace = startOffset + sourceLength - 1; 591 SourceCode bodySource(source.provider(), startOffsetExcludingOpenBrace, endOffsetExcludingCloseBrace, firstLine, startColumn); 592 593 return FunctionExecutable::create(exec->vm(), bodySource, unlinkedExecutable, firstLine, firstLine + lineCount, startColumn, endColumnExcludingBraces, false); 576 594 } 577 595 -
trunk/Source/JavaScriptCore/runtime/Executable.h
r158681 r159520 94 94 CodeBlockHash hashFor(CodeSpecializationKind) const; 95 95 96 bool isEvalExecutable() 97 { 98 return structure()->typeInfo().type() == EvalExecutableType; 99 } 96 100 bool isFunctionExecutable() 97 101 { 98 102 return structure()->typeInfo().type() == FunctionExecutableType; 103 } 104 bool isProgramExecutable() 105 { 106 return structure()->typeInfo().type() == ProgramExecutableType; 99 107 } 100 108 … … 356 364 , m_features(isInStrictContext ? StrictModeFeature : 0) 357 365 , m_neverInline(false) 366 , m_startColumn(UINT_MAX) 367 , m_endColumn(UINT_MAX) 358 368 { 359 369 } … … 364 374 , m_features(isInStrictContext ? StrictModeFeature : 0) 365 375 , m_neverInline(false) 376 , m_startColumn(UINT_MAX) 377 , m_endColumn(UINT_MAX) 366 378 { 367 379 } … … 379 391 int lastLine() const { return m_lastLine; } 380 392 unsigned startColumn() const { return m_startColumn; } 393 unsigned endColumn() const { return m_endColumn; } 381 394 382 395 bool usesEval() const { return m_features & EvalFeature; } … … 396 409 DECLARE_INFO; 397 410 398 void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine, unsigned startColumn )411 void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine, unsigned startColumn, unsigned endColumn) 399 412 { 400 413 m_features = features; … … 402 415 m_firstLine = firstLine; 403 416 m_lastLine = lastLine; 417 ASSERT(startColumn != UINT_MAX); 404 418 m_startColumn = startColumn; 419 ASSERT(endColumn != UINT_MAX); 420 m_endColumn = endColumn; 405 421 } 406 422 … … 438 454 int m_lastLine; 439 455 unsigned m_startColumn; 456 unsigned m_endColumn; 440 457 }; 441 458 … … 550 567 typedef ScriptExecutable Base; 551 568 552 static FunctionExecutable* create(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn )553 { 554 FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn );569 static FunctionExecutable* create(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, bool bodyIncludesBraces = true) 570 { 571 FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn, bodyIncludesBraces); 555 572 executable->finishCreation(vm); 556 573 return executable; … … 639 656 void clearCode(); 640 657 658 bool bodyIncludesBraces() const { return m_bodyIncludesBraces; } 659 641 660 private: 642 FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, unsigned lastLine, unsigned startColumn );661 FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, bool bodyIncludesBraces); 643 662 644 663 bool isCompiling() … … 659 678 RefPtr<FunctionCodeBlock> m_codeBlockForCall; 660 679 RefPtr<FunctionCodeBlock> m_codeBlockForConstruct; 680 bool m_bodyIncludesBraces; 661 681 }; 662 682 -
trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
r156624 r159520 94 94 String program; 95 95 if (args.isEmpty()) 96 program = ASCIILiteral("(function() { 96 program = ASCIILiteral("(function() {\n})"); 97 97 else if (args.size() == 1) 98 program = makeString("(function() { 98 program = makeString("(function() {", args.at(0).toString(exec)->value(exec), "\n})"); 99 99 else { 100 100 StringBuilder builder; … … 105 105 builder.append(args.at(i).toString(exec)->value(exec)); 106 106 } 107 builder.appendLiteral(") { 107 builder.appendLiteral(") {"); 108 108 builder.append(args.at(args.size() - 1).toString(exec)->value(exec)); 109 109 builder.appendLiteral("\n})"); -
trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp
r156624 r159520 86 86 87 87 // Compatibility hack for the Optimost JavaScript library. (See <rdar://problem/6595040>.) 88 static inline void insertSemicolonIfNeeded(String& functionBody) 89 { 88 static inline void insertSemicolonIfNeeded(String& functionBody, bool bodyIncludesBraces) 89 { 90 if (!bodyIncludesBraces) 91 functionBody = makeString("{ ", functionBody, "}"); 92 90 93 ASSERT(functionBody[0] == '{'); 91 94 ASSERT(functionBody[functionBody.length() - 1] == '}'); … … 110 113 FunctionExecutable* executable = function->jsExecutable(); 111 114 String sourceString = executable->source().toString(); 112 insertSemicolonIfNeeded(sourceString );115 insertSemicolonIfNeeded(sourceString, executable->bodyIncludesBraces()); 113 116 return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString)); 114 117 } -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r159395 r159520 739 739 DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff; 740 740 ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff; 741 UnlinkedProgramCodeBlock* unlinkedCode = vm().codeCache()->getProgramCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error);741 UnlinkedProgramCodeBlock* unlinkedCodeBlock = vm().codeCache()->getProgramCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error); 742 742 743 743 if (hasDebugger()) … … 749 749 } 750 750 751 return unlinkedCode ;751 return unlinkedCodeBlock; 752 752 } 753 753 … … 758 758 DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff; 759 759 ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff; 760 UnlinkedEvalCodeBlock* unlinkedCode = vm().codeCache()->getEvalCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error);760 UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error); 761 761 762 762 if (hasDebugger()) … … 768 768 } 769 769 770 return unlinkedCode ;770 return unlinkedCodeBlock; 771 771 } 772 772 -
trunk/Source/WebCore/ChangeLog
r159519 r159520 1 2013-11-19 Mark Lam <mark.lam@apple.com> 2 3 Add tracking of endColumn for Executables. 4 https://bugs.webkit.org/show_bug.cgi?id=124245. 5 6 Reviewed by Geoffrey Garen. 7 8 Test: js/dom/script-start-end-locations.html 9 10 * ForwardingHeaders/bytecode: Added. 11 * ForwardingHeaders/bytecode/CodeBlock.h: Added. 12 * WebCore.exp.in: 13 * testing/Internals.cpp: 14 (WebCore::GetCallerCodeBlockFunctor::GetCallerCodeBlockFunctor): 15 (WebCore::GetCallerCodeBlockFunctor::operator()): 16 (WebCore::GetCallerCodeBlockFunctor::codeBlock): 17 (WebCore::Internals::parserMetaData): 18 * testing/Internals.h: 19 * testing/Internals.idl: 20 1 21 2013-11-15 Jer Noble <jer.noble@apple.com> 2 22 -
trunk/Source/WebCore/WebCore.exp.in
r159511 r159520 825 825 __ZN7WebCore22RuntimeEnabledFeatures14sharedFeaturesEv 826 826 __ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv 827 __ZN7WebCore22ScriptExecutionContext2vmEv 827 828 __ZN7WebCore22StorageEventDispatcher34dispatchLocalStorageEventsToFramesERNS_9PageGroupERKN3WTF6VectorINS3_6RefPtrINS_5FrameEEELm0ENS3_15CrashOnOverflowEEERKNS3_6StringESE_SE_SE_PNS_14SecurityOriginE 828 829 __ZN7WebCore22URLWithUserTypedStringEP8NSStringP5NSURL -
trunk/Source/WebCore/testing/Internals.cpp
r159188 r159520 96 96 #include "ViewportArguments.h" 97 97 #include "WorkerThread.h" 98 #include <bytecode/CodeBlock.h> 99 #include <runtime/JSCJSValue.h> 98 100 #include <wtf/text/CString.h> 99 101 #include <wtf/text/StringBuffer.h> … … 158 160 #include "MockMediaPlayerMediaSource.h" 159 161 #endif 162 163 using JSC::CodeBlock; 164 using JSC::FunctionExecutable; 165 using JSC::JSFunction; 166 using JSC::JSValue; 167 using JSC::ScriptExecutable; 168 using JSC::StackVisitor; 160 169 161 170 namespace WebCore { … … 1251 1260 inspectorController->didCancelFrame(); 1252 1261 #endif 1262 } 1263 1264 class GetCallerCodeBlockFunctor { 1265 public: 1266 GetCallerCodeBlockFunctor() 1267 : m_iterations(0) 1268 , m_codeBlock(0) 1269 { 1270 } 1271 1272 StackVisitor::Status operator()(StackVisitor& visitor) 1273 { 1274 ++m_iterations; 1275 if (m_iterations < 2) 1276 return StackVisitor::Continue; 1277 1278 m_codeBlock = visitor->codeBlock(); 1279 return StackVisitor::Done; 1280 } 1281 1282 CodeBlock* codeBlock() const { return m_codeBlock; } 1283 1284 private: 1285 int m_iterations; 1286 CodeBlock* m_codeBlock; 1287 }; 1288 1289 String Internals::parserMetaData(ScriptValue value) 1290 { 1291 JSC::VM* vm = contextDocument()->vm(); 1292 JSC::ExecState* exec = vm->topCallFrame; 1293 JSC::JSValue code = value.jsValue(); 1294 ScriptExecutable* executable; 1295 1296 if (!code || code.isNull() || code.isUndefined()) { 1297 GetCallerCodeBlockFunctor iter; 1298 exec->iterate(iter); 1299 CodeBlock* codeBlock = iter.codeBlock(); 1300 executable = codeBlock->ownerExecutable(); 1301 } else if (code.isFunction()) { 1302 JSFunction* funcObj = JSC::jsCast<JSFunction*>(code.toObject(exec)); 1303 executable = funcObj->jsExecutable(); 1304 } else 1305 return String(); 1306 1307 unsigned startLine = executable->lineNo(); 1308 unsigned startColumn = executable->startColumn(); 1309 unsigned endLine = executable->lastLine(); 1310 unsigned endColumn = executable->endColumn(); 1311 1312 StringBuilder result; 1313 1314 if (executable->isFunctionExecutable()) { 1315 FunctionExecutable* funcExecutable = reinterpret_cast<FunctionExecutable*>(executable); 1316 String inferredName = funcExecutable->inferredName().string(); 1317 result.append("function \""); 1318 result.append(inferredName); 1319 result.append("\""); 1320 } else if (executable->isEvalExecutable()) 1321 result.append("eval"); 1322 else { 1323 ASSERT(executable->isProgramExecutable()); 1324 result.append("program"); 1325 } 1326 1327 result.append(" { "); 1328 result.appendNumber(startLine); 1329 result.append(":"); 1330 result.appendNumber(startColumn); 1331 result.append(" - "); 1332 result.appendNumber(endLine); 1333 result.append(":"); 1334 result.appendNumber(endColumn); 1335 result.append(" }"); 1336 1337 return result.toString(); 1253 1338 } 1254 1339 -
trunk/Source/WebCore/testing/Internals.h
r158853 r159520 32 32 #include "ExceptionCodePlaceholder.h" 33 33 #include "NodeList.h" 34 #include "ScriptValue.h" 34 35 #include <runtime/ArrayBuffer.h> 35 36 #include <runtime/Float32Array.h> … … 181 182 void emitInspectorDidCancelFrame(); 182 183 184 String parserMetaData(ScriptValue = ScriptValue()); 185 183 186 bool hasSpellingMarker(int from, int length, ExceptionCode&); 184 187 bool hasGrammarMarker(int from, int length, ExceptionCode&); -
trunk/Source/WebCore/testing/Internals.idl
r158853 r159520 139 139 void emitInspectorDidCancelFrame(); 140 140 141 // Calling parserMetaData() with no arguments gets the metadata for the script of the current scope. 142 DOMString parserMetaData(optional any func); 143 141 144 [RaisesException] boolean hasSpellingMarker(long from, long length); 142 145 [RaisesException] boolean hasGrammarMarker(long from, long length); -
trunk/Source/WebKit/ChangeLog
r159485 r159520 1 2013-11-19 Mark Lam <mark.lam@apple.com> 2 3 Add tracking of endColumn for Executables. 4 https://bugs.webkit.org/show_bug.cgi?id=124245. 5 6 Reviewed by Geoffrey Garen. 7 8 * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: 9 - Added an exported symbol to make the Win32 build happy. The Win64 symbol 10 is currently a copy of the Win32 one. It'll need to be updated if the 11 mangled symbol is different for Win64. 12 1 13 2013-11-18 Mark Rowe <mrowe@apple.com> 2 14 -
trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
r159073 r159520 463 463 symbolWithPointer(?cacheStorage@WebCore@@YAAAVApplicationCacheStorage@1@XZ, ?cacheStorage@WebCore@@YAAEAVApplicationCacheStorage@1@XZ) 464 464 symbolWithPointer(?setDefaultOriginQuota@ApplicationCacheStorage@WebCore@@QAEX_J@Z, ?setDefaultOriginQuota@ApplicationCacheStorage@WebCore@@QEAAX_J@Z) 465 symbolWithPointer(?vm@ScriptExecutionContext@WebCore@@QAEPAVVM@JSC@@XZ, ?vm@ScriptExecutionContext@WebCore@@QAEPAVVM@JSC@@XZ)
Note: See TracChangeset
for help on using the changeset viewer.