Commit 99749531 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

        Track memory leaks.

        * dev/inst-builder-gen.py,
        * dev/inst-nodes-gen.py,
        * dev/mipsy.xml,
        * dev/parse-asm-parse-gen.py,
        * src/inst/data_section.hh,
        * src/inst/exp.hh,
        * src/inst/program_builder.cc,
        * src/inst/section.hh,
        * src/inst/text_section.hh,
        * src/vm/cpu.hh, src/vm/cpu.cc
        * src/vm/segment.hh,
        * src/vm/vm-tasks.cc:
        Use pointers instead of references for each allocated attribute, 
        and delete them.
parent a546ec24
2004-02-29 Benot Perrot <benoit@lrde.epita.fr>
Track memory leaks.
* dev/inst-builder-gen.py,
* dev/inst-nodes-gen.py,
* dev/mipsy.xml,
* dev/parse-asm-parse-gen.py,
* src/inst/data_section.hh,
* src/inst/exp.hh,
* src/inst/program_builder.cc,
* src/inst/section.hh,
* src/inst/text_section.hh,
* src/vm/cpu.hh, src/vm/cpu.cc
* src/vm/segment.hh,
* src/vm/vm-tasks.cc:
Use pointers instead of references for each allocated attribute,
and delete them.
2004-02-24 Benot Perrot <benoit@lrde.epita.fr>
* dev/doc-inst-set-gen.py,
......
......@@ -66,18 +66,18 @@ namespace inst
// FIXME: fill end of program with NOPs for pipeline (really dirty!)
for (unsigned i = 0; i < 6; ++i)
_program->text_section().
add_inst (* new Sll(* new Register(Register::general, Cpu::zero),
* new Register(Register::general, Cpu::zero),
* new IntExp(0)));
add_inst (new Sll(new Register(Register::general, Cpu::zero),
new Register(Register::general, Cpu::zero),
new IntExp(0)));
return _program;
}
public:
void add_data_label(Label& label)
void add_data_label(Label *label)
{
_program->data_section ().add_label(label);
}
void add_inst_label(Label& label)
void add_inst_label(Label *label)
{
_program->text_section ().add_label(label);
}
......@@ -91,13 +91,14 @@ namespace inst
{
_program->data_section ().add_word (imm);
}
void add_word (Label& label)
void add_word (Label *label)
{
// FIXME: use a precondition
_program->data_section ().
add_word (_program->data_section ().get_offset(label));
add_word (_program->data_section ().get_offset(* label));
}
void add_asciiz (const std::string& str)
void add_asciiz (const std::string *str)
{
_program->data_section ().add_asciiz (str);
}
......@@ -105,10 +106,10 @@ namespace inst
public:"""
type_map = {
"register": "Register&",
"immediate": "Exp&",
"label": "Exp&",
"address": "Register&"
"register": "Register *",
"immediate": "Exp *",
"label": "Exp *",
"address": "Register *"
}
for inst in instructions:
......@@ -120,22 +121,22 @@ for inst in instructions:
proto = ""
call = ""
for attribute in inst.format.attributes:
proto = proto + attribute.type + "& " + attribute.name + ", "
proto = proto + attribute.type + " *" + attribute.name + ", "
call = call + attribute.name + ", "
proto = string.rstrip(proto, ", ")
call = string.rstrip(call, ", ")
print " void\tadd_" + inst.opcode + "(" + proto + ")"
print " {"
call = "* new " + class_id(inst.opcode) + "(" + call + ")"
call = "new " + class_id(inst.opcode) + "(" + call + ")"
print " _program->text_section().add_inst (" + call + ");"
if inst.kind == "branch":
print " if (fill_delay_slot_p)"
print " _program->text_section()."
print " add_inst (* new Sll(* new Register(Register::general, " + \
print " add_inst (new Sll(new Register(Register::general, " + \
"Cpu::zero), "
print " * new Register(Register::general, " + \
print " new Register(Register::general, " + \
"Cpu::zero), "
print " * new IntExp(0)));"
print " new IntExp(0)));"
print " }"
else: # syntax.level == "complex"
......@@ -143,7 +144,7 @@ for inst in instructions:
for token in syntax.tokens:
proto = proto + type_map[token.kind]
if token.name:
proto = proto + " " + token.name
proto = proto + token.name
proto = proto + ", "
proto = string.rstrip(proto, ", ")
print " void\tadd_" + inst.opcode + "(" + proto + ");"
......
......@@ -82,7 +82,7 @@ def class_generate(inst):
init = ""
dels = ""
for attribute in format.attributes:
args = args + attribute.type + "& " + attribute.name + ", "
args = args + attribute.type + " *" + attribute.name + ", "
init = init + attribute.name + "_(" + attribute.name + "), "
args = string.rstrip(args, ", ")
init = string.rstrip(init, ", ")
......@@ -105,7 +105,11 @@ def class_generate(inst):
print " {}\n"
sys.stdout = impl
print " " + class_id + "::~" + class_id + "()"
print " {}\n"
print " {"
for attribute in format.attributes:
# FIXME: there should be some preconditions
print " delete " + attribute.name + "_;"
print " }\n"
# Methods: accessors
sys.stdout = header
......@@ -124,7 +128,7 @@ def class_generate(inst):
print " " + c + attribute.type + " &"
print " " + class_id + "::get_" + attribute.name + "() " + c
print " {"
print " return " + attribute.name + "_;"
print " return *" + attribute.name + "_;"
print " }"
sys.stdout = header
print " /** \\} */"
......@@ -185,7 +189,7 @@ def class_generate(inst):
print " protected:"
for attribute in format.attributes:
id = attribute.name + "_"
print " " + attribute.type + "\t&" + id + ";"
print " " + attribute.type + "\t*" + id + ";"
# End of declaration
print " };"
......
......@@ -102,7 +102,7 @@
<syntax alias="addi">
<token kind="register" />
<token kind="register" />
<token kind="immediate" name="imm" value="*new OpExp(*new IntExp(0), OpExp::sub, ${imm})" />
<token kind="immediate" name="imm" value="new OpExp(new IntExp(0), OpExp::sub, ${imm})" />
</syntax>
</instruction>
<instruction opcode="subu" level="native" kind="arithmetic">
......@@ -121,7 +121,7 @@
<syntax alias="addiu">
<token kind="register" />
<token kind="register" />
<token kind="immediate" name="imm" value="*new OpExp(*new IntExp(0), OpExp::sub, ${imm})" />
<token kind="immediate" name="imm" value="new OpExp(new IntExp(0), OpExp::sub, ${imm})" />
</syntax>
</instruction>
......@@ -130,7 +130,7 @@
dest. If an overflow occurs (FIXME), then trap.</description>
<syntax alias="sub">
<token kind="register" name="dest" />
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)" />
<token kind="register" default="${dest}" />
</syntax>
</instruction>
......@@ -139,7 +139,7 @@ dest. If an overflow occurs (FIXME), then trap.</description>
dest.</description>
<syntax alias="subu">
<token kind="register" name="dest" />
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)" />
<token kind="register" default="${dest}" />
</syntax>
</instruction>
......@@ -504,7 +504,7 @@ dest.</description>
<syntax alias="nor">
<token kind="register" name="dest" />
<token kind="register" default="${dest}"/>
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)" />
</syntax>
</instruction>
......@@ -718,7 +718,7 @@ else clear it.</description>
<description>Branch to label if src equals zero.</description>
<syntax alias="beq">
<token kind="register" />
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)"/>
<token kind="hidden" value="new Register(Register::general, Cpu::zero)"/>
<token kind="label" />
</syntax>
</instruction>
......@@ -745,7 +745,7 @@ else clear it.</description>
<description>Branch to label if src does not equal zero.</description>
<syntax alias="bne">
<token kind="register" />
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)"/>
<token kind="hidden" value="new Register(Register::general, Cpu::zero)"/>
<token kind="label" />
</syntax>
</instruction>
......@@ -992,7 +992,7 @@ dest as a signed value.</description>
</format>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
</instruction>
......@@ -1006,7 +1006,7 @@ dest as an unsigned value.</description>
</format>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
</instruction>
......@@ -1021,7 +1021,7 @@ dest as a signed value.</description>
</format>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
</instruction>
......@@ -1043,7 +1043,7 @@ dest as a signed value.</description>
<description>Move the computed address into dest.</description>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
<syntax>
......@@ -1064,7 +1064,7 @@ dest as a signed value.</description>
</format>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
</instruction>
......@@ -1079,7 +1079,7 @@ dest as a signed value.</description>
</format>
<syntax>
<token kind="register" />
<token kind="immediate" default="* new IntExp(0)" />
<token kind="immediate" default="new IntExp(0)" />
<token kind="address" />
</syntax>
</instruction>
......@@ -1091,7 +1091,7 @@ dest as a signed value.</description>
<syntax alias="addu">
<token kind="register" />
<token kind="register" />
<token kind="hidden" value="*new Register(Register::general, Cpu::zero)"/>
<token kind="hidden" value="new Register(Register::general, Cpu::zero)"/>
</syntax>
</instruction>
......@@ -1145,9 +1145,9 @@ dest as a signed value.</description>
<instruction opcode="nop" level="pseudo" kind="nop">
<description>To do nothing.</description>
<syntax alias="sll">
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="* new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="* new IntExp(0)" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)" />
<token kind="hidden" value="new IntExp(0)" />
</syntax>
</instruction>
......
......@@ -119,7 +119,7 @@ datas
data
// Label
: LABEL_DEF
{ program_builder.add_data_label(* $1); }
{ program_builder.add_data_label($1); }
// Reserve space
| DIR_SPACE INTEGER
{ program_builder.add_space ($2); }
......@@ -127,9 +127,9 @@ data
| DIR_WORD INTEGER
{ program_builder.add_word ($2); }
| DIR_WORD LABEL
{ program_builder.add_word (*$2); }
{ program_builder.add_word ($2); }
| DIR_ASCIIZ STRING
{ program_builder.add_asciiz (* $2); }
{ program_builder.add_asciiz ($2); }
// Instruction definitions
instructions
......@@ -139,7 +139,7 @@ instructions
instruction
// Label
: LABEL_DEF
{ program_builder.add_inst_label(* $1); }
{ program_builder.add_inst_label($1); }
// Opcodes"""
......@@ -217,10 +217,10 @@ for inst in instructions:
if token[0] != "":
i = i + 1
rule = rule + " " + token[0]
value = "*$" + str(i)
value = "$" + str(i)
if token[2] != "":
value = re.sub(r"\$\{([^}]*)\}",
(lambda m: "*$" + str(tokidx[m.groups(0)[0]])),
(lambda m: "$" + str(tokidx[m.groups(0)[0]])),
token[2])
if token[0] in tokid_map.values():
action = action + value + ", "
......@@ -234,15 +234,15 @@ for inst in instructions:
## Epilogue --------------------------
print """
exp:
exp EXP_ADD exp { $$ = new OpExp(*$1, OpExp::add, *$3); }
| exp EXP_SUB exp { $$ = new OpExp(*$1, OpExp::sub, *$3); }
| exp EXP_MUL exp { $$ = new OpExp(*$1, OpExp::mul, *$3); }
| exp EXP_DIV exp { $$ = new OpExp(*$1, OpExp::div, *$3); }
exp EXP_ADD exp { $$ = new OpExp($1, OpExp::add, $3); }
| exp EXP_SUB exp { $$ = new OpExp($1, OpExp::sub, $3); }
| exp EXP_MUL exp { $$ = new OpExp($1, OpExp::mul, $3); }
| exp EXP_DIV exp { $$ = new OpExp($1, OpExp::div, $3); }
| EXP_SUB exp %prec EXP_UMINUS
{ $$ = new OpExp(*new IntExp(0), OpExp::sub, *$2); }
{ $$ = new OpExp(new IntExp(0), OpExp::sub, $2); }
| LPAREN exp RPAREN { $$ = $2; }
| INTEGER { $$ = new IntExp($1); }
| LABEL { $$ = new LabelExp(*$1); }
| LABEL { $$ = new LabelExp($1); }
%%
void
......
......@@ -2,58 +2,35 @@
(Created-By-Prcs-Version 1 3 2)
(Project-Description "")
(Project-Version mipsy 0 73)
(Parent-Version mipsy 0 72)
(Project-Version mipsy 0 74)
(Parent-Version mipsy 0 73)
(Version-Log
"Index: ChangeLog
from Benot Perrot <benoit@lrde.epita.fr>
* dev/doc-inst-set-gen.py,
Track memory leaks.
* dev/inst-builder-gen.py,
* dev/inst-makefile-gen.py,
* dev/inst-nodes-gen.py,
* dev/mipsy.py,
* dev/mipsy.xml,
* dev/parse-asm-parse-gen.py,
* dev/parse-asm-scan-gen.py,
* src/common.hh,
* src/mipsy-tasks.cc, src/mipsy-tasks.hh,
* src/mipsy.cc,
* src/modules.hh,
* src/inst/data_section.hh,
* src/inst/exp-visitor.hh,
* src/inst/exp.hh,
* src/inst/inst-tasks.cc, src/inst/inst-tasks.hh,
* src/inst/inst.hh,
* src/inst/label.cc, src/inst/label.hh,
* src/inst/program.hh,
* src/inst/program_builder.cc,
* src/inst/program_solver.hh,
* src/inst/register.hh,
* src/inst/section.hh,
* src/inst/text_section.hh,
* src/parse/asm-scan.hh,
* src/parse/libparse.cc, src/parse/libparse.hh,
* src/parse/parse-tasks.cc, src/parse/parse-tasks.hh,
* src/task/task-tasks.cc, src/task/task-tasks.hh,
* src/task/task.cc, src/task/task.hh,
* src/task/task_register.cc, src/task/task_register.hh,
* src/vm/cpu.hh, src/vm/cpu.cc,
* src/vm/memory.hh,
* src/vm/mmu.hh,
* src/vm/cpu.hh, src/vm/cpu.cc
* src/vm/segment.hh,
* src/vm/table.hh,
* src/vm/virtual_machine.hh,
* src/vm/vm-tasks.cc, src/vm/vm-tasks.hh:
Update Copyright.
Suggested by Akim Demaille.
* src/vm/vm-tasks.cc:
Use pointers instead of references for each allocated attribute,
and delete them.
")
(New-Version-Log
"")
(Checkin-Time "Tue, 24 Feb 2004 21:51:05 +0100")
(Checkin-Time "Sun, 29 Feb 2004 20:00:21 +0100")
(Checkin-Login benoit)
(Files
......@@ -61,7 +38,7 @@ from Beno
;; ./
(AUTHORS (mipsy/0_AUTHORS 1.1 644))
(COPYING (mipsy/1_COPYING 1.1 644))
(ChangeLog (mipsy/2_ChangeLog 1.67 604))
(ChangeLog (mipsy/2_ChangeLog 1.68 604))
(Makefile.am (mipsy/3_Makefile.a 1.8 604))
(NEWS (mipsy/b/25_NEWS 1.6 604))
(README (mipsy/4_README 1.2 644))
......@@ -75,12 +52,12 @@ from Beno
;; ./dev/
(dev/doc-inst-set-gen.py (mipsy/c/21_doc-inst-s 1.3 705))
(dev/inst-builder-gen.py (mipsy/15_mipsy-buil 1.10 705))
(dev/inst-builder-gen.py (mipsy/15_mipsy-buil 1.11 705))
(dev/inst-makefile-gen.py (mipsy/b/15_mipsy-mk-i 1.7 705))
(dev/inst-nodes-gen.py (mipsy/12_mipsy-inst 1.8 705))
(dev/inst-nodes-gen.py (mipsy/12_mipsy-inst 1.9 705))
(dev/mipsy.py (mipsy/16_mipsy.py 1.8 705))
(dev/mipsy.xml (mipsy/17_mipsy.xml 1.15 604))
(dev/parse-asm-parse-gen.py (mipsy/13_mipsy-pars 1.9 705))
(dev/mipsy.xml (mipsy/17_mipsy.xml 1.16 604))
(dev/parse-asm-parse-gen.py (mipsy/13_mipsy-pars 1.10 705))
(dev/parse-asm-scan-gen.py (mipsy/14_mipsy-scan 1.11 705))
;; ./doc/
......@@ -102,20 +79,20 @@ from Beno
(src/modules.hh (mipsy/23_modules.hh 1.3 644))
;; ./src/inst/
(src/inst/data_section.hh (mipsy/24_data_secti 1.5 604))
(src/inst/data_section.hh (mipsy/24_data_secti 1.6 604))
(src/inst/exp-visitor.hh (mipsy/25_exp-visito 1.4 604))
(src/inst/exp.hh (mipsy/26_exp.hh 1.4 604))
(src/inst/exp.hh (mipsy/26_exp.hh 1.5 604))
(src/inst/inst-tasks.cc (mipsy/b/23_inst-tasks 1.2 644))
(src/inst/inst-tasks.hh (mipsy/b/22_inst-tasks 1.2 644))
(src/inst/inst.hh (mipsy/27_inst.hh 1.3 644))
(src/inst/label.cc (mipsy/b/21_label.cc 1.3 604))
(src/inst/label.hh (mipsy/b/20_label.hh 1.3 604))
(src/inst/program.hh (mipsy/28_program.hh 1.3 644))
(src/inst/program_builder.cc (mipsy/29_program_bu 1.12 604))
(src/inst/program_builder.cc (mipsy/29_program_bu 1.13 604))
(src/inst/program_solver.hh (mipsy/30_program_so 1.7 644))
(src/inst/register.hh (mipsy/31_register.h 1.5 644))
(src/inst/section.hh (mipsy/b/24_section.hh 1.6 604))
(src/inst/text_section.hh (mipsy/32_text_secti 1.5 604))
(src/inst/section.hh (mipsy/b/24_section.hh 1.7 604))
(src/inst/text_section.hh (mipsy/32_text_secti 1.6 604))
;; ./src/misc/
(src/misc/Makefile.am (mipsy/33_Makefile.a 1.2 644))
......@@ -144,14 +121,14 @@ from Beno
;; ./src/vm/
(src/vm/Makefile.am (mipsy/b/0_Makefile.a 1.4 604))
(src/vm/cpu.hh (mipsy/b/1_cpu.hh 1.14 604))
(src/vm/cpu.cc (mipsy/b/5_virtual_ma 1.21 604))
(src/vm/cpu.hh (mipsy/b/1_cpu.hh 1.15 604))
(src/vm/cpu.cc (mipsy/b/5_virtual_ma 1.22 604))
(src/vm/memory.hh (mipsy/b/2_memory.hh 1.9 604))
(src/vm/mmu.hh (mipsy/c/15_mmu.hh 1.3 604))
(src/vm/segment.hh (mipsy/b/3_segment.hh 1.3 644))
(src/vm/segment.hh (mipsy/b/3_segment.hh 1.4 644))
(src/vm/table.hh (mipsy/b/4_table.hh 1.4 604))
(src/vm/virtual_machine.hh (mipsy/b/6_virtual_ma 1.15 604))
(src/vm/vm-tasks.cc (mipsy/b/7_vm-tasks.c 1.6 604))
(src/vm/vm-tasks.cc (mipsy/b/7_vm-tasks.c 1.7 604))
(src/vm/vm-tasks.hh (mipsy/b/8_vm-tasks.h 1.4 604))
;; ./tests/
......
......@@ -50,7 +50,7 @@ namespace inst
}
public:
void add_label(Label& label)
void add_label(Label *label)
{
Section::add_label(label, _size);
}
......@@ -78,10 +78,10 @@ namespace inst
add_byte(w / pow);
}
void add_asciiz(const std::string& s)
void add_asciiz(const std::string* s)
{
for (unsigned i = 0; i < s.size (); ++i)
add_byte(s[i]);
for (unsigned i = 0; i < s->size (); ++i)
add_byte((*s)[i]);
add_byte(0);
}
......
......@@ -113,7 +113,7 @@ namespace inst
public Exp
{
public:
LabelExp(Label label):
LabelExp(Label *label):
label(label)
{
}
......@@ -135,11 +135,11 @@ namespace inst
public:
const Label& get_label() const
{
return label;
return *label;
}
Label& get_label()
{
return label;
return *label;
}
public:
......@@ -148,7 +148,7 @@ namespace inst
ostr << label;
}
protected:
Label label;
Label *label;
};
......@@ -158,7 +158,7 @@ namespace inst
public:
typedef enum { add, sub, mul, div } kind_type;
public:
OpExp(Exp& left, kind_type kind, Exp& right):
OpExp(Exp *left, kind_type kind, Exp *right):
kind(kind), left(left), right(right)
{
assertion(left && right);
......@@ -182,26 +182,26 @@ namespace inst
public:
const Exp& get_left() const
{
return left;
return *left;
}
Exp& get_left()
{
return left;
return *left;
}
const Exp& get_right() const
{
return left;
return *left;
}
Exp& get_right()
{
return right;
return *right;
}
public:
virtual void print(std::ostream& ostr) const
{
ostr << left;
ostr << *left;
switch (kind)
{
case add: ostr << " + "; break;
......@@ -209,14 +209,14 @@ namespace inst
case mul: ostr << " * "; break;
case div: ostr << " / "; break;
}
ostr << right;
ostr << *right;
}
public:
const kind_type kind;
protected:
Exp& left;
Exp& right;
Exp *left;
Exp *right;
};
} // namespace inst
......
This diff is collapsed.
......@@ -47,11 +47,11 @@ namespace inst
}
protected:
void add_label(Label& label, int offset)
void add_label(Label *label, int offset)
{
// FIXME: check that this label has not already been added.
offsets[label] = offset;
labels[offset].push_back(&label);
offsets[*label] = offset;
labels[offset].push_back(label);
}
public:
bool has_label(const Label& label) const
......
......@@ -37,6 +37,12 @@ namespace inst
TextSection()
{
}
virtual ~TextSection()
{
for (std::vector<inst::Inst*>::iterator
it = insts.begin(); it != insts.end(); ++it)
delete (*it);
}
public:
int size() const
......@@ -45,15 +51,15 @@ namespace inst
}
public:
void add_label(Label& label)
void add_label(Label *label)
{
Section::add_label(label, insts.size() * 4);
}
public:
void add_inst(inst::Inst& inst)