Changeset 84021 in webkit


Ignore:
Timestamp:
Apr 15, 2011 12:55:54 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-04-14 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Make JSNodeFilterCondition handle its lifetime correctly
https://bugs.webkit.org/show_bug.cgi?id=58622

Add export

2011-04-14 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Make JSNodeFilterCondition handle its lifetime correctly
https://bugs.webkit.org/show_bug.cgi?id=58622

Switch over to a WeakHandle and external roots to keep the
condition value live.

  • bindings/js/JSNodeFilterCondition.cpp: (WebCore::JSNodeFilterCondition::JSNodeFilterCondition): (WebCore::JSNodeFilterCondition::markAggregate): (WebCore::JSNodeFilterCondition::acceptNode): (WebCore::JSNodeFilterCondition::WeakOwner::isReachableFromOpaqueRoots):
  • bindings/js/JSNodeFilterCondition.h: (WebCore::JSNodeFilterCondition::create):
  • bindings/js/JSNodeFilterCustom.cpp: (WebCore::toNodeFilter):
  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r83997 r84021  
     12011-04-14  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Make JSNodeFilterCondition handle its lifetime correctly
     6        https://bugs.webkit.org/show_bug.cgi?id=58622
     7
     8        Add export
     9
     10        * JavaScriptCore.exp:
     11
    1122011-04-14  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r83955 r84021  
    170170__ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
    171171__ZN3JSC15WeakHandleOwner26isReachableFromOpaqueRootsENS_6HandleINS_7UnknownEEEPvRNS_9MarkStackE
     172__ZN3JSC15WeakHandleOwner8finalizeENS_6HandleINS_7UnknownEEEPv
    172173__ZN3JSC15WeakHandleOwnerD2Ev
    173174__ZN3JSC15createTypeErrorEPNS_9ExecStateERKNS_7UStringE
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r83974 r84021  
    665665                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    666666                        proxyType = 2;
    667                         remoteGlobalIDString = 4539C8FF0EC27F6400A70F4C /* gtest.framework */;
     667                        remoteGlobalIDString = 4539C8FF0EC27F6400A70F4C;
    668668                        remoteInfo = "gtest-framework";
    669669                };
     
    672672                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    673673                        proxyType = 2;
    674                         remoteGlobalIDString = 40C848FA101A209C0083642A /* libgtest.a */;
     674                        remoteGlobalIDString = 40C848FA101A209C0083642A;
    675675                        remoteInfo = "gtest-static";
    676676                };
     
    679679                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    680680                        proxyType = 2;
    681                         remoteGlobalIDString = 40C8490B101A217E0083642A /* libgtest_main.a */;
     681                        remoteGlobalIDString = 40C8490B101A217E0083642A;
    682682                        remoteInfo = "gtest_main-static";
    683683                };
     
    686686                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    687687                        proxyType = 2;
    688                         remoteGlobalIDString = 40899F430FFA7184000B29AE /* gtest_unittest-framework */;
     688                        remoteGlobalIDString = 40899F430FFA7184000B29AE;
    689689                        remoteInfo = "gtest_unittest-framework";
    690690                };
     
    693693                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    694694                        proxyType = 2;
    695                         remoteGlobalIDString = 40C84987101A36850083642A /* gtest_unittest */;
     695                        remoteGlobalIDString = 40C84987101A36850083642A;
    696696                        remoteInfo = "gtest_unittest-static";
    697697                };
     
    700700                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    701701                        proxyType = 2;
    702                         remoteGlobalIDString = 4089A0130FFACEFC000B29AE /* sample1_unittest-framework */;
     702                        remoteGlobalIDString = 4089A0130FFACEFC000B29AE;
    703703                        remoteInfo = "sample1_unittest-framework";
    704704                };
     
    707707                        containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
    708708                        proxyType = 2;
    709                         remoteGlobalIDString = 40C84997101A36A60083642A /* sample1_unittest-static */;
     709                        remoteGlobalIDString = 40C84997101A36A60083642A;
    710710                        remoteInfo = "sample1_unittest-static";
    711711                };
  • trunk/Source/WebCore/ChangeLog

    r84018 r84021  
     12011-04-14  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Make JSNodeFilterCondition handle its lifetime correctly
     6        https://bugs.webkit.org/show_bug.cgi?id=58622
     7
     8        Switch over to a WeakHandle and external roots to keep the
     9        condition value live.
     10
     11        * bindings/js/JSNodeFilterCondition.cpp:
     12        (WebCore::JSNodeFilterCondition::JSNodeFilterCondition):
     13        (WebCore::JSNodeFilterCondition::markAggregate):
     14        (WebCore::JSNodeFilterCondition::acceptNode):
     15        (WebCore::JSNodeFilterCondition::WeakOwner::isReachableFromOpaqueRoots):
     16        * bindings/js/JSNodeFilterCondition.h:
     17        (WebCore::JSNodeFilterCondition::create):
     18        * bindings/js/JSNodeFilterCustom.cpp:
     19        (WebCore::toNodeFilter):
     20        * bindings/scripts/CodeGeneratorJS.pm:
     21
    1222011-04-13  Luiz Agostini  <luiz.agostini@openbossa.org>
    223
  • trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp

    r77151 r84021  
    3333ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition);
    3434
    35 JSNodeFilterCondition::JSNodeFilterCondition(JSValue filter)
    36     : m_filter(filter)
     35JSNodeFilterCondition::JSNodeFilterCondition(JSGlobalData& globalData, NodeFilter* owner, JSValue filter)
     36    : m_filter(globalData, filter, &m_weakOwner, owner)
    3737{
    38 }
    39 
    40 void JSNodeFilterCondition::markAggregate(MarkStack& markStack)
    41 {
    42     markStack.append(&m_filter);
    4338}
    4439
     
    4742    JSLock lock(SilenceAssertionsOnly);
    4843
    49     if (!m_filter->isObject())
     44    if (!m_filter.isObject())
    5045        return NodeFilter::FILTER_ACCEPT;
    5146
     
    6358    CallType callType = getCallData(function, callData);
    6459    if (callType == CallTypeNone) {
    65         function = m_filter->get(exec, Identifier(exec, "acceptNode"));
     60        function = m_filter.get().get(exec, Identifier(exec, "acceptNode"));
    6661        callType = getCallData(function, callData);
    6762        if (callType == CallTypeNone) {
     
    8984}
    9085
     86bool JSNodeFilterCondition::WeakOwner::isReachableFromOpaqueRoots(JSC::Handle<Unknown>, void* context, MarkStack& markStack)
     87{
     88    return markStack.containsOpaqueRoot(context);
     89}
     90
    9191} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.h

    r77151 r84021  
    2222
    2323#include "NodeFilterCondition.h"
     24#include <heap/Weak.h>
    2425#include <runtime/JSValue.h>
    2526#include <wtf/PassRefPtr.h>
     
    2829
    2930    class Node;
     31    class NodeFilter;
    3032
    3133    class JSNodeFilterCondition : public NodeFilterCondition {
    3234    public:
    33         static PassRefPtr<JSNodeFilterCondition> create(JSC::JSValue filter)
     35        static PassRefPtr<JSNodeFilterCondition> create(JSC::JSGlobalData& globalData, NodeFilter* owner, JSC::JSValue filter)
    3436        {
    35             return adoptRef(new JSNodeFilterCondition(filter));
     37            return adoptRef(new JSNodeFilterCondition(globalData, owner, filter));
    3638        }
    3739
    3840    private:
    39         JSNodeFilterCondition(JSC::JSValue filter);
     41        JSNodeFilterCondition(JSC::JSGlobalData&, NodeFilter* owner, JSC::JSValue filter);
    4042
    4143        virtual short acceptNode(ScriptState*, Node*) const;
    42         virtual void markAggregate(JSC::MarkStack&);
    4344
    44         mutable JSC::DeprecatedPtr<JSC::Unknown> m_filter;
     45        class WeakOwner : public JSC::WeakHandleOwner {
     46            virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     47        };
     48        WeakOwner m_weakOwner;
     49        mutable JSC::Weak<JSC::Unknown> m_filter;
    4550    };
    4651
  • trunk/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp

    r77151 r84021  
    4040{
    4141    Base::markChildren(markStack);
    42     impl()->markAggregate(markStack);
     42    markStack.addOpaqueRoot(impl());
    4343}
    4444
    45 PassRefPtr<NodeFilter> toNodeFilter(JSValue value)
     45PassRefPtr<NodeFilter> toNodeFilter(JSGlobalData& globalData, JSValue value)
    4646{
    4747    if (value.inherits(&JSNodeFilter::s_info))
    4848        return static_cast<JSNodeFilter*>(asObject(value))->impl();
    4949
    50     return NodeFilter::create(JSNodeFilterCondition::create(value));
     50    RefPtr<NodeFilter> result = NodeFilter::create();
     51    result->setCondition(JSNodeFilterCondition::create(globalData, result.get(), value));
     52    return result.release();
    5153}
    5254
  • trunk/Source/WebCore/bindings/js/JSNodeIteratorCustom.cpp

    r58333 r84021  
    3535
    3636    if (NodeFilter* filter = m_impl->filter())
    37         filter->markAggregate(markStack);
     37        markStack.addOpaqueRoot(filter);
    3838}
    3939
  • trunk/Source/WebCore/bindings/js/JSTreeWalkerCustom.cpp

    r58298 r84021  
    3535
    3636    if (NodeFilter* filter = m_impl->filter())
    37         filter->markAggregate(markStack);
     37        markStack.addOpaqueRoot(filter);
    3838}
    3939
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r83955 r84021  
    924924    if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) {
    925925        if ($interfaceName eq "NodeFilter") {
    926             push(@headerContent, "PassRefPtr<NodeFilter> toNodeFilter(JSC::JSValue);\n");
     926            push(@headerContent, "PassRefPtr<NodeFilter> toNodeFilter(JSC::JSGlobalData&, JSC::JSValue);\n");
    927927        } else {
    928928            push(@headerContent, "$implType* to${interfaceName}(JSC::JSValue);\n");
     
    24672467    }
    24682468
     2469    if ($type eq "NodeFilter") {
     2470        $implIncludes{"JS$type.h"} = 1;
     2471        return "to$type(exec->globalData(), $value)";
     2472    }
     2473
    24692474    if ($type eq "MediaQueryListListener") {
    24702475        $implIncludes{"MediaQueryListListener.h"} = 1;
  • trunk/Source/WebCore/dom/NodeFilter.h

    r71515 r84021  
    7171        }
    7272
     73        static PassRefPtr<NodeFilter> create()
     74        {
     75            return adoptRef(new NodeFilter());
     76        }
     77
    7378        short acceptNode(ScriptState*, Node*) const;
    74         void markAggregate(JSC::MarkStack& markStack) { m_condition->markAggregate(markStack); };
    7579
    7680        // Do not call these functions. They are just scaffolding to support the Objective-C bindings.
    7781        // They operate in the main thread normal world, and they swallow JS exceptions.
    7882        short acceptNode(Node* node) const { return acceptNode(scriptStateFromNode(mainThreadNormalWorld(), node), node); }
     83       
     84        void setCondition(PassRefPtr<NodeFilterCondition> condition) { ASSERT(!m_condition); m_condition = condition; }
    7985
    8086    private:
    8187        NodeFilter(PassRefPtr<NodeFilterCondition> condition) : m_condition(condition) { }
     88        NodeFilter() {}
    8289
    8390        RefPtr<NodeFilterCondition> m_condition;
Note: See TracChangeset for help on using the changeset viewer.