Ignore:
Timestamp:
Feb 15, 2017, 9:09:22 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Drop PassRefPtr
https://bugs.webkit.org/show_bug.cgi?id=168320

Reviewed by Saam Barati.

Source/JavaScriptCore:

  • API/JSContextRef.cpp:

(JSGlobalContextCreateInGroup):
Use Ref<VM> from the factory function.

  • API/JSScriptRef.cpp:

(OpaqueJSScript::create):
Return Ref<> instead.

  • API/tests/JSONParseTest.cpp:

(testJSONParse):
Use Ref<VM>.

  • assembler/LinkBuffer.cpp:

(JSC::LinkBuffer::finalizeCodeWithoutDisassembly):
Use reference since we already perform null check.

  • assembler/MacroAssemblerCodeRef.h:

(JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef):
Take Ref<>&& instead of PassRefPtr<>.

  • bytecode/CallLinkInfo.h:

(JSC::CallLinkInfo::setStub):
(JSC::CallLinkInfo::setSlowStub):
Take Ref<>&& instead of PassRefPtr<>.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
Take RefPtr<SourceProvider>. Currently, the SourceProvider would be nullptr.
We will change it to Ref<SourceProvider> in https://bugs.webkit.org/show_bug.cgi?id=168325.

(JSC::CodeBlock::finishCreation):
Take Ref<TypeSet>&&.

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::setJITCode):
Take Ref<>&& instead.

(JSC::CodeBlock::jitCode):
Return RefPtr<> instead.

  • bytecode/EvalCodeBlock.h:

(JSC::EvalCodeBlock::create):
Take RefPtr<>&& instead since SourceProvider woule be nullptr.

(JSC::EvalCodeBlock::EvalCodeBlock):

  • bytecode/FunctionCodeBlock.h:

(JSC::FunctionCodeBlock::create):
(JSC::FunctionCodeBlock::FunctionCodeBlock):
Take RefPtr<>&& instead since SourceProvider woule be nullptr.

  • bytecode/GlobalCodeBlock.h:

(JSC::GlobalCodeBlock::GlobalCodeBlock):
Take RefPtr<>&& instead since SourceProvider woule be nullptr.

  • bytecode/ModuleProgramCodeBlock.h:

(JSC::ModuleProgramCodeBlock::create):
(JSC::ModuleProgramCodeBlock::ModuleProgramCodeBlock):
Take RefPtr<>&& instead since SourceProvider woule be nullptr.

  • bytecode/ProgramCodeBlock.h:

(JSC::ProgramCodeBlock::create):
(JSC::ProgramCodeBlock::ProgramCodeBlock):
Take RefPtr<>&& instead since SourceProvider woule be nullptr.

  • debugger/DebuggerParseData.cpp:

(JSC::gatherDebuggerParseDataForSource):
Ensure the provider is not nullptr. It is OK because we already
touch provider->xxx values.

  • dfg/DFGBlockInsertionSet.cpp:

(JSC::DFG::BlockInsertionSet::insert):
Take Ref<>&& instead.

  • dfg/DFGBlockInsertionSet.h:
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::inlineCall):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::parseCodeBlock):
Pass Ref<>&& to appendBlock.

  • dfg/DFGDriver.cpp:

(JSC::DFG::compileImpl):
(JSC::DFG::compile):
Pass Ref<Plan>&&. And take Ref<>&& callback.

  • dfg/DFGDriver.h:
  • dfg/DFGGraph.h:

appendBlock takes Ref<>&&.

(JSC::DFG::Graph::appendBlock):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):

  • dfg/DFGJITCompiler.h:

(JSC::DFG::JITCompiler::jitCode):

  • dfg/DFGJITFinalizer.cpp:

(JSC::DFG::JITFinalizer::JITFinalizer):
Take Ref<JITCode>&&.

(JSC::DFG::JITFinalizer::finalize):
(JSC::DFG::JITFinalizer::finalizeFunction):
(JSC::DFG::JITFinalizer::finalizeCommon):
Pass compilation reference since we already perform null check.

  • dfg/DFGJITFinalizer.h:
  • dfg/DFGWorklist.cpp:

(JSC::DFG::Worklist::enqueue):
Take Ref<Plan>&&.

  • dfg/DFGWorklist.h:
  • ftl/FTLJITFinalizer.cpp:

(JSC::FTL::JITFinalizer::finalizeFunction):
Dereference and pass jitCode & compilation references.

  • jit/GCAwareJITStubRoutine.cpp:

