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.h

    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
     
    3232#include "Nodes.h"
    3333#include "SamplingTool.h"
     34#include <wtf/PassOwnPtr.h>
    3435
    3536namespace JSC {
     
    172173        bool needsActivation() const { return m_features & (EvalFeature | ClosureFeature | WithFeature | CatchFeature); }
    173174
    174         virtual ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0;
     175        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0;
    175176
    176177    protected:
     
    204205        JSObject* compile(ExecState*, ScopeChainNode*);
    205206
    206         ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    207207        static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); }
    208208
     
    213213        {
    214214        }
     215
     216        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     217
    215218        EvalCodeBlock* m_evalCodeBlock;
    216219
     
    250253        JSObject* compile(ExecState*, ScopeChainNode*);
    251254
    252         // CodeBlocks for program code are transient and therefore do not gain from from throwing out there exception information.
    253         ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) { ASSERT_NOT_REACHED(); return 0; }
    254 
    255255    private:
    256256        ProgramExecutable(ExecState* exec, const SourceCode& source)
     
    259259        {
    260260        }
     261
     262        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     263
    261264        ProgramCodeBlock* m_programCodeBlock;
    262265
     
    351354
    352355        void recompile(ExecState*);
    353         ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    354356        void markAggregate(MarkStack& markStack);
    355357        static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
     
    387389        bool compileForConstruct(ExecState*, ScopeChainNode*);
    388390
     391        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     392
    389393        unsigned m_numVariables : 31;
    390394        bool m_forceUsesArguments : 1;
Note: See TracChangeset for help on using the changeset viewer.