Title: [181673] trunk
Revision
181673
Author
[email protected]
Date
2015-03-17 17:07:24 -0700 (Tue, 17 Mar 2015)

Log Message

Function bodies should always include braces
https://bugs.webkit.org/show_bug.cgi?id=142795

Reviewed by Michael Saboff.

Source/_javascript_Core:

Having a mode for excluding the opening and closing braces from a function
body was unnecessary and confusing.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock): Adopt the new one true linking function.

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::link):
(JSC::UnlinkedFunctionExecutable::codeBlockFor): No need to pass through
a boolean: there is only one kind of function now.

(JSC::UnlinkedFunctionExecutable::linkInsideExecutable): Deleted.
(JSC::UnlinkedFunctionExecutable::linkGlobalCode): Deleted. Let's only
have one way to do things. This removes the old mode that would pretend
that a function always started at column 1. That pretense was not true:
an attribute event listener does not necessarily start at column 1.

* bytecode/UnlinkedCodeBlock.h:
* generate-js-builtins: Adopt the new one true linking function.

* parser/Parser.h:
(JSC::Parser<LexerType>::parse):
(JSC::parse): needsReparsingAdjustment is always true now, so I removed it.

* runtime/Executable.cpp:
(JSC::ScriptExecutable::newCodeBlockFor):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::ProgramExecutable::initializeGlobalProperties):
(JSC::FunctionExecutable::fromGlobalCode):
* runtime/Executable.h:
(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::bodyIncludesBraces): Deleted. Removed unused stuff.

* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck): Always provide a
leading space because that's what this function's comment says is required
for web compatibility. We used to fake this up after the fact when
stringifying, based on the bodyIncludesBraces flag, but that flag is gone now.

* runtime/FunctionPrototype.cpp:
(JSC::insertSemicolonIfNeeded):
(JSC::functionProtoFuncToString): No need to add braces and/or a space
after the fact -- we always have them now.

LayoutTests:

Updated these test results to reflect the fact that _javascript_Core now
honors the source code text positions provided by WebCore, even for 
attribute event handlers.

Unfortunately, the column numbers we used to report were wrong, and they
are still wrong now. The old column numbers were wrong because we would
always pretend that they started on column 1. The new column numbers
are wrong because WebCore records the column number after it finishes
parsing the element, rather than while it is parsing the event listener
attribute.

* fast/events/window-onerror2-expected.txt:
* fast/profiler/dead-time-expected.txt:
* fast/profiler/inline-event-handler-expected.txt:
* fast/profiler/stop-profiling-after-setTimeout-expected.txt:
* js/dom/script-start-end-locations-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181672 => 181673)


--- trunk/LayoutTests/ChangeLog	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/ChangeLog	2015-03-18 00:07:24 UTC (rev 181673)
@@ -1,3 +1,27 @@
+2015-03-17  Geoffrey Garen  <[email protected]>
+
+        Function bodies should always include braces
+        https://bugs.webkit.org/show_bug.cgi?id=142795
+
+        Reviewed by Michael Saboff.
+
+        Updated these test results to reflect the fact that _javascript_Core now
+        honors the source code text positions provided by WebCore, even for 
+        attribute event handlers.
+
+        Unfortunately, the column numbers we used to report were wrong, and they
+        are still wrong now. The old column numbers were wrong because we would
+        always pretend that they started on column 1. The new column numbers
+        are wrong because WebCore records the column number after it finishes
+        parsing the element, rather than while it is parsing the event listener
+        attribute.
+
+        * fast/events/window-onerror2-expected.txt:
+        * fast/profiler/dead-time-expected.txt:
+        * fast/profiler/inline-event-handler-expected.txt:
+        * fast/profiler/stop-profiling-after-setTimeout-expected.txt:
+        * js/dom/script-start-end-locations-expected.txt:
+
 2015-03-17  Zalan Bujtas  <[email protected]>
 
         Simple line layout: Split fragments on renderer boundary on the fly.

Modified: trunk/LayoutTests/fast/events/window-onerror2-expected.txt (181672 => 181673)


