VariableEnvironmentNode should inherit from ParserArenaDeletable because VariableEnvironment's must have their destructors run
https://bugs.webkit.org/show_bug.cgi?id=149359
Reviewed by Andreas Kling.
VariableEnvironment must have its destructor run.
Therefore, VariableEnvironmentNode should inherit from ParserArenaDeletable.
Also, anything that inherits from VariableEnvironmentNode must use
ParserArenaDeletable's operator new. Also, any other nodes that own
a VariableEnvironment must also have their destructors run.
* parser/Nodes.h:
(JSC::VariableEnvironmentNode::VariableEnvironmentNode):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@190014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 5138c56..08dfb5e 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,19 @@
+2015-09-19 Saam barati <sbarati@apple.com>
+
+ VariableEnvironmentNode should inherit from ParserArenaDeletable because VariableEnvironment's must have their destructors run
+ https://bugs.webkit.org/show_bug.cgi?id=149359
+
+ Reviewed by Andreas Kling.
+
+ VariableEnvironment must have its destructor run.
+ Therefore, VariableEnvironmentNode should inherit from ParserArenaDeletable.
+ Also, anything that inherits from VariableEnvironmentNode must use
+ ParserArenaDeletable's operator new. Also, any other nodes that own
+ a VariableEnvironment must also have their destructors run.
+
+ * parser/Nodes.h:
+ (JSC::VariableEnvironmentNode::VariableEnvironmentNode):
+
2015-09-18 Sukolsak Sakshuwong <sukolsak@gmail.com>
Remove duplicate code in the WebAssembly parser
diff --git a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index 48647a3..a3e5f56 100644
--- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -2850,13 +2850,13 @@
tryData = generator.pushTry(here.get());
}
- generator.emitPushCatchScope(m_thrownValueIdent, thrownValueRegister.get(), m_catchEnvironment);
+ generator.emitPushCatchScope(m_thrownValueIdent, thrownValueRegister.get(), m_lexicalVariables);
generator.emitProfileControlFlow(m_tryBlock->endOffset() + 1);
if (m_finallyBlock)
generator.emitNode(dst, m_catchBlock);
else
generator.emitNodeInTailPosition(dst, m_catchBlock);
- generator.emitPopCatchScope(m_catchEnvironment);
+ generator.emitPopCatchScope(m_lexicalVariables);
generator.emitLabel(catchEndLabel.get());
}
diff --git a/Source/JavaScriptCore/parser/NodeConstructors.h b/Source/JavaScriptCore/parser/NodeConstructors.h
index f349137..86525f0 100644
--- a/Source/JavaScriptCore/parser/NodeConstructors.h
+++ b/Source/JavaScriptCore/parser/NodeConstructors.h
@@ -878,12 +878,12 @@
inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& thrownValueIdent, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock)
: StatementNode(location)
+ , VariableEnvironmentNode(catchEnvironment)
, m_tryBlock(tryBlock)
, m_thrownValueIdent(thrownValueIdent)
, m_catchBlock(catchBlock)
, m_finallyBlock(finallyBlock)
{
- m_catchEnvironment.swap(catchEnvironment);
}
inline FunctionParameters::FunctionParameters()
diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h
index 0f1954a..a8e3357 100644
--- a/Source/JavaScriptCore/parser/Nodes.h
+++ b/Source/JavaScriptCore/parser/Nodes.h
@@ -209,7 +209,7 @@
int m_lastLine;
};
- class VariableEnvironmentNode {
+ class VariableEnvironmentNode : public ParserArenaDeletable {
public:
VariableEnvironmentNode()
{
@@ -1286,6 +1286,8 @@
class BlockNode : public StatementNode, public VariableEnvironmentNode {
public:
+ using ParserArenaDeletable::operator new;
+
BlockNode(const JSTokenLocation&, SourceElements*, VariableEnvironment&);
StatementNode* singleStatement() const;
@@ -1398,6 +1400,8 @@
class ForNode : public StatementNode, public VariableEnvironmentNode {
public:
+ using ParserArenaDeletable::operator new;
+
ForNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode*, VariableEnvironment&);
private:
@@ -1413,6 +1417,8 @@
class EnumerationNode : public StatementNode, public ThrowableExpressionData, public VariableEnvironmentNode {
public:
+ using ParserArenaDeletable::operator new;
+
EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*, VariableEnvironment&);
protected:
@@ -1513,8 +1519,10 @@
ExpressionNode* m_expr;
};
- class TryNode : public StatementNode {
+ class TryNode : public StatementNode, public VariableEnvironmentNode {
public:
+ using ParserArenaDeletable::operator new;
+
TryNode(const JSTokenLocation&, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock);
private:
@@ -1524,7 +1532,6 @@
const Identifier& m_thrownValueIdent;
StatementNode* m_catchBlock;
StatementNode* m_finallyBlock;
- VariableEnvironment m_catchEnvironment;
};
class ScopeNode : public StatementNode, public ParserArenaRoot, public VariableEnvironmentNode {
@@ -2112,6 +2119,8 @@
class SwitchNode : public StatementNode, public VariableEnvironmentNode {
public:
+ using ParserArenaDeletable::operator new;
+
SwitchNode(const JSTokenLocation&, ExpressionNode*, CaseBlockNode*, VariableEnvironment&);
private: