Commit 81f752b2 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

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

	* src/vm/cpu.hh (get_unlimited): Print a lovely error message when
	an unlimited register is used before initialized.
	* tests/runtime/Makefile.am, tests/runtime/uninitialized-x.s: 
	Test the case.
parent 9451583f
2004-07-08 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/cpu.hh (get_unlimited): Print a lovely error message when
an unlimited register is used before initialized.
* tests/runtime/Makefile.am, tests/runtime/uninitialized-x.s:
Test the case.
2004-06-27 Benot Perrot <benoit@lrde.epita.fr>
Update distribution's files.
......
......@@ -110,7 +110,13 @@ namespace vm
/// Return the unlimited register indexed by \a i.
register_type get_unlimited(int i) const
{
precondition(has_unlimited(i));
if (!has_unlimited(i))
{
std::cerr
<< "Warning: unlimited register `$x" << i
<< "' used before initialized" << std::endl;
exit(exit_runtime);
}
return unlimited_.get(i);
}
/// Set the unlimited register indexed by \a i to \a r.
......@@ -127,10 +133,8 @@ namespace vm
register_type get_register(const inst::Register& reg) const
{
if (reg.get_kind() == inst::Register::unlimited)
{
precondition(has_unlimited(reg.get_index ()));
return unlimited_.get(reg.get_index ());
}
return get_unlimited(reg.get_index());
precondition(reg.get_kind() == inst::Register::general &&
Cpu::zero <= reg.get_index() && reg.get_index() <= Cpu::ra);
return get_register((kind_type) reg.get_index());
......@@ -139,13 +143,14 @@ namespace vm
void set_register(const inst::Register& reg, register_type r)
{
if (reg.get_kind() == inst::Register::unlimited)
unlimited_.put(reg.get_index(), r);
else
{
unlimited_.put(reg.get_index(), r);
return;
precondition(reg.get_kind() == inst::Register::general &&
Cpu::zero <= reg.get_index() &&
reg.get_index() <= Cpu::ra);
set_register((kind_type) reg.get_index(), r);
}
precondition(reg.get_kind() == inst::Register::general &&
Cpu::zero <= reg.get_index() && reg.get_index() <= Cpu::ra);
set_register((kind_type) reg.get_index(), r);
}
/** \} */
......
......@@ -107,7 +107,7 @@ namespace vm
while (!cpu_.get_halt())
{
cpu_.step();
cpu_.step();
cp0_.set_count(cp0_.get_count() + 1);
}
}
......
### Sources
ASM_FILES = \
neg.s \
no-main.s
no-main.s \
uninitialized-x.s
dist_noinst_DATA = $(ASM_FILES)
NOLFLAGS = --nop-after-branch --execute
# FIXME: find a way to specify different flags for each test?
NOLFLAGS = --nop-after-branch --unlimited-regs --execute
### Machinery
MODULE = runtime
......
.text
main:
li $t0, 42
move $t0, $x2097
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