<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
computer	O
engineering	O
and	O
programming	B-Application
language	I-Application
implementations	I-Application
,	O
a	O
stack	B-Application
machine	I-Application
is	O
a	O
computer	O
processor	O
or	O
a	O
virtual	B-Architecture
machine	I-Architecture
in	O
which	O
the	O
primary	O
interaction	O
is	O
moving	O
short-lived	O
temporary	O
values	O
to	O
and	O
from	O
a	O
push	B-Application
down	I-Application
stack	B-Application
.	O
</s>
<s>
In	O
the	O
case	O
of	O
a	O
hardware	O
processor	O
,	O
a	O
hardware	O
stack	B-Application
is	O
used	O
.	O
</s>
<s>
The	O
use	O
of	O
a	O
stack	B-Application
significantly	O
reduces	O
the	O
required	O
number	O
of	O
processor	B-General_Concept
registers	I-General_Concept
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
extend	O
push-down	B-Application
automata	I-Application
with	O
additional	O
load/store	O
operations	O
or	O
multiple	O
stacks	B-Application
and	O
hence	O
are	O
Turing-complete	O
.	O
</s>
<s>
Most	O
or	O
all	O
stack	B-Application
machine	I-Application
instructions	O
assume	O
that	O
operands	O
will	O
be	O
from	O
the	O
stack	B-Application
,	O
and	O
results	O
placed	O
in	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
stack	B-Application
easily	O
holds	O
more	O
than	O
two	O
inputs	O
or	O
more	O
than	O
one	O
result	O
,	O
so	O
a	O
rich	O
set	O
of	O
operations	O
can	O
be	O
computed	O
.	O
</s>
<s>
In	O
stack	B-Application
machine	I-Application
code	O
(	O
sometimes	O
called	O
p-code	O
)	O
,	O
instructions	O
will	O
frequently	O
have	O
only	O
an	O
opcode	B-Language
commanding	O
an	O
operation	O
,	O
with	O
no	O
additional	O
fields	O
identifying	O
a	O
constant	O
,	O
register	B-General_Concept
or	O
memory	O
cell	O
,	O
known	O
as	O
a	O
zero	O
address	O
format	O
.	O
</s>
<s>
Branches	O
,	O
load	O
immediates	O
,	O
and	O
load/store	B-General_Concept
instructions	I-General_Concept
require	O
an	O
argument	O
field	O
,	O
but	O
stack	B-Application
machines	I-Application
often	O
arrange	O
that	O
the	O
frequent	O
cases	O
of	O
these	O
still	O
fit	O
together	O
with	O
the	O
opcode	B-Language
into	O
a	O
compact	O
group	O
of	O
bits	O
.	O
</s>
<s>
Some	O
stack	B-Application
machine	I-Application
instruction	B-General_Concept
sets	I-General_Concept
are	O
intended	O
for	O
interpretive	O
execution	O
of	O
a	O
virtual	B-Architecture
machine	I-Architecture
,	O
rather	O
than	O
driving	O
hardware	O
directly	O
.	O
</s>
<s>
Memory	O
is	O
often	O
accessed	O
by	O
separate	O
or	O
instructions	O
containing	O
a	O
memory	B-General_Concept
address	I-General_Concept
or	O
calculating	O
the	O
address	O
from	O
values	O
in	O
the	O
stack	B-Application
.	O
</s>
<s>
All	O
practical	O
stack	B-Application
machines	I-Application
have	O
variants	O
of	O
the	O
load	O
–	O
store	O
opcodes	B-Language
for	O
accessing	O
local	O
variables	O
and	O
formal	O
parameters	O
without	O
explicit	O
address	O
calculations	O
.	O
</s>
<s>
This	O
can	O
be	O
by	O
offsets	O
from	O
the	O
current	O
top-of-stack	O
address	O
,	O
or	O
by	O
offsets	O
from	O
a	O
stable	O
frame-base	O
register	B-General_Concept
.	O
</s>
<s>
The	O
instruction	B-General_Concept
set	I-General_Concept
carries	O
out	O
most	O
ALU	O
actions	O
with	O
postfix	O
(	O
reverse	B-Application
Polish	I-Application
notation	O
)	O
operations	O
that	O
work	O
only	O
on	O
the	O
expression	O
stack	B-Application
,	O
not	O
on	O
data	O
registers	O
or	O
main	O
memory	O
cells	O
.	O
</s>
<s>
For	O
example	O
,	O
consider	O
the	O
expression	O
A*( 	O
B-C	O
)	O
+( D+E	O
)	O
,	O
written	O
in	O
reverse	B-Application
Polish	I-Application
notation	O
as	O
A	O
B	O
C	O
-	O
*	O
D	O
E	O
+	O
+	O
.	O
</s>
<s>
Compiling	O
and	O
running	O
this	O
on	O
a	O
simple	O
imaginary	O
stack	B-Application
machine	I-Application
would	O
take	O
the	O
form	O
:	O
</s>
<s>
#	O
stack	B-Application
contents	O
(	O
leftmost	O
=	O
top	O
=	O
most	O
recent	O
)	O
:	O
</s>
<s>
The	O
arithmetic	O
operations	O
'	O
subtract	O
 '	O
,	O
'	O
multiply	O
 '	O
,	O
and	O
'	O
add	O
 '	O