--- trunk/LayoutTests/fast/events/window-onerror2-expected.txt	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/fast/events/window-onerror2-expected.txt	2015-03-18 00:07:24 UTC (rev 181673)
@@ -1,6 +1,6 @@
 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: 66
+Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 167
 Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html, line: 29, column: 47
 

Modified: trunk/LayoutTests/fast/profiler/dead-time-expected.txt (181672 => 181673)


--- trunk/LayoutTests/fast/profiler/dead-time-expected.txt	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/fast/profiler/dead-time-expected.txt	2015-03-18 00:07:24 UTC (rev 181673)
@@ -4,7 +4,7 @@
 
 Profile title: Dead time in profile.
 Thread_1 (no file) (line 0:0)
-   onload dead-time.html (line 21:1)
+   onload dead-time.html (line 21:45)
       startTest dead-time.html (line 13:1)
          setTimeout (no file) (line 0:0)
    (program) dead-time.html (line 1:1)

Modified: trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt (181672 => 181673)


--- trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt	2015-03-18 00:07:24 UTC (rev 181673)
@@ -7,7 +7,7 @@
    startTest inline-event-handler.html (line 11:1)
       getElementById (no file) (line 0:0)
       click (no file) (line 0:0)
-         onclick inline-event-handler.html (line 31:1)
+         onclick inline-event-handler.html (line 31:127)
             eventListener inline-event-handler.html (line 17:26)
                anonymousFunction profiler-test-JS-resources.js (line 29:37)
                   insertNewText profiler-test-JS-resources.js (line 17:26)

Modified: trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt (181672 => 181673)


--- trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt	2015-03-18 00:07:24 UTC (rev 181673)
@@ -4,7 +4,7 @@
 
 Profile title: Stop profiling from a timeout
 Thread_1 (no file) (line 0:0)
-   onload stop-profiling-after-setTimeout.html (line 21:1)
+   onload stop-profiling-after-setTimeout.html (line 21:45)
       startTest stop-profiling-after-setTimeout.html (line 13:1)
          setTimeout (no file) (line 0:0)
    (program) stop-profiling-after-setTimeout.html (line 1:1)

Modified: trunk/LayoutTests/js/dom/script-start-end-locations-expected.txt (181672 => 181673)


--- trunk/LayoutTests/js/dom/script-start-end-locations-expected.txt	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/LayoutTests/js/dom/script-start-end-locations-expected.txt	2015-03-18 00:07:24 UTC (rev 181673)
@@ -243,32 +243,32 @@
 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 }
+function "" { 1:16 - 1:245 }
+function "nf1a" { 1:77 - 1:236 }
+function "nf1b" { 1:107 - 1:226 }
+function "nf1c" { 1:137 - 1:216 }
 eval { 1:1 - 1:56 }
-function "" { 1:1 - 17:8 }
+function "" { 1:16 - 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 }
+function "" { 1:16 - 1:245 }
+function "nf1a" { 1:77 - 1:236 }
+function "nf1b" { 1:107 - 1:226 }
+function "nf1c" { 1:137 - 1:216 }
 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 }
+function "" { 1:16 - 1:254 }
+function "nfi1a" { 1:78 - 1:244 }
+function "nfi1b" { 1:110 - 1:233 }
+function "nfi1c" { 1:142 - 1:222 }
 eval { 1:1 - 1:56 }
