Ignore:
Timestamp:
Sep 6, 2012, 12:45:35 PM (13 years ago)
Author:
[email protected]
Message:

Rolled out <http://trac.webkit.org/changeset/127698> because it broke
fast/dom/HTMLScriptElement/script-reexecution-pretty-diff.html

Named functions should not allocate scope objects for their names
https://bugs.webkit.org/show_bug.cgi?id=95659

Reviewed by Oliver Hunt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r127698 r127774  
    134134const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionExecutable) };
    135135
    136 FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, FunctionBodyNode* node)
    137     : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, node->source(), node->isStrictMode())
     136FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext)
     137    : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, source, inStrictContext)
    138138    , m_numCapturedVariables(0)
    139     , m_forceUsesArguments(node->usesArguments())
    140     , m_parameters(node->parameters())
    141     , m_name(node->ident())
    142     , m_inferredName(node->inferredName().isNull() ? globalData.propertyNames->emptyIdentifier : node->inferredName())
    143 {
    144     m_firstLine = node->lineNo();
    145     m_lastLine = node->lastLine();
     139    , m_forceUsesArguments(forceUsesArguments)
     140    , m_parameters(parameters)
     141    , m_name(name)
     142    , m_inferredName(inferredName.isNull() ? globalData.propertyNames->emptyIdentifier : inferredName)
     143{
     144}
     145
     146FunctionExecutable::FunctionExecutable(ExecState* exec, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext)
     147    : ScriptExecutable(exec->globalData().functionExecutableStructure.get(), exec, source, inStrictContext)
     148    , m_numCapturedVariables(0)
     149    , m_forceUsesArguments(forceUsesArguments)
     150    , m_parameters(parameters)
     151    , m_name(name)
     152    , m_inferredName(inferredName.isNull() ? exec->globalData().propertyNames->emptyIdentifier : inferredName)
     153{
    146154}
    147155
     
    203211        if (!lexicalGlobalObject->evalEnabled())
    204212            return throwError(exec, createEvalError(exec, ASCIILiteral("Eval is disabled")));
    205         RefPtr<EvalNode> evalNode = parse<EvalNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), isStrictMode() ? JSParseStrict : JSParseNormal, EvalNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
     213        RefPtr<EvalNode> evalNode = parse<EvalNode>(globalData, lexicalGlobalObject, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, EvalNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
    206214        if (!evalNode) {
    207215            ASSERT(exception);
     
    286294    JSGlobalData* globalData = &exec->globalData();
    287295    JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
    288     RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
     296    RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
    289297    if (programNode)
    290298        return 0;
     
    328336        m_programCodeBlock = newCodeBlock.release();
    329337    } else {
    330         RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), isStrictMode() ? JSParseStrict : JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
     338        RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
    331339        if (!programNode) {
    332340            ASSERT(exception);
     
    471479    JSGlobalData* globalData = scope->globalData();
    472480    JSGlobalObject* globalObject = scope->globalObject();
    473     RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(
    474         globalData,
    475         globalObject,
    476         m_source,
    477         m_parameters.get(),
    478         name(),
    479         isStrictMode() ? JSParseStrict : JSParseNormal,
    480         FunctionBodyNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode,
    481         0,
    482         0,
    483         &exception
    484     );
     481    RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(globalData, globalObject, m_source, m_parameters.get(), isStrictMode() ? JSParseStrict : JSParseNormal, FunctionBodyNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, 0, 0, &exception);
    485482
    486483    if (!body) {
     
    651648}
    652649
    653 FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& name, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception)
     650FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception)
    654651{
    655652    JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
    656     RefPtr<ProgramNode> program = parse<ProgramNode>(&exec->globalData(), lexicalGlobalObject, source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, debugger, exec, exception);
     653    RefPtr<ProgramNode> program = parse<ProgramNode>(&exec->globalData(), lexicalGlobalObject, source, 0, JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, debugger, exec, exception);
    657654    if (!program) {
    658655        ASSERT(*exception);
     
    660657    }
    661658
    662     // This function assumes an input string that would result in a single anonymous function expression.
     659    // Uses of this function that would not result in a single function expression are invalid.
    663660    StatementNode* exprStatement = program->singleStatement();
    664661    ASSERT(exprStatement);
     
    669666    FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
    670667    ASSERT(body);
    671     ASSERT(body->ident().isNull());
    672 
    673     FunctionExecutable* functionExecutable = FunctionExecutable::create(exec->globalData(), body);
    674     functionExecutable->m_nameValue.set(exec->globalData(), functionExecutable, jsString(&exec->globalData(), name.ustring()));
    675     return functionExecutable;
     668
     669    return FunctionExecutable::create(exec->globalData(), functionName, functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
    676670}
    677671
Note: See TracChangeset for help on using the changeset viewer.