Changeset 79904 in webkit for trunk/Source/JavaScriptCore/jit


Ignore:
Timestamp:
Feb 28, 2011, 1:05:22 PM (14 years ago)
Author:
[email protected]
Message:

2011-02-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

Simplify lifetime and other issues with the scopechain
by making it gc allocated. This allows us to simplify
function exit and unwinding, as well as making the
current iterative refcounting go away.

  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::createActivation):
  • bytecode/StructureStubInfo.cpp:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall): (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
  • bytecompiler/BytecodeGenerator.h:
  • debugger/Debugger.cpp: (JSC::Recompiler::operator()):
  • debugger/DebuggerCallFrame.h: (JSC::DebuggerCallFrame::scopeChain):
  • interpreter/CachedCall.h: (JSC::CachedCall::CachedCall):
  • interpreter/CallFrame.h:
  • interpreter/Interpreter.cpp: (JSC::depth): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::throwException): (JSC::Interpreter::execute): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::privateExecute):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallInitializeCallFrame): (JSC::JIT::compileOpCall):
  • jit/JITCall32_64.cpp: (JSC::JIT::compileOpCallInitializeCallFrame): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this): (JSC::JIT::compileOpCall):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_end): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this):
  • jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_end):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • jit/JITStubs.h:
  • runtime/ArgList.cpp:
  • runtime/Completion.cpp: (JSC::evaluate):
  • runtime/Completion.h:
  • runtime/DateConversion.cpp:
  • runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::compileForCallInternal): (JSC::FunctionExecutable::compileForConstructInternal):
  • runtime/FunctionConstructor.cpp: (JSC::constructFunction):
  • runtime/GCActivityCallbackCF.cpp:
  • runtime/Identifier.cpp:
  • runtime/JSCell.h:
  • runtime/JSChunk.cpp: Added.
  • runtime/JSChunk.h: Added.
  • runtime/JSFunction.cpp: (JSC::JSFunction::JSFunction): (JSC::JSFunction::markChildren): (JSC::JSFunction::getCallData): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getConstructData):
  • runtime/JSFunction.h: (JSC::JSFunction::scope): (JSC::JSFunction::setScope):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::markChildren):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): (JSC::JSGlobalObject::globalScopeChain):
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • runtime/JSLock.cpp:
  • runtime/JSNumberCell.cpp:
  • runtime/JSZombie.cpp:
  • runtime/MarkedBlock.cpp:
  • runtime/MarkedSpace.cpp:
  • runtime/PropertyNameArray.cpp:
  • runtime/ScopeChain.cpp: (JSC::ScopeChainNode::print): (JSC::ScopeChainNode::localDepth): (JSC::ScopeChainNode::markChildren):
  • runtime/ScopeChain.h: (JSC::ScopeChainNode::ScopeChainNode): (JSC::ScopeChainNode::createStructure): (JSC::ScopeChainNode::push): (JSC::ScopeChainNode::pop): (JSC::ScopeChainIterator::ScopeChainIterator): (JSC::ScopeChainIterator::operator*): (JSC::ScopeChainIterator::operator->): (JSC::ScopeChainIterator::operator++): (JSC::ScopeChainNode::begin): (JSC::ScopeChainNode::end): (JSC::ExecState::globalData): (JSC::ExecState::lexicalGlobalObject): (JSC::ExecState::globalThisValue):
  • runtime/ScopeChainMark.h:
  • wtf/DateMath.cpp:

2011-02-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

Update WebCore to deal with the absence of the ScopeChain
class.

  • ForwardingHeaders/runtime/ScopeChain.h: Added.
  • bindings/js/JSHTMLElementCustom.cpp: (WebCore::JSHTMLElement::pushEventHandlerScope):
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::scopeChain): (WebCore::JSJavaScriptCallFrame::scopeType):
  • bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::initializeJSFunction):
  • bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState::evaluate):
  • bindings/js/JSNodeCustom.cpp: (WebCore::JSNode::pushEventHandlerScope):
  • bindings/js/JavaScriptCallFrame.cpp: (WebCore::JavaScriptCallFrame::scopeChain):
  • bindings/js/JavaScriptCallFrame.h:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/c/c_class.cpp:
  • bridge/c/c_runtime.cpp:
  • bridge/jni/JNIBridge.cpp:
  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtConnectionObject::execute):
  • plugins/PluginViewNone.cpp:

