Ignore:
Timestamp:
Oct 4, 2010, 3:43:18 PM (15 years ago)
Author:
[email protected]
Message:

2010-10-04 Oliver Hunt <[email protected]>

Reviewed by Geoff Garen.

Lazily create activation objects
https://bugs.webkit.org/show_bug.cgi?id=47107

Make it possible to lazily create the activation object
for a function that needs one. This allows us to reduce
the overhead of entering a function that may require
an activation in some cases, but not always.

This does make exception handling a little more complex as
it's now necessary to verify that a callframes activation
has been created, and create it if not, in all of the
paths used in exception handling.

We also need to add logic to check for the existence of
the activation in the scoped_var opcodes, as well as
op_ret, op_ret_object_or_this and op_tearoff_activation
so that we can avoid creating an activation unnecesarily
on function exit.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): (JSC::CodeBlock::createActivation):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::setActivationRegister): (JSC::CodeBlock::activationRegister):
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitNewFunctionInternal): (JSC::BytecodeGenerator::emitNewFunctionExpression): (JSC::BytecodeGenerator::createActivationIfNecessary):
  • bytecompiler/BytecodeGenerator.h:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::resolveSkip): (JSC::Interpreter::resolveGlobalDynamic): (JSC::Interpreter::resolveBase): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::throwException): (JSC::Interpreter::privateExecute):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JIT.h:
  • jit/JITCall32_64.cpp: (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_end): (JSC::JIT::emit_op_get_scoped_var): (JSC::JIT::emit_op_put_scoped_var): (JSC::JIT::emit_op_tear_off_activation): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this): (JSC::JIT::emit_op_create_activation): (JSC::JIT::emit_op_resolve_global_dynamic):
  • jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_get_scoped_var): (JSC::JIT::emit_op_put_scoped_var): (JSC::JIT::emit_op_tear_off_activation): (JSC::JIT::emit_op_create_activation):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r67943 r69045  
    19071907{
    19081908    STUB_INIT_STACK_FRAME(stackFrame);
    1909 
     1909   
     1910    ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->r(stackFrame.callFrame->codeBlock()->activationRegister()).jsValue());
    19101911    return stackFrame.args[0].function()->make(stackFrame.callFrame, stackFrame.callFrame->scopeChain());
    19111912}
     
    22142215
    22152216    ASSERT(stackFrame.callFrame->codeBlock()->needsFullScopeChain());
     2217    JSValue activationValue = stackFrame.args[0].jsValue();
     2218    if (!activationValue) {
     2219        if (JSValue v = stackFrame.args[1].jsValue())
     2220            asArguments(v)->copyRegisters();
     2221        return;
     2222    }
    22162223    JSActivation* activation = asActivation(stackFrame.args[0].jsValue());
    22172224    activation->copyRegisters();
     
    26862693    ScopeChainIterator end = scopeChain->end();
    26872694    ASSERT(iter != end);
     2695    CodeBlock* codeBlock = callFrame->codeBlock();
     2696    bool checkTopLevel = codeBlock->codeType() == FunctionCode && codeBlock->needsFullScopeChain();
     2697    ASSERT(skip || !checkTopLevel);
     2698    if (checkTopLevel && skip--) {
     2699        if (callFrame->r(codeBlock->activationRegister()).jsValue())
     2700            ++iter;
     2701    }
    26882702    while (skip--) {
    26892703        ++iter;
     
    27012715    } while (++iter != end);
    27022716
    2703     CodeBlock* codeBlock = callFrame->codeBlock();
    27042717    unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
    27052718    stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
     
    30503063    FunctionExecutable* function = stackFrame.args[0].function();
    30513064    JSFunction* func = function->make(callFrame, callFrame->scopeChain());
     3065    ASSERT(callFrame->codeBlock()->codeType() != FunctionCode || !callFrame->codeBlock()->needsFullScopeChain() || callFrame->r(callFrame->codeBlock()->activationRegister()).jsValue());
    30523066
    30533067    /*
     
    31563170{
    31573171    STUB_INIT_STACK_FRAME(stackFrame);
     3172    ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->r(stackFrame.callFrame->codeBlock()->activationRegister()).jsValue());
    31583173
    31593174    CallFrame* callFrame = stackFrame.callFrame;
Note: See TracChangeset for help on using the changeset viewer.