-function "" { 1:1 - 17:8 }
+function "" { 1:16 - 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 "" { 1:16 - 17:9 }
 function "nfi2a" { 4:22 - 15:5 }
 function "nfi2b" { 6:26 - 13:9 }
 function "nfi2c" { 8:30 - 11:13 }

Modified: trunk/Source/_javascript_Core/ChangeLog (181672 => 181673)


--- trunk/Source/_javascript_Core/ChangeLog	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-03-18 00:07:24 UTC (rev 181673)
@@ -1,3 +1,55 @@
+2015-03-17  Geoffrey Garen  <[email protected]>
+
+        Function bodies should always include braces
+        https://bugs.webkit.org/show_bug.cgi?id=142795
+
+        Reviewed by Michael Saboff.
+
+        Having a mode for excluding the opening and closing braces from a function
+        body was unnecessary and confusing.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock): Adopt the new one true linking function.
+
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::generateFunctionCodeBlock):
+        (JSC::UnlinkedFunctionExecutable::link):
+        (JSC::UnlinkedFunctionExecutable::codeBlockFor): No need to pass through
+        a boolean: there is only one kind of function now.
+
+        (JSC::UnlinkedFunctionExecutable::linkInsideExecutable): Deleted.
+        (JSC::UnlinkedFunctionExecutable::linkGlobalCode): Deleted. Let's only
+        have one way to do things. This removes the old mode that would pretend
+        that a function always started at column 1. That pretense was not true:
+        an attribute event listener does not necessarily start at column 1.
+
+        * bytecode/UnlinkedCodeBlock.h:
+        * generate-js-builtins: Adopt the new one true linking function.
+
+        * parser/Parser.h:
+        (JSC::Parser<LexerType>::parse):
+        (JSC::parse): needsReparsingAdjustment is always true now, so I removed it.
+
+        * runtime/Executable.cpp:
+        (JSC::ScriptExecutable::newCodeBlockFor):
+        (JSC::FunctionExecutable::FunctionExecutable):
+        (JSC::ProgramExecutable::initializeGlobalProperties):
+        (JSC::FunctionExecutable::fromGlobalCode):
+        * runtime/Executable.h:
+        (JSC::FunctionExecutable::create):
+        (JSC::FunctionExecutable::bodyIncludesBraces): Deleted. Removed unused stuff.
+
+        * runtime/FunctionConstructor.cpp:
+        (JSC::constructFunctionSkippingEvalEnabledCheck): Always provide a
+        leading space because that's what this function's comment says is required
+        for web compatibility. We used to fake this up after the fact when
+        stringifying, based on the bodyIncludesBraces flag, but that flag is gone now.
+
+        * runtime/FunctionPrototype.cpp:
+        (JSC::insertSemicolonIfNeeded):
+        (JSC::functionProtoFuncToString): No need to add braces and/or a space
+        after the fact -- we always have them now.
+
 2015-03-17  Mark Lam  <[email protected]>
 
         Refactor execution time limit tests out of testapi.c.

Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -72,7 +72,7 @@
         &m_vm, source, 0, Identifier(), builtinMode, 
         JSParserStrictMode::NotStrict, 
         JSParserCodeType::Program,
-        error, &positionBeforeLastNewline, false, constructorKind);
+        error, &positionBeforeLastNewline, constructorKind);
 
     if (!program) {
         dataLog("Fatal error compiling builtin function '", name.string(), "': ", error.message());

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -1753,7 +1753,7 @@
         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
         if (vm()->typeProfiler() || vm()->controlFlowProfiler())
             vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
-        m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->linkInsideExecutable(*m_vm, ownerExecutable->source()));
+        m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
     }
 
     m_functionExprs.resizeToFit(unlinkedCodeBlock->numberOfFunctionExprs());
@@ -1761,7 +1761,7 @@
         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i);
         if (vm()->typeProfiler() || vm()->controlFlowProfiler())
             vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
-        m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->linkInsideExecutable(*m_vm, ownerExecutable->source()));
+        m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
     }
 
     if (unlinkedCodeBlock->hasRareData()) {

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -52,13 +52,13 @@
 static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(
     VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source,
     CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode,
-    UnlinkedFunctionKind functionKind, bool bodyIncludesBraces, ParserError& error)
+    UnlinkedFunctionKind functionKind, ParserError& error)
 {
     JSParserBuiltinMode builtinMode = executable->isBuiltinFunction() ? JSParserBuiltinMode::Builtin : JSParserBuiltinMode::NotBuiltin;
     JSParserStrictMode strictMode = executable->isInStrictContext() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;
     std::unique_ptr<FunctionNode> function = parse<FunctionNode>(
         &vm, source, executable->parameters(), executable->name(), builtinMode,
-        strictMode, JSParserCodeType::Function, error, 0, bodyIncludesBraces);
+        strictMode, JSParserCodeType::Function, error, 0);
 
     if (!function) {
         ASSERT(error.isValid());
@@ -129,12 +129,13 @@
     visitor.append(&thisObject->m_symbolTableForConstruct);
 }
 
