Commit 5c4dbc40 authored by weinig@apple.com's avatar weinig@apple.com

Replace use of OwnArrayPtr<Foo> with std::unique_ptr<Foo[]> in JavaScriptCore

https://bugs.webkit.org/show_bug.cgi?id=121583

Reviewed by Anders Carlsson.

* API/JSStringRefCF.cpp:
(JSStringCreateWithCFString):
* API/JSStringRefQt.cpp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGDisassembler.cpp:
(JSC::DFG::Disassembler::dumpDisassembly):
* runtime/Arguments.cpp:
(JSC::Arguments::tearOff):
* runtime/Arguments.h:
(JSC::Arguments::isTornOff):
(JSC::Arguments::allocateSlowArguments):
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
* runtime/JSPropertyNameIterator.h:
* runtime/JSSegmentedVariableObject.h:
* runtime/JSVariableObject.h:
* runtime/PropertyNameArray.h:
* runtime/RegExp.cpp:
* runtime/StructureChain.h:
(JSC::StructureChain::finishCreation):
* runtime/SymbolTable.h:
(JSC::SharedSymbolTable::setSlowArguments):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156079 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9aeea987
......@@ -31,7 +31,7 @@
#include "JSStringRef.h"
#include "OpaqueJSString.h"
#include <runtime/JSCJSValue.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/StdLibExtras.h>
JSStringRef JSStringCreateWithCFString(CFStringRef string)
{
......@@ -47,7 +47,7 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
if (static_cast<size_t>(convertedSize) == length && static_cast<size_t>(usedBufferLength) == length)
return OpaqueJSString::create(lcharBuffer.data(), length).leakRef();
OwnArrayPtr<UniChar> buffer = adoptArrayPtr(new UniChar[length]);
auto buffer = std::make_unique<UniChar[]>(length);
CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get());
COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size);
return OpaqueJSString::create(reinterpret_cast<UChar*>(buffer.get()), length).leakRef();
......
......@@ -32,7 +32,6 @@
#include "JSStringRef.h"
#include "OpaqueJSString.h"
#include <runtime/JSCJSValue.h>
#include <wtf/OwnArrayPtr.h>
QString JSStringCopyQString(JSStringRef string)
{
......
2013-09-18 Sam Weinig <sam@webkit.org>
Replace use of OwnArrayPtr<Foo> with std::unique_ptr<Foo[]> in JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=121583
Reviewed by Anders Carlsson.
* API/JSStringRefCF.cpp:
(JSStringCreateWithCFString):
* API/JSStringRefQt.cpp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGDisassembler.cpp:
(JSC::DFG::Disassembler::dumpDisassembly):
* runtime/Arguments.cpp:
(JSC::Arguments::tearOff):
* runtime/Arguments.h:
(JSC::Arguments::isTornOff):
(JSC::Arguments::allocateSlowArguments):
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
* runtime/JSPropertyNameIterator.h:
* runtime/JSSegmentedVariableObject.h:
* runtime/JSVariableObject.h:
* runtime/PropertyNameArray.h:
* runtime/RegExp.cpp:
* runtime/StructureChain.h:
(JSC::StructureChain::finishCreation):
* runtime/SymbolTable.h:
(JSC::SharedSymbolTable::setSlowArguments):
2013-09-18 Brent Fulgham <bfulgham@apple.com>
[Windows] Unreviewed build fix after r156064.
......
......@@ -40,6 +40,7 @@
#include "Options.h"
#include "StrongInlines.h"
#include "UnlinkedCodeBlock.h"
#include <wtf/StdLibExtras.h>
#include <wtf/text/WTFString.h>
using namespace std;
......@@ -262,7 +263,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionBodyNode* functionBody, Unl
if (capturesAnyArgumentByName && !shouldTearOffArgumentsEagerly()) {
size_t parameterCount = m_symbolTable->parameterCount();
OwnArrayPtr<SlowArgument> slowArguments = adoptArrayPtr(new SlowArgument[parameterCount]);
auto slowArguments = std::make_unique<SlowArgument[]>(parameterCount);
for (size_t i = 0; i < parameterCount; ++i) {
if (!capturedArguments[i]) {
ASSERT(slowArguments[i].status == SlowArgument::Normal);
......
......@@ -42,6 +42,7 @@
#include <wtf/CommaPrinter.h>
#include <wtf/HashMap.h>
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
namespace JSC { namespace DFG {
......@@ -2242,7 +2243,7 @@ bool ByteCodeParser::parseBlock(unsigned limit)
#else
const unsigned maxRopeArguments = 3;
#endif
OwnArrayPtr<Node*> toStringNodes = adoptArrayPtr(new Node*[numOperands]);
auto toStringNodes = std::make_unique<Node*[]>(numOperands);
for (int i = 0; i < numOperands; i++)
toStringNodes[i] = addToGraph(ToString, get(startOperand - i));
......
......@@ -30,6 +30,7 @@
#include "CodeBlockWithJITType.h"
#include "DFGGraph.h"
#include <wtf/StdLibExtras.h>
namespace JSC { namespace DFG {
......@@ -154,7 +155,7 @@ void Disassembler::dumpDisassembly(PrintStream& out, const char* prefix, LinkBuf
amountOfNodeWhiteSpace = 0;
else
amountOfNodeWhiteSpace = Graph::amountOfNodeWhiteSpace(context);
OwnArrayPtr<char> prefixBuffer = adoptArrayPtr(new char[prefixLength + amountOfNodeWhiteSpace + 1]);
auto prefixBuffer = std::make_unique<char[]>(prefixLength + amountOfNodeWhiteSpace + 1);
strcpy(prefixBuffer.get(), prefix);
for (int i = 0; i < amountOfNodeWhiteSpace; ++i)
prefixBuffer[i + prefixLength] = ' ';
......
......@@ -311,7 +311,7 @@ void Arguments::tearOff(CallFrame* callFrame)
// Must be called for the same call frame from which it was created.
ASSERT(bitwise_cast<WriteBarrier<Unknown>*>(callFrame) == m_registers);
m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
m_registerArray = std::make_unique<WriteBarrier<Unknown>[]>(m_numArguments);
m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
// If we have a captured argument that logically aliases activation storage,
......@@ -357,7 +357,7 @@ void Arguments::tearOff(CallFrame* callFrame, InlineCallFrame* inlineCallFrame)
if (!m_numArguments)
return;
m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
m_registerArray = std::make_unique<WriteBarrier<Unknown>[]>(m_numArguments);
m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
tearOffForInlineCallFrame(
......
......@@ -31,6 +31,7 @@
#include "JSGlobalObject.h"
#include "Interpreter.h"
#include "ObjectConstructor.h"
#include <wtf/StdLibExtras.h>
namespace JSC {
......@@ -81,7 +82,7 @@ public:
void copyToArguments(ExecState*, CallFrame*, uint32_t length);
void tearOff(CallFrame*);
void tearOff(CallFrame*, InlineCallFrame*);
bool isTornOff() const { return m_registerArray; }
bool isTornOff() const { return m_registerArray.get(); }
void didTearOffActivation(ExecState*, JSActivation*);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
......@@ -131,9 +132,9 @@ private:
bool m_isStrictMode;
WriteBarrierBase<Unknown>* m_registers;
OwnArrayPtr<WriteBarrier<Unknown> > m_registerArray;
std::unique_ptr<WriteBarrier<Unknown>[]> m_registerArray;
OwnArrayPtr<SlowArgument> m_slowArguments;
std::unique_ptr<SlowArgument[]> m_slowArguments;
WriteBarrier<JSFunction> m_callee;
};
......@@ -160,7 +161,7 @@ inline void Arguments::allocateSlowArguments()
{
if (m_slowArguments)
return;
m_slowArguments = adoptArrayPtr(new SlowArgument[m_numArguments]);
m_slowArguments = std::make_unique<SlowArgument[]>(m_numArguments);
for (size_t i = 0; i < m_numArguments; ++i) {
ASSERT(m_slowArguments[i].status == SlowArgument::Normal);
m_slowArguments[i].index = CallFrame::argumentOffset(i);
......
......@@ -30,6 +30,7 @@
#include "JSPropertyNameIterator.h"
#include "JSGlobalObject.h"
#include <wtf/StdLibExtras.h>
namespace JSC {
......@@ -39,7 +40,7 @@ inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyN
: JSCell(exec->vm(), exec->vm().propertyNameIteratorStructure.get())
, m_numCacheableSlots(numCacheableSlots)
, m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
, m_jsStrings(m_jsStringsSize ? adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize]) : nullptr)
, m_jsStrings(m_jsStringsSize ? std::make_unique<WriteBarrier<Unknown>[]>(m_jsStringsSize) : nullptr)
{
}
......
......@@ -33,6 +33,7 @@
#include "JSString.h"
#include "Operations.h"
#include "PropertyNameArray.h"
#include <memory>
namespace JSC {
......@@ -95,7 +96,7 @@ namespace JSC {
uint32_t m_numCacheableSlots;
uint32_t m_jsStringsSize;
unsigned m_cachedStructureInlineCapacity;
OwnArrayPtr<WriteBarrier<Unknown> > m_jsStrings;
std::unique_ptr<WriteBarrier<Unknown>[]> m_jsStrings;
};
ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const
......
......@@ -34,7 +34,6 @@
#include "JSSymbolTableObject.h"
#include "Register.h"
#include "SymbolTable.h"
#include <wtf/OwnArrayPtr.h>
#include <wtf/SegmentedVector.h>
namespace JSC {
......
......@@ -33,7 +33,6 @@
#include "JSSymbolTableObject.h"
#include "Register.h"
#include "SymbolTable.h"
#include <wtf/OwnArrayPtr.h>
namespace JSC {
......
......@@ -24,7 +24,6 @@
#include "CallFrame.h"
#include "Identifier.h"
#include <wtf/HashSet.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/Vector.h>
namespace JSC {
......
......@@ -32,7 +32,6 @@
#include <stdlib.h>
#include <string.h>
#include <wtf/Assertions.h>
#include <wtf/OwnArrayPtr.h>
#define REGEXP_FUNC_TEST_DATA_GEN 0
......
......@@ -30,10 +30,10 @@
#include "JSObject.h"
#include "Structure.h"
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
......@@ -71,7 +71,7 @@ namespace JSC {
for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
++size;
m_vector = adoptArrayPtr(new WriteBarrier<Structure>[size + 1]);
m_vector = std::make_unique<WriteBarrier<Structure>[]>(size + 1);
size_t i = 0;
for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
......@@ -82,7 +82,7 @@ namespace JSC {
friend class LLIntOffsetsExtractor;
StructureChain(VM&, Structure*);
OwnArrayPtr<WriteBarrier<Structure> > m_vector;
std::unique_ptr<WriteBarrier<Structure>[]> m_vector;
};
} // namespace JSC
......
......@@ -32,6 +32,7 @@
#include "ConcurrentJITLock.h"
#include "JSObject.h"
#include "Watchpoint.h"
#include <memory>
#include <wtf/HashTraits.h>
#include <wtf/text/StringImpl.h>
......@@ -472,7 +473,7 @@ public:
// 0 if we don't capture any arguments; parameterCount() in length if we do.
const SlowArgument* slowArguments() { return m_slowArguments.get(); }
void setSlowArguments(OwnArrayPtr<SlowArgument> slowArguments) { m_slowArguments = std::move(slowArguments); }
void setSlowArguments(std::unique_ptr<SlowArgument[]> slowArguments) { m_slowArguments = std::move(slowArguments); }
DECLARE_EXPORT_INFO;
......@@ -492,7 +493,7 @@ private:
int m_captureStart;
int m_captureEnd;
OwnArrayPtr<SlowArgument> m_slowArguments;
std::unique_ptr<SlowArgument[]> m_slowArguments;
};
} // namespace JSC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment