Skip to content

Commit 9c6e7f7

Browse files
author
Sam Weinig
committed
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): Canonical link: https://commits.webkit.org/139594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156079 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 56119b2 commit 9c6e7f7

16 files changed

Lines changed: 58 additions & 23 deletions

‎Source/JavaScriptCore/API/JSStringRefCF.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "JSStringRef.h"
3232
#include "OpaqueJSString.h"
3333
#include <runtime/JSCJSValue.h>
34-
#include <wtf/OwnArrayPtr.h>
34+
#include <wtf/StdLibExtras.h>
3535

3636
JSStringRef JSStringCreateWithCFString(CFStringRef string)
3737
{
@@ -47,7 +47,7 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
4747
if (static_cast<size_t>(convertedSize) == length && static_cast<size_t>(usedBufferLength) == length)
4848
return OpaqueJSString::create(lcharBuffer.data(), length).leakRef();
4949

50-
OwnArrayPtr<UniChar> buffer = adoptArrayPtr(new UniChar[length]);
50+
auto buffer = std::make_unique<UniChar[]>(length);
5151
CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get());
5252
COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size);
5353
return OpaqueJSString::create(reinterpret_cast<UChar*>(buffer.get()), length).leakRef();

‎Source/JavaScriptCore/API/JSStringRefQt.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "JSStringRef.h"
3333
#include "OpaqueJSString.h"
3434
#include <runtime/JSCJSValue.h>
35-
#include <wtf/OwnArrayPtr.h>
3635