-FunctionExecutable* UnlinkedFunctionExecutable::linkInsideExecutable(VM& vm, const SourceCode& ownerSource)
+FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource)
 {
     SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
     unsigned firstLine = source.firstLine() + m_firstLineOffset;
     unsigned startOffset = source.startOffset() + m_startOffset;
 
+    // Adjust to one-based indexing.
     bool startColumnIsOnFirstSourceLine = !m_firstLineOffset;
     unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1);
     bool endColumnIsOnStartLine = !m_lineCount;
@@ -144,27 +145,6 @@
     return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumn);
 }
 
-FunctionExecutable* UnlinkedFunctionExecutable::linkGlobalCode(VM& vm, const SourceCode& source)
-{
-    ASSERT(!m_sourceOverride);
-    unsigned firstLine = source.firstLine() + m_firstLineOffset;
-    unsigned startOffset = source.startOffset() + m_startOffset;
-
-    // We don't have any owner executable. The source string is effectively like a global
-    // string (like in the handling of eval). Hence, the startColumn is always 1.
-    unsigned startColumn = 1;
-    bool endColumnIsOnStartLine = !m_lineCount;
-    // The unlinkedBodyEndColumn is 0-based. Hence, we need to add 1 to it. But if the
-    // endColumn is on the startLine, then we need to subtract back the adjustment for
-    // the open brace resulting in an adjustment of 0.
-    unsigned endColumnExcludingBraces = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? 0 : 1);
-    unsigned startOffsetExcludingOpenBrace = startOffset + 1;
-    unsigned endOffsetExcludingCloseBrace = startOffset + m_sourceLength - 1;
-    SourceCode code(source.provider(), startOffsetExcludingOpenBrace, endOffsetExcludingCloseBrace, firstLine, startColumn);
-
-    return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumnExcludingBraces, false);
-}
-
 UnlinkedFunctionExecutable* UnlinkedFunctionExecutable::fromGlobalCode(const Identifier& name, ExecState& exec, const SourceCode& source, JSObject*& exception)
 {
     ParserError error;
@@ -186,8 +166,7 @@
 
 UnlinkedFunctionCodeBlock* UnlinkedFunctionExecutable::codeBlockFor(
     VM& vm, const SourceCode& source, CodeSpecializationKind specializationKind, 
-    DebuggerMode debuggerMode, ProfilerMode profilerMode, bool bodyIncludesBraces, 
-    ParserError& error)
+    DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
 {
     switch (specializationKind) {
     case CodeForCall:
@@ -203,7 +182,7 @@
     UnlinkedFunctionCodeBlock* result = generateFunctionCodeBlock(
         vm, this, source, specializationKind, debuggerMode, profilerMode, 
         isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, 
-        bodyIncludesBraces, error);
+        error);
     
     if (error.isValid())
         return nullptr;

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (181672 => 181673)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-03-18 00:07:24 UTC (rev 181673)
@@ -135,12 +135,11 @@
 
     UnlinkedFunctionCodeBlock* codeBlockFor(
         VM&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, 
-        bool bodyIncludesBraces, ParserError&);
+        ParserError&);
 
     static UnlinkedFunctionExecutable* fromGlobalCode(const Identifier&, ExecState&, const SourceCode&, JSObject*& exception);
 
-    FunctionExecutable* linkInsideExecutable(VM&, const SourceCode&);
-    FunctionExecutable* linkGlobalCode(VM&, const SourceCode&);
+    FunctionExecutable* link(VM&, const SourceCode&);
 
     void clearCodeForRecompilation()
     {

Modified: trunk/Source/_javascript_Core/generate-js-builtins (181672 => 181673)


--- trunk/Source/_javascript_Core/generate-js-builtins	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/generate-js-builtins	2015-03-18 00:07:24 UTC (rev 181673)
@@ -267,7 +267,7 @@
 #define JSC_DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
 FunctionExecutable* codeName##Generator(VM& vm) \\
 { \\
-    return vm.builtinExecutables()->codeName##Executable()->linkGlobalCode(vm, vm.builtinExecutables()->codeName##Source()); \\
+    return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source()); \\
 }
 
 JSC_FOREACH_BUILTIN(JSC_DEFINE_BUILTIN_GENERATOR)

Modified: trunk/Source/_javascript_Core/parser/Parser.h (181672 => 181673)


--- trunk/Source/_javascript_Core/parser/Parser.h	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2015-03-18 00:07:24 UTC (rev 181673)
@@ -433,7 +433,7 @@
     ~Parser();
 
     template <class ParsedNode>
-    std::unique_ptr<ParsedNode> parse(ParserError&, bool needReparsingAdjustment);
+    std::unique_ptr<ParsedNode> parse(ParserError&);
 
     JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
     Vector<RefPtr<StringImpl>>&& closedVariables() { return WTF::move(m_closedVariables); }
@@ -904,12 +904,12 @@
 
 template <typename LexerType>
 template <class ParsedNode>
-std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, bool needReparsingAdjustment)
+std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error)
 {
     int errLine;
     String errMsg;
 
-    if (ParsedNode::scopeIsFunction && needReparsingAdjustment)
+    if (ParsedNode::scopeIsFunction)
         m_lexer->setIsReparsing();
 
     m_sourceElements = 0;
@@ -987,8 +987,7 @@
     VM* vm, const SourceCode& source, FunctionParameters* parameters,
     const Identifier& name, JSParserBuiltinMode builtinMode,
     JSParserStrictMode strictMode, JSParserCodeType codeType,
-    ParserError& error, JSTextPosition* positionBeforeLastNewline = 0, 
-    bool needReparsingAdjustment = false, 
+    ParserError& error, JSTextPosition* positionBeforeLastNewline = 0,
     ConstructorKind defaultConstructorKind = ConstructorKind::None)
 {
     SamplingRegion samplingRegion("Parsing");
@@ -996,7 +995,7 @@
     ASSERT(!source.provider()->source().isNull());
     if (source.provider()->source().is8Bit()) {
         Parser<Lexer<LChar>> parser(vm, source, parameters, name, builtinMode, strictMode, codeType, defaultConstructorKind);
-        std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
+        std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error);
         if (positionBeforeLastNewline)
             *positionBeforeLastNewline = parser.positionBeforeLastNewline();
         if (builtinMode == JSParserBuiltinMode::Builtin) {
@@ -1008,7 +1007,7 @@
         return result;
     }
     Parser<Lexer<UChar>> parser(vm, source, parameters, name, builtinMode, strictMode, codeType);
-    std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
+    std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error);
     if (positionBeforeLastNewline)
         *positionBeforeLastNewline = parser.positionBeforeLastNewline();
     return result;

Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/runtime/Executable.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -237,7 +237,7 @@
     ProfilerMode profilerMode = globalObject->hasProfiler() ? ProfilerOn : ProfilerOff;
     UnlinkedFunctionCodeBlock* unlinkedCodeBlock =
         executable->m_unlinkedExecutable->codeBlockFor(
-            *vm, executable->m_source, kind, debuggerMode, profilerMode, executable->bodyIncludesBraces(), error);
+            *vm, executable->m_source, kind, debuggerMode, profilerMode, error);
     recordParse(executable->m_unlinkedExecutable->features(), executable->m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn(), endColumn()); 
     if (!unlinkedCodeBlock) {
         exception = vm->throwException(
@@ -396,11 +396,9 @@
 
 FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, 
     UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, 
-    unsigned lastLine, unsigned startColumn, unsigned endColumn, 
-    bool bodyIncludesBraces)
+    unsigned lastLine, unsigned startColumn, unsigned endColumn)
     : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext())
     , m_unlinkedExecutable(vm, this, unlinkedExecutable)
