Ignore:
Timestamp:
Sep 17, 2012, 6:15:04 PM (13 years ago)
Author:
[email protected]
Message:

Refactored the arguments object so it doesn't dictate closure layout
https://bugs.webkit.org/show_bug.cgi?id=96955

Reviewed by Oliver Hunt.

  • bytecode/CodeBlock.h:

(JSC::ExecState::argumentAfterCapture): Helper function for accessing an
argument that has been moved for capture.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator): Generate metadata for arguments
that are captured. We don't move any arguments yet, but we do use this
metadata to tell the arguments object if an argument is stored in the
activation.

  • dfg/DFGOperations.cpp:
  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetByValOnArguments):
(JSC::DFG::SpeculativeJIT::compileGetArgumentsLength):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile): Updated for the arguments object not
malloc'ing a separate backing store, and for a rename from deletedArguments
to slowArguments.

  • interpreter/CallFrame.h:

(ExecState):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwindCallFrame):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL): Updated for small interface changes.

  • runtime/Arguments.cpp:

(JSC::Arguments::visitChildren):
(JSC::Arguments::copyToArguments):
(JSC::Arguments::fillArgList):
(JSC::Arguments::getOwnPropertySlotByIndex):
(JSC::Arguments::createStrictModeCallerIfNecessary):
(JSC::Arguments::createStrictModeCalleeIfNecessary):
(JSC::Arguments::getOwnPropertySlot):
(JSC::Arguments::getOwnPropertyDescriptor):
(JSC::Arguments::getOwnPropertyNames):
(JSC::Arguments::putByIndex):
(JSC::Arguments::put):
(JSC::Arguments::deletePropertyByIndex):
(JSC::Arguments::deleteProperty):
(JSC::Arguments::defineOwnProperty):
(JSC::Arguments::tearOff): Moved all data inline into the object, for speed,
and refactored all internal argument accesses to use helper functions, so
we can change the implementation without changing lots of code.

(JSC::Arguments::didTearOffActivation): This function needs to account
for arguments that were moved by the activation object. We do this accounting
through a side vector that tells us where our arguments will be in the
activation.

(JSC::Arguments::tearOffForInlineCallFrame):

  • runtime/Arguments.h:

(Arguments):
(JSC::Arguments::length):
(JSC::Arguments::isTornOff):
(JSC::Arguments::Arguments):
(JSC::Arguments::allocateSlowArguments):
(JSC::Arguments::tryDeleteArgument):
(JSC::Arguments::trySetArgument):
(JSC::Arguments::tryGetArgument):
(JSC::Arguments::isDeletedArgument):
(JSC::Arguments::isArgument):
(JSC::Arguments::argument):
(JSC::Arguments::finishCreation):

  • runtime/JSActivation.h:

(JSC::JSActivation::create):
(JSActivation):
(JSC::JSActivation::captureStart):
(JSC::JSActivation::storageSize):
(JSC::JSActivation::registerOffset):
(JSC::JSActivation::isValid): The activation object is no longer responsible
for copying extra arguments provided by the caller. The argumnents object
does this instead. This means we can allocate and initialize an activation
without worrying about the call frame's argument count.

  • runtime/SymbolTable.h:

(JSC::SlowArgument::SlowArgument):
(SlowArgument):
(JSC):
(JSC::SharedSymbolTable::parameterCount):
(SharedSymbolTable):
(JSC::SharedSymbolTable::slowArguments):
(JSC::SharedSymbolTable::setSlowArguments): Added data structures to back
the algorithms above.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r128534 r128832  
    424424    }
    425425
    426     bool capturesAnyArgument = codeBlock->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks; // May reify arguments object.
    427     if (!capturesAnyArgument && functionBody->hasCapturedVariables()) {
     426    bool mayReifyArgumentsObject = codeBlock->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks;
     427    bool capturesAnyArgumentByName = false;
     428    if (functionBody->hasCapturedVariables()) {
    428429        FunctionParameters& parameters = *functionBody->parameters();
    429430        for (size_t i = 0; i < parameters.size(); ++i) {
    430431            if (!functionBody->captures(parameters[i]))
    431432                continue;
    432             capturesAnyArgument = true;
     433            capturesAnyArgumentByName = true;
    433434            break;
    434435        }
    435436    }
    436437
    437     if (capturesAnyArgument) {
     438    if (mayReifyArgumentsObject || capturesAnyArgumentByName) {
    438439        symbolTable->setCaptureMode(SharedSymbolTable::AllOfTheThings);
    439440        symbolTable->setCaptureStart(-CallFrame::offsetFor(symbolTable->parameterCountIncludingThis()));
     
    441442        symbolTable->setCaptureMode(SharedSymbolTable::SomeOfTheThings);
    442443        symbolTable->setCaptureStart(m_codeBlock->m_numVars);
     444    }
     445
     446    if (mayReifyArgumentsObject && capturesAnyArgumentByName) {
     447        size_t parameterCount = symbolTable->parameterCount();
     448        OwnArrayPtr<SlowArgument> slowArguments = adoptArrayPtr(new SlowArgument[parameterCount]);
     449        for (size_t i = 0; i < parameterCount; ++i) {
     450            slowArguments[i].status = SlowArgument::Captured;
     451            slowArguments[i].indexIfCaptured = CallFrame::argumentOffset(i);
     452        }
     453        symbolTable->setSlowArguments(slowArguments.release());
    443454    }
    444455
     
    682693    if (entry.isNull())
    683694        return false;
    684    
     695
    685696    if (m_codeBlock->usesArguments() && m_codeType == FunctionCode)
    686697        return true;
Note: See TracChangeset for help on using the changeset viewer.