Ignore:
Timestamp:
Mar 8, 2011, 3:17:32 PM (14 years ago)
Author:
[email protected]
Message:

2011-03-07 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Make CodeBlock GC write barrier safe
https://bugs.webkit.org/show_bug.cgi?id=55910

In order to make CodeBlock WriteBarrier safe it was necessary
to make it have a single GC owner, and for that reason I have
made ExecutableBase a GC allocated object. This required
updating their creation routines as well as all sites that hold
a reference to them. GC objects that held Executable's have been
converted to WriteBarriers, and all other sites now use Global<>.

As an added benefit this gets rid of JSGlobalData's list of
GlobalCodeBlocks.

Perf testing shows a 0.5% progression on v8, vs. a 0.3% regression
on SunSpider. Given none of the tests that show regressions
demonstrate a regression on their own, and sampling shows up nothing.
I suspect we're just getting one or two additional gc passes at
the end of the run.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::EvalCodeCache::markAggregate): (JSC::CodeBlock::markAggregate):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::ownerExecutable): (JSC::CodeBlock::addConstant): (JSC::CodeBlock::constantRegister): (JSC::CodeBlock::getConstant): (JSC::CodeBlock::addFunctionDecl): (JSC::CodeBlock::addFunctionExpr): (JSC::GlobalCodeBlock::GlobalCodeBlock): (JSC::ExecState::r):
  • bytecode/EvalCodeCache.h: (JSC::EvalCodeCache::get):
  • bytecode/SamplingTool.h: (JSC::ScriptSampleRecord::ScriptSampleRecord):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::addConstantValue): (JSC::BytecodeGenerator::emitEqualityOp):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::makeFunction):
  • debugger/Debugger.cpp: (JSC::evaluateInGlobalCallFrame):
  • debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::evaluate):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::callEval):
  • jit/JITInlineMethods.h: (JSC::JIT::emitLoadDouble): (JSC::JIT::emitLoadInt32ToDouble):
  • jit/JITStubs.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::hostFunctionStub): (JSC::JITThunks::clearHostFunctionStubs):
  • jit/JITStubs.h:
  • runtime/Completion.cpp: (JSC::checkSyntax): (JSC::evaluate):
  • runtime/Executable.cpp: (JSC::EvalExecutable::EvalExecutable): (JSC::ProgramExecutable::ProgramExecutable): (JSC::FunctionExecutable::FunctionExecutable): (JSC::FunctionExecutable::~FunctionExecutable): (JSC::EvalExecutable::markChildren): (JSC::ProgramExecutable::markChildren): (JSC::FunctionExecutable::markChildren): (JSC::FunctionExecutable::fromGlobalCode):
  • runtime/Executable.h: (JSC::ExecutableBase::ExecutableBase): (JSC::ExecutableBase::createStructure): (JSC::NativeExecutable::create): (JSC::NativeExecutable::NativeExecutable): (JSC::VPtrHackExecutable::VPtrHackExecutable): (JSC::ScriptExecutable::ScriptExecutable): (JSC::EvalExecutable::create): (JSC::EvalExecutable::createStructure): (JSC::ProgramExecutable::create): (JSC::ProgramExecutable::createStructure): (JSC::FunctionExecutable::create): (JSC::FunctionExecutable::createStructure):
  • runtime/FunctionConstructor.cpp: (JSC::constructFunction):
  • runtime/Heap.cpp: (JSC::Heap::destroy): (JSC::Heap::markRoots):
  • runtime/Heap.h:
  • runtime/JSActivation.cpp: (JSC::JSActivation::JSActivation): (JSC::JSActivation::markChildren):
  • runtime/JSActivation.h: (JSC::JSActivation::JSActivationData::JSActivationData):
  • runtime/JSCell.h:
  • runtime/JSFunction.cpp: (JSC::JSFunction::JSFunction): (JSC::JSFunction::~JSFunction): (JSC::JSFunction::markChildren):
  • runtime/JSFunction.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::storeVPtrs): (JSC::JSGlobalData::JSGlobalData): (JSC::JSGlobalData::getHostFunction):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • runtime/JSObject.cpp:
  • runtime/JSStaticScopeObject.cpp: (JSC::JSStaticScopeObject::markChildren):
  • runtime/JSStaticScopeObject.h: (JSC::JSStaticScopeObject::JSStaticScopeObjectData::JSStaticScopeObjectData): (JSC::JSStaticScopeObject::JSStaticScopeObject):
  • runtime/JSZombie.cpp: (JSC::JSZombie::leakedZombieStructure):
  • runtime/JSZombie.h: (JSC::JSZombie::createStructure):
  • runtime/MarkedSpace.h:
File:
1 edited

Legend:

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

    r79904 r80598  
    365365        size_t i = 0;
    366366        do {
    367             printf("   k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).utf8().data());
     367            printf("   k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].get()).utf8().data());
    368368            ++i;
    369369            ++registerIndex;
     
    13611361
    13621362CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, JSGlobalObject *globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, SymbolTable* symTab, bool isConstructor)
    1363     : m_globalObject(globalObject)
     1363    : m_globalObject(globalObject->globalData(), ownerExecutable, globalObject)
    13641364    , m_heap(&m_globalObject->globalData().heap)
    13651365    , m_numCalleeRegisters(0)
     
    13671367    , m_numParameters(0)
    13681368    , m_isConstructor(isConstructor)
    1369     , m_ownerExecutable(ownerExecutable)
     1369    , m_ownerExecutable(globalObject->globalData(), ownerExecutable, ownerExecutable)
    13701370    , m_globalData(0)
    13711371#ifndef NDEBUG
     
    15281528}
    15291529
     1530void EvalCodeCache::markAggregate(MarkStack& markStack)
     1531{
     1532    EvalCacheMap::iterator end = m_cacheMap.end();
     1533    for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr)
     1534        markStack.append(&ptr->second);
     1535}
     1536
    15301537void CodeBlock::markAggregate(MarkStack& markStack)
    15311538{
    1532     for (size_t i = 0; i < m_constantRegisters.size(); ++i)
    1533         markStack.deprecatedAppend(&m_constantRegisters[i]);
     1539    markStack.append(&m_globalObject);
     1540    markStack.append(&m_ownerExecutable);
     1541    if (m_rareData)
     1542        m_rareData->m_evalCodeCache.markAggregate(markStack);
     1543    markStack.appendValues(m_constantRegisters.data(), m_constantRegisters.size());
    15341544    for (size_t i = 0; i < m_functionExprs.size(); ++i)
    1535         m_functionExprs[i]->markAggregate(markStack);
     1545        markStack.append(&m_functionExprs[i]);
    15361546    for (size_t i = 0; i < m_functionDecls.size(); ++i)
    1537         m_functionDecls[i]->markAggregate(markStack);
     1547        markStack.append(&m_functionDecls[i]);
    15381548}
    15391549
Note: See TracChangeset for help on using the changeset viewer.