⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181673 in webkit


Ignore:
Timestamp:
Mar 17, 2015, 5:07:24 PM (11 years ago)
Author:
ggaren@apple.com
Message:

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

Reviewed by Michael Saboff.

Source/JavaScriptCore:

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 JavaScriptCore 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:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181667 r181673  
     12015-03-17  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Function bodies should always include braces
     4        https://bugs.webkit.org/show_bug.cgi?id=142795
     5
     6        Reviewed by Michael Saboff.
     7
     8        Updated these test results to reflect the fact that JavaScriptCore now
     9        honors the source code text positions provided by WebCore, even for
     10        attribute event handlers.
     11
     12        Unfortunately, the column numbers we used to report were wrong, and they
     13        are still wrong now. The old column numbers were wrong because we would
     14        always pretend that they started on column 1. The new column numbers
     15        are wrong because WebCore records the column number after it finishes
     16        parsing the element, rather than while it is parsing the event listener
     17        attribute.
     18
     19        * fast/events/window-onerror2-expected.txt:
     20        * fast/profiler/dead-time-expected.txt:
     21        * fast/profiler/inline-event-handler-expected.txt:
     22        * fast/profiler/stop-profiling-after-setTimeout-expected.txt:
     23        * js/dom/script-start-end-locations-expected.txt:
     24
    1252015-03-17  Zalan Bujtas  <zalan@apple.com>
    226
  • trunk/LayoutTests/fast/events/window-onerror2-expected.txt

    r159520 r181673  
    22
    33Main 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: 66
     4Main frame window.onerror: Exception in onload at window-onerror2.html, line: 2, column: 167
    55Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html, line: 29, column: 47
    66
  • trunk/LayoutTests/fast/profiler/dead-time-expected.txt

    r163140 r181673  
    55Profile title: Dead time in profile.
    66Thread_1 (no file) (line 0:0)
    7    onload dead-time.html (line 21:1)
     7   onload dead-time.html (line 21:45)
    88      startTest dead-time.html (line 13:1)
    99         setTimeout (no file) (line 0:0)
  • trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt

    r163140 r181673  
    88      getElementById (no file) (line 0:0)
    99      click (no file) (line 0:0)
    10          onclick inline-event-handler.html (line 31:1)
     10         onclick inline-event-handler.html (line 31:127)
    1111            eventListener inline-event-handler.html (line 17:26)
    1212               anonymousFunction profiler-test-JS-resources.js (line 29:37)
  • trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt

    r163140 r181673  
    55Profile title: Stop profiling from a timeout
    66Thread_1 (no file) (line 0:0)
    7    onload stop-profiling-after-setTimeout.html (line 21:1)
     7   onload stop-profiling-after-setTimeout.html (line 21:45)
    88      startTest stop-profiling-after-setTimeout.html (line 13:1)
    99         setTimeout (no file) (line 0:0)
  • trunk/LayoutTests/js/dom/script-start-end-locations-expected.txt

    r159520 r181673  
    244244
    245245  new Function Object:
    246 function "" { 1:1 - 1:228 }
    247 function "nf1a" { 1:60 - 1:219 }
    248 function "nf1b" { 1:90 - 1:209 }
    249 function "nf1c" { 1:120 - 1:199 }
    250 eval { 1:1 - 1:56 }
    251 function "" { 1:1 - 17:8 }
     246function "" { 1:16 - 1:245 }
     247function "nf1a" { 1:77 - 1:236 }
     248function "nf1b" { 1:107 - 1:226 }
     249function "nf1c" { 1:137 - 1:216 }
     250eval { 1:1 - 1:56 }
     251function "" { 1:16 - 17:8 }
    252252function "nf2a" { 4:21 - 15:5 }
    253253function "nf2b" { 6:25 - 13:9 }
    254254function "nf2c" { 8:29 - 11:13 }
    255255eval { 1:1 - 1:56 }
    256 function "" { 1:1 - 1:228 }
    257 function "nf1a" { 1:60 - 1:219 }
    258 function "nf1b" { 1:90 - 1:209 }
    259 function "nf1c" { 1:120 - 1:199 }
    260 eval { 1:1 - 1:56 }
    261 function "" { 1:1 - 1:237 }
    262 function "nfi1a" { 1:61 - 1:227 }
    263 function "nfi1b" { 1:93 - 1:216 }
    264 function "nfi1c" { 1:125 - 1:205 }
    265 eval { 1:1 - 1:56 }
    266 function "" { 1:1 - 17:8 }
     256function "" { 1:16 - 1:245 }
     257function "nf1a" { 1:77 - 1:236 }
     258function "nf1b" { 1:107 - 1:226 }
     259function "nf1c" { 1:137 - 1:216 }
     260eval { 1:1 - 1:56 }
     261function "" { 1:16 - 1:254 }
     262function "nfi1a" { 1:78 - 1:244 }
     263function "nfi1b" { 1:110 - 1:233 }
     264function "nfi1c" { 1:142 - 1:222 }
     265eval { 1:1 - 1:56 }
     266function "" { 1:16 - 17:8 }
    267267function "nf2a" { 4:21 - 15:5 }
    268268function "nf2b" { 6:25 - 13:9 }
    269269function "nf2c" { 8:29 - 11:13 }
    270270eval { 1:1 - 1:56 }
    271 function "" { 1:1 - 17:9 }
     271function "" { 1:16 - 17:9 }
    272272function "nfi2a" { 4:22 - 15:5 }
    273273function "nfi2b" { 6:26 - 13:9 }
  • trunk/Source/JavaScriptCore/ChangeLog

    r181670 r181673  
     12015-03-17  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Function bodies should always include braces
     4        https://bugs.webkit.org/show_bug.cgi?id=142795
     5
     6        Reviewed by Michael Saboff.
     7
     8        Having a mode for excluding the opening and closing braces from a function
     9        body was unnecessary and confusing.
     10
     11        * bytecode/CodeBlock.cpp:
     12        (JSC::CodeBlock::CodeBlock): Adopt the new one true linking function.
     13
     14        * bytecode/UnlinkedCodeBlock.cpp:
     15        (JSC::generateFunctionCodeBlock):
     16        (JSC::UnlinkedFunctionExecutable::link):
     17        (JSC::UnlinkedFunctionExecutable::codeBlockFor): No need to pass through
     18        a boolean: there is only one kind of function now.
     19
     20        (JSC::UnlinkedFunctionExecutable::linkInsideExecutable): Deleted.
     21        (JSC::UnlinkedFunctionExecutable::linkGlobalCode): Deleted. Let's only
     22        have one way to do things. This removes the old mode that would pretend
     23        that a function always started at column 1. That pretense was not true:
     24        an attribute event listener does not necessarily start at column 1.
     25
     26        * bytecode/UnlinkedCodeBlock.h:
     27        * generate-js-builtins: Adopt the new one true linking function.
     28
     29        * parser/Parser.h:
     30        (JSC::Parser<LexerType>::parse):
     31        (JSC::parse): needsReparsingAdjustment is always true now, so I removed it.
     32
     33        * runtime/Executable.cpp:
     34        (JSC::ScriptExecutable::newCodeBlockFor):
     35        (JSC::FunctionExecutable::FunctionExecutable):
     36        (JSC::ProgramExecutable::initializeGlobalProperties):
     37        (JSC::FunctionExecutable::fromGlobalCode):
     38        * runtime/Executable.h:
     39        (JSC::FunctionExecutable::create):
     40        (JSC::FunctionExecutable::bodyIncludesBraces): Deleted. Removed unused stuff.
     41
     42        * runtime/FunctionConstructor.cpp:
     43        (JSC::constructFunctionSkippingEvalEnabledCheck): Always provide a
     44        leading space because that's what this function's comment says is required
     45        for web compatibility. We used to fake this up after the fact when
     46        stringifying, based on the bodyIncludesBraces flag, but that flag is gone now.
     47
     48        * runtime/FunctionPrototype.cpp:
     49        (JSC::insertSemicolonIfNeeded):
     50        (JSC::functionProtoFuncToString): No need to add braces and/or a space
     51        after the fact -- we always have them now.
     52
    1532015-03-17  Mark Lam  <mark.lam@apple.com>
    254
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r181664 r181673  
    7373        JSParserStrictMode::NotStrict,
    7474        JSParserCodeType::Program,
    75         error, &positionBeforeLastNewline, false, constructorKind);
     75        error, &positionBeforeLastNewline, constructorKind);
    7676
    7777    if (!program) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r181481 r181673  
    17541754        if (vm()->typeProfiler() || vm()->controlFlowProfiler())
    17551755            vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
    1756         m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->linkInsideExecutable(*m_vm, ownerExecutable->source()));
     1756        m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
    17571757    }
    17581758
     
    17621762        if (vm()->typeProfiler() || vm()->controlFlowProfiler())
    17631763            vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
    1764         m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->linkInsideExecutable(*m_vm, ownerExecutable->source()));
     1764        m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
    17651765    }
    17661766
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r181664 r181673  
    5353    VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source,
    5454    CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode,
    55     UnlinkedFunctionKind functionKind, bool bodyIncludesBraces, ParserError& error)
     55    UnlinkedFunctionKind functionKind, ParserError& error)
    5656{
    5757    JSParserBuiltinMode builtinMode = executable->isBuiltinFunction() ? JSParserBuiltinMode::Builtin : JSParserBuiltinMode::NotBuiltin;
     
    5959    std::unique_ptr<FunctionNode> function = parse<FunctionNode>(
    6060        &vm, source, executable->parameters(), executable->name(), builtinMode,
    61         strictMode, JSParserCodeType::Function, error, 0, bodyIncludesBraces);
     61        strictMode, JSParserCodeType::Function, error, 0);
    6262
    6363    if (!function) {
     
    130130}
    131131
    132 FunctionExecutable* UnlinkedFunctionExecutable::linkInsideExecutable(VM& vm, const SourceCode& ownerSource)
     132FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource)
    133133{
    134134    SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
     
    136136    unsigned startOffset = source.startOffset() + m_startOffset;
    137137
     138    // Adjust to one-based indexing.
    138139    bool startColumnIsOnFirstSourceLine = !m_firstLineOffset;
    139140    unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1);
     
    145146}
    146147
    147 FunctionExecutable* UnlinkedFunctionExecutable::linkGlobalCode(VM& vm, const SourceCode& source)
    148 {
    149     ASSERT(!m_sourceOverride);
    150     unsigned firstLine = source.firstLine() + m_firstLineOffset;
    151     unsigned startOffset = source.startOffset() + m_startOffset;
    152 
    153     // We don't have any owner executable. The source string is effectively like a global
    154     // string (like in the handling of eval). Hence, the startColumn is always 1.
    155     unsigned startColumn = 1;
    156     bool endColumnIsOnStartLine = !m_lineCount;
    157     // The unlinkedBodyEndColumn is 0-based. Hence, we need to add 1 to it. But if the
    158     // endColumn is on the startLine, then we need to subtract back the adjustment for
    159     // the open brace resulting in an adjustment of 0.
    160     unsigned endColumnExcludingBraces = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? 0 : 1);
    161     unsigned startOffsetExcludingOpenBrace = startOffset + 1;
    162     unsigned endOffsetExcludingCloseBrace = startOffset + m_sourceLength - 1;
    163     SourceCode code(source.provider(), startOffsetExcludingOpenBrace, endOffsetExcludingCloseBrace, firstLine, startColumn);
    164 
    165     return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumnExcludingBraces, false);
    166 }
    167 
    168148UnlinkedFunctionExecutable* UnlinkedFunctionExecutable::fromGlobalCode(const Identifier& name, ExecState& exec, const SourceCode& source, JSObject*& exception)
    169149{
     
    187167UnlinkedFunctionCodeBlock* UnlinkedFunctionExecutable::codeBlockFor(
    188168    VM& vm, const SourceCode& source, CodeSpecializationKind specializationKind,
    189     DebuggerMode debuggerMode, ProfilerMode profilerMode, bool bodyIncludesBraces,
    190     ParserError& error)
     169    DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
    191170{
    192171    switch (specializationKind) {
     
    204183        vm, this, source, specializationKind, debuggerMode, profilerMode,
    205184        isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction,
    206         bodyIncludesBraces, error);
     185        error);
    207186   
    208187    if (error.isValid())
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r181664 r181673  
    136136    UnlinkedFunctionCodeBlock* codeBlockFor(
    137137        VM&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode,
    138         bool bodyIncludesBraces, ParserError&);
     138        ParserError&);
    139139
    140140    static UnlinkedFunctionExecutable* fromGlobalCode(const Identifier&, ExecState&, const SourceCode&, JSObject*& exception);
    141141
    142     FunctionExecutable* linkInsideExecutable(VM&, const SourceCode&);
    143     FunctionExecutable* linkGlobalCode(VM&, const SourceCode&);
     142    FunctionExecutable* link(VM&, const SourceCode&);
    144143
    145144    void clearCodeForRecompilation()
  • trunk/Source/JavaScriptCore/generate-js-builtins

    r181213 r181673  
    268268FunctionExecutable* codeName##Generator(VM& vm) \\
    269269{ \\
    270     return vm.builtinExecutables()->codeName##Executable()->linkGlobalCode(vm, vm.builtinExecutables()->codeName##Source()); \\
     270    return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source()); \\
    271271}
    272272
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r181664 r181673  
    434434
    435435    template <class ParsedNode>
    436     std::unique_ptr<ParsedNode> parse(ParserError&, bool needReparsingAdjustment);
     436    std::unique_ptr<ParsedNode> parse(ParserError&);
    437437
    438438    JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
     
    905905template <typename LexerType>
    906906template <class ParsedNode>
    907 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, bool needReparsingAdjustment)
     907std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error)
    908908{
    909909    int errLine;
    910910    String errMsg;
    911911
    912     if (ParsedNode::scopeIsFunction && needReparsingAdjustment)
     912    if (ParsedNode::scopeIsFunction)
    913913        m_lexer->setIsReparsing();
    914914
     
    988988    const Identifier& name, JSParserBuiltinMode builtinMode,
    989989    JSParserStrictMode strictMode, JSParserCodeType codeType,
    990     ParserError& error, JSTextPosition* positionBeforeLastNewline = 0,
    991     bool needReparsingAdjustment = false,
     990    ParserError& error, JSTextPosition* positionBeforeLastNewline = 0,
    992991    ConstructorKind defaultConstructorKind = ConstructorKind::None)
    993992{
     
    997996    if (source.provider()->source().is8Bit()) {
    998997        Parser<Lexer<LChar>> parser(vm, source, parameters, name, builtinMode, strictMode, codeType, defaultConstructorKind);
    999         std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
     998        std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error);
    1000999        if (positionBeforeLastNewline)
    10011000            *positionBeforeLastNewline = parser.positionBeforeLastNewline();
     
    10091008    }
    10101009    Parser<Lexer<UChar>> parser(vm, source, parameters, name, builtinMode, strictMode, codeType);
    1011     std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
     1010    std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error);
    10121011    if (positionBeforeLastNewline)
    10131012        *positionBeforeLastNewline = parser.positionBeforeLastNewline();
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r181664 r181673  
    238238    UnlinkedFunctionCodeBlock* unlinkedCodeBlock =
    239239        executable->m_unlinkedExecutable->codeBlockFor(
    240             *vm, executable->m_source, kind, debuggerMode, profilerMode, executable->bodyIncludesBraces(), error);
     240            *vm, executable->m_source, kind, debuggerMode, profilerMode, error);
    241241    recordParse(executable->m_unlinkedExecutable->features(), executable->m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn(), endColumn());
    242242    if (!unlinkedCodeBlock) {
     
    397397FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source,
    398398    UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine,
    399     unsigned lastLine, unsigned startColumn, unsigned endColumn,
    400     bool bodyIncludesBraces)
     399    unsigned lastLine, unsigned startColumn, unsigned endColumn)
    401400    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext())
    402401    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
    403     , m_bodyIncludesBraces(bodyIncludesBraces)
    404402{
    405403    RELEASE_ASSERT(!source.isNull());
     
    509507    for (size_t i = 0; i < functionDeclarations.size(); ++i) {
    510508        UnlinkedFunctionExecutable* unlinkedFunctionExecutable = functionDeclarations[i].second.get();
    511         JSValue value = JSFunction::create(vm, unlinkedFunctionExecutable->linkInsideExecutable(vm, m_source), scope);
     509        JSValue value = JSFunction::create(vm, unlinkedFunctionExecutable->link(vm, m_source), scope);
    512510        globalObject->addFunction(callFrame, functionDeclarations[i].first, value);
    513511        if (vm.typeProfiler() || vm.controlFlowProfiler()) {
     
    615613    if (!unlinkedExecutable)
    616614        return nullptr;
    617     return unlinkedExecutable->linkGlobalCode(exec.vm(), source);
     615    return unlinkedExecutable->link(exec.vm(), source);
    618616}
    619617
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r181664 r181673  
    544544    static FunctionExecutable* create(
    545545        VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable,
    546         unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn,
    547         bool bodyIncludesBraces = true)
    548     {
    549         FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn, bodyIncludesBraces);
     546        unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn)
     547    {
     548        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn);
    550549        executable->finishCreation(vm);
    551550        return executable;
     
    644643    void clearCode();
    645644
    646     bool bodyIncludesBraces() const { return m_bodyIncludesBraces; }
    647 
    648645private:
    649646    FunctionExecutable(
    650647        VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine,
    651         unsigned lastLine, unsigned startColumn, unsigned endColumn,
    652         bool bodyIncludesBraces);
     648        unsigned lastLine, unsigned startColumn, unsigned endColumn);
    653649
    654650    bool isCompiling()
     
    668664    RefPtr<FunctionCodeBlock> m_codeBlockForCall;
    669665    RefPtr<FunctionCodeBlock> m_codeBlockForConstruct;
    670     bool m_bodyIncludesBraces;
    671666    RefPtr<TypeSet> m_returnStatementTypeSet;
    672667};
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r181208 r181673  
    9494    String program;
    9595    if (args.isEmpty())
    96         program = ASCIILiteral("(function() {\n})");
     96        program = ASCIILiteral("(function() { \n})");
    9797    else if (args.size() == 1)
    98         program = makeString("(function() {", args.at(0).toString(exec)->value(exec), "\n})");
     98        program = makeString("(function() { ", args.at(0).toString(exec)->value(exec), "\n})");
    9999    else {
    100100        StringBuilder builder;
     
    105105            builder.append(args.at(i).toString(exec)->value(exec));
    106106        }
    107         builder.appendLiteral(") {");
     107        builder.appendLiteral(") { ");
    108108        builder.append(args.at(args.size() - 1).toString(exec)->value(exec));
    109109        builder.appendLiteral("\n})");
  • trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp

    r173120 r181673  
    8383
    8484// Compatibility hack for the Optimost JavaScript library. (See <rdar://problem/6595040>.)
    85 static inline void insertSemicolonIfNeeded(String& functionBody, bool bodyIncludesBraces)
     85static inline void insertSemicolonIfNeeded(String& functionBody)
    8686{
    87     if (!bodyIncludesBraces)
    88         functionBody = makeString("{ ", functionBody, '}');
    89 
    9087    ASSERT(functionBody[0] == '{');
    9188    ASSERT(functionBody[functionBody.length() - 1] == '}');
     
    110107        FunctionExecutable* executable = function->jsExecutable();
    111108        String sourceString = executable->source().toString();
    112         insertSemicolonIfNeeded(sourceString, executable->bodyIncludesBraces());
     109        insertSemicolonIfNeeded(sourceString);
    113110        return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString));
    114111    }
Note: See TracChangeset for help on using the changeset viewer.