-    , m_bodyIncludesBraces(bodyIncludesBraces)
 {
     RELEASE_ASSERT(!source.isNull());
     ASSERT(source.length());
@@ -508,7 +506,7 @@
 
     for (size_t i = 0; i < functionDeclarations.size(); ++i) {
         UnlinkedFunctionExecutable* unlinkedFunctionExecutable = functionDeclarations[i].second.get();
-        JSValue value = JSFunction::create(vm, unlinkedFunctionExecutable->linkInsideExecutable(vm, m_source), scope);
+        JSValue value = JSFunction::create(vm, unlinkedFunctionExecutable->link(vm, m_source), scope);
         globalObject->addFunction(callFrame, functionDeclarations[i].first, value);
         if (vm.typeProfiler() || vm.controlFlowProfiler()) {
             vm.functionHasExecutedCache()->insertUnexecutedRange(sourceID(), 
@@ -614,7 +612,7 @@
     UnlinkedFunctionExecutable* unlinkedExecutable = UnlinkedFunctionExecutable::fromGlobalCode(name, exec, source, exception);
     if (!unlinkedExecutable)
         return nullptr;
-    return unlinkedExecutable->linkGlobalCode(exec.vm(), source);
+    return unlinkedExecutable->link(exec.vm(), source);
 }
 
 String FunctionExecutable::paramString() const

Modified: trunk/Source/_javascript_Core/runtime/Executable.h (181672 => 181673)


--- trunk/Source/_javascript_Core/runtime/Executable.h	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/runtime/Executable.h	2015-03-18 00:07:24 UTC (rev 181673)
@@ -543,10 +543,9 @@
 
     static FunctionExecutable* create(
         VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, 
-        unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, 
-        bool bodyIncludesBraces = true)
+        unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn)
     {
-        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn, bodyIncludesBraces);
+        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn);
         executable->finishCreation(vm);
         return executable;
     }
