Skip to content

Commit 4e48840

Browse files
committed
Purge PassRefPtr in JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=145750 Source/JavaScriptCore: As a step to purge PassRefPtr, this patch replaces PassRefPtr with Ref or RefPtr. Reviewed by Darin Adler. * API/JSClassRef.cpp: (OpaqueJSClass::createNoAutomaticPrototype): * API/JSClassRef.h: * API/JSContextRef.cpp: * API/JSScriptRef.cpp: (OpaqueJSScript::create): * API/JSStringRef.cpp: (JSStringCreateWithCharacters): (JSStringCreateWithUTF8CString): * API/OpaqueJSString.cpp: (OpaqueJSString::create): * API/OpaqueJSString.h: (OpaqueJSString::create): * bytecompiler/StaticPropertyAnalysis.h: (JSC::StaticPropertyAnalysis::create): * debugger/DebuggerCallFrame.h: (JSC::DebuggerCallFrame::create): * dfg/DFGToFTLDeferredCompilationCallback.cpp: (JSC::DFG::ToFTLDeferredCompilationCallback::create): * dfg/DFGToFTLDeferredCompilationCallback.h: * dfg/DFGToFTLForOSREntryDeferredCompilationCallback.cpp: (JSC::DFG::Ref<ToFTLForOSREntryDeferredCompilationCallback>ToFTLForOSREntryDeferredCompilationCallback::create): (JSC::DFG::ToFTLForOSREntryDeferredCompilationCallback::create): Deleted. * dfg/DFGToFTLForOSREntryDeferredCompilationCallback.h: * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::create): (JSC::DFG::ensureGlobalDFGWorklist): (JSC::DFG::ensureGlobalFTLWorklist): * dfg/DFGWorklist.h: * heap/EdenGCActivityCallback.h: (JSC::GCActivityCallback::createEdenTimer): * heap/FullGCActivityCallback.h: (JSC::GCActivityCallback::createFullTimer): * heap/GCActivityCallback.h: * inspector/InjectedScriptHost.h: * inspector/JavaScriptCallFrame.h: (Inspector::JavaScriptCallFrame::create): * inspector/ScriptArguments.cpp: (Inspector::ScriptArguments::create): * inspector/ScriptArguments.h: * jit/JITStubRoutine.h: (JSC::JITStubRoutine::createSelfManagedRoutine): * jit/JITToDFGDeferredCompilationCallback.cpp: (JSC::JITToDFGDeferredCompilationCallback::create): * jit/JITToDFGDeferredCompilationCallback.h: * jsc.cpp: (jscmain): * parser/NodeConstructors.h: (JSC::ArrayPatternNode::create): (JSC::ObjectPatternNode::create): (JSC::BindingNode::create): * parser/Nodes.cpp: (JSC::FunctionParameters::create): * parser/Nodes.h: * parser/SourceProvider.h: (JSC::StringSourceProvider::create): * profiler/Profile.cpp: (JSC::Profile::create): * profiler/Profile.h: * profiler/ProfileGenerator.cpp: (JSC::ProfileGenerator::create): * profiler/ProfileGenerator.h: * profiler/ProfileNode.h: (JSC::ProfileNode::create): * runtime/DataView.cpp: (JSC::DataView::create): * runtime/DataView.h: * runtime/DateInstanceCache.h: (JSC::DateInstanceData::create): * runtime/JSPromiseReaction.cpp: (JSC::createExecutePromiseReactionMicrotask): * runtime/JSPromiseReaction.h: * runtime/PropertyNameArray.h: (JSC::PropertyNameArrayData::create): * runtime/TypeSet.h: (JSC::StructureShape::create): (JSC::TypeSet::create): * runtime/TypedArrayBase.h: (JSC::TypedArrayBase::create): (JSC::TypedArrayBase::createUninitialized): (JSC::TypedArrayBase::subarrayImpl): * runtime/VM.cpp: (JSC::VM::createContextGroup): (JSC::VM::create): (JSC::VM::createLeaked): * runtime/VM.h: * yarr/RegularExpression.cpp: (JSC::Yarr::RegularExpression::Private::create): Source/WebCore: Reviewed by Darin Adler. As a step to purge PassRefPtr, this patch replaces PassRefPtr with Ref or RefPtr. No new tests, no behavior changes. * bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::commonVM): Canonical link: https://commits.webkit.org/163825@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ff93cba commit 4e48840

