Commit 352beffc by Olli Etuaho Committed by Jamie Madill

Remove RemoveAllTreeNodes, since it was a no-op

IntermNode operator delete() or any of the IntermNode destructors don't do anything, since all the AST memory is allocated on the PoolAllocator. Because of this, RemoveAllTreeNodes was simply a no-op, and redundant with the PoolAllocator deallocation procedure, and could confuse people reading the code to think that IntermNodes should be deleted individually, when in fact this is not the case. BUG=angle:831 Change-Id: Ie1ccaa51986aabf267280d92a8e76ca9f97a19e5 Reviewed-on: https://chromium-review.googlesource.com/230730Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent ea7a2121
...@@ -97,8 +97,6 @@ ...@@ -97,8 +97,6 @@
'compiler/translator/QualifierAlive.h', 'compiler/translator/QualifierAlive.h',
'compiler/translator/RegenerateStructNames.cpp', 'compiler/translator/RegenerateStructNames.cpp',
'compiler/translator/RegenerateStructNames.h', 'compiler/translator/RegenerateStructNames.h',
'compiler/translator/RemoveTree.cpp',
'compiler/translator/RemoveTree.h',
'compiler/translator/RenameFunction.h', 'compiler/translator/RenameFunction.h',
'compiler/translator/RewriteElseBlocks.cpp', 'compiler/translator/RewriteElseBlocks.cpp',
'compiler/translator/RewriteElseBlocks.h', 'compiler/translator/RewriteElseBlocks.h',
......
...@@ -311,8 +311,8 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -311,8 +311,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
translate(root); translate(root);
} }
// Cleanup memory. // Cleanup. The IntermNode tree doesn't need to be deleted here, since the
intermediate.remove(parseContext.treeRoot); // memory will be freed in a big chunk by the PoolAllocator.
SetGlobalParseContext(NULL); SetGlobalParseContext(NULL);
return success; return success;
} }
......
...@@ -157,26 +157,6 @@ bool TIntermLoop::replaceChildNode( ...@@ -157,26 +157,6 @@ bool TIntermLoop::replaceChildNode(
return false; return false;
} }
void TIntermLoop::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
if (mInit)
{
nodeQueue->push(mInit);
}
if (mCond)
{
nodeQueue->push(mCond);
}
if (mExpr)
{
nodeQueue->push(mExpr);
}
if (mBody)
{
nodeQueue->push(mBody);
}
}
bool TIntermBranch::replaceChildNode( bool TIntermBranch::replaceChildNode(
TIntermNode *original, TIntermNode *replacement) TIntermNode *original, TIntermNode *replacement)
{ {
...@@ -184,14 +164,6 @@ bool TIntermBranch::replaceChildNode( ...@@ -184,14 +164,6 @@ bool TIntermBranch::replaceChildNode(
return false; return false;
} }
void TIntermBranch::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
if (mExpression)
{
nodeQueue->push(mExpression);
}
}
bool TIntermBinary::replaceChildNode( bool TIntermBinary::replaceChildNode(
TIntermNode *original, TIntermNode *replacement) TIntermNode *original, TIntermNode *replacement)
{ {
...@@ -200,18 +172,6 @@ bool TIntermBinary::replaceChildNode( ...@@ -200,18 +172,6 @@ bool TIntermBinary::replaceChildNode(
return false; return false;
} }
void TIntermBinary::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
if (mLeft)
{
nodeQueue->push(mLeft);
}
if (mRight)
{
nodeQueue->push(mRight);
}
}
bool TIntermUnary::replaceChildNode( bool TIntermUnary::replaceChildNode(
TIntermNode *original, TIntermNode *replacement) TIntermNode *original, TIntermNode *replacement)
{ {
...@@ -219,14 +179,6 @@ bool TIntermUnary::replaceChildNode( ...@@ -219,14 +179,6 @@ bool TIntermUnary::replaceChildNode(
return false; return false;
} }
void TIntermUnary::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
if (mOperand)
{
nodeQueue->push(mOperand);
}
}
bool TIntermAggregate::replaceChildNode( bool TIntermAggregate::replaceChildNode(
TIntermNode *original, TIntermNode *replacement) TIntermNode *original, TIntermNode *replacement)
{ {
...@@ -237,14 +189,6 @@ bool TIntermAggregate::replaceChildNode( ...@@ -237,14 +189,6 @@ bool TIntermAggregate::replaceChildNode(
return false; return false;
} }
void TIntermAggregate::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
for (size_t childIndex = 0; childIndex < mSequence.size(); childIndex++)
{
nodeQueue->push(mSequence[childIndex]);
}
}
void TIntermAggregate::setPrecisionFromChildren() void TIntermAggregate::setPrecisionFromChildren()
{ {
if (getBasicType() == EbtBool) if (getBasicType() == EbtBool)
...@@ -300,22 +244,6 @@ bool TIntermSelection::replaceChildNode( ...@@ -300,22 +244,6 @@ bool TIntermSelection::replaceChildNode(
return false; return false;
} }
void TIntermSelection::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
{
if (mCondition)
{
nodeQueue->push(mCondition);
}
if (mTrueBlock)
{
nodeQueue->push(mTrueBlock);
}
if (mFalseBlock)
{
nodeQueue->push(mFalseBlock);
}
}
// //
// Say whether or not an operation node changes the value of a variable. // Say whether or not an operation node changes the value of a variable.
// //
......
...@@ -238,10 +238,6 @@ class TIntermNode ...@@ -238,10 +238,6 @@ class TIntermNode
virtual bool replaceChildNode( virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement) = 0; TIntermNode *original, TIntermNode *replacement) = 0;
// For traversing a tree in no particular order, but using
// heap memory.
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const = 0;
protected: protected:
TSourceLoc mLine; TSourceLoc mLine;
}; };
...@@ -332,8 +328,6 @@ class TIntermLoop : public TIntermNode ...@@ -332,8 +328,6 @@ class TIntermLoop : public TIntermNode
void setUnrollFlag(bool flag) { mUnrollFlag = flag; } void setUnrollFlag(bool flag) { mUnrollFlag = flag; }
bool getUnrollFlag() const { return mUnrollFlag; } bool getUnrollFlag() const { return mUnrollFlag; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected: protected:
TLoopType mType; TLoopType mType;
TIntermNode *mInit; // for-loop initialization TIntermNode *mInit; // for-loop initialization
...@@ -361,8 +355,6 @@ class TIntermBranch : public TIntermNode ...@@ -361,8 +355,6 @@ class TIntermBranch : public TIntermNode
TOperator getFlowOp() { return mFlowOp; } TOperator getFlowOp() { return mFlowOp; }
TIntermTyped* getExpression() { return mExpression; } TIntermTyped* getExpression() { return mExpression; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected: protected:
TOperator mFlowOp; TOperator mFlowOp;
TIntermTyped *mExpression; // non-zero except for "return exp;" statements TIntermTyped *mExpression; // non-zero except for "return exp;" statements
...@@ -395,8 +387,6 @@ class TIntermSymbol : public TIntermTyped ...@@ -395,8 +387,6 @@ class TIntermSymbol : public TIntermTyped
virtual TIntermSymbol *getAsSymbolNode() { return this; } virtual TIntermSymbol *getAsSymbolNode() { return this; }
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; } virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected: protected:
int mId; int mId;
TString mSymbol; TString mSymbol;
...@@ -420,7 +410,6 @@ class TIntermRaw : public TIntermTyped ...@@ -420,7 +410,6 @@ class TIntermRaw : public TIntermTyped
virtual TIntermRaw *getAsRawNode() { return this; } virtual TIntermRaw *getAsRawNode() { return this; }
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; } virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected: protected:
TString mRawText; TString mRawText;
...@@ -460,8 +449,6 @@ class TIntermConstantUnion : public TIntermTyped ...@@ -460,8 +449,6 @@ class TIntermConstantUnion : public TIntermTyped
TIntermTyped *fold(TOperator, TIntermTyped *, TInfoSink &); TIntermTyped *fold(TOperator, TIntermTyped *, TInfoSink &);
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected: protected:
ConstantUnion *mUnionArrayPointer; ConstantUnion *mUnionArrayPointer;
}; };
...@@ -520,8 +507,6 @@ class TIntermBinary : public TIntermOperator ...@@ -520,8 +507,6 @@ class TIntermBinary : public TIntermOperator
void setAddIndexClamp() { mAddIndexClamp = true; } void setAddIndexClamp() { mAddIndexClamp = true; }
bool getAddIndexClamp() { return mAddIndexClamp; } bool getAddIndexClamp() { return mAddIndexClamp; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected: protected:
TIntermTyped* mLeft; TIntermTyped* mLeft;
TIntermTyped* mRight; TIntermTyped* mRight;
...@@ -562,8 +547,6 @@ class TIntermUnary : public TIntermOperator ...@@ -562,8 +547,6 @@ class TIntermUnary : public TIntermOperator
void setUseEmulatedFunction() { mUseEmulatedFunction = true; } void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; } bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected: protected:
TIntermTyped *mOperand; TIntermTyped *mOperand;
...@@ -614,8 +597,6 @@ class TIntermAggregate : public TIntermOperator ...@@ -614,8 +597,6 @@ class TIntermAggregate : public TIntermOperator
void setUseEmulatedFunction() { mUseEmulatedFunction = true; } void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; } bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
void setPrecisionFromChildren(); void setPrecisionFromChildren();
void setBuiltInFunctionPrecision(); void setBuiltInFunctionPrecision();
...@@ -665,8 +646,6 @@ class TIntermSelection : public TIntermTyped ...@@ -665,8 +646,6 @@ class TIntermSelection : public TIntermTyped
TIntermNode *getFalseBlock() const { return mFalseBlock; } TIntermNode *getFalseBlock() const { return mFalseBlock; }
TIntermSelection *getAsSelectionNode() { return this; } TIntermSelection *getAsSelectionNode() { return this; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected: protected:
TIntermTyped *mCondition; TIntermTyped *mCondition;
TIntermNode *mTrueBlock; TIntermNode *mTrueBlock;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <algorithm> #include <algorithm>
#include "compiler/translator/Intermediate.h" #include "compiler/translator/Intermediate.h"
#include "compiler/translator/RemoveTree.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
...@@ -510,12 +509,3 @@ bool TIntermediate::postProcess(TIntermNode *root) ...@@ -510,12 +509,3 @@ bool TIntermediate::postProcess(TIntermNode *root)
return true; return true;
} }
//
// This deletes the tree.
//
void TIntermediate::remove(TIntermNode *root)
{
if (root)
RemoveAllTreeNodes(root);
}
...@@ -55,7 +55,6 @@ class TIntermediate ...@@ -55,7 +55,6 @@ class TIntermediate
TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &); TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &);
TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &); TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &);
bool postProcess(TIntermNode *); bool postProcess(TIntermNode *);
void remove(TIntermNode *);
void outputTree(TIntermNode *); void outputTree(TIntermNode *);
private: private:
......
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/RemoveTree.h"
//
// Code to delete the intermediate tree.
//
void RemoveAllTreeNodes(TIntermNode* root)
{
std::queue<TIntermNode*> nodeQueue;
nodeQueue.push(root);
while (!nodeQueue.empty())
{
TIntermNode *node = nodeQueue.front();
nodeQueue.pop();
node->enqueueChildren(&nodeQueue);
delete node;
}
}
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef COMPILER_TRANSLATOR_REMOVETREE_H_
#define COMPILER_TRANSLATOR_REMOVETREE_H_
void RemoveAllTreeNodes(TIntermNode*);
#endif // COMPILER_TRANSLATOR_REMOVETREE_H_
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