act	O
on	O
the	O
two	O
topmost	O
operands	O
of	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
computer	O
takes	O
both	O
operands	O
from	O
the	O
topmost	O
(	O
most	O
recent	O
)	O
values	O
of	O
the	O
stack	B-Application
.	O
</s>
<s>
In	O
other	O
words	O
the	O
instruction	O
's	O
operands	O
are	O
"	O
popped	O
"	O
off	O
the	O
stack	B-Application
,	O
and	O
its	O
result(s )	O
are	O
then	O
"	O
pushed	O
"	O
back	O
onto	O
the	O
stack	B-Application
,	O
ready	O
for	O
the	O
next	O
instruction	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
may	O
have	O
their	O
expression	O
stack	B-Application
and	O
their	O
call-return	B-General_Concept
stack	I-General_Concept
separated	O
or	O
as	O
one	O
integrated	O
structure	O
.	O
</s>
<s>
If	O
they	O
are	O
separated	O
,	O
the	O
instructions	O
of	O
the	O
stack	B-Application
machine	I-Application
can	O
be	O
pipelined	B-General_Concept
with	O
fewer	O
interactions	O
and	O
less	O
design	O
complexity	O
,	O
so	O
it	O
will	O
usually	O
run	O
faster	O
.	O
</s>
<s>
Optimisation	O
of	O
compiled	O
stack	B-Application
code	O
is	O
quite	O
possible	O
.	O
</s>
<s>
Some	O
stack	B-Application
machines	I-Application
have	O
a	O
stack	B-Application
of	O
limited	O
size	O
,	O
implemented	O
as	O
a	O
register	B-General_Concept
file	O
.	O
</s>
<s>
A	O
large	O
register	B-General_Concept
file	O
uses	O
a	O
lot	O
of	O
transistors	O
and	O
hence	O
this	O
method	O
is	O
only	O
suitable	O
for	O
small	O
systems	O
.	O
</s>
<s>
A	O
few	O
machines	O
have	O
both	O
an	O
expression	O
stack	B-Application
in	O
memory	O
and	O
a	O
separate	O
register	B-General_Concept
stack	B-Application
.	O
</s>
<s>
Some	O
machines	O
have	O
a	O
stack	B-Application
of	O
unlimited	O
size	O
,	O
implemented	O
as	O
an	O
array	O
in	O
RAM	O
,	O
which	O
is	O
cached	O
by	O
some	O
number	O
"	O
top	O
of	O
stack	B-Application
"	O
address	B-General_Concept
registers	I-General_Concept
to	O
reduce	O
memory	O
access	O
.	O
</s>
<s>
Except	O
for	O
explicit	O
"	O
load	O
from	O
memory	O
"	O
instructions	O
,	O
the	O
order	O
of	O
operand	O
usage	O
is	O
identical	O
with	O
the	O
order	O
of	O
the	O
operands	O
in	O
the	O
data	O
stack	B-Application
,	O
so	O
excellent	O
prefetching	O
can	O
be	O
accomplished	O
easily	O
.	O
</s>
<s>
With	O
a	O
stack	B-Application
stored	O
completely	O
in	O
RAM	O
,	O
this	O
does	O
implicit	O
writes	O
and	O
reads	O
of	O
the	O
in-memory	O
stack	B-Application
:	O
</s>
<s>
for	O
a	O
total	O
of	O
5	O
data	B-General_Concept
cache	I-General_Concept
references	O
.	O
</s>
<s>
The	O
next	O
step	O
up	O
from	O
this	O
is	O
a	O
stack	B-Application
machine	I-Application
or	O
interpreter	O
with	O
a	O
single	O
top-of-stack	O
register	B-General_Concept
.	O
</s>
<s>
for	O
a	O
total	O
of	O
5	O
data	B-General_Concept
cache	I-General_Concept
references	O
,	O
worst-case	O
.	O
</s>
<s>
Generally	O
,	O
interpreters	O
do	O
n't	O
track	O
emptiness	O
,	O
because	O
they	O
do	O
n't	O
have	O
to	O
—	O
anything	O
below	O
the	O
stack	B-Application
pointer	O
is	O
a	O
non-empty	O
value	O
,	O
and	O
the	O
TOS	O
cache	B-General_Concept
register	B-General_Concept
is	O
always	O
kept	O
hot	O
.	O
</s>
<s>
Typical	O
Java	B-Language
interpreters	O
do	O
not	O
buffer	O
the	O
top-of-stack	O
this	O
way	O
,	O
however	O
,	O
because	O
the	O
program	O
and	O
stack	B-Application
have	O
a	O
mix	O
of	O
short	O
and	O
wide	O
data	O
values	O
.	O
</s>
<s>
If	O
the	O
hardwired	O
stack	B-Application
machine	I-Application
has	O
2	O
or	O
more	O
top-stack	O
registers	O
,	O
or	O
a	O
register	B-General_Concept
file	O
,	O
then	O
all	O
memory	O
access	O
is	O
avoided	O
in	O
this	O
example	O
and	O
there	O
is	O
only	O
1	O
data	B-General_Concept
cache	I-General_Concept
cycle	O
.	O
</s>
<s>
the	O
Z4	B-Device
(	O
1945	O
)	O
computer	O
by	O
Konrad	O
Zuse	O
.	O
</s>
<s>
the	O
English	B-Device
Electric	I-Device
KDF9	I-Device
machine	O
.	O
</s>
<s>
the	O
Xerox	B-Device
Dandelion	I-Device
introduced	O
27	O
April	O
1981	O
,	O
utilized	O
a	O
stack	B-Application
machine	I-Application
architecture	O
to	O
save	O
memory	O
.	O
</s>
<s>
the	O
UCSD	B-Language
Pascal	I-Language
p-machine	O
(	O
as	O
the	O
Pascal	B-Device
MicroEngine	I-Device
and	O
many	O
others	O
)	O
supported	O
a	O
complete	O
student	O
programming	O
environment	O
on	O
early	O
8-bit	O
microprocessors	O
with	O
poor	O
instruction	B-General_Concept
sets	I-General_Concept
and	O
little	O
RAM	O
,	O
by	O
compiling	O
to	O
a	O
virtual	B-Architecture
stack	B-Application
machine	I-Application
.	O
</s>
<s>
MU5	B-Device
and	O
ICL	B-Device
2900	I-Device
Series	I-Device
.	O
</s>
<s>
Hybrid	O
stack	B-Application
and	O
accumulator	B-General_Concept
machines	I-General_Concept
.	O
</s>
<s>
The	O
accumulator	B-General_Concept
register	B-General_Concept
buffered	O
the	O
memory	O
stack	B-Application
's	O
top	O
data	O
value	O
.	O
</s>
<s>
Variants	O
of	O
load	O
and	O
store	O
opcodes	B-Language
controlled	O
when	O
that	O
register	B-General_Concept
was	O
spilled	O
to	O
the	O
memory	O
stack	B-Application
or	O
reloaded	O
from	O
there	O
.	O
</s>
<s>
Like	O
HP	B-Device
3000	I-Device
,	O
except	O
that	O
compilers	O
,	O
not	O
microcode	B-Device
,	O
controlled	O
when	O
the	O
register	B-General_Concept
stack	B-Application
spilled	O
to	O
the	O
memory	O
stack	B-Application
or	O
was	O
refilled	O
from	O
the	O
memory	O
stack	B-Application
.	O
</s>
<s>
The	O
Setun	B-Device
Ternary	B-Device
computer	I-Device
performed	O
balanced	B-Algorithm
ternary	I-Algorithm
using	O
a	O
stack	B-Application
.	O
</s>
<s>
The	O
4stack	O
processor	O
by	O
Bernd	O
Paysan	O
has	O
four	O
stacks	B-Application
.	O
</s>
<s>
Patriot	O
Scientific	O
's	O
Ignite	B-Application
stack	B-Application
machine	I-Application
designed	O
by	O
Charles	O
H	O
.	O
Moore	O
holds	O
a	O
leading	O
functional	O
density	O
benchmark	O
.	O
</s>
<s>
Inmos	B-General_Concept
transputers	I-General_Concept
.	O
</s>
<s>
ZPU	O
A	O
physically-small	O
CPU	B-Device
designed	O
to	O
supervise	O
FPGA	B-Architecture
systems	O
.	O
</s>
<s>
Some	O
technical	O
handheld	O
calculators	O
use	O
reverse	B-Application
Polish	I-Application
notation	O
in	O
their	O
keyboard	O
interface	O
,	O
instead	O
of	O
having	O
parenthesis	O
keys	O
.	O
</s>
<s>
This	O
is	O
a	O
form	O
of	O
stack	B-Application
machine	I-Application
.	O
</s>
<s>
The	O
Plus	O
key	O
relies	O
on	O
its	O
two	O
operands	O
already	O
being	O
at	O
the	O
correct	O
topmost	O
positions	O
of	O
the	O
user-visible	O
stack	B-Application
.	O
</s>
<s>
Examples	O
of	O
virtual	B-Architecture
stack	B-Application
machines	I-Application
interpreted	O
in	O
software	O
:	O
</s>
<s>
Pure	O
stack	B-Application
machines	I-Application
are	O
quite	O
inefficient	O
for	O
procedures	O
which	O
access	O
multiple	O
fields	O
from	O
the	O
same	O
object	O
.	O
</s>
<s>
The	O
stack	B-Application
machine	I-Application
code	O
must	O
reload	O
the	O
object	O
pointer	O
for	O
each	O
pointer+offset	O
calculation	O
.	O
</s>
<s>
A	O
common	O
fix	O
for	O
this	O
is	O
to	O
add	O
some	O
register-machine	O
features	O
to	O
the	O
stack	B-Application
machine	I-Application
:	O
a	O
visible	O
register	B-General_Concept
file	O
dedicated	O
to	O
holding	O
addresses	O
,	O
and	O
register-style	O
instructions	O
for	O
doing	O
loads	O
and	O
simple	O
address	O
calculations	O
.	O
</s>
<s>
It	O
is	O
uncommon	O
to	O
have	O
the	O
registers	O
be	O
fully	O
general	O
purpose	O
,	O
because	O
then	O
there	O
is	O
no	O
strong	O
reason	O
to	O
have	O
an	O
expression	O
stack	B-Application
and	O
postfix	O
instructions	O
.	O
</s>
<s>
Another	O
common	O
hybrid	O
is	O
to	O
start	O
with	O
a	O
register	B-Application
machine	I-Application
architecture	O
,	O
and	O
add	O
another	O
memory	B-General_Concept
address	I-General_Concept
mode	O
which	O
emulates	O
the	O
push	O
or	O
pop	O
operations	O
of	O
stack	B-Application
machines	I-Application
:	O
'	O
memaddress	O
=	O
reg	O
;	O
reg	O
+	O
=	O
instr.displ	O
'	O
.	O
</s>
<s>
This	O
was	O
first	O
used	O
in	O
DEC	O
's	O
PDP-11	B-Device
minicomputer	O
.	O
</s>
<s>
This	O
feature	O
was	O
carried	O
forward	O
in	O
VAX	B-Device
computers	O
and	O
in	O
Motorola	B-Device
6800	I-Device
and	O
M68000	B-Device
microprocessors	O
.	O
</s>
<s>
This	O
allowed	O
the	O
use	O
of	O
simpler	O
stack	B-Application
methods	O
in	O
early	O
compilers	O
.	O
</s>
<s>
It	O
also	O
efficiently	O
supported	O
virtual	B-Architecture
machines	I-Architecture
using	O
stack	B-Application
interpreters	O
or	O
threaded	B-Application
code	I-Application
.	O
</s>
<s>
However	O
,	O
this	O
feature	O
did	O
not	O
help	O
the	O
register	B-Application
machine	I-Application
's	O
own	O
code	O
to	O
become	O
as	O
compact	O
as	O
pure	O
stack	B-Application
machine	I-Application
code	O
.	O
</s>
<s>
Also	O
,	O
the	O
execution	O
speed	O
was	O
less	O
than	O
when	O
compiling	O
well	O
to	O
the	O
register	B-General_Concept
architecture	O
.	O
</s>
<s>
It	O
is	O
faster	O
to	O
change	O
the	O
top-of-stack	O
pointer	O
only	O
occasionally	O
(	O
once	O
per	O
call	O
or	O
return	O
)	O
rather	O
than	O
constantly	O
stepping	O
it	O
up	O
and	O
down	O
throughout	O
each	O
program	O
statement	O
,	O
and	O
it	O
is	O
even	O
faster	O
to	O
avoid	O
memory	O
references	O
entirely	O
.	O
</s>
<s>
More	O
recently	O
,	O
so-called	O
second-generation	O
stack	B-Application
machines	I-Application
have	O
adopted	O
a	O
dedicated	O
collection	O
of	O
registers	O
to	O
serve	O
as	O
address	B-General_Concept
registers	I-General_Concept
,	O
off-loading	O
the	O
task	O
of	O
memory	B-General_Concept
addressing	I-General_Concept
from	O
the	O
data	O
stack	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
MuP21	O
relies	O
on	O
a	O
register	B-General_Concept
called	O
"	O
A	O
"	O
,	O
while	O
the	O
more	O
recent	O
GreenArrays	O
processors	O
relies	O
on	O
two	O
registers	O
:	O
A	O
and	O
B	O
.	O
</s>
<s>
The	O
Intel	O
x86	O
family	O
of	O
microprocessors	O
have	O
a	O
register-style	O
(	O
accumulator	B-General_Concept
)	O
instruction	B-General_Concept
set	I-General_Concept
for	O
most	O
operations	O
,	O
but	O
use	O
stack	B-Application
instructions	O
for	O
its	O
x87	B-Application
,	O
Intel	B-Device
8087	I-Device
floating	O
point	O
arithmetic	O
,	O
dating	O
back	O
to	O
the	O
iAPX87	O
(	O
8087	B-Device
)	O
coprocessor	O
for	O
the	O
8086	O
and	O
8088	O
.	O
</s>
<s>
That	O
is	O
,	O
there	O
are	O
no	O
programmer-accessible	O
floating	O
point	O
registers	O
,	O
but	O
only	O
an	O
80-bit	O
wide	O
,	O
8-level	O
deep	O
stack	B-Application
.	O
</s>
<s>
The	O
x87	B-Application
relies	O
heavily	O
on	O
the	O
x86	O
CPU	B-Device
for	O
assistance	O
in	O
performing	O
its	O
operations	O
.	O
</s>
<s>
Most	O
current	O
computers	O
(	O
of	O
any	O
instruction	B-General_Concept
set	I-General_Concept
style	O
)	O
and	O
most	O
compilers	O
use	O
a	O
large	O
call-return	B-General_Concept
stack	I-General_Concept
in	O
memory	O
to	O
organize	O
the	O
short-lived	O
local	O
variables	O
and	O
return	O
links	O
for	O
all	O
currently	O
active	O
procedures	O
or	O
functions	O
.	O
</s>
<s>
Each	O
nested	O
call	O
creates	O
a	O
new	O
stack	B-Application
frame	O
in	O
memory	O
,	O
which	O
persists	O
until	O
that	O
call	O
completes	O
.	O
</s>
<s>
This	O
call-return	B-General_Concept
stack	I-General_Concept
may	O
be	O
entirely	O
managed	O
by	O
the	O
hardware	O
via	O
specialized	O
address	B-General_Concept
registers	I-General_Concept
and	O
special	O
address	O
modes	O
in	O
the	O
instructions	O
.	O
</s>
<s>
Or	O
it	O
may	O
be	O
merely	O
a	O
set	O
of	O
conventions	O
followed	O
by	O
the	O
compilers	O
,	O
using	O
generic	O
registers	O
and	O
register+offset	O
address	O
modes	O
.	O
</s>
<s>
Since	O
this	O
technique	O
is	O
now	O
nearly	O
universal	O
,	O
even	O
on	O
register	B-Application
machines	I-Application
,	O
it	O
is	O
not	O
helpful	O
to	O
refer	O
to	O
all	O
these	O
machines	O
as	O
stack	B-Application
machines	I-Application
.	O
</s>
<s>
That	O
term	O
is	O
commonly	O
reserved	O
for	O
machines	O
which	O
also	O
use	O
an	O
expression	O
stack	B-Application
and	O
stack-only	O
arithmetic	O
instructions	O
to	O
evaluate	O
the	O
pieces	O
of	O
a	O
single	O
statement	O
.	O
</s>
<s>
Computers	O
commonly	O
provide	O
direct	O
,	O
efficient	O
access	O
to	O
the	O
program	O
's	O
global	O
variables	O
and	O
to	O
the	O
local	O
variables	O
of	O
only	O
the	O
current	O
innermost	O
procedure	O
or	O
function	O
,	O
the	O
topmost	O
stack	B-Application
frame	O
.	O
</s>
<s>
'	O
Up	O
level	O
 '	O
addressing	O
of	O
the	O
contents	O
of	O
callers	O
 '	O
stack	B-Application
frames	O
is	O
usually	O
not	O
needed	O
and	O
not	O
supported	O
as	O
directly	O
by	O
the	O
hardware	O
.	O
</s>
<s>
Some	O
Burroughs	O
stack	B-Application
machines	I-Application
do	O
support	O
up-level	O
refs	O
directly	O
in	O
the	O
hardware	O
,	O
with	O
specialized	O
address	O
modes	O
and	O
a	O
special	O
'	O
display	O
 '	O
register	B-General_Concept
file	O
holding	O
the	O
frame	O
addresses	O
of	O
all	O
outer	O
scopes	O
.	O
</s>
<s>
Currently	O
,	O
only	O
MCST	O
Elbrus	B-Device
has	O
done	O
this	O
in	O
hardware	O
.	O
</s>
<s>
When	O
Niklaus	O
Wirth	O
developed	O
the	O
first	O
Pascal	B-Application
compiler	O
for	O
the	O
CDC	B-Device
6000	I-Device
,	O
he	O
found	O
that	O
it	O
was	O
faster	O
overall	O
to	O
pass	O
in	O
the	O
frame	O
pointers	O
as	O
a	O
chain	O
,	O
rather	O
than	O
constantly	O
updating	O
complete	O
arrays	O
of	O
frame	O
pointers	O
.	O
</s>
<s>
The	O
task	O
and	O
its	O
creator	O
share	O
the	O
stack	B-Application
frames	O
that	O
existed	O
at	O
the	O
time	O
of	O
task	O
creation	O
,	O
but	O
not	O
the	O
creator	O
's	O
subsequent	O
frames	O
nor	O
the	O
task	O
's	O
own	O
frames	O
.	O
</s>
<s>
This	O
was	O
supported	O
by	O
a	O
cactus	O
stack	B-Application
,	O
whose	O
layout	O
diagram	O
resembled	O
the	O
trunk	O
and	O
arms	O
of	O
a	O
Saguaro	B-Application
cactus	O
.	O
</s>
<s>
Each	O
task	O
had	O
its	O
own	O
memory	O
segment	O
holding	O
its	O
stack	B-Application
and	O
the	O
frames	O
that	O
it	O
owns	O
.	O
</s>
<s>
The	O
base	O
of	O
this	O
stack	B-Application
is	O
linked	O
to	O
the	O
middle	O
of	O
its	O
creator	O
's	O
stack	B-Application
.	O
</s>
<s>
In	O
machines	O
with	O
a	O
conventional	O
flat	O
address	O
space	O
,	O
the	O
creator	O
stack	B-Application
and	O
task	O
stacks	B-Application
would	O
be	O
separate	O
heap	O
objects	O
in	O
one	O
heap	O
.	O
</s>
<s>
These	O
languages	O
organize	O
their	O
procedure	O
'	O
activation	O
records	O
 '	O
