Don't use TIntermSymbol nodes for function parameters
Parameter nodes are not needed - it's simpler to just create a
TVariable object for each parameter when the TFunction is initialized.
With this change we also store only one object per each parameter type
used in built-in functions, instead of one array of TConstParameter
entries for each unique parameter sequence.
This simplifies code and reduces binary size and compiler memory use.
Compiler perf does not seem to be significantly affected.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: I2b82400dd594731074309f92a705e75135a4c82c
Reviewed-on: https://chromium-review.googlesource.com/955589
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index 74b38d2..e780f40 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -328,24 +328,23 @@
}
}
-void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence &args)
+void TOutputGLSLBase::writeFunctionParameters(const TFunction *func)
{
TInfoSinkBase &out = objSink();
- for (TIntermSequence::const_iterator iter = args.begin(); iter != args.end(); ++iter)
+ size_t paramCount = func->getParamCount();
+ for (size_t i = 0; i < paramCount; ++i)
{
- const TIntermSymbol *arg = (*iter)->getAsSymbolNode();
- ASSERT(arg != nullptr);
-
- const TType &type = arg->getType();
+ const TVariable *param = func->getParam(i);
+ const TType &type = param->getType();
writeVariableType(type);
- if (arg->variable().symbolType() != SymbolType::Empty)
- out << " " << hashName(&arg->variable());
+ if (param->symbolType() != SymbolType::Empty)
+ out << " " << hashName(param);
if (type.isArray())
out << ArrayString(type);
// Put a comma if this is not the last argument.
- if (iter != args.end() - 1)
+ if (i != paramCount - 1)
out << ", ";
}
}
@@ -890,10 +889,9 @@
return false;
}
-bool TOutputGLSLBase::visitFunctionPrototype(Visit visit, TIntermFunctionPrototype *node)
+void TOutputGLSLBase::visitFunctionPrototype(TIntermFunctionPrototype *node)
{
TInfoSinkBase &out = objSink();
- ASSERT(visit == PreVisit);
const TType &type = node->getType();
writeVariableType(type);
@@ -903,10 +901,8 @@
out << " " << hashFunctionNameIfNeeded(node->getFunction());
out << "(";
- writeFunctionParameters(*(node->getSequence()));
+ writeFunctionParameters(node->getFunction());
out << ")";
-
- return false;
}
bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)