(JSC::createJITStubRoutine):
Return Ref<> instead.

  • jit/GCAwareJITStubRoutine.h:

(JSC::createJITStubRoutine):

  • jit/JIT.cpp:

(JSC::JIT::link):
Pass compilation reference since we already perform null check.

  • jit/JITStubRoutine.h:

(JSC::JITStubRoutine::asCodePtr):
Take Ref<>&& instead. And this drops unnecessary null check.

  • jit/JITThunks.cpp:

(JSC::JITThunks::hostFunctionStub):
Pass Ref<> to NativeExecutable::create.

  • llint/LLIntEntrypoint.cpp:

(JSC::LLInt::setFunctionEntrypoint):
(JSC::LLInt::setEvalEntrypoint):
(JSC::LLInt::setProgramEntrypoint):
(JSC::LLInt::setModuleProgramEntrypoint):
Use Ref<>&& instead.

  • parser/SourceCode.h:

(JSC::SourceCode::SourceCode):
(JSC::SourceCode::subExpression):
Add constructors taking Ref<>&&.
We still have constructors that take RefPtr<>&&.
We will change it to Ref<SourceProvider>&& in https://bugs.webkit.org/show_bug.cgi?id=168325.

  • parser/UnlinkedSourceCode.h:

(JSC::UnlinkedSourceCode::UnlinkedSourceCode):
Add constructors taking Ref<>&&.
We still have constructors that take RefPtr<>&&.
We will change it to Ref<SourceProvider>&& in https://bugs.webkit.org/show_bug.cgi?id=168325.

  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::addCompilation):
Take Ref<Compilation>&&.

  • profiler/ProfilerDatabase.h:

Change data structures to hold Ref<> instead of RefPtr<>.

  • runtime/EvalExecutable.h:

(JSC::EvalExecutable::generatedJITCode):
Return Ref<> instead.

  • runtime/ExecutableBase.h:

(JSC::ExecutableBase::generatedJITCodeForCall):
(JSC::ExecutableBase::generatedJITCodeForConstruct):
(JSC::ExecutableBase::generatedJITCodeFor):
Return Ref<> instead.

  • runtime/Identifier.cpp:

(JSC::Identifier::add):
(JSC::Identifier::add8):

  • runtime/Identifier.h:

(JSC::Identifier::add):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::setInputCursor):
And take Ref<> in this method.

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::inputCursor):
Change m_inputCursor from RefPtr<> to Ref<>.

  • runtime/JSPropertyNameEnumerator.cpp:

(JSC::JSPropertyNameEnumerator::create):
(JSC::JSPropertyNameEnumerator::finishCreation):
Take Ref<PropertyNameArray>&&.

  • runtime/JSPropertyNameEnumerator.h:

(JSC::propertyNameEnumerator):

  • runtime/JSString.h:

(JSC::JSString::JSString):
Take Ref<StringImpl>&& since we do not allow nullptr in this constructor.

(JSC::JSString::create):
(JSC::JSString::createHasOtherOwner):
Take Ref<StringImpl>&& in these factory functions. And drop unnecessary assertions.

(JSC::jsSingleCharacterString):
Use StringImpl::create() which returns Ref<>.

(JSC::jsNontrivialString):
Dereference impl() since we ensure that s.length() > 1.

(JSC::jsString):
Use releaseNonNull() since we ensure that s.length() > 1.

(JSC::jsOwnedString):
Use releaseNonNull() since we ensure that s.length() > 1.

  • runtime/ModuleProgramExecutable.h:
  • runtime/NativeExecutable.cpp:

(JSC::NativeExecutable::create):
(JSC::NativeExecutable::finishCreation):
Take Ref<JITCode>&&.

  • runtime/NativeExecutable.h:
  • runtime/ProgramExecutable.h:

Return Ref<JITCode>.

  • runtime/PropertyNameArray.h:

(JSC::PropertyNameArray::releaseData):
(JSC::PropertyNameArray::setData): Deleted.
This is not used.

  • runtime/RegExpKey.h:

(JSC::RegExpKey::RegExpKey):
Take RefPtr<>&&.

  • runtime/SmallStrings.cpp:

(JSC::SmallStringsStorage::rep):
Return StringImpl& since m_reps is already initialized in the constructor.

(JSC::SmallStrings::createEmptyString):
Dereference StringImpl::empty().

(JSC::SmallStrings::createSingleCharacterString):
Use StringImpl&.