3736
QString JSStringCopyQString(JSStringRef string)
3837
{

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
2013-09-18 Sam Weinig <sam@webkit.org>
2+
3+
Replace use of OwnArrayPtr<Foo> with std::unique_ptr<Foo[]> in JavaScriptCore
4+
https://bugs.webkit.org/show_bug.cgi?id=121583
5+
6+
Reviewed by Anders Carlsson.
7+
8+
* API/JSStringRefCF.cpp:
9+
(JSStringCreateWithCFString):
10+
* API/JSStringRefQt.cpp:
11+
* bytecompiler/BytecodeGenerator.cpp:
12+
(JSC::BytecodeGenerator::BytecodeGenerator):
13+
* dfg/DFGByteCodeParser.cpp:
14+
(JSC::DFG::ByteCodeParser::parseBlock):
15+
* dfg/DFGDisassembler.cpp:
16+
(JSC::DFG::Disassembler::dumpDisassembly):
17+
* runtime/Arguments.cpp:
18+
(JSC::Arguments::tearOff):
19+
* runtime/Arguments.h:
20+
(JSC::Arguments::isTornOff):
21+
(JSC::Arguments::allocateSlowArguments):
22+
* runtime/JSPropertyNameIterator.cpp:
23+
(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
24+
* runtime/JSPropertyNameIterator.h:
25+
* runtime/JSSegmentedVariableObject.h:
26+
* runtime/JSVariableObject.h:
27+
* runtime/PropertyNameArray.h:
28+
* runtime/RegExp.cpp:
29+
* runtime/StructureChain.h:
30+
(JSC::StructureChain::finishCreation):
31+
* runtime/SymbolTable.h:
32+
(JSC::SharedSymbolTable::setSlowArguments):
33+
134
2013-09-18 Brent Fulgham <bfulgham@apple.com>
235

336
[Windows] Unreviewed build fix after r156064.

‎Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Options.h"
4141
#include "StrongInlines.h"
4242
#include "UnlinkedCodeBlock.h"
43+
#include <wtf/StdLibExtras.h>
4344
#include <wtf/text/WTFString.h>
4445

4546
using namespace std;
@@ -262,7 +263,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionBodyNode* functionBody, Unl
262263

263264
if (capturesAnyArgumentByName && !shouldTearOffArgumentsEagerly()) {
264265
size_t parameterCount = m_symbolTable->parameterCount();
265-
OwnArrayPtr<SlowArgument> slowArguments = adoptArrayPtr(new SlowArgument[parameterCount]);
266+
auto slowArguments = std::make_unique<SlowArgument[]>(parameterCount);
266267
for (size_t i = 0; i < parameterCount; ++i) {
267268
if (!capturedArguments[i]) {
268269
ASSERT(slowArguments[i].status == SlowArgument::Normal);

‎Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <wtf/CommaPrinter.h>
4343
#include <wtf/HashMap.h>
4444
#include <wtf/MathExtras.h>
45+
#include <wtf/StdLibExtras.h>
4546

4647
namespace JSC { namespace DFG {
4748

@@ -2242,7 +2243,7 @@ bool ByteCodeParser::parseBlock(unsigned limit)
22422243
#else
22432244
const unsigned maxRopeArguments = 3;
22442245
#endif
2245-
OwnArrayPtr<Node*> toStringNodes = adoptArrayPtr(new Node*[numOperands]);
2246+
auto toStringNodes = std::make_unique<Node*[]>(numOperands);
22462247
for (int i = 0; i < numOperands; i++)
22472248
toStringNodes[i] = addToGraph(ToString, get(startOperand - i));
22482249

‎Source/JavaScriptCore/dfg/DFGDisassembler.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "CodeBlockWithJITType.h"
3232
#include "DFGGraph.h"
33+
#include <wtf/StdLibExtras.h>
3334

3435
namespace JSC { namespace DFG {
3536

@@ -154,7 +155,7 @@ void Disassembler::dumpDisassembly(PrintStream& out, const char* prefix, LinkBuf
154155
amountOfNodeWhiteSpace = 0;
155156
else
156157
amountOfNodeWhiteSpace = Graph::amountOfNodeWhiteSpace(context);
157-
OwnArrayPtr<char> prefixBuffer = adoptArrayPtr(new char[prefixLength + amountOfNodeWhiteSpace + 1]);
158+
auto prefixBuffer = std::make_unique<char[]>(prefixLength + amountOfNodeWhiteSpace + 1);
158159
strcpy(prefixBuffer.get(), prefix);
159160
for (int i = 0; i < amountOfNodeWhiteSpace; ++i)
160161
prefixBuffer[i + prefixLength] = ' ';

‎Source/JavaScriptCore/runtime/Arguments.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void Arguments::tearOff(CallFrame* callFrame)
311311
// Must be called for the same call frame from which it was created.
312312
ASSERT(bitwise_cast<WriteBarrier<Unknown>*>(callFrame) == m_registers);
313313

314-
m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
314+
m_registerArray = std::make_unique<WriteBarrier<Unknown>[]>(m_numArguments);
315315
m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
316316

317317
// If we have a captured argument that logically aliases activation storage,
@@ -357,7 +357,7 @@ void Arguments::tearOff(CallFrame* callFrame, InlineCallFrame* inlineCallFrame)
357357
if (!m_numArguments)
358358
return;
359359

360-
m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
360+
m_registerArray = std::make_unique<WriteBarrier<Unknown>[]>(m_numArguments);
361361
m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
362362

363363
tearOffForInlineCallFrame(

‎Source/JavaScriptCore/runtime/Arguments.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "JSGlobalObject.h"
3232
#include "Interpreter.h"
3333
#include "ObjectConstructor.h"
34+
#include <wtf/StdLibExtras.h>
3435

3536
namespace JSC {
3637

@@ -81,7 +82,7 @@ class Arguments : public JSDestructibleObject {
8182
void copyToArguments(ExecState*, CallFrame*, uint32_t length);
8283
void tearOff(CallFrame*);
8384
void tearOff(CallFrame*, InlineCallFrame*);
84-
bool isTornOff() const { return m_registerArray; }
85+
bool isTornOff() const { return m_registerArray.get(); }
8586
void didTearOffActivation(ExecState*, JSActivation*);
8687

8788
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
@@ -131,9 +132,9 @@ class Arguments : public JSDestructibleObject {
131132
bool m_isStrictMode;
132133

133134
WriteBarrierBase<Unknown>* m_registers;
134-
OwnArrayPtr<WriteBarrier<Unknown> > m_registerArray;
135+
std::unique_ptr<WriteBarrier<Unknown>[]> m_registerArray;
135136

136-
OwnArrayPtr<SlowArgument> m_slowArguments;
137+
std::unique_ptr<SlowArgument[]> m_slowArguments;
137138

138139
WriteBarrier<JSFunction> m_callee;
139140
};
@@ -160,7 +161,7 @@ inline void Arguments::allocateSlowArguments()
160161
{
161162
if (m_slowArguments)
162163
return;
163-
m_slowArguments = adoptArrayPtr(new SlowArgument[m_numArguments]);
164+
m_slowArguments = std::make_unique<SlowArgument[]>(m_numArguments);
164165
for (size_t i = 0; i < m_numArguments; ++i) {
165166
ASSERT(m_slowArguments[i].status == SlowArgument::Normal);
166167
m_slowArguments[i].index = CallFrame::argumentOffset(i);

‎Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "JSPropertyNameIterator.h"
3131

3232
#include "JSGlobalObject.h"
33+
#include <wtf/StdLibExtras.h>
3334

3435
namespace JSC {
3536

@@ -39,7 +40,7 @@ inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyN
3940
: JSCell(exec->vm(), exec->vm().propertyNameIteratorStructure.get())
4041
, m_numCacheableSlots(numCacheableSlots)
4142
, m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
42-
, m_jsStrings(m_jsStringsSize ? adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize]) : nullptr)
43+
, m_jsStrings(m_jsStringsSize ? std::make_unique<WriteBarrier<Unknown>[]>(m_jsStringsSize) : nullptr)
4344
{
4445
}
4546

‎Source/JavaScriptCore/runtime/JSPropertyNameIterator.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "JSString.h"
3434
#include "Operations.h"
3535
#include "PropertyNameArray.h"
36+
#include <memory>
3637

3738
namespace JSC {
3839

@@ -95,7 +96,7 @@ namespace JSC {
9596
uint32_t m_numCacheableSlots;
9697
uint32_t m_jsStringsSize;
9798
unsigned m_cachedStructureInlineCapacity;
98-
OwnArrayPtr<WriteBarrier<Unknown> > m_jsStrings;
99+
std::unique_ptr<WriteBarrier<Unknown>[]> m_jsStrings;
99100
};
100101

101102
ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const

0 commit comments

Comments
 (0)