Ignore:
Timestamp:
Jul 6, 2010, 9:14:44 AM (15 years ago)
Author:
Darin Adler
Message:

2010-07-06 Darin Adler <Darin Adler>

Reviewed by Adam Barth.

Add adoptPtr and leakPtr functions for OwnPtr and PassOwnPtr
https://bugs.webkit.org/show_bug.cgi?id=41320

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): Use assignment instead of set since the result of reparseExceptionInfo is now a PassOwnPtr.
  • bytecode/CodeBlock.h: Change extractExceptionInfo to return a PassOwnPtr instead of a raw pointer.
  • runtime/Executable.cpp: (JSC::FunctionExecutable::reparseExceptionInfo): Return a PassOwnPtr. (JSC::EvalExecutable::reparseExceptionInfo): Ditto. (JSC::ProgramExecutable::reparseExceptionInfo): Added. This was in the header before, but it's better to not have it there to reduce header dependencies. Return a PassOwnPtr.
  • runtime/Executable.h: Made reparseExceptionInfo return a PassOwnPtr, and put it in the private sections of classes other than the base class.
  • wtf/MessageQueue.h: (WTF::MessageQueue::append): Use leakPtr instead of release. (WTF::MessageQueue::appendAndCheckEmpty): Ditto. (WTF::MessageQueue::prepend): Ditto.
  • wtf/OwnPtr.h: Tweaked formatting. Changed the release function to return a PassOwnPtr rather than a raw pointer. Added a leakPtr function that returns a raw pointer. Put the constructor that takes a raw pointer and the set function into a section guarded by LOOSE_OWN_PTR. Adapted to the new adoptPtr function from PassOwnPtr.h.
  • wtf/PassOwnPtr.h: Tweaked formatting. Renamed the release function to leakPtr. Added an adoptPtr function that creates a new PassOwnPtr. Put the constructor and assignment operators that take a raw pointer into a section guarded by LOOSE_PASS_OWN_PTR.

2010-07-06 Darin Adler <Darin Adler>

Reviewed by Adam Barth.

Add adoptPtr and leakPtr functions for OwnPtr and PassOwnPtr
https://bugs.webkit.org/show_bug.cgi?id=41320

Made code changes required because of the change to the release function.
The equivalent to the old release function is now named leakPtr and
should be used sparingly. The new release function returns a PassOwnPtr.

  • css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::getFontData): Changed code to call leakPtr instead of release.
  • css/CSSParser.cpp: (WebCore::CSSParser::addProperty): Ditto.
  • css/CSSSegmentedFontFace.cpp: (WebCore::CSSSegmentedFontFace::getFontData): Removed unneeded type casting. Not sure why this changed the type to FontData* and then casted back to SimpleFontData*.
  • css/MediaQuery.cpp: (WebCore::MediaQuery::MediaQuery): Removed call to release on a PassOwnPtr, since the data member is now an OwnPtr. (WebCore::MediaQuery::~MediaQuery): Removed now-unneeded delete.
  • css/MediaQuery.h: Changed m_expressions to be an OwnPtr.
  • html/HTMLToken.h: (WebCore::AtomicHTMLToken::AtomicHTMLToken): Use assignment instead of the set function since there are no raw pointers involved.
  • loader/CachedResource.cpp: (WebCore::CachedResource::makePurgeable): Ditto.
  • loader/CrossOriginPreflightResultCache.cpp: (WebCore::CrossOriginPreflightResultCache::appendEntry): Use leakPtr instead of release, and also add FIXME about deleting the old value if the original and URL are already in the map. I believe dealing with this FIXME may fix a storage leak.
  • loader/CrossOriginPreflightResultCache.h: Change the argument to be PassOwnPtr instead of a raw pointer, since this function does take ownership.
  • loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Use assignment instead of the set function since there are no raw pointers involved.
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::startIconLoader): Ditto.
  • loader/TextResourceDecoder.cpp: (WebCore::TextResourceDecoder::decode): Ditto. (WebCore::TextResourceDecoder::flush): Ditto.
  • page/DOMTimer.cpp: (WebCore::DOMTimer::fired): Use OwnPtr instead of an explicit delete.
  • platform/CrossThreadCopier.h: Removed explicit code that tried to copy PassOwnPtr in a complicated way. It did nothing different from just returning the PassOwnPtr. This presumably was done because PassRefPtr has issues when copied cross-thread, but there are no similar issues for PassOwnPtr. Someone with more experience than I might be able to remove the specialization altogether, because CrossThreadCopierPassThrough does the right thing in this case.
  • platform/SharedBuffer.cpp: (WebCore::SharedBuffer::adoptPurgeableBuffer): Changed argument to be a PassOwnPtr. (WebCore::SharedBuffer::releasePurgeableBuffer): Changed result to be a PassOwnPtr.
  • platform/SharedBuffer.h: Updated for changes above.
  • rendering/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::applyResource): Changed one site to use assignment instead of the set function since there are no raw pointers involved. Changed another site to use leakPtr instead of release.
  • rendering/RenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): Use assignment instead of the set function since there are no raw pointers involved.
  • rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::setContent): Use leakPtr instead of release. (WebCore::RenderStyle::setBoxShadow): Ditto.
  • workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::connectToWorker): Removed unneeded call to release function in a code path that passes a PassOwnPtr to a function that takes a PassOwnPtr.
  • workers/WorkerContext.cpp: (WebCore::WorkerContext::setTimeout): Changed argument type to PassOwnPtr. (WebCore::WorkerContext::setInterval): Ditto.
  • workers/WorkerContext.h: Updated for changes above.
  • workers/WorkerMessagingProxy.cpp: (WebCore::WorkerMessagingProxy::postMessageToWorkerObject): (WebCore::WorkerMessagingProxy::postMessageToWorkerContext): Removed unneeded call to release function in code paths that pass a PassOwnPtr to a function that takes a PassOwnPtr.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Executable.cpp

    r61588 r62551  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    230230}
    231231
    232 ExceptionInfo* FunctionExecutable::reparseExceptionInfo(JSGlobalData* globalData, ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
     232PassOwnPtr<ExceptionInfo> FunctionExecutable::reparseExceptionInfo(JSGlobalData* globalData, ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
    233233{
    234234    RefPtr<FunctionBodyNode> newFunctionBody = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source);
    235235    if (!newFunctionBody)
    236         return 0;
     236        return PassOwnPtr<ExceptionInfo>();
    237237    if (m_forceUsesArguments)
    238238        newFunctionBody->setUsesArguments();
     
    261261}
    262262
    263 ExceptionInfo* EvalExecutable::reparseExceptionInfo(JSGlobalData* globalData, ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
     263PassOwnPtr<ExceptionInfo> EvalExecutable::reparseExceptionInfo(JSGlobalData* globalData, ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
    264264{
    265265    RefPtr<EvalNode> newEvalBody = globalData->parser->parse<EvalNode>(globalData, 0, 0, m_source);
    266266    if (!newEvalBody)
    267         return 0;
     267        return PassOwnPtr<ExceptionInfo>();
    268268
    269269    ScopeChain scopeChain(scopeChainNode);
     
    335335}
    336336
    337 };
    338 
    339 
     337PassOwnPtr<ExceptionInfo> ProgramExecutable::reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*)
     338{
     339    // CodeBlocks for program code are transient and therefore do not gain from from throwing out their exception information.
     340    return PassOwnPtr<ExceptionInfo>();
     341}
     342
     343}
Note: See TracChangeset for help on using the changeset viewer.