(JSC::SmallStrings::singleCharacterStringRep):
Return StringImpl&.

(JSC::SmallStrings::initialize):
Use AtomicStringImpl::add instead.

  • runtime/SmallStrings.h:
  • runtime/Structure.cpp:

(JSC::Structure::toStructureShape):
Return Ref<>.

  • runtime/Structure.h:
  • runtime/TypeLocationCache.cpp:

(JSC::TypeLocationCache::getTypeLocation):
Take RefPtr<TypeSet>&&.

  • runtime/TypeLocationCache.h:
  • runtime/TypeProfilerLog.cpp:

Pass Ref<>&&.

(JSC::TypeProfilerLog::processLogEntries):

  • runtime/TypeSet.cpp:

(JSC::TypeSet::addTypeInformation):
Take RefPtr<>&& since it can be nullptr.
And clean up "not found" code.

(JSC::TypeSet::allStructureRepresentations):
Use range based iteration.

(JSC::StructureShape::leastCommonAncestor):
We found that this method accidentally takes const Vector<> instead of const Vector<>&.
And internally, we just use raw pointers since these StructureShapes are owned by the m_proto trees which starts from the given Vector<>.

(JSC::StructureShape::hasSamePrototypeChain):
Take const reference instead. And use raw pointers internally.

(JSC::StructureShape::merge):
Take Ref<>&&.

  • runtime/TypeSet.h:

(JSC::StructureShape::setProto):
Take Ref<>&&.

  • runtime/VM.cpp:

(JSC::VM::getHostFunction):
Pass Ref<>&&.

(JSC::VM::queueMicrotask):
Take and pass Ref<>&&.

  • runtime/VM.h:

(JSC::QueuedTask::QueuedTask):
Take Ref<>&&.

  • tools/FunctionOverrides.cpp:

(JSC::initializeOverrideInfo):
We need this change due to Ref<>&& and RefPtr<>&& ambiguity of SourceCode constructors.
Once SourceCode is fixed to only take Ref<>&&, this change is unnecessary.

Source/WebCore:

  • bindings/js/ScriptSourceCode.h:

(WebCore::ScriptSourceCode::ScriptSourceCode):
Use Ref and pass it to SourceCode.

  • replay/ReplayController.cpp:

(WebCore::ReplayController::frameNavigated):
Pass reference.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp

    r209764 r212365  
    7171    VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationMode mode,
    7272    unsigned osrEntryBytecodeIndex, const Operands<JSValue>& mustHandleValues,
    73     PassRefPtr<DeferredCompilationCallback> callback)
     73    Ref<DeferredCompilationCallback>&& callback)
    7474{
    7575    if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount())
     
    9797        vm.typeProfilerLog()->processLogEntries(ASCIILiteral("Preparing for DFG compilation."));
    9898   
    99     RefPtr<Plan> plan = adoptRef(
    100         new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues));
     99    Ref<Plan> plan = adoptRef(
     100        *new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues));
    101101   
    102     plan->callback = callback;
     102    plan->callback = WTFMove(callback);
    103103    if (Options::useConcurrentJIT()) {
    104104        Worklist& worklist = ensureGlobalWorklistFor(mode);
    105105        if (logCompilationChanges(mode))
    106106            dataLog("Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist.queueLength(), ".\n");
    107         worklist.enqueue(plan);
     107        worklist.enqueue(WTFMove(plan));
    108108        return CompilationDeferred;
    109109    }
     
    115115static CompilationResult compileImpl(
    116116    VM&, CodeBlock*, CodeBlock*, CompilationMode, unsigned, const Operands<JSValue>&,
    117     PassRefPtr<DeferredCompilationCallback>)
     117    Ref<DeferredCompilationCallback>&&)
    118118{
    119119    return CompilationFailed;
     
    124124    VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationMode mode,
    125125    unsigned osrEntryBytecodeIndex, const Operands<JSValue>& mustHandleValues,
    126     PassRefPtr<DeferredCompilationCallback> passedCallback)
     126    Ref<DeferredCompilationCallback>&& callback)
    127127{
    128     RefPtr<DeferredCompilationCallback> callback = passedCallback;
    129128    CompilationResult result = compileImpl(
    130129        vm, codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues,
    131         callback);
     130        callback.copyRef());
    132131    if (result != CompilationDeferred)
    133132        callback->compilationDidComplete(codeBlock, profiledDFGCodeBlock, result);
Note: See TracChangeset for help on using the changeset viewer.