@@ -643,13 +642,10 @@
 
     void clearCode();
 
-    bool bodyIncludesBraces() const { return m_bodyIncludesBraces; }
-
 private:
     FunctionExecutable(
         VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, 
-        unsigned lastLine, unsigned startColumn, unsigned endColumn, 
-        bool bodyIncludesBraces);
+        unsigned lastLine, unsigned startColumn, unsigned endColumn);
 
     bool isCompiling()
     {
@@ -667,7 +663,6 @@
     WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable;
     RefPtr<FunctionCodeBlock> m_codeBlockForCall;
     RefPtr<FunctionCodeBlock> m_codeBlockForConstruct;
-    bool m_bodyIncludesBraces;
     RefPtr<TypeSet> m_returnStatementTypeSet;
 };
 

Modified: trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -93,9 +93,9 @@
     // We also need \n before the closing } to handle // comments at the end of the last line
     String program;
     if (args.isEmpty())
-        program = ASCIILiteral("(function() {\n})");
+        program = ASCIILiteral("(function() { \n})");
     else if (args.size() == 1)
-        program = makeString("(function() {", args.at(0).toString(exec)->value(exec), "\n})");
+        program = makeString("(function() { ", args.at(0).toString(exec)->value(exec), "\n})");
     else {
         StringBuilder builder;
         builder.appendLiteral("(function(");
@@ -104,7 +104,7 @@
             builder.append(',');
             builder.append(args.at(i).toString(exec)->value(exec));
         }
-        builder.appendLiteral(") {");
+        builder.appendLiteral(") { ");
         builder.append(args.at(args.size() - 1).toString(exec)->value(exec));
         builder.appendLiteral("\n})");
         program = builder.toString();

Modified: trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp (181672 => 181673)


--- trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp	2015-03-18 00:03:07 UTC (rev 181672)
+++ trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp	2015-03-18 00:07:24 UTC (rev 181673)
@@ -82,11 +82,8 @@
 // Functions
 
 // Compatibility hack for the Optimost _javascript_ library. (See <rdar://problem/6595040>.)
-static inline void insertSemicolonIfNeeded(String& functionBody, bool bodyIncludesBraces)
+static inline void insertSemicolonIfNeeded(String& functionBody)
 {
-    if (!bodyIncludesBraces)
-        functionBody = makeString("{ ", functionBody, '}');
-
     ASSERT(functionBody[0] == '{');
     ASSERT(functionBody[functionBody.length() - 1] == '}');
 
@@ -109,7 +106,7 @@
             return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}"));
         FunctionExecutable* executable = function->jsExecutable();
         String sourceString = executable->source().toString();
-        insertSemicolonIfNeeded(sourceString, executable->bodyIncludesBraces());
+        insertSemicolonIfNeeded(sourceString);
         return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString));
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to