51 files changed

Lines changed: 218 additions & 110 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/JavaScriptCore/API/JSClassRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ OpaqueJSClass::~OpaqueJSClass()
108108
JSClassRelease(prototypeClass);
109109
}
110110

111-
PassRefPtr<OpaqueJSClass> OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition)
111+
Ref<OpaqueJSClass> OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition)
112112
{
113-
return adoptRef(new OpaqueJSClass(definition, 0));
113+
return adoptRef(*new OpaqueJSClass(definition, 0));
114114
}
115115

116116
PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* clientDefinition)

Source/JavaScriptCore/API/JSClassRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct OpaqueJSClassContextData {
8686

8787
struct OpaqueJSClass : public ThreadSafeRefCounted<OpaqueJSClass> {
8888
static PassRefPtr<OpaqueJSClass> create(const JSClassDefinition*);
89-
static PassRefPtr<OpaqueJSClass> createNoAutomaticPrototype(const JSClassDefinition*);
89+
static Ref<OpaqueJSClass> createNoAutomaticPrototype(const JSClassDefinition*);
9090
JS_EXPORT_PRIVATE ~OpaqueJSClass();
9191

9292
String className();

Source/JavaScriptCore/API/JSContextRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const GlobalObjectMethodTable JSC::javaScriptCoreAPIGlobalObjectMethodTable = {
7676
JSContextGroupRef JSContextGroupCreate()
7777
{
7878
initializeThreading();
79-
return toRef(VM::createContextGroup().leakRef());
79+
return toRef(&VM::createContextGroup().leakRef());
8080
}
8181

8282
JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group)

Source/JavaScriptCore/API/JSScriptRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ using namespace JSC;
4141

4242
struct OpaqueJSScript : public SourceProvider {
4343
public:
44-
static WTF::PassRefPtr<OpaqueJSScript> create(VM* vm, const String& url, int startingLineNumber, const String& source)
44+
static WTF::RefPtr<OpaqueJSScript> create(VM* vm, const String& url, int startingLineNumber, const String& source)
4545
{
46-
return WTF::adoptRef(new OpaqueJSScript(vm, url, startingLineNumber, source));
46+
return WTF::adoptRef(*new OpaqueJSScript(vm, url, startingLineNumber, source));
4747
}
4848

4949
virtual const String& source() const override

Source/JavaScriptCore/API/JSStringRef.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace WTF::Unicode;
3737
JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
3838
{
3939
initializeThreading();
40-
return OpaqueJSString::create(chars, numChars).leakRef();
40+
return &OpaqueJSString::create(chars, numChars).leakRef();
4141
}
4242

4343
JSStringRef JSStringCreateWithUTF8CString(const char* string)
@@ -51,12 +51,12 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
5151
const LChar* stringStart = reinterpret_cast<const LChar*>(string);
5252
if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length, &sourceIsAllASCII)) {
5353
if (sourceIsAllASCII)
54-
return OpaqueJSString::create(stringStart, length).leakRef();
55-
return OpaqueJSString::create(buffer.data(), p - buffer.data()).leakRef();
54+
return &OpaqueJSString::create(stringStart, length).leakRef();
55+
return &OpaqueJSString::create(buffer.data(), p - buffer.data()).leakRef();
5656
}
5757
}
5858

59-
return OpaqueJSString::create().leakRef();
59+
return &OpaqueJSString::create().leakRef();
6060
}
6161

6262
JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars)

Source/JavaScriptCore/API/JSStringRefCF.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
4141
// it can hold. (<rdar://problem/6806478>)
4242
size_t length = CFStringGetLength(string);
4343
if (!length)
44-
return OpaqueJSString::create(reinterpret_cast<const LChar*>(""), 0).leakRef();
44+
return &OpaqueJSString::create(reinterpret_cast<const LChar*>(""), 0).leakRef();
4545

4646
Vector<LChar, 1024> lcharBuffer(length);
4747
CFIndex usedBufferLength;
4848
CFIndex convertedSize = CFStringGetBytes(string, CFRangeMake(0, length), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), length, &usedBufferLength);
4949
if (static_cast<size_t>(convertedSize) == length && static_cast<size_t>(usedBufferLength) == length)
50-
return OpaqueJSString::create(lcharBuffer.data(), length).leakRef();
50+
return &OpaqueJSString::create(lcharBuffer.data(), length).leakRef();
5151

