diff ir/irfunction.cpp @ 1508:e1e93343fc11

Move function codegen data from IrFunction to new FuncGen. This change reduces memory consumption significantly by releasing the memory held by the STL containers that are now inside FuncGen.
author Christian Kamm <kamm incasoftware de>
date Sat, 20 Jun 2009 19:11:44 +0200
parents 3f5ea912149d
children
line wrap: on
line diff
--- a/ir/irfunction.cpp	Tue Jun 16 23:00:27 2009 +0200
+++ b/ir/irfunction.cpp	Sat Jun 20 19:11:44 2009 +0200
@@ -93,6 +93,37 @@
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
+FuncGen::FuncGen()
+{
+    landingPad = NULL;
+    nextUnique.push(0);
+}
+
+std::string FuncGen::getScopedLabelName(const char* ident)
+{
+    if(labelScopes.empty())
+        return std::string(ident);
+
+    std::string result = "__";
+    for(unsigned int i = 0; i < labelScopes.size(); ++i)
+        result += labelScopes[i] + "_";
+    return result + ident;
+}
+
+void FuncGen::pushUniqueLabelScope(const char* name)
+{
+    std::ostringstream uniquename;
+    uniquename << name << nextUnique.top()++;
+    nextUnique.push(0);
+    labelScopes.push_back(uniquename.str());
+}
+
+void FuncGen::popLabelScope()
+{
+    labelScopes.pop_back();
+    nextUnique.pop();
+}
+
 IrFunction::IrFunction(FuncDeclaration* fd)
 {
     decl = fd;
@@ -116,35 +147,6 @@
     
     _arguments = NULL;
     _argptr = NULL;
-    
-    landingPad = NULL;
-    
-    nextUnique.push(0);
-}
-
-std::string IrFunction::getScopedLabelName(const char* ident)
-{
-    if(labelScopes.empty())
-        return std::string(ident);
-
-    std::string result = "__";
-    for(unsigned int i = 0; i < labelScopes.size(); ++i)
-        result += labelScopes[i] + "_";
-    return result + ident;
-}
-
-void IrFunction::pushUniqueLabelScope(const char* name)
-{
-    std::ostringstream uniquename;
-    uniquename << name << nextUnique.top()++;
-    nextUnique.push(0);
-    labelScopes.push_back(uniquename.str());
-}
-
-void IrFunction::popLabelScope()
-{
-    labelScopes.pop_back();
-    nextUnique.pop();
 }
 
 void IrFunction::setNeverInline()