Skip to content

Commit 6d632bb

Browse files
committed
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 * JavaScriptCore.exp: 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: Canonical link: https://commits.webkit.org/73763@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84021 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 71f8242 commit 6d632bb

11 files changed

Lines changed: 80 additions & 28 deletions

File tree

Source/JavaScriptCore/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2011-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+
112
2011-04-14 Alexey Proskuryakov <ap@apple.com>
213

314
Reviewed by Dan Bernstein.

Source/JavaScriptCore/JavaScriptCore.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ __ZN3JSC14TimeoutChecker5resetEv
169169
__ZN3JSC14throwTypeErrorEPNS_9ExecStateE
170170
__ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
171171
__ZN3JSC15WeakHandleOwner26isReachableFromOpaqueRootsENS_6HandleINS_7UnknownEEEPvRNS_9MarkStackE
172+
__ZN3JSC15WeakHandleOwner8finalizeENS_6HandleINS_7UnknownEEEPv
172173
__ZN3JSC15WeakHandleOwnerD2Ev
173174
__ZN3JSC15createTypeErrorEPNS_9ExecStateERKNS_7UStringE
174175
__ZN3JSC16InternalFunction12vtableAnchorEv

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,49 +664,49 @@
664664
isa = PBXContainerItemProxy;
665665
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
666666
proxyType = 2;
667-
remoteGlobalIDString = 4539C8FF0EC27F6400A70F4C /* gtest.framework */;
667+
remoteGlobalIDString = 4539C8FF0EC27F6400A70F4C;
668668
remoteInfo = "gtest-framework";
669669
};
670670
F33EE0E4135678CA00E09E65 /* PBXContainerItemProxy */ = {
671671
isa = PBXContainerItemProxy;
672672
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
673673
proxyType = 2;
674-
remoteGlobalIDString = 40C848FA101A209C0083642A /* libgtest.a */;
674+
remoteGlobalIDString = 40C848FA101A209C0083642A;
675675
remoteInfo = "gtest-static";
676676
};
677677
F33EE0E6135678CA00E09E65 /* PBXContainerItemProxy */ = {
678678
isa = PBXContainerItemProxy;
679679
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
680680
proxyType = 2;
681-
remoteGlobalIDString = 40C8490B101A217E0083642A /* libgtest_main.a */;
681+
remoteGlobalIDString = 40C8490B101A217E0083642A;
682682
remoteInfo = "gtest_main-static";
683683
};
684684
F33EE0E8135678CA00E09E65 /* PBXContainerItemProxy */ = {
685685
isa = PBXContainerItemProxy;
686686
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
687687
proxyType = 2;
688-
remoteGlobalIDString = 40899F430FFA7184000B29AE /* gtest_unittest-framework */;
688+
remoteGlobalIDString = 40899F430FFA7184000B29AE;
689689
remoteInfo = "gtest_unittest-framework";
690690
};
691691
F33EE0EA135678CA00E09E65 /* PBXContainerItemProxy */ = {
692692
isa = PBXContainerItemProxy;
693693
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
694694
proxyType = 2;
695-
remoteGlobalIDString = 40C84987101A36850083642A /* gtest_unittest */;
695+
remoteGlobalIDString = 40C84987101A36850083642A;
696696
remoteInfo = "gtest_unittest-static";
697697
};
698698
F33EE0EC135678CA00E09E65 /* PBXContainerItemProxy */ = {
699699
isa = PBXContainerItemProxy;
700700
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
701701
proxyType = 2;
702-
remoteGlobalIDString = 4089A0130FFACEFC000B29AE /* sample1_unittest-framework */;
702+
remoteGlobalIDString = 4089A0130FFACEFC000B29AE;
703703
remoteInfo = "sample1_unittest-framework";
704704
};
705705
F33EE0EE135678CA00E09E65 /* PBXContainerItemProxy */ = {
706706
isa = PBXContainerItemProxy;
707707
containerPortal = F33EE0D3135678CA00E09E65 /* gtest.xcodeproj */;
708708
proxyType = 2;
709-
remoteGlobalIDString = 40C84997101A36A60083642A /* sample1_unittest-static */;
709+
remoteGlobalIDString = 40C84997101A36A60083642A;
710710
remoteInfo = "sample1_unittest-static";
711711
};
712712
/* End PBXContainerItemProxy section */