5252
auto buffer = std::make_unique<UniChar[]>(length);
5353
CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get());
5454
static_assert(sizeof(UniChar) == sizeof(UChar), "UniChar and UChar must be same size");
55-
return OpaqueJSString::create(reinterpret_cast<UChar*>(buffer.get()), length).leakRef();
55+
return &OpaqueJSString::create(reinterpret_cast<UChar*>(buffer.get()), length).leakRef();
5656
}
5757

5858
CFStringRef JSStringCopyCFString(CFAllocatorRef allocator, JSStringRef string)

Source/JavaScriptCore/API/OpaqueJSString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
using namespace JSC;
3636

37-
PassRefPtr<OpaqueJSString> OpaqueJSString::create(const String& string)
37+
RefPtr<OpaqueJSString> OpaqueJSString::create(const String& string)
3838
{
3939
if (string.isNull())
4040
return nullptr;

Source/JavaScriptCore/API/OpaqueJSString.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ namespace JSC {
3636
}
3737

3838
struct OpaqueJSString : public ThreadSafeRefCounted<OpaqueJSString> {
39-
static PassRefPtr<OpaqueJSString> create()
39+
static Ref<OpaqueJSString> create()
4040
{
41-
return adoptRef(new OpaqueJSString);
41+
return adoptRef(*new OpaqueJSString);
4242
}
4343

44-
static PassRefPtr<OpaqueJSString> create(const LChar* characters, unsigned length)
44+
static Ref<OpaqueJSString> create(const LChar* characters, unsigned length)
4545
{
46-
return adoptRef(new OpaqueJSString(characters, length));
46+
return adoptRef(*new OpaqueJSString(characters, length));
4747
}
4848

49-
static PassRefPtr<OpaqueJSString> create(const UChar* characters, unsigned length)
49+
static Ref<OpaqueJSString> create(const UChar* characters, unsigned length)
5050
{
51-
return adoptRef(new OpaqueJSString(characters, length));
51+
return adoptRef(*new OpaqueJSString(characters, length));
5252
}
5353

54-
JS_EXPORT_PRIVATE static PassRefPtr<OpaqueJSString> create(const String&);
54+
JS_EXPORT_PRIVATE static RefPtr<OpaqueJSString> create(const String&);
5555

5656
JS_EXPORT_PRIVATE ~OpaqueJSString();
5757

Source/JavaScriptCore/ChangeLog

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,101 @@
1+
2015-06-08 Gyuyoung Kim <gyuyoung.kim@webkit.org>
2+
3+
Purge PassRefPtr in JavaScriptCore
4+
https://bugs.webkit.org/show_bug.cgi?id=145750
5+
6+
As a step to purge PassRefPtr, this patch replaces PassRefPtr with Ref or RefPtr.
7+
8+
Reviewed by Darin Adler.
9+
10+
* API/JSClassRef.cpp:
11+
(OpaqueJSClass::createNoAutomaticPrototype):
12+
* API/JSClassRef.h:
13+
* API/JSContextRef.cpp:
14+
* API/JSScriptRef.cpp:
15+
(OpaqueJSScript::create):
16+
* API/JSStringRef.cpp:
17+
(JSStringCreateWithCharacters):
18+
(JSStringCreateWithUTF8CString):
19+
* API/OpaqueJSString.cpp:
20+
(OpaqueJSString::create):
21+
* API/OpaqueJSString.h:
22+
(OpaqueJSString::create):
23+
* bytecompiler/StaticPropertyAnalysis.h:
24+
(JSC::StaticPropertyAnalysis::create):
25+
* debugger/DebuggerCallFrame.h:
26+
(JSC::DebuggerCallFrame::create):
27+
* dfg/DFGToFTLDeferredCompilationCallback.cpp:
28+
(JSC::DFG::ToFTLDeferredCompilationCallback::create):
29+
* dfg/DFGToFTLDeferredCompilationCallback.h:
30+
* dfg/DFGToFTLForOSREntryDeferredCompilationCallback.cpp:
31+
(JSC::DFG::Ref<ToFTLForOSREntryDeferredCompilationCallback>ToFTLForOSREntryDeferredCompilationCallback::create):
32+
(JSC::DFG::ToFTLForOSREntryDeferredCompilationCallback::create): Deleted.
33+
* dfg/DFGToFTLForOSREntryDeferredCompilationCallback.h:
34+
* dfg/DFGWorklist.cpp:
35+
(JSC::DFG::Worklist::create):
36+
(JSC::DFG::ensureGlobalDFGWorklist):
37+
(JSC::DFG::ensureGlobalFTLWorklist):
38+
* dfg/DFGWorklist.h:
39+
* heap/EdenGCActivityCallback.h:
40+
(JSC::GCActivityCallback::createEdenTimer):
41+
* heap/FullGCActivityCallback.h:
42+
(JSC::GCActivityCallback::createFullTimer):
43+
* heap/GCActivityCallback.h:
44+
* inspector/InjectedScriptHost.h:
45+
* inspector/JavaScriptCallFrame.h:
46+
(Inspector::JavaScriptCallFrame::create):
47+
* inspector/ScriptArguments.cpp:
48+
(Inspector::ScriptArguments::create):
49+
* inspector/ScriptArguments.h:
50+
* jit/JITStubRoutine.h:
51+
(JSC::JITStubRoutine::createSelfManagedRoutine):
52+
* jit/JITToDFGDeferredCompilationCallback.cpp:
53+
(JSC::JITToDFGDeferredCompilationCallback::create):
54+
* jit/JITToDFGDeferredCompilationCallback.h:
55+
* jsc.cpp:
56+
(jscmain):
57+
* parser/NodeConstructors.h:
58+
(JSC::ArrayPatternNode::create):
59+
(JSC::ObjectPatternNode::create):
60+
(JSC::BindingNode::create):
61+
* parser/Nodes.cpp:
62+
(JSC::FunctionParameters::create):
63+
* parser/Nodes.h:
64+
* parser/SourceProvider.h:
65+
(JSC::StringSourceProvider::create):
66+
* profiler/Profile.cpp:
67+
(JSC::Profile::create):
68+
* profiler/Profile.h:
69+
* profiler/ProfileGenerator.cpp:
70+
(JSC::ProfileGenerator::create):
71+
* profiler/ProfileGenerator.h:
72+
* profiler/ProfileNode.h:
73+
(JSC::ProfileNode::create):
74+
* runtime/DataView.cpp:
75+
(JSC::DataView::create):
76+
* runtime/DataView.h:
77+
* runtime/DateInstanceCache.h:
78+
(JSC::DateInstanceData::create):
79+
* runtime/JSPromiseReaction.cpp:
80+
(JSC::createExecutePromiseReactionMicrotask):
81+
* runtime/JSPromiseReaction.h:
82+
* runtime/PropertyNameArray.h:
83+
(JSC::PropertyNameArrayData::create):
84+
* runtime/TypeSet.h:
85+
(JSC::StructureShape::create):
86+
(JSC::TypeSet::create):
87+
* runtime/TypedArrayBase.h:
88+
(JSC::TypedArrayBase::create):
89+
(JSC::TypedArrayBase::createUninitialized):
90+
(JSC::TypedArrayBase::subarrayImpl):
91+
* runtime/VM.cpp:
92+
(JSC::VM::createContextGroup):
93+
(JSC::VM::create):
94+
(JSC::VM::createLeaked):
95+
* runtime/VM.h:
96+
* yarr/RegularExpression.cpp:
97+
(JSC::Yarr::RegularExpression::Private::create):
98+
199
2015-06-08 Filip Pizlo <fpizlo@apple.com>
2100

3101
It should be possible to hoist all constants in DFG SSA

Source/JavaScriptCore/bytecompiler/StaticPropertyAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ namespace JSC {
3535
// Reference count indicates number of live registers that alias this object.
3636
class StaticPropertyAnalysis : public RefCounted<StaticPropertyAnalysis> {
3737
public:
38-
static PassRefPtr<StaticPropertyAnalysis> create(Vector<UnlinkedInstruction, 0, UnsafeVectorOverflow>* instructions, unsigned target)
38+
static Ref<StaticPropertyAnalysis> create(Vector<UnlinkedInstruction, 0, UnsafeVectorOverflow>* instructions, unsigned target)
3939
{
40-
return adoptRef(new StaticPropertyAnalysis(instructions, target));
40+
return adoptRef(*new StaticPropertyAnalysis(instructions, target));
4141
}
4242

4343
void addPropertyIndex(unsigned propertyIndex) { m_propertyIndexes.add(propertyIndex); }

0 commit comments

Comments
 (0)