Commit 7f17a50c by Dmitry Skiba Committed by Jamie Madill

Store TFunction::returnType by a const pointer.

On 32-bit Android this change saves ~30KiB per compiler instance. BUG=492725 Change-Id: I8bea48d57ee7eac0a0ee417035085c0d335aea09 Reviewed-on: https://chromium-review.googlesource.com/281047Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarDmitry Skiba <dskiba@google.com>
parent efa3d8eb
...@@ -1877,7 +1877,7 @@ TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn) ...@@ -1877,7 +1877,7 @@ TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn)
} }
TString tempString; TString tempString;
TType type(publicType); const TType *type = new TType(publicType);
return new TFunction(&tempString, type, op); return new TFunction(&tempString, type, op);
} }
......
...@@ -229,7 +229,7 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *e ...@@ -229,7 +229,7 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *e
} }
else else
{ {
TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op, ext); TFunction *function = new TFunction(NewPoolTString(name), rvalue, op, ext);
function->addParameter(TConstParameter(ptype1)); function->addParameter(TConstParameter(ptype1));
......
...@@ -220,14 +220,7 @@ struct TParameter ...@@ -220,14 +220,7 @@ struct TParameter
class TFunction : public TSymbol class TFunction : public TSymbol
{ {
public: public:
TFunction(TOperator o) TFunction(const TString *name, const TType *retType, TOperator tOp = EOpNull, const char *ext = "")
: TSymbol(0),
returnType(TType(EbtVoid, EbpUndefined)),
op(o),
defined(false)
{
}
TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull, const char *ext = "")
: TSymbol(name), : TSymbol(name),
returnType(retType), returnType(retType),
mangledName(TFunction::mangleName(*name)), mangledName(TFunction::mangleName(*name)),
...@@ -263,7 +256,7 @@ class TFunction : public TSymbol ...@@ -263,7 +256,7 @@ class TFunction : public TSymbol
} }
const TType &getReturnType() const const TType &getReturnType() const
{ {
return returnType; return *returnType;
} }
TOperator getBuiltInOp() const TOperator getBuiltInOp() const
...@@ -292,7 +285,7 @@ class TFunction : public TSymbol ...@@ -292,7 +285,7 @@ class TFunction : public TSymbol
private: private:
typedef TVector<TConstParameter> TParamList; typedef TVector<TConstParameter> TParamList;
TParamList parameters; TParamList parameters;
TType returnType; const TType *returnType;
TString mangledName; TString mangledName;
TOperator op; TOperator op;
bool defined; bool defined;
......
...@@ -369,14 +369,14 @@ function_identifier ...@@ -369,14 +369,14 @@ function_identifier
| IDENTIFIER { | IDENTIFIER {
if (context->reservedErrorCheck(@1, *$1.string)) if (context->reservedErrorCheck(@1, *$1.string))
context->recover(); context->recover();
TType type(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
} }
| FIELD_SELECTION { | FIELD_SELECTION {
if (context->reservedErrorCheck(@1, *$1.string)) if (context->reservedErrorCheck(@1, *$1.string))
context->recover(); context->recover();
TType type(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
} }
...@@ -700,7 +700,7 @@ function_prototype ...@@ -700,7 +700,7 @@ function_prototype
else else
{ {
// Insert the unmangled name to detect potential future redefinition as a variable. // Insert the unmangled name to detect potential future redefinition as a variable.
TFunction *function = new TFunction(NewPoolTString($1->getName().c_str()), $1->getReturnType()); TFunction *function = new TFunction(NewPoolTString($1->getName().c_str()), &$1->getReturnType());
context->symbolTable.getOuterLevel()->insertUnmangled(function); context->symbolTable.getOuterLevel()->insertUnmangled(function);
} }
...@@ -768,7 +768,7 @@ function_header ...@@ -768,7 +768,7 @@ function_header
// Add the function as a prototype after parsing it (we do not support recursion) // Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function; TFunction *function;
TType type($1); const TType *type = new TType($1);
function = new TFunction($2.string, type); function = new TFunction($2.string, type);
$$ = function; $$ = function;
......
...@@ -2603,7 +2603,7 @@ yyreduce: ...@@ -2603,7 +2603,7 @@ yyreduce:
{ {
if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string))
context->recover(); context->recover();
TType type(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction((yyvsp[0].lex).string, type); TFunction *function = new TFunction((yyvsp[0].lex).string, type);
(yyval.interm.function) = function; (yyval.interm.function) = function;
} }
...@@ -2615,7 +2615,7 @@ yyreduce: ...@@ -2615,7 +2615,7 @@ yyreduce:
{ {
if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string))
context->recover(); context->recover();
TType type(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction((yyvsp[0].lex).string, type); TFunction *function = new TFunction((yyvsp[0].lex).string, type);
(yyval.interm.function) = function; (yyval.interm.function) = function;
} }
...@@ -3199,7 +3199,7 @@ yyreduce: ...@@ -3199,7 +3199,7 @@ yyreduce:
else else
{ {
// Insert the unmangled name to detect potential future redefinition as a variable. // Insert the unmangled name to detect potential future redefinition as a variable.
TFunction *function = new TFunction(NewPoolTString((yyvsp[-1].interm.function)->getName().c_str()), (yyvsp[-1].interm.function)->getReturnType()); TFunction *function = new TFunction(NewPoolTString((yyvsp[-1].interm.function)->getName().c_str()), &(yyvsp[-1].interm.function)->getReturnType());
context->symbolTable.getOuterLevel()->insertUnmangled(function); context->symbolTable.getOuterLevel()->insertUnmangled(function);
} }
...@@ -3282,7 +3282,7 @@ yyreduce: ...@@ -3282,7 +3282,7 @@ yyreduce:
// Add the function as a prototype after parsing it (we do not support recursion) // Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function; TFunction *function;
TType type((yyvsp[-2].interm.type)); const TType *type = new TType((yyvsp[-2].interm.type));
function = new TFunction((yyvsp[-1].lex).string, type); function = new TFunction((yyvsp[-1].lex).string, type);
(yyval.interm.function) = function; (yyval.interm.function) = function;
......
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