Use std::unique_ptr instead of OwnPtr in JSC classes
https://bugs.webkit.org/show_bug.cgi?id=139009
Reviewed by Filip Pizlo.
As a step of using std::unique_ptr<>, this patch replaces OwnPtr with
std::unique_ptr<>|std::make_unique<>.
* bytecode/DFGExitProfile.cpp:
(JSC::DFG::ExitProfile::add):
* bytecode/DFGExitProfile.h:
* bytecode/LazyOperandValueProfile.cpp:
(JSC::CompressedLazyOperandValueProfileHolder::add):
* bytecode/LazyOperandValueProfile.h:
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::specializedSweep):
(JSC::MarkedBlock::stopAllocating):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::clearNewlyAllocated):
* inspector/ContentSearchUtilities.cpp:
(Inspector::ContentSearchUtilities::findMagicComment):
* runtime/RegExp.cpp:
(JSC::RegExp::invalidateCode):
* runtime/RegExp.h:
* yarr/RegularExpression.cpp:
(JSC::Yarr::RegularExpression::Private::compile):
(JSC::Yarr::RegularExpression::isValid):
* yarr/YarrInterpreter.cpp:
(JSC::Yarr::ByteCompiler::compile):
(JSC::Yarr::ByteCompiler::regexBegin):
(JSC::Yarr::byteCompile):
* yarr/YarrInterpreter.h:
(JSC::Yarr::BytecodePattern::BytecodePattern):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176553 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 3a09a7c..2971b42 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,39 @@
+2014-11-27 Gyuyoung Kim <gyuyoung.kim@samsung.com>
+
+ Use std::unique_ptr instead of OwnPtr in JSC classes
+ https://bugs.webkit.org/show_bug.cgi?id=139009
+
+ Reviewed by Filip Pizlo.
+
+ As a step of using std::unique_ptr<>, this patch replaces OwnPtr with
+ std::unique_ptr<>|std::make_unique<>.
+
+ * bytecode/DFGExitProfile.cpp:
+ (JSC::DFG::ExitProfile::add):
+ * bytecode/DFGExitProfile.h:
+ * bytecode/LazyOperandValueProfile.cpp:
+ (JSC::CompressedLazyOperandValueProfileHolder::add):
+ * bytecode/LazyOperandValueProfile.h:
+ * heap/MarkedBlock.cpp:
+ (JSC::MarkedBlock::specializedSweep):
+ (JSC::MarkedBlock::stopAllocating):
+ * heap/MarkedBlock.h:
+ (JSC::MarkedBlock::clearNewlyAllocated):
+ * inspector/ContentSearchUtilities.cpp:
+ (Inspector::ContentSearchUtilities::findMagicComment):
+ * runtime/RegExp.cpp:
+ (JSC::RegExp::invalidateCode):
+ * runtime/RegExp.h:
+ * yarr/RegularExpression.cpp:
+ (JSC::Yarr::RegularExpression::Private::compile):
+ (JSC::Yarr::RegularExpression::isValid):
+ * yarr/YarrInterpreter.cpp:
+ (JSC::Yarr::ByteCompiler::compile):
+ (JSC::Yarr::ByteCompiler::regexBegin):
+ (JSC::Yarr::byteCompile):
+ * yarr/YarrInterpreter.h:
+ (JSC::Yarr::BytecodePattern::BytecodePattern):
+
2014-11-24 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Clean up OwnPtr and PassOwnPtr in JSC - bytecode, jit, inspector, and interpreter
diff --git a/Source/JavaScriptCore/bytecode/DFGExitProfile.h b/Source/JavaScriptCore/bytecode/DFGExitProfile.h
index d67cf44..cdecbaf 100644
--- a/Source/JavaScriptCore/bytecode/DFGExitProfile.h
+++ b/Source/JavaScriptCore/bytecode/DFGExitProfile.h
@@ -32,7 +32,6 @@
#include "ExitKind.h"
#include "ExitingJITType.h"
#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
namespace JSC { namespace DFG {
diff --git a/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.cpp b/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.cpp
index e58420e..de654db 100644
--- a/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.cpp
+++ b/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.cpp
@@ -46,7 +46,7 @@
const ConcurrentJITLocker&, const LazyOperandValueProfileKey& key)
{
if (!m_data)
- m_data = adoptPtr(new LazyOperandValueProfile::List());
+ m_data = std::make_unique<LazyOperandValueProfile::List>();
else {
for (unsigned i = 0; i < m_data->size(); ++i) {
if (m_data->at(i).key() == key)
diff --git a/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h b/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h
index 95ef941..74e4f33 100644
--- a/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h
+++ b/Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h
@@ -31,7 +31,6 @@
#include "VirtualRegister.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
#include <wtf/SegmentedVector.h>
namespace JSC {
@@ -161,7 +160,7 @@
private:
friend class LazyOperandValueProfileParser;
- OwnPtr<LazyOperandValueProfile::List> m_data;
+ std::unique_ptr<LazyOperandValueProfile::List> m_data;
};
class LazyOperandValueProfileParser {
diff --git a/Source/JavaScriptCore/heap/MarkedBlock.cpp b/Source/JavaScriptCore/heap/MarkedBlock.cpp
index 7b9f792..db8e371 100644
--- a/Source/JavaScriptCore/heap/MarkedBlock.cpp
+++ b/Source/JavaScriptCore/heap/MarkedBlock.cpp
@@ -102,7 +102,7 @@
// We only want to discard the newlyAllocated bits if we're creating a FreeList,
// otherwise we would lose information on what's currently alive.
if (sweepMode == SweepToFreeList && m_newlyAllocated)
- m_newlyAllocated.clear();
+ m_newlyAllocated = nullptr;
m_state = ((sweepMode == SweepToFreeList) ? FreeListed : Marked);
return FreeList(head, count * cellSize());
@@ -190,7 +190,7 @@
// way to tell what's live vs dead.
ASSERT(!m_newlyAllocated);
- m_newlyAllocated = adoptPtr(new WTF::Bitmap<atomsPerBlock>());
+ m_newlyAllocated = std::make_unique<WTF::Bitmap<atomsPerBlock>>();
SetNewlyAllocatedFunctor functor(this);
forEachCell(functor);
diff --git a/Source/JavaScriptCore/heap/MarkedBlock.h b/Source/JavaScriptCore/heap/MarkedBlock.h
index f2626b7..097badd 100644
--- a/Source/JavaScriptCore/heap/MarkedBlock.h
+++ b/Source/JavaScriptCore/heap/MarkedBlock.h
@@ -209,7 +209,7 @@
WTF::Bitmap<atomsPerBlock, WTF::BitmapNotAtomic, uint8_t> m_marks;
WTF::Bitmap<atomsPerBlock, WTF::BitmapNotAtomic, uint8_t> m_rememberedSet;
#endif
- OwnPtr<WTF::Bitmap<atomsPerBlock>> m_newlyAllocated;
+ std::unique_ptr<WTF::Bitmap<atomsPerBlock>> m_newlyAllocated;
DestructorType m_destructorType;
MarkedAllocator* m_allocator;
@@ -400,7 +400,7 @@
inline bool MarkedBlock::clearNewlyAllocated()
{
if (m_newlyAllocated) {
- m_newlyAllocated.clear();
+ m_newlyAllocated = nullptr;
return true;
}
return false;
diff --git a/Source/JavaScriptCore/runtime/RegExp.cpp b/Source/JavaScriptCore/runtime/RegExp.cpp
index ed4d609..462b9e3 100644
--- a/Source/JavaScriptCore/runtime/RegExp.cpp
+++ b/Source/JavaScriptCore/runtime/RegExp.cpp
@@ -502,7 +502,7 @@
#if ENABLE(YARR_JIT)
m_regExpJITCode.clear();
#endif
- m_regExpBytecode.clear();
+ m_regExpBytecode = nullptr;
}
#if ENABLE(YARR_JIT_DEBUG)
diff --git a/Source/JavaScriptCore/runtime/RegExp.h b/Source/JavaScriptCore/runtime/RegExp.h
index 4162862..2e16f29 100644
--- a/Source/JavaScriptCore/runtime/RegExp.h
+++ b/Source/JavaScriptCore/runtime/RegExp.h
@@ -130,7 +130,7 @@
#if ENABLE(YARR_JIT)
Yarr::YarrCodeBlock m_regExpJITCode;
#endif
- OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
+ std::unique_ptr<Yarr::BytecodePattern> m_regExpBytecode;
};
} // namespace JSC
diff --git a/Source/JavaScriptCore/yarr/RegularExpression.cpp b/Source/JavaScriptCore/yarr/RegularExpression.cpp
index 718e33f..f4aaec9 100644
--- a/Source/JavaScriptCore/yarr/RegularExpression.cpp
+++ b/Source/JavaScriptCore/yarr/RegularExpression.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora Ltd.
@@ -44,7 +45,7 @@
int lastMatchLength;
unsigned m_numSubpatterns;
- OwnPtr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
+ std::unique_ptr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
private:
Private(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
@@ -54,7 +55,7 @@
{
}
- PassOwnPtr<JSC::Yarr::BytecodePattern> compile(const String& patternString, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
+ std::unique_ptr<JSC::Yarr::BytecodePattern> compile(const String& patternString, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
{
JSC::Yarr::YarrPattern pattern(patternString, (caseSensitivity == TextCaseInsensitive), (multilineMode == MultilineEnabled), &m_constructionError);
if (m_constructionError) {
@@ -178,7 +179,7 @@
bool RegularExpression::isValid() const
{
- return d->m_regExpByteCode;
+ return d->m_regExpByteCode.get();
}
} } // namespace JSC::Yarr
diff --git a/Source/JavaScriptCore/yarr/YarrInterpreter.cpp b/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
index 9ed4f6a..4f32933 100644
--- a/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
+++ b/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
@@ -1472,13 +1472,13 @@
m_currentAlternativeIndex = 0;
}
- PassOwnPtr<BytecodePattern> compile(BumpPointerAllocator* allocator)
+ std::unique_ptr<BytecodePattern> compile(BumpPointerAllocator* allocator)
{
regexBegin(m_pattern.m_numSubpatterns, m_pattern.m_body->m_callFrameSize, m_pattern.m_body->m_alternatives[0]->onceThrough());
emitDisjunction(m_pattern.m_body);
regexEnd();
- return adoptPtr(new BytecodePattern(m_bodyDisjunction.release(), m_allParenthesesInfo, m_pattern, allocator));
+ return std::make_unique<BytecodePattern>(WTF::move(m_bodyDisjunction), m_allParenthesesInfo, m_pattern, allocator);
}
void checkInput(unsigned count)
@@ -1778,7 +1778,7 @@
void regexBegin(unsigned numSubpatterns, unsigned callFrameSize, bool onceThrough)
{
- m_bodyDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));
+ m_bodyDisjunction = std::make_unique<ByteDisjunction>(numSubpatterns, callFrameSize);
m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeBegin(onceThrough));
m_bodyDisjunction->terms[0].frameLocation = 0;
m_currentAlternativeIndex = 0;
@@ -1920,13 +1920,13 @@
private:
YarrPattern& m_pattern;
- OwnPtr<ByteDisjunction> m_bodyDisjunction;
+ std::unique_ptr<ByteDisjunction> m_bodyDisjunction;
unsigned m_currentAlternativeIndex;
Vector<ParenthesesStackEntry> m_parenthesesStack;
Vector<OwnPtr<ByteDisjunction>> m_allParenthesesInfo;
};
-PassOwnPtr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator)
+std::unique_ptr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator)
{
return ByteCompiler(pattern).compile(allocator);
}
diff --git a/Source/JavaScriptCore/yarr/YarrInterpreter.h b/Source/JavaScriptCore/yarr/YarrInterpreter.h
index 466363b..052e25b 100644
--- a/Source/JavaScriptCore/yarr/YarrInterpreter.h
+++ b/Source/JavaScriptCore/yarr/YarrInterpreter.h
@@ -336,8 +336,8 @@
struct BytecodePattern {
WTF_MAKE_FAST_ALLOCATED;
public:
- BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<OwnPtr<ByteDisjunction>>& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator)
- : m_body(body)
+ BytecodePattern(std::unique_ptr<ByteDisjunction> body, Vector<OwnPtr<ByteDisjunction>>& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator)
+ : m_body(WTF::move(body))
, m_ignoreCase(pattern.m_ignoreCase)
, m_multiline(pattern.m_multiline)
, m_allocator(allocator)
@@ -354,7 +354,7 @@
m_userCharacterClasses.shrinkToFit();
}
- OwnPtr<ByteDisjunction> m_body;
+ std::unique_ptr<ByteDisjunction> m_body;
bool m_ignoreCase;
bool m_multiline;
// Each BytecodePattern is associated with a RegExp, each RegExp is associated
@@ -369,7 +369,7 @@
Vector<OwnPtr<CharacterClass>> m_userCharacterClasses;
};
-JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
+JS_EXPORT_PRIVATE std::unique_ptr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
JS_EXPORT_PRIVATE unsigned interpret(BytecodePattern*, const String& input, unsigned start, unsigned* output);
unsigned interpret(BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output);
unsigned interpret(BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output);