2011-02-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

More updates for the absence of the ScopeChain class

  • WebView/WebScriptDebugDelegate.mm: (-[WebScriptCallFrame scopeChain]):
Location:
trunk/Source/JavaScriptCore/jit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITCall.cpp

    r70111 r79904  
    5050{
    5151    store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
    52     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT3); // newScopeChain
     52    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT3); // newScopeChain
    5353    storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register))));
    5454    storePtr(regT3, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register))));
     
    199199    // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
    200200
    201     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
     201    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); // newScopeChain
    202202
    203203    store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
  • trunk/Source/JavaScriptCore/jit/JITCall32_64.cpp

    r79247 r79904  
    5151    // regT0 holds callee, regT1 holds argCount
    5252    store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
    53     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT3); // scopeChain
     53    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT3); // scopeChain
    5454    storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register)))); // callee
    5555    storePtr(regT3, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)))); // scopeChain
     
    108108    unsigned dst = currentInstruction[1].u.operand;
    109109
    110     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    111     if (m_codeBlock->needsFullScopeChain()) {
    112         Jump activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), Imm32(JSValue::EmptyValueTag));
    113         JITStubCall(this, cti_op_ret_scopeChain).call();
    114         activationNotCreated.link(this);
    115     }
    116110    emitLoad(dst, regT1, regT0);
    117111    emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
     
    126120    unsigned result = currentInstruction[1].u.operand;
    127121    unsigned thisReg = currentInstruction[2].u.operand;
    128 
    129     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    130     if (m_codeBlock->needsFullScopeChain()) {
    131         Jump activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), Imm32(JSValue::EmptyValueTag));
    132         JITStubCall(this, cti_op_ret_scopeChain).call();
    133         activationNotCreated.link(this);
    134     }
    135122
    136123    emitLoad(result, regT1, regT0);
     
    292279    // Fast version of stack frame initialization, directly relative to edi.
    293280    // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
    294     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT2);
     281    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT2);
    295282
    296283    store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r78732 r79904  
    331331void JIT::emit_op_end(Instruction* currentInstruction)
    332332{
    333     if (m_codeBlock->needsFullScopeChain())
    334         JITStubCall(this, cti_op_end).call();
    335 
    336333    ASSERT(returnValueRegister != callFrameRegister);
    337334    emitGetVirtualRegister(currentInstruction[1].u.operand, returnValueRegister);
     
    544541void JIT::emit_op_ret(Instruction* currentInstruction)
    545542{
    546     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    547     if (m_codeBlock->needsFullScopeChain()) {
    548         Jump activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
    549         JITStubCall(this, cti_op_ret_scopeChain).call();
    550         activationNotCreated.link(this);
    551     }
    552543    ASSERT(callFrameRegister != regT1);
    553544    ASSERT(regT1 != returnValueRegister);
     
    570561void JIT::emit_op_ret_object_or_this(Instruction* currentInstruction)
    571562{
    572     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    573     if (m_codeBlock->needsFullScopeChain()) {
    574         Jump activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
    575         JITStubCall(this, cti_op_ret_scopeChain).call();
    576         activationNotCreated.link(this);
    577     }
    578 
    579563    ASSERT(callFrameRegister != regT1);
    580564    ASSERT(regT1 != returnValueRegister);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r78732 r79904  
    449449void JIT::emit_op_end(Instruction* currentInstruction)
    450450{
    451     if (m_codeBlock->needsFullScopeChain())
    452         JITStubCall(this, cti_op_end).call();
    453451    ASSERT(returnValueRegister != callFrameRegister);
    454452    emitLoad(currentInstruction[1].u.operand, regT1, regT0);
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r79551 r79904  
    11751175        structure = asObject(proto)->inheritorID();
    11761176    else
    1177         structure = constructor->scope().node()->globalObject->emptyObjectStructure();
     1177        structure = constructor->scope()->globalObject->emptyObjectStructure();
    11781178    JSValue result = constructEmptyObject(callFrame, structure);
    11791179
     
    12031203    CHECK_FOR_EXCEPTION_AT_END();
    12041204    return JSValue::encode(result);
    1205 }
    1206 
    1207 DEFINE_STUB_FUNCTION(void, op_end)
    1208 {
    1209     STUB_INIT_STACK_FRAME(stackFrame);
    1210 
    1211     ScopeChainNode* scopeChain = stackFrame.callFrame->scopeChain();
    1212     ASSERT(scopeChain->refCount > 1);
    1213     scopeChain->deref();
    12141205}
    12151206
     
    18481839    ASSERT(!function->isHostFunction());
    18491840    FunctionExecutable* executable = function->jsExecutable();
    1850     ScopeChainNode* callDataScopeChain = function->scope().node();
     1841    ScopeChainNode* callDataScopeChain = function->scope();
    18511842    JSObject* error = executable->compileForCall(stackFrame.callFrame, callDataScopeChain);
    18521843    if (error) {
     
    18691860    ASSERT(!function->isHostFunction());
    18701861    FunctionExecutable* executable = function->jsExecutable();
    1871     ScopeChainNode* callDataScopeChain = function->scope().node();
     1862    ScopeChainNode* callDataScopeChain = function->scope();
    18721863    JSObject* error = executable->compileForConstruct(stackFrame.callFrame, callDataScopeChain);
    18731864    if (error) {
     
    19301921    callFrame->setArgumentCountIncludingThis(argCount);
    19311922    callFrame->setCallee(callee);
    1932     callFrame->setScopeChain(callee->scope().node());
     1923    callFrame->setScopeChain(callee->scope());
    19331924    callFrame->setReturnPC(pc.value());
    19341925
     
    19891980    callFrame->setArgumentCountIncludingThis(argCount);
    19901981    callFrame->setCallee(callee);
    1991     callFrame->setScopeChain(callee->scope().node());
     1982    callFrame->setScopeChain(callee->scope());
    19921983    callFrame->setReturnPC(pc.value());
    19931984
     
    20102001    else {
    20112002        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    2012         JSObject* error = functionExecutable->compileForCall(callFrame, callee->scope().node());
     2003        JSObject* error = functionExecutable->compileForCall(callFrame, callee->scope());
    20132004        if (error) {
    20142005            callFrame->globalData().exception = createStackOverflowError(callFrame);
     
    20442035    else {
    20452036        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    2046         JSObject* error = functionExecutable->compileForConstruct(callFrame, callee->scope().node());
     2037        JSObject* error = functionExecutable->compileForConstruct(callFrame, callee->scope());
    20472038        if (error) {
    20482039            throwStackOverflowError(callFrame, stackFrame.globalData, ReturnAddressPtr(callFrame->returnPC()), STUB_RETURN_ADDRESS);
     
    20712062
    20722063    JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
    2073     stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->copy()->push(activation));
     2064    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(activation));
    20742065    return activation;
    20752066}
     
    21732164    ASSERT(*stackFrame.enabledProfilerReference);
    21742165    (*stackFrame.enabledProfilerReference)->didExecute(stackFrame.callFrame, stackFrame.args[0].jsValue());
    2175 }
    2176 
    2177 DEFINE_STUB_FUNCTION(void, op_ret_scopeChain)
    2178 {
    2179     STUB_INIT_STACK_FRAME(stackFrame);
    2180 
    2181     ASSERT(stackFrame.callFrame->codeBlock()->needsFullScopeChain());
    2182     stackFrame.callFrame->scopeChain()->deref();
    21832166}
    21842167
     
    30092992    if (!function->name().isNull()) {
    30102993        JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
    3011         func->scope().push(functionScopeObject);
     2994        func->setScope(callFrame->globalData(), func->scope()->push(functionScopeObject));
    30122995    }
    30132996
     
    31193102    Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
    31203103    JSValue baseValue = argv[0].jsValue();
    3121     JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
     3104    JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject.get();
    31223105
    31233106    if (baseValue == globalObject && funcVal == globalObject->evalFunction()) {
  • trunk/Source/JavaScriptCore/jit/JITStubs.h

    r75408 r79904  
    391391    void JIT_STUB cti_op_put_getter(STUB_ARGS_DECLARATION);
    392392    void JIT_STUB cti_op_put_setter(STUB_ARGS_DECLARATION);
    393     void JIT_STUB cti_op_ret_scopeChain(STUB_ARGS_DECLARATION);
    394393    void JIT_STUB cti_op_tear_off_activation(STUB_ARGS_DECLARATION);
    395394    void JIT_STUB cti_op_tear_off_arguments(STUB_ARGS_DECLARATION);
Note: See TracChangeset for help on using the changeset viewer.