Diff
Modified: trunk/Source/_javascript_Core/API/JSScriptRef.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/API/JSScriptRef.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/API/JSScriptRef.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -68,7 +68,7 @@
static bool parseScript(VM* vm, const SourceCode& source, ParserError& error)
{
- return JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
+ return !!JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
}
extern "C" {
Modified: trunk/Source/_javascript_Core/ChangeLog (176824 => 176825)
--- trunk/Source/_javascript_Core/ChangeLog 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-12-05 00:59:33 UTC (rev 176825)
@@ -1,3 +1,76 @@
+2014-12-04 Geoffrey Garen <[email protected]>
+
+ Removed the concept of ParserArenaRefCounted
+ https://bugs.webkit.org/show_bug.cgi?id=139277
+
+ Reviewed by Oliver Hunt.
+
+ This is a step toward a parser speedup.
+
+ Now that we have a clear root node type for each parse tree, there's no
+ need to have a concept for "I might be refcounted or arena allocated".
+ Instead, we can just use unique_ptr to manage the tree as a whole.
+
+ * API/JSScriptRef.cpp:
+ (parseScript):
+ * builtins/BuiltinExecutables.cpp:
+ (JSC::BuiltinExecutables::createBuiltinExecutable): Updated for type change.
+
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::generateFunctionCodeBlock): Use unique_ptr. No need to call
+ destroyData() explicitly: the unique_ptr destructor will do everything
+ we need, as Bjarne intended.
+
+ * parser/NodeConstructors.h:
+ (JSC::ParserArenaRoot::ParserArenaRoot):
+ (JSC::ParserArenaRefCounted::ParserArenaRefCounted): Deleted.
+
+ * parser/Nodes.cpp:
+ (JSC::ScopeNode::ScopeNode):
+ (JSC::ProgramNode::ProgramNode):
+ (JSC::EvalNode::EvalNode):
+ (JSC::FunctionNode::FunctionNode):
+ (JSC::ProgramNode::create): Deleted.
+ (JSC::EvalNode::create): Deleted.
+ (JSC::FunctionNode::create): Deleted. All special create semantics can
+ just go away now that we play by C++ constructor / destructor rules.
+
+ * parser/Nodes.h:
+ (JSC::ParserArenaRoot::parserArena):
+ (JSC::ParserArenaRoot::~ParserArenaRoot): Just a normal class now, which
+ holds onto the whole parse tree by virtue of owning the arena in which
+ all the parsed nodes (except for itself) were allocated.
+
+ (JSC::ProgramNode::closedVariables):
+ (JSC::ParserArenaRefCounted::~ParserArenaRefCounted): Deleted.
+
+ (JSC::ScopeNode::destroyData): Deleted. No need to destroy anything
+ explicitly anymore -- we can just rely on destructors.
+
+ (JSC::ScopeNode::parserArena): Deleted.
+
+ * parser/Parser.h:
+ (JSC::Parser<LexerType>::parse):
+ (JSC::parse): unique_ptr all the things.
+
+ * parser/ParserArena.cpp:
+ (JSC::ParserArena::reset):
+ (JSC::ParserArena::isEmpty):
+ (JSC::ParserArena::contains): Deleted.
+ (JSC::ParserArena::last): Deleted.
+ (JSC::ParserArena::removeLast): Deleted.
+ (JSC::ParserArena::derefWithArena): Deleted.
+ * parser/ParserArena.h:
+ (JSC::ParserArena::swap): Much delete. Such wow.
+
+ * runtime/CodeCache.cpp:
+ (JSC::CodeCache::getGlobalCodeBlock):
+ (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
+ * runtime/Completion.cpp:
+ (JSC::checkSyntax):
+ * runtime/Executable.cpp:
+ (JSC::ProgramExecutable::checkSyntax): unique_ptr all the things.
+
2014-12-04 Andreas Kling <[email protected]>
REGRESSION(r173188): Text inserted when trying to delete a word from the Twitter message box.
Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -46,7 +46,7 @@
{
JSTextPosition positionBeforeLastNewline;
ParserError error;
- RefPtr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, error, &positionBeforeLastNewline);
+ std::unique_ptr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, error, &positionBeforeLastNewline);
if (!program) {
dataLog("Fatal error compiling builtin function '", name.string(), "': ", error.m_message);
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -51,7 +51,7 @@
static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, bool bodyIncludesBraces, ParserError& error)
{
- RefPtr<FunctionNode> function = parse<FunctionNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error, 0, bodyIncludesBraces);
+ std::unique_ptr<FunctionNode> function = parse<FunctionNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error, 0, bodyIncludesBraces);
if (!function) {
ASSERT(error.m_type != ParserError::ErrorNone);
@@ -64,7 +64,6 @@
UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode, ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction));
OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(vm, function.get(), result, debuggerMode, profilerMode)));
error = generator->generate();
- function->destroyData();
if (error.m_type != ParserError::ErrorNone)
return 0;
return result;
Modified: trunk/Source/_javascript_Core/parser/NodeConstructors.h (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/NodeConstructors.h 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/NodeConstructors.h 2014-12-05 00:59:33 UTC (rev 176825)
@@ -37,9 +37,9 @@
return parserArena.allocateDeletable(size);
}
- inline ParserArenaRefCounted::ParserArenaRefCounted(ParserArena& parserArena)
+ inline ParserArenaRoot::ParserArenaRoot(ParserArena& parserArena)
{
- parserArena.derefWithArena(adoptRef(this));
+ m_arena.swap(parserArena);
}
inline Node::Node(const JSTokenLocation& location)
Modified: trunk/Source/_javascript_Core/parser/Nodes.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/Nodes.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/Nodes.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -78,7 +78,7 @@
ScopeNode::ScopeNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, bool inStrictContext)
: StatementNode(endLocation)
- , ParserArenaRefCounted(parserArena)
+ , ParserArenaRoot(parserArena)
, m_startLineNumber(startLocation.line)
, m_startStartOffset(startLocation.startOffset)
, m_startLineStartOffset(startLocation.lineStartOffset)
@@ -90,7 +90,7 @@
ScopeNode::ScopeNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, CodeFeatures features, int numConstants)
: StatementNode(endLocation)
- , ParserArenaRefCounted(parserArena)
+ , ParserArenaRoot(parserArena)
, m_startLineNumber(startLocation.line)
, m_startStartOffset(startLocation.startOffset)
, m_startLineStartOffset(startLocation.lineStartOffset)
@@ -99,7 +99,6 @@
, m_numConstants(numConstants)
, m_statements(children)
{
- m_arena.swap(parserArena);
if (varStack)
m_varStack.swap(*varStack);
if (funcStack)
@@ -114,25 +113,13 @@
// ------------------------------ ProgramNode -----------------------------
-inline ProgramNode::ProgramNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
+ProgramNode::ProgramNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
: ScopeNode(parserArena, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants)
, m_startColumn(startColumn)
, m_endColumn(endColumn)
{
}
-PassRefPtr<ProgramNode> ProgramNode::create(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
-{
- RefPtr<ProgramNode> node = new ProgramNode(parserArena, startLocation, endLocation, startColumn, endColumn, children, varStack, funcStack, capturedVariables, source, features, numConstants);
-
- ASSERT(node->m_arena.last() == node);
- node->m_arena.removeLast();
- ASSERT(!node->m_arena.contains(node.get()));
-
- return node.release();
-}
-
-
void ProgramNode::setClosedVariables(Vector<RefPtr<StringImpl>>&& closedVariables)
{
m_closedVariables = WTF::move(closedVariables);
@@ -140,23 +127,12 @@
// ------------------------------ EvalNode -----------------------------
-inline EvalNode::EvalNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
+EvalNode::EvalNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
: ScopeNode(parserArena, startLocation, endLocation, source, children, varStack, funcStack, capturedVariables, features, numConstants)
, m_endColumn(endColumn)
{
}
-PassRefPtr<EvalNode> EvalNode::create(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& source, CodeFeatures features, int numConstants)
-{
- RefPtr<EvalNode> node = new EvalNode(parserArena, startLocation, endLocation, endColumn, children, varStack, funcStack, capturedVariables, source, features, numConstants);
-
- ASSERT(node->m_arena.last() == node);
- node->m_arena.removeLast();
- ASSERT(!node->m_arena.contains(node.get()));
-
- return node.release();
-}
-
// ------------------------------ FunctionBodyNode -----------------------------
PassRefPtr<FunctionParameters> FunctionParameters::create(ParameterNode* firstParameter)
@@ -210,26 +186,15 @@
m_endColumn = position.offset - position.lineStartOffset;
}
-// =====================
+// ------------------------------ FunctionNode -----------------------------
-inline FunctionNode::FunctionNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
+FunctionNode::FunctionNode(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
: ScopeNode(parserArena, startLocation, endLocation, sourceCode, children, varStack, funcStack, capturedVariables, features, numConstants)
, m_startColumn(startColumn)
, m_endColumn(endColumn)
{
}
-PassRefPtr<FunctionNode> FunctionNode::create(ParserArena& parserArena, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, IdentifierSet& capturedVariables, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
-{
- RefPtr<FunctionNode> node = new FunctionNode(parserArena, startLocation, endLocation, startColumn, endColumn , children, varStack, funcStack, capturedVariables, sourceCode, features, numConstants);
-
- ASSERT(node->m_arena.last() == node);
- node->m_arena.removeLast();
- ASSERT(!node->m_arena.contains(node.get()));
-
- return node.release();
-}
-
void FunctionNode::finishParsing(PassRefPtr<FunctionParameters> parameters, const Identifier& ident, enum FunctionMode functionMode)
{
ASSERT(!source().isNull());
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2014-12-05 00:59:33 UTC (rev 176825)
@@ -111,16 +111,17 @@
T data;
};
- class ParserArenaRefCounted : public RefCounted<ParserArenaRefCounted> {
+ class ParserArenaRoot {
WTF_MAKE_FAST_ALLOCATED;
protected:
- ParserArenaRefCounted(ParserArena&);
+ ParserArenaRoot(ParserArena&);
public:
- virtual ~ParserArenaRefCounted()
- {
- ASSERT(deletionHasBegun());
- }
+ ParserArena& parserArena() { return m_arena; }
+ virtual ~ParserArenaRoot() { }
+
+ protected:
+ ParserArena m_arena;
};
class Node : public ParserArenaFreeable {
@@ -1404,7 +1405,7 @@
ParameterNode* m_next;
};
- class ScopeNode : public StatementNode, public ParserArenaRefCounted {
+ class ScopeNode : public StatementNode, public ParserArenaRoot {
public:
typedef DeclarationStacks::VarStack VarStack;
typedef DeclarationStacks::FunctionStack FunctionStack;
@@ -1412,18 +1413,8 @@
ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, bool inStrictContext);
ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, const SourceCode&, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, CodeFeatures, int numConstants);
- using ParserArenaRefCounted::operator new;
+ using ParserArenaRoot::operator new;
- void destroyData()
- {
- m_arena.reset();
- m_varStack.clear();
- m_functionStack.clear();
- m_statements = 0;
- m_capturedVariables.clear();
- }
-
- ParserArena& parserArena() { return m_arena; }
const SourceCode& source() const { return m_source; }
const String& sourceURL() const { return m_source.provider()->url(); }
intptr_t sourceID() const { return m_source.providerID(); }
@@ -1466,8 +1457,6 @@
void setClosedVariables(Vector<RefPtr<StringImpl>>&&) { }
protected:
- ParserArena m_arena;
-
int m_startLineNumber;
unsigned m_startStartOffset;
unsigned m_startLineStartOffset;
@@ -1484,7 +1473,7 @@
class ProgramNode : public ScopeNode {
public:
- static PassRefPtr<ProgramNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
+ ProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
unsigned startColumn() const { return m_startColumn; }
unsigned endColumn() const { return m_endColumn; }
@@ -1493,9 +1482,8 @@
void setClosedVariables(Vector<RefPtr<StringImpl>>&&);
const Vector<RefPtr<StringImpl>>& closedVariables() const { return m_closedVariables; }
- private:
- ProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
+ private:
virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
Vector<RefPtr<StringImpl>> m_closedVariables;
unsigned m_startColumn;
@@ -1504,7 +1492,7 @@
class EvalNode : public ScopeNode {
public:
- static PassRefPtr<EvalNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
+ EvalNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
ALWAYS_INLINE unsigned startColumn() const { return 0; }
unsigned endColumn() const { return m_endColumn; }
@@ -1512,8 +1500,6 @@
static const bool scopeIsFunction = false;
private:
- EvalNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
-
virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
unsigned m_endColumn;
@@ -1584,7 +1570,7 @@
class FunctionNode final : public ScopeNode {
public:
- static PassRefPtr<FunctionNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
+ FunctionNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
FunctionParameters* parameters() const { return m_parameters.get(); }
@@ -1602,8 +1588,6 @@
static const bool scopeIsFunction = true;
private:
- FunctionNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
-
Identifier m_ident;
FunctionMode m_functionMode;
RefPtr<FunctionParameters> m_parameters;
Modified: trunk/Source/_javascript_Core/parser/Parser.h (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/Parser.h 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/Parser.h 2014-12-05 00:59:33 UTC (rev 176825)
@@ -402,7 +402,7 @@
~Parser();
template <class ParsedNode>
- PassRefPtr<ParsedNode> parse(ParserError&, bool needReparsingAdjustment);
+ std::unique_ptr<ParsedNode> parse(ParserError&, bool needReparsingAdjustment);
JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
Vector<RefPtr<StringImpl>>&& closedVariables() { return WTF::move(m_closedVariables); }
@@ -861,7 +861,7 @@
template <typename LexerType>
template <class ParsedNode>
-PassRefPtr<ParsedNode> Parser<LexerType>::parse(ParserError& error, bool needReparsingAdjustment)
+std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, bool needReparsingAdjustment)
{
int errLine;
String errMsg;
@@ -892,14 +892,14 @@
m_sourceElements = 0;
}
- RefPtr<ParsedNode> result;
+ std::unique_ptr<ParsedNode> result;
if (m_sourceElements) {
JSTokenLocation endLocation;
endLocation.line = m_lexer->lineNumber();
endLocation.lineStartOffset = m_lexer->currentLineStartOffset();
endLocation.startOffset = m_lexer->currentOffset();
unsigned endColumn = endLocation.startOffset - endLocation.lineStartOffset;
- result = ParsedNode::create(m_parserArena,
+ result = std::make_unique<ParsedNode>(m_parserArena,
startLocation,
endLocation,
startColumn,
@@ -936,18 +936,18 @@
}
}
- return result.release();
+ return result;
}
template <class ParsedNode>
-PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0, bool needReparsingAdjustment = false)
+std::unique_ptr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0, bool needReparsingAdjustment = false)
{
SamplingRegion samplingRegion("Parsing");
ASSERT(!source.provider()->source().isNull());
if (source.provider()->source().is8Bit()) {
Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode);
- RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
+ std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
if (strictness == JSParseBuiltin) {
@@ -956,13 +956,13 @@
RELEASE_ASSERT(result);
result->setClosedVariables(parser.closedVariables());
}
- return result.release();
+ return result;
}
Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode);
- RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
+ std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
- return result.release();
+ return result;
}
} // namespace
Modified: trunk/Source/_javascript_Core/parser/ParserArena.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/ParserArena.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/ParserArena.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -63,21 +63,6 @@
deallocateObjects();
}
-bool ParserArena::contains(ParserArenaRefCounted* object) const
-{
- return m_refCountedObjects.find(object) != notFound;
-}
-
-ParserArenaRefCounted* ParserArena::last() const
-{
- return m_refCountedObjects.last().get();
-}
-
-void ParserArena::removeLast()
-{
- m_refCountedObjects.removeLast();
-}
-
void ParserArena::reset()
{
// Since this code path is used only when parsing fails, it's not bothering to reuse
@@ -92,7 +77,6 @@
m_identifierArena->clear();
m_freeablePools.clear();
m_deletableObjects.clear();
- m_refCountedObjects.clear();
}
void ParserArena::allocateFreeablePool()
@@ -106,18 +90,4 @@
ASSERT(freeablePool() == pool);
}
-bool ParserArena::isEmpty() const
-{
- return !m_freeablePoolEnd
- && (!m_identifierArena || m_identifierArena->isEmpty())
- && m_freeablePools.isEmpty()
- && m_deletableObjects.isEmpty()
- && m_refCountedObjects.isEmpty();
}
-
-void ParserArena::derefWithArena(PassRefPtr<ParserArenaRefCounted> object)
-{
- m_refCountedObjects.append(object);
-}
-
-}
Modified: trunk/Source/_javascript_Core/parser/ParserArena.h (176824 => 176825)
--- trunk/Source/_javascript_Core/parser/ParserArena.h 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/parser/ParserArena.h 2014-12-05 00:59:33 UTC (rev 176825)
@@ -33,7 +33,6 @@
namespace JSC {
class ParserArenaDeletable;
- class ParserArenaRefCounted;
class IdentifierArena {
WTF_MAKE_FAST_ALLOCATED;
@@ -49,8 +48,6 @@
const Identifier& makeNumericIdentifier(VM*, double number);
- bool isEmpty() const { return m_identifiers.isEmpty(); }
-
public:
static const int MaximumCachableCharacter = 128;
typedef SegmentedVector<Identifier, 64> IdentifierVector;
@@ -131,7 +128,6 @@
m_identifierArena.swap(otherArena.m_identifierArena);
m_freeablePools.swap(otherArena.m_freeablePools);
m_deletableObjects.swap(otherArena.m_deletableObjects);
- m_refCountedObjects.swap(otherArena.m_refCountedObjects);
}
void* allocateFreeable(size_t size)
@@ -154,12 +150,6 @@
return deletable;
}
- void derefWithArena(PassRefPtr<ParserArenaRefCounted>);
- bool contains(ParserArenaRefCounted*) const;
- ParserArenaRefCounted* last() const;
- void removeLast();
-
- bool isEmpty() const;
JS_EXPORT_PRIVATE void reset();
IdentifierArena& identifierArena()
@@ -187,7 +177,6 @@
OwnPtr<IdentifierArena> m_identifierArena;
Vector<void*> m_freeablePools;
Vector<ParserArenaDeletable*> m_deletableObjects;
- Vector<RefPtr<ParserArenaRefCounted>> m_refCountedObjects;
};
}
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -92,7 +92,7 @@
}
typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode;
- RefPtr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, error);
+ std::unique_ptr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, error);
if (!rootNode) {
m_sourceCode.remove(addResult.iterator);
return 0;
@@ -109,7 +109,6 @@
auto generator = std::make_unique<BytecodeGenerator>(vm, rootNode.get(), unlinkedCodeBlock, debuggerMode, profilerMode);
error = generator->generate();
- rootNode->destroyData();
if (error.m_type != ParserError::ErrorNone) {
m_sourceCode.remove(addResult.iterator);
return 0;
@@ -142,7 +141,7 @@
return jsCast<UnlinkedFunctionExecutable*>(addResult.iterator->value.cell.get());
JSTextPosition positionBeforeLastNewline;
- RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error, &positionBeforeLastNewline);
+ std::unique_ptr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error, &positionBeforeLastNewline);
if (!program) {
RELEASE_ASSERT(error.m_type != ParserError::ErrorNone);
m_sourceCode.remove(addResult.iterator);
Modified: trunk/Source/_javascript_Core/runtime/Completion.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/runtime/Completion.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/runtime/Completion.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -55,8 +55,7 @@
{
JSLockHolder lock(vm);
RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
- RefPtr<ProgramNode> programNode = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
- return programNode;
+ return !!parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
}
JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, JSValue* returnedException)
Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (176824 => 176825)
--- trunk/Source/_javascript_Core/runtime/Executable.cpp 2014-12-05 00:55:30 UTC (rev 176824)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp 2014-12-05 00:59:33 UTC (rev 176825)
@@ -461,7 +461,7 @@
ParserError error;
VM* vm = &exec->vm();
JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
- RefPtr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
+ std::unique_ptr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
if (programNode)
return 0;
ASSERT(error.m_type != ParserError::ErrorNone);