From bc87fa30d72df7db6265be50b2c39dc218076f9f Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 10 Jun 2010 23:17:06 -0700 Subject: ruby: get rid of RefCnt and Allocator stuff use base/refcnt.hh This was somewhat tricky because the RefCnt API was somewhat odd. The biggest confusion was that the the RefCnt object's constructor that took a TYPE& cloned the object. I created an explicit virtual clone() function for things that took advantage of this version of the constructor. I was conservative and used clone() when I was in doubt of whether or not it was necessary. I still think that there are probably too many instances of clone(), but hopefully not too many. I converted several instances of const MsgPtr & to a simple MsgPtr. If the function wants to avoid the overhead of creating another reference, then it should just use a regular pointer instead of a ref counting ptr. There were a couple of instances where refcounted objects were created on the stack. This seems pretty dangerous since if you ever accidentally make a reference to that object with a ref counting pointer, bad things are bound to happen. --- src/mem/slicc/ast/EnqueueStatementAST.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mem/slicc/ast') diff --git a/src/mem/slicc/ast/EnqueueStatementAST.py b/src/mem/slicc/ast/EnqueueStatementAST.py index faf966460..b27bff629 100644 --- a/src/mem/slicc/ast/EnqueueStatementAST.py +++ b/src/mem/slicc/ast/EnqueueStatementAST.py @@ -48,12 +48,12 @@ class EnqueueStatementAST(StatementAST): msg_type = self.type_ast.type # Add new local var to symbol table - v = Var(self.symtab, "out_msg", self.location, msg_type, "out_msg", + v = Var(self.symtab, "out_msg", self.location, msg_type, "*out_msg", self.pairs) self.symtab.newSymbol(v) # Declare message - code("${{msg_type.ident}} out_msg;") + code("${{msg_type.ident}} *out_msg = new ${{msg_type.ident}};") # The other statements t = self.statements.generate(code, None) -- cgit v1.2.3