as	O
separate	O
heap	O
objects	O
rather	O
than	O
as	O
stack	B-Application
frames	O
appended	O
to	O
a	O
linear	O
stack	B-Application
.	O
</s>
<s>
In	O
simple	O
languages	O
like	O
Forth	B-Application
that	O
lack	O
local	O
variables	O
and	O
naming	O
of	O
parameters	O
,	O
stack	B-Application
frames	O
would	O
contain	O
nothing	O
more	O
than	O
return	O
branch	O
addresses	O
and	O
frame	O
management	O
overhead	O
.	O
</s>
<s>
So	O
their	O
return	O
stack	B-Application
holds	O
bare	O
return	O
addresses	O
rather	O
than	O
frames	O
.	O
</s>
<s>
The	O
return	O
stack	B-Application
is	O
separate	O
from	O
the	O
data	O
value	O
stack	B-Application
,	O
to	O
improve	O
the	O
flow	O
of	O
call	O
setup	O
and	O
returns	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
are	O
often	O
compared	O
to	O
register	B-Application
machines	I-Application
,	O
which	O
hold	O
values	O
in	O
an	O
array	O
of	O
registers	O
.	O
</s>
<s>
Register	B-Application
machines	I-Application
may	O
store	O
stack-like	O
structures	O
in	O
this	O
array	O
,	O
but	O
a	O
register	B-Application
machine	I-Application
has	O
instructions	O
which	O
circumvent	O
the	O
stack	B-Application
interface	O
.	O
</s>
<s>
Register	B-Application
machines	I-Application
routinely	O
outperform	O
stack	B-Application
machines	I-Application
,	O
and	O
stack	B-Application
machines	I-Application
have	O
remained	O
a	O
niche	O
player	O
in	O
hardware	O
systems	O
.	O
</s>
<s>
But	O
stack	B-Application
machines	I-Application
are	O
often	O
used	O
in	O
implementing	O
virtual	B-Architecture
machines	I-Architecture
because	O
of	O
their	O
simplicity	O
and	O
ease	O
of	O
implementation	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
have	O
higher	O
code	O
density	O
.	O
</s>
<s>
In	O
contrast	O
to	O
common	O
stack	B-Application
machine	I-Application
instructions	O
which	O
can	O
easily	O
fit	O
in	O
6	O
bits	O
or	O
less	O
,	O
register	B-Application
machines	I-Application
require	O
two	O
or	O
three	O
register-number	O
fields	O
per	O
ALU	O
instruction	O
to	O
select	O
operands	O
;	O
the	O
densest	O
register	B-Application
machines	I-Application
average	O
about	O
16	O
bits	O
per	O
instruction	O
plus	O
the	O
operands	O
.	O
</s>
<s>
Register	B-Application
machines	I-Application
also	O
use	O
a	O
wider	O
offset	O
field	O
for	O
load-store	O
opcodes	B-Language
.	O
</s>
<s>
A	O
stack	B-Application
machine	I-Application
's	O
compact	O
code	O
naturally	O
fits	O
more	O
instructions	O
in	O
cache	B-General_Concept
,	O
and	O
therefore	O
could	O
achieve	O
better	O
cache	B-General_Concept
efficiency	O
,	O
reducing	O
memory	O
costs	O
or	O
permitting	O
faster	O
memory	O
systems	O
for	O
a	O
given	O
cost	O
.	O
</s>
<s>
In	O
addition	O
,	O
most	O
stack-machine	O
instructions	O
are	O
very	O
simple	O
,	O
made	O
from	O
only	O
one	O
opcode	B-Language
field	O
or	O
one	O
operand	O
field	O
.	O
</s>
<s>
Thus	O
,	O
stack-machines	O
require	O
very	O
little	O
electronic	O
resources	O
to	O
decode	O
each	O
instruction	O
.	O
</s>
<s>
A	O
program	O
has	O
to	O
execute	O
more	O
instructions	O
when	O
compiled	O
to	O
a	O
stack	B-Application
machine	I-Application
than	O
when	O
compiled	O
to	O
a	O
register	B-Application
machine	I-Application
or	O
memory-to-memory	O
machine	O
.	O
</s>
<s>
Most	O
register	B-General_Concept
interpreters	O
specify	O
their	O
registers	O
by	O
number	O
.	O
</s>
<s>
But	O
a	O
host	O
machine	O
's	O
registers	O
ca	O
n't	O
be	O
accessed	O
in	O
an	O
indexed	O
array	O
,	O
so	O
a	O
memory	O
array	O
is	O
allotted	O
for	O
virtual	B-Architecture
registers	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
instructions	O
of	O
a	O
register	B-General_Concept
interpreter	O
must	O
use	O
memory	O
for	O
passing	O
generated	O
data	O
to	O
the	O
next	O
instruction	O
.	O
</s>
<s>
This	O
forces	O
register	B-General_Concept
interpreters	O
to	O
be	O
much	O
slower	O
on	O
microprocessors	O
made	O
with	O
a	O
fine	O
process	O
rule	O
(	O
i.e.	O
</s>
<s>
These	O
require	O
several	O
clocks	O
for	O
memory	O
access	O
,	O
but	O
only	O
one	O
clock	O
for	O
register	B-General_Concept
access	O
.	O
</s>
<s>
In	O
a	O
stack	B-Application
machine	I-Application
,	O
the	O
operands	O
used	O
in	O
the	O
instructions	O
are	O
always	O
at	O
a	O
known	O
offset	O
(	O
set	O
in	O
the	O
stack	B-Application
pointer	O
)	O
,	O
from	O
a	O
fixed	O
location	O
(	O
the	O
bottom	O
of	O
the	O
stack	B-Application
,	O
which	O
in	O
a	O
hardware	O
design	O
might	O
always	O
be	O
at	O
memory	B-General_Concept
location	I-General_Concept
zero	O
)	O
,	O
saving	O
precious	O
in-cache	O
or	O
in-CPU	O
storage	O
from	O
being	O
used	O
to	O
store	O
quite	O
so	O
many	O
memory	O
addresses	O
or	O
index	O
numbers	O
.	O
</s>
<s>
This	O
may	O
preserve	O
such	O
registers	O
and	O
cache	B-General_Concept
for	O
use	O
in	O
non-flow	O
computation	O
.	O
</s>
<s>
Some	O
in	O
the	O
industry	O
believe	O
that	O
stack	B-Application
machines	I-Application
execute	O
more	O
data	B-General_Concept
cache	I-General_Concept
cycles	O
for	O
temporary	O
values	O
and	O
local	O
variables	O
than	O
do	O
register	B-Application
machines	I-Application
.	O
</s>
<s>
On	O
stack	B-Application
machines	I-Application
,	O
temporary	O
values	O
often	O
get	O
spilled	O
into	O
memory	O
,	O
whereas	O
on	O
machines	O
with	O
many	O
registers	O
these	O
temps	O
usually	O
remain	O
in	O
registers	O
.	O
</s>
<s>
Values	O
spilled	O
to	O
memory	O
add	O
more	O
cache	B-General_Concept
cycles	O
.	O
</s>
<s>
This	O
spilling	O
effect	O
depends	O
on	O
the	O
number	O
of	O
hidden	O
registers	O
used	O
to	O
buffer	O
top-of-stack	O
values	O
,	O
upon	O
the	O
frequency	O
of	O
nested	O
procedure	O
calls	O
,	O
and	O
upon	O
host	O
computer	O
interrupt	O
processing	O
rates	O
.	O
</s>
<s>
On	O
register	B-Application
machines	I-Application
using	O
optimizing	O
compilers	O
,	O
it	O
is	O
very	O
common	O
for	O
the	O
most-used	O
local	O
variables	O
to	O
remain	O
in	O
registers	O
rather	O
than	O
in	O
stack	B-Application
frame	O
memory	O
cells	O
.	O
</s>
<s>
This	O
eliminates	O
most	O
data	B-General_Concept
cache	I-General_Concept
cycles	O
for	O
reading	O
and	O
writing	O
those	O
values	O
.	O
</s>
<s>
The	O
development	O
of	O
"	O
stack	B-Application
scheduling	O
"	O
for	O
performing	O
live-variable	O
analysis	O
,	O
and	O
thus	O
retaining	O
key	O
variables	O
on	O
the	O
stack	B-Application
for	O
extended	O
periods	O
,	O
helps	O
this	O
concern	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
register	B-Application
machines	I-Application
must	O
spill	O
many	O
of	O
their	O
registers	O
to	O
memory	O
across	O
nested	O
procedure	O
calls	O
.	O
</s>
<s>
This	O
can	O
lead	O
to	O
more	O
data	B-General_Concept
cache	I-General_Concept
traffic	O
than	O
in	O
an	O
advanced	O
stack	B-Application
machine	I-Application
implementation	O
.	O
</s>
<s>
In	O
register	B-Application
machines	I-Application
,	O
a	O
common	O
subexpression	O
(	O
a	O
subexpression	O
which	O
is	O
used	O
multiple	O
times	O
with	O
the	O
same	O
result	O
value	O
)	O
can	O
be	O
evaluated	O
just	O
once	O
and	O
its	O
result	O
saved	O
in	O
a	O
fast	O
register	B-General_Concept
.	O
</s>
<s>
The	O
subsequent	O
reuses	O
have	O
no	O
time	O
or	O
code	O
cost	O
,	O
just	O
a	O
register	B-General_Concept
reference	O
.	O
</s>
<s>
With	O
stack	B-Application
machines	I-Application
,	O
in	O
contrast	O
,	O
results	O
can	O
be	O
stored	O
in	O
one	O
of	O
two	O
ways	O
.	O
</s>
<s>
Storing	O
and	O
subsequent	O
retrievals	O
cost	O
additional	O
instructions	O
and	O
additional	O
data	B-General_Concept
cache	I-General_Concept
cycles	O
.	O
</s>
<s>
Doing	O
this	O
is	O
only	O
a	O
win	O
if	O
the	O
subexpression	O
computation	O
costs	O
more	O
in	O
time	O
than	O
fetching	O
from	O
memory	O
,	O
which	O
in	O
most	O
stack	B-Application
CPUs	B-Device
,	O
almost	O
always	O
is	O
the	O
case	O
.	O
</s>
<s>
It	O
is	O
never	O
worthwhile	O
for	O
simple	O
variables	O
and	O
pointer	O
fetches	O
,	O
because	O
those	O
already	O
have	O
the	O
same	O
cost	O
of	O
one	O
data	B-General_Concept
cache	I-General_Concept
cycle	O
per	O
access	O
.	O
</s>
<s>
The	O
second	O
way	O
leaves	O
a	O
computed	O
value	O
on	O
the	O
data	O
stack	B-Application
,	O
duplicating	O
it	O
as	O
needed	O
.	O
</s>
<s>
This	O
uses	O
operations	O
to	O
copy	O
stack	B-Application
entries	O
.	O
</s>
<s>
The	O
stack	B-Application
must	O
be	O
depth	O
shallow	O
enough	O
for	O
the	O
CPU	B-Device
's	O
available	O
copy	O
instructions	O
.	O
</s>
<s>
Hand-written	O
stack	B-Application
code	O
often	O
uses	O
this	O
approach	O
,	O
and	O
achieves	O
speeds	O
like	O
general-purpose	O
register	B-Application
machines	I-Application
.	O
</s>
<s>
Unfortunately	O
,	O
algorithms	O
for	O
optimal	O
"	O
stack	B-Application
scheduling	O
"	O
are	O
not	O
in	O
wide	O
use	O
by	O
programming	O
languages	O
.	O
</s>
<s>
In	O
modern	O
machines	O
,	O
the	O
time	O
to	O
fetch	O
a	O
variable	O
from	O
the	O
data	B-General_Concept
cache	I-General_Concept
is	O
often	O
several	O
times	O
longer	O
than	O
the	O
time	O
needed	O
for	O
basic	O
ALU	O
operations	O
.	O
</s>
<s>
Complex	O
machines	O
can	O
do	O
this	O
with	O
a	O
deep	O
pipeline	O
and	O
"	O
out-of-order	B-General_Concept
execution	I-General_Concept
"	O
that	O
examines	O
and	O
runs	O
many	O
instructions	O
at	O
once	O
.	O
</s>
<s>
Register	B-Application
machines	I-Application
can	O
even	O
do	O
this	O
with	O
much	O
simpler	O
"	O
in-order	O
"	O
hardware	O
,	O
a	O
shallow	O
pipeline	O
,	O
and	O
slightly	O
smarter	O
compilers	O
.	O
</s>
<s>
It	O
is	O
not	O
possible	O
on	O
stack	B-Application
machines	I-Application
without	O
exposing	O
some	O
aspect	O
of	O
the	O
micro-architecture	O
to	O
the	O
programmer	O
.	O
</s>
<s>
Without	O
stack	B-Application
permutation	O
or	O
hardware	O
multithreading	O
,	O
relatively	O
little	O
useful	O
code	O
can	O
be	O
put	O
in	O
between	O
while	O
waiting	O
for	O
the	O
Load	O
B	O
to	O
finish	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
can	O
work	O
around	O
the	O
memory	O
delay	O
by	O
either	O
having	O
a	O
deep	O
out-of-order	B-General_Concept
execution	I-General_Concept
pipeline	O
covering	O
many	O
instructions	O
at	O
once	O
,	O
or	O
more	O
likely	O
,	O
they	O
can	O
permute	O
the	O
stack	B-Application
such	O
that	O
they	O
can	O
work	O
on	O
other	O
workloads	O
while	O
the	O
load	O
completes	O
,	O
or	O
they	O
can	O
interlace	O
the	O
execution	O
of	O
different	O
program	O
threads	O
,	O
as	O
in	O
the	O
Unisys	O
A9	O
system	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
can	O
omit	O
the	O
operand	O
fetching	O
stage	O
of	O
a	O
register	B-Application
machine	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
in	O
the	O
Java	B-Language
Optimized	I-Language
Processor	I-Language
(	O
JOP	O
)	O
microprocessor	O
the	O
top	O
2	O
operands	O
of	O
stack	B-Application
directly	O
enter	O
a	O
data	O
forwarding	O
circuit	O
that	O
is	O
faster	O
than	O
the	O
register	B-General_Concept
file	O
.	O
</s>
<s>
The	O
Tomasulo	B-General_Concept
algorithm	I-General_Concept
finds	O
instruction-level	B-Operating_System
parallelism	I-Operating_System
by	O
issuing	O
instructions	O
as	O
their	O
data	O
becomes	O
available	O
.	O
</s>
<s>
Conceptually	O
,	O
the	O
addresses	O
of	O
positions	O
in	O
a	O
stack	B-Application
are	O
no	O
different	O
than	O
the	O
register	B-General_Concept
indexes	O
of	O
a	O
register	B-General_Concept
file	O
.	O
</s>
<s>
This	O
view	O
permits	O
the	O
out-of-order	B-General_Concept
execution	I-General_Concept
of	O
the	O
Tomasulo	B-General_Concept
algorithm	I-General_Concept
to	O
be	O
used	O
with	O
stack	B-Application
machines	I-Application
.	O
</s>
<s>
Out-of-order	B-General_Concept
execution	I-General_Concept
in	O
stack	B-Application
machines	I-Application
seems	O
to	O
reduce	O
or	O
avoid	O
many	O
theoretical	O
and	O
practical	O
difficulties	O
.	O
</s>
<s>
The	O
cited	O
research	O
shows	O
that	O
such	O
a	O
stack	B-Application
machine	I-Application
can	O
exploit	O
instruction-level	B-Operating_System
parallelism	I-Operating_System
,	O
and	O
the	O
resulting	O
hardware	O
must	O
cache	B-General_Concept
data	O
for	O
the	O
instructions	O
.	O
</s>
<s>
Such	O
machines	O
effectively	O
bypass	O
most	O
memory	O
accesses	O
to	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
result	O
achieves	O
throughput	O
(	O
instructions	O
per	O
clock	O
)	O
comparable	O
to	O
RISC	B-Architecture
register	B-Application
machines	I-Application
,	O
with	O
much	O
higher	O
code	O
densities	O
(	O
because	O
operand	O
addresses	O
are	O
implicit	O
)	O
.	O
</s>
<s>
One	O
issue	O
brought	O
up	O
in	O
the	O
research	O
was	O
that	O
it	O
takes	O
about	O
1.88	O
stack-machine	O
instructions	O
to	O
do	O
the	O
work	O
of	O
a	O
register	B-Application
machine	I-Application
's	O
RISC	B-Architecture
instruction	O
.	O
</s>
<s>
Competitive	O
out-of-order	O
stack	B-Application
machines	I-Application
therefore	O
require	O
about	O
twice	O
as	O
many	O
electronic	O
resources	O
to	O
track	O
instructions	O
(	O
"	O
issue	O
stations	O
"	O
)	O
.	O
</s>
<s>
This	O
might	O
be	O
compensated	O
by	O
savings	O
in	O
instruction	O
cache	B-General_Concept
and	O
memory	O
and	O
instruction	O
decoding	O
circuits	O
.	O
</s>
<s>
Some	O
simple	O
stack	B-Application
machines	I-Application
have	O
a	O
chip	O
design	O
which	O
is	O
fully	O
customized	O
all	O
the	O
way	O
down	O
to	O
the	O
level	O
of	O
individual	O
registers	O
.	O
</s>
<s>
The	O
top	O
of	O
stack	B-Application
address	B-General_Concept
register	I-General_Concept
and	O
the	O
N	O
top	O
of	O
stack	B-Application
data	O
buffers	O
are	O
built	O
from	O
separate	O
individual	O
register	B-General_Concept
circuits	O
,	O
with	O
separate	O
adders	O
and	O
ad	O
hoc	O
connections	O
.	O
</s>
<s>
However	O
,	O
most	O
stack	B-Application
machines	I-Application
are	O
built	O
from	O
larger	O
circuit	O
components	O
where	O
the	O
N	O
data	O
buffers	O
are	O
stored	O
together	O
within	O
a	O
register	B-General_Concept
file	O
and	O
share	O
read/write	O
buses	O
.	O
</s>
<s>
The	O
decoded	O
stack	B-Application
instructions	O
are	O
mapped	O
into	O
one	O
or	O
more	O
sequential	O
actions	O
on	O
that	O
hidden	O
register	B-General_Concept
file	O
.	O
</s>
<s>
But	O
if	O
the	O
code	O
stream	O
instead	O
had	O
explicit	O
register-select	O
fields	O
which	O
directly	O
manipulated	O
the	O
underlying	O
register	B-General_Concept
file	O
,	O
the	O
compiler	O
could	O
make	O
better	O
use	O
of	O
all	O
registers	O
and	O
the	O
program	O
would	O
run	O
faster	O
.	O
</s>
<s>
Microprogrammed	B-Device
stack	B-Application
machines	I-Application
are	O
an	O
example	O
of	O
this	O
.	O
</s>
<s>
The	O
inner	O
microcode	B-Device
engine	O
is	O
some	O
kind	O
of	O
RISC-like	O
register	B-Application
machine	I-Application
or	O
a	O
VLIW-like	O
machine	O
using	O
multiple	O
register	B-General_Concept
files	O
.	O
</s>
<s>
When	O
controlled	O
directly	O
by	O
task-specific	O
microcode	B-Device
,	O
that	O
engine	O
gets	O
much	O
more	O
work	O
completed	O
per	O
cycle	O
than	O
when	O
controlled	O
indirectly	O
by	O
equivalent	O
stack	B-Application
code	O
for	O
that	O
same	O
task	O
.	O
</s>
<s>
The	O
object	O
code	O
translators	O
for	O
the	O
HP	B-Device
3000	I-Device
and	O
Tandem	O
T/16	O
are	O
another	O
example	O
.	O
</s>
<s>
They	O
translated	O
stack	B-Application
code	O
sequences	O
into	O
equivalent	O
sequences	O
of	O
RISC	B-Architecture
code	O
.	O
</s>
<s>
Minor	O
'	O
local	O
 '	O
optimizations	O
removed	O
much	O
of	O
the	O
overhead	O
of	O
a	O
stack	B-Application
architecture	I-Application
.	O
</s>
<s>
Despite	O
that	O
burden	O
,	O
the	O
cycle	O
efficiency	O
of	O
the	O
translated	O
code	O
matched	O
the	O
cycle	O
efficiency	O
of	O
the	O
original	O
stack	B-Application
code	O
.	O
</s>
<s>
And	O
when	O
the	O
source	O
code	O
was	O
recompiled	O
directly	O
to	O
the	O
register	B-Application
machine	I-Application
via	O
optimizing	O
compilers	O
,	O
the	O
efficiency	O
doubled	O
.	O
</s>
<s>
This	O
shows	O
that	O
the	O
stack	B-Application
architecture	I-Application
and	O
its	O
non-optimizing	O
compilers	O
were	O
wasting	O
over	O
half	O
of	O
the	O
power	O
of	O
the	O
underlying	O
hardware	O
.	O
</s>
<s>
Register	B-General_Concept
files	O
are	O
good	O
tools	O
for	O
computing	O
because	O
they	O
have	O
high	O
bandwidth	O
and	O
very	O
low	O
latency	O
,	O
compared	O
to	O
memory	O
references	O
via	O
data	B-General_Concept
caches	I-General_Concept
.	O
</s>
<s>
In	O
a	O
simple	O
machine	O
,	O
the	O
register	B-General_Concept
file	O
allows	O
reading	O
two	O
independent	O
registers	O
and	O
writing	O
of	O
a	O
third	O
,	O
all	O
in	O
one	O
ALU	O
cycle	O
with	O
one-cycle	O
or	O
less	O
latency	O
.	O
</s>
<s>
Whereas	O
the	O
corresponding	O
data	B-General_Concept
cache	I-General_Concept
can	O
start	O
only	O
one	O
read	O
or	O
one	O
write	O
(	O
not	O
both	O
)	O
per	O
cycle	O
,	O
and	O
the	O
read	O
typically	O
has	O
a	O
latency	O
of	O
two	O
ALU	O
cycles	O
.	O
</s>
<s>
In	O
a	O
complex	O
machine	O
like	O
Athlon	B-Architecture
that	O
completes	O
two	O
or	O
more	O
instructions	O
per	O
cycle	O
,	O
the	O
register	B-General_Concept
file	O
allows	O
reading	O
of	O
four	O
or	O
more	O
independent	O
registers	O
and	O
writing	O
of	O
two	O
others	O
,	O
all	O
in	O
one	O
ALU	O
cycle	O
with	O
one-cycle	O
latency	O
.	O
</s>
<s>
Whereas	O
the	O
corresponding	O
dual-ported	O
data	B-General_Concept
cache	I-General_Concept
can	O
start	O
only	O
two	O
reads	O
or	O
writes	O
per	O
cycle	O
,	O
with	O
multiple	O
cycles	O
of	O
latency	O
.	O
</s>
<s>
It	O
is	O
very	O
expensive	O
to	O
build	O
a	O
cache	B-General_Concept
with	O
additional	O
ports	O
.	O
</s>
<s>
Since	O
a	O
stack	B-Application
is	O
a	O
component	O
of	O
most	O
software	O
programs	O
,	O
even	O
when	O
the	O
software	O
used	O
is	O
not	O
strictly	O
a	O
stack	B-Application
machine	I-Application
,	O
a	O
hardware	O
stack	B-Application
machine	I-Application
might	O
more	O
closely	O
mimic	O
the	O
inner	O
workings	O
of	O
its	O
programs	O
.	O
</s>
<s>
Processor	B-General_Concept
registers	I-General_Concept
have	O
a	O
high	O
thermal	O
cost	O
,	O
and	O
a	O
stack	B-Application
machine	I-Application
might	O
claim	O
higher	O
energy	O
efficiency	O
.	O
</s>
<s>
Responding	O
to	O
an	O
interrupt	O
involves	O
saving	O
the	O
registers	O
to	O
a	O
stack	B-Application
,	O
and	O
then	O
branching	O
to	O
the	O
interrupt	O
handler	O
code	O
.	O
</s>
<s>
Often	O
stack	B-Application
machines	I-Application
respond	O
more	O
quickly	O
to	O
interrupts	O
,	O
because	O
most	O
parameters	O
are	O
already	O
on	O
a	O
stack	B-Application
and	O
there	O
is	O
no	O
need	O
to	O
push	O
them	O
there	O
.	O
</s>
<s>
Some	O
register	B-Application
machines	I-Application
deal	O
with	O
this	O
by	O
having	O
multiple	O
register	B-General_Concept
files	O
that	O
can	O
be	O
instantly	O
swapped	O
but	O
this	O
increases	O
costs	O
and	O
slows	O
down	O
the	O
register	B-General_Concept
file	O
.	O
</s>
<s>
Interpreters	O
for	O
virtual	B-Architecture
stack	B-Application
machines	I-Application
are	O
easier	O
to	O
build	O
than	O
interpreters	O
for	O
register	B-Application
machines	I-Application
;	O
the	O
logic	O
for	O
handling	O
memory	B-General_Concept
address	I-General_Concept
modes	O
is	O
in	O
just	O
one	O
place	O
rather	O
than	O
repeated	O
in	O
many	O
instructions	O
.	O
</s>
<s>
Stack	B-Application
machines	I-Application
also	O
tend	O
to	O
have	O
fewer	O
variations	O
of	O
an	O
opcode	B-Language
;	O
one	O
generalized	O
opcode	B-Language
will	O
handle	O
both	O
frequent	O
cases	O
and	O
obscure	O
corner	O
cases	O
of	O
memory	O
references	O
or	O
function	O
call	O
setup	O
.	O
</s>
<s>
Interpreters	O
for	O
virtual	B-Architecture
stack	B-Application
machines	I-Application
are	O
often	O
slower	O
than	O
interpreters	O
for	O
other	O
styles	O
of	O
virtual	B-Architecture
machine	I-Architecture
.	O
</s>
<s>
In	O
some	O
interpreters	O
,	O
the	O
interpreter	O
must	O
execute	O
a	O
N-way	O
switch	O
jump	O
to	O
decode	O
the	O
next	O
opcode	B-Language
and	O
branch	O
to	O
its	O
steps	O
for	O
that	O
particular	O
opcode	B-Language
.	O
</s>
<s>
Another	O
method	O
for	O
selecting	O
opcodes	B-Language
is	O
threaded	B-Application
code	I-Application
.	O
</s>
<s>
So	O
the	O
host	O
machine	O
's	O
execution	O
pipeline	O
must	O
restart	O
each	O
time	O
the	O
hosted	O
interpreter	O
decodes	O
another	O
virtual	B-Architecture
instruction	O
.	O
</s>
<s>
This	O
happens	O
more	O
often	O
for	O
virtual	B-Architecture
stack	B-Application
machines	I-Application
than	O
for	O
other	O
styles	O
of	O
virtual	B-Architecture
machine	I-Architecture
.	O
</s>
<s>
One	O
example	O
is	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
Its	O
canonical	O
virtual	B-Architecture
machine	I-Architecture
is	O
specified	O
as	O
an	O
8-bit	O
stack	B-Application
machine	I-Application
.	O
</s>
<s>
However	O
,	O
the	O
Dalvik	B-Application
virtual	I-Application
machine	I-Application
for	O
Java	B-Language
used	O
on	O
Android	B-Application
smartphones	B-Application
is	O
a	O
16-bit	O
virtual-register	O
machine	O
-	O
a	O
choice	O
made	O
for	O
efficiency	O
reasons	O
.	O
</s>
<s>
Similarly	O
version	O
5.0	O
of	O
Lua	B-Language
replaced	O
its	O
virtual	B-Architecture
stack	B-Application
machine	I-Application
with	O
a	O
faster	O
virtual	B-Architecture
register	B-Application
machine	I-Application
.	O
</s>
<s>
Since	O
Java	B-Language
virtual	I-Language
machine	I-Language
became	O
popular	O
,	O
microprocessors	O
have	O
employed	O
advanced	O
branch	B-General_Concept
predictors	I-General_Concept
for	O
indirect	O
jumps	O
.	O
</s>
<s>
This	O
advance	O
avoids	O
most	O
of	O
pipeline	O
restarts	O
from	O
N-way	O
jumps	O
and	O
eliminates	O
much	O
of	O
the	O
instruction	O
count	O
costs	O
that	O
affect	O
stack	B-Application
interpreters	O
.	O
</s>