Source/WebCore/ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2011-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+
122
2011-04-13 Luiz Agostini <luiz.agostini@openbossa.org>
223

324
Reviewed by Andreas Kling.

Source/WebCore/bindings/js/JSNodeFilterCondition.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,16 @@ using namespace JSC;
3232

3333
ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition);
3434

35-
JSNodeFilterCondition::JSNodeFilterCondition(JSValue filter)
36-
: m_filter(filter)
35+
JSNodeFilterCondition::JSNodeFilterCondition(JSGlobalData& globalData, NodeFilter* owner, JSValue filter)
36+
: m_filter(globalData, filter, &m_weakOwner, owner)
3737
{
3838
}
3939

40-
void JSNodeFilterCondition::markAggregate(MarkStack& markStack)
41-
{
42-
markStack.append(&m_filter);
43-
}
44-
4540
short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) const
4641
{
4742
JSLock lock(SilenceAssertionsOnly);
4843

49-
if (!m_filter->isObject())
44+
if (!m_filter.isObject())
5045
return NodeFilter::FILTER_ACCEPT;
5146

5247
// The exec argument here should only be null if this was called from a
@@ -62,7 +57,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode)
6257
CallData callData;
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) {
6863
throwError(exec, createTypeError(exec, "NodeFilter object does not have an acceptNode function"));
@@ -88,4 +83,9 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode)
8883
return intResult;
8984
}
9085

86+
bool JSNodeFilterCondition::WeakOwner::isReachableFromOpaqueRoots(JSC::Handle<Unknown>, void* context, MarkStack& markStack)
87+
{
88+
return markStack.containsOpaqueRoot(context);
89+
}
90+
9191
} // namespace WebCore

Source/WebCore/bindings/js/JSNodeFilterCondition.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,32 @@
2121
#define JSNodeFilterCondition_h
2222

2323
#include "NodeFilterCondition.h"
24+
#include <heap/Weak.h>
2425
#include <runtime/JSValue.h>
2526
#include <wtf/PassRefPtr.h>
2627

2728
namespace WebCore {
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

4752
} // namespace WebCore

Source/WebCore/bindings/js/JSNodeFilterCustom.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ namespace WebCore {
3939
void JSNodeFilter::markChildren(MarkStack& markStack)
4040
{
4141
Base::markChildren(markStack);
42-
impl()->markAggregate(markStack);
42+
markStack.addOpaqueRoot(impl());
4343
}
4444

45-
PassRefPtr<NodeFilter> toNodeFilter(JSValue value)
45+
PassRefPtr<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

5355
} // namespace WebCore

Source/WebCore/bindings/js/JSNodeIteratorCustom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void JSNodeIterator::markChildren(MarkStack& markStack)
3434
Base::markChildren(markStack);
3535

3636
if (NodeFilter* filter = m_impl->filter())
37-
filter->markAggregate(markStack);
37+
markStack.addOpaqueRoot(filter);
3838
}
3939

4040
}

Source/WebCore/bindings/js/JSTreeWalkerCustom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void JSTreeWalker::markChildren(MarkStack& markStack)
3434
Base::markChildren(markStack);
3535

3636
if (NodeFilter* filter = m_impl->filter())
37-
filter->markAggregate(markStack);
37+
markStack.addOpaqueRoot(filter);
3838
}
3939

4040
}

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ sub GenerateHeader
923923
}
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");
929929
}
@@ -2466,6 +2466,11 @@ sub JSValueToNative
24662466
return "exec->globalData(), $value";
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;
24712476
return "MediaQueryListListener::create(ScriptValue(exec->globalData(), " . $value ."))";

0 commit comments

Comments
 (0)