Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tiger
nolimips
Commits
b5747e87
Commit
b5747e87
authored
Jul 18, 2003
by
Benoit Perrot
Browse files
Make stack_size a variable.
parent
f10b0bc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
b5747e87
2003-07-17 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/memory.hh: stack_size is an argument of Memory constructor.
2003-07-17 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/virtual_machine.hh: (step) Return a boolean that
...
...
src/vm/memory.hh
View file @
b5747e87
...
...
@@ -29,7 +29,7 @@
# ifndef INT32_MAX
# define INT32_MAX 2147483647
# endif
# include <string.h>
//
# include <string.h>
namespace
vm
{
...
...
@@ -37,15 +37,14 @@ namespace vm
class
Memory
{
public:
static
const
int
stack_size
=
128
*
1024
;
static
const
int
stack_bottom
=
INT32_MAX
-
3
;
static
const
int
stack_top
=
stack_bottom
-
stack_size
+
4
;
static
const
int
stack_bottom
=
INT32_MAX
-
3
;
static
const
int
default_stack_size
=
128
*
1024
;
public:
Memory
()
:
_heap
(
0
),
_stack
(
stack_size
)
Memory
(
int
stack_size
=
default_stack_size
)
:
heap
(
0
),
stack
(
stack_size
),
stack_top
(
stack_bottom
-
stack_size
+
4
)
{
assertion
(
stack_size
>
0
);
}
protected:
...
...
@@ -60,47 +59,47 @@ namespace vm
int
sbrk
(
int
size
)
{
precondition
(
size
>=
0
);
int
ptr
=
_
heap
.
size
();
int
ptr
=
heap
.
size
();
if
(
size
)
// FIXME: check collision with stack
_
heap
.
resize
(
size
+
_
heap
.
size
());
heap
.
resize
(
size
+
heap
.
size
());
return
ptr
;
}
public:
int
get_
heap_size
()
int
heap_size
()
const
{
return
_
heap
.
size
();
return
heap
.
size
();
}
int
get_
stack_size
()
int
stack_size
()
const
{
return
_
stack
.
size
();
return
stack
.
size
();
}
public:
void
store
(
const
inst
::
DataSection
&
data_section
)
{
_
heap
.
resize
(
data_section
.
size
());
heap
.
resize
(
data_section
.
size
());
for
(
int
i
=
0
;
i
<
data_section
.
size
();
++
i
)
_
heap
.
store_byte
(
i
,
data_section
.
load_byte
(
i
));
heap
.
store_byte
(
i
,
data_section
.
load_byte
(
i
));
}
void
store_byte
(
int
offset
,
int
b
)
{
precondition
(
offset
>=
0
);
if
(
offset
<
_
heap
.
size
())
_
heap
.
store_byte
(
offset
,
b
);
if
(
offset
<
heap
.
size
())
heap
.
store_byte
(
offset
,
b
);
else
_
stack
.
store_byte
(
translate
(
offset
),
b
);
stack
.
store_byte
(
translate
(
offset
),
b
);
}
void
store_word
(
int
offset
,
int
w
)
{
precondition
(
offset
>=
0
);
if
(
offset
<
_
heap
.
size
())
_
heap
.
store_word
(
offset
,
w
);
if
(
offset
<
heap
.
size
())
heap
.
store_word
(
offset
,
w
);
else
_
stack
.
store_word
(
translate
(
offset
),
w
);
stack
.
store_word
(
translate
(
offset
),
w
);
}
...
...
@@ -108,23 +107,24 @@ namespace vm
int
load_byte
(
int
offset
)
const
{
precondition
(
offset
>=
0
);
if
(
offset
<
_
heap
.
size
())
return
_
heap
.
load_byte
(
offset
);
return
_
stack
.
load_byte
(
translate
(
offset
));
if
(
offset
<
heap
.
size
())
return
heap
.
load_byte
(
offset
);
return
stack
.
load_byte
(
translate
(
offset
));
}
int
load_word
(
int
offset
)
const
{
precondition
(
offset
>=
0
);
if
(
offset
<
_
heap
.
size
())
return
_
heap
.
load_word
(
offset
);
return
_
stack
.
load_word
(
translate
(
offset
));
if
(
offset
<
heap
.
size
())
return
heap
.
load_word
(
offset
);
return
stack
.
load_word
(
translate
(
offset
));
}
protected:
Segment
_heap
;
Segment
_stack
;
Segment
heap
;
Segment
stack
;
const
int
stack_top
;
};
}
// namespace vm
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment