Ignore:
Timestamp:
May 1, 2014, 10:26:24 AM (11 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r167964.
https://bugs.webkit.org/show_bug.cgi?id=132431

Memory improvements should not regress memory usage (Requested
by olliej on #webkit).

Reverted changeset:

"Don't hold on to parameter BindingNodes forever"
https://bugs.webkit.org/show_bug.cgi?id=132360
http://trac.webkit.org/changeset/167964

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r167964 r168107  
    5252static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error)
    5353{
    54     RefPtr<FunctionParameters> parameters = executable->parameters(&vm);
    55     if (!parameters) {
    56         error = ParserError(ParserError::StackOverflow);
    57         error.m_line = source.firstLine();
    58         return 0;
    59     }
    60 
    61     RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, parameters.get(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error);
     54    RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error);
    6255
    6356    if (!body) {
     
    6861    if (executable->forceUsesArguments())
    6962        body->setUsesArguments();
    70     body->finishParsing(parameters.get(), executable->name(), executable->functionMode());
     63    body->finishParsing(executable->parameters(), executable->name(), executable->functionMode());
    7164    executable->recordParse(body->features(), body->hasCapturedVariables());
    7265   
     
    10093    , m_name(node->ident())
    10194    , m_inferredName(node->inferredName())
    102     , m_parameterCount(node->parameterCount())
     95    , m_parameters(node->parameters())
    10396    , m_firstLineOffset(node->firstLine() - source.firstLine())
    10497    , m_lineCount(node->lastLine() - node->firstLine())
     
    111104    , m_functionMode(node->functionMode())
    112105{
     106}
     107
     108size_t UnlinkedFunctionExecutable::parameterCount() const
     109{
     110    return m_parameters->size();
    113111}
    114112
     
    125123    visitor.append(&thisObject->m_symbolTableForCall);
    126124    visitor.append(&thisObject->m_symbolTableForConstruct);
    127     visitor.append(&thisObject->m_parameterString);
    128125}
    129126
     
    188185}
    189186
    190 void UnlinkedFunctionExecutable::finishCreation(VM& vm, const SourceCode& source, FunctionBodyNode* node)
    191 {
    192     Base::finishCreation(vm);
    193     m_nameValue.set(vm, this, jsString(&vm, name().string()));
    194     // We make an isolated copy of the parameter string as we don't want to keep the
    195     // full source string alive.
    196     String parameterString = source.provider()->getRange(node->parametersStartOffset(), node->parametersEndOffset()).isolatedCopy();
    197     m_parameterString.set(vm, this, jsString(&vm, parameterString));
    198 }
    199 
    200187String UnlinkedFunctionExecutable::paramString() const
    201188{
    202     return m_parameterString->tryGetValue();
    203 }
    204 
    205 RefPtr<FunctionParameters> UnlinkedFunctionExecutable::parameters(VM* vm)
    206 {
    207     if (!m_parameterCount)
    208         return FunctionParameters::create(nullptr);
    209 
    210     SourceCode parameterSource = makeSource(m_parameterString->tryGetValue());
    211     RefPtr<FunctionParameters> parameters = parseParameters(vm, parameterSource, toStrictness());
    212     ASSERT(!parameters || parameters->size() == m_parameterCount);
    213     return parameters;
     189    FunctionParameters& parameters = *m_parameters;
     190    StringBuilder builder;
     191    for (size_t pos = 0; pos < parameters.size(); ++pos) {
     192        if (!builder.isEmpty())
     193            builder.appendLiteral(", ");
     194        parameters.at(pos)->toString(builder);
     195    }
     196    return builder.toString();
    214197}
    215198
Note: See TracChangeset for help on using the changeset viewer.