1998Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev]	byte&#45;code anyone? -->
<!--X-From-R13: ptNnzv&#45;pt.UenlEntr.Sqzbagba.OP.QO (Quevf Uenl) -->
<!--X-Date: Mon, 16 Feb 1998 18:27:36 +0000 -->
<!--X-Message-Id: 9802161647.8ues@ami&#45;cg.GraySage.Edmonton.AB.CA -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev]	byte-code anyone?</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00491.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00493.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00561.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00539.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00492">Author</A>
&nbsp;|&nbsp;<A HREF="#00492">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00492">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev]	byte-code anyone?</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI>
<LI><em>Subject</em>: Re: [MUD-Dev]	byte-code anyone?</LI>
<LI><em>From</em>: <A HREF="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</A> (Chris Gray)</LI>
<LI><em>Date</em>: Mon, 16 Feb 98 09:47:20 MST</LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
[Jon Leonard:]

:I've been implementing something similar in the MUD I'm writing, but I
:realized fairly early on that I could get even better speedups by compiling
:all the way to machine code instead of just to bytecode.  (What JIT runtimes
:do for Java)

I thought about that. It's still a possibility, but I probably won't need
it. I would do direct code generation within my system, rather than go via
an external compiler. I would have to *really* want it, however, since doing
it that way is inherently non-portable. Since most of the things that a
MUD scenario does (string operations, DB access, NL parsing, dynamic
calls, etc.) are fairly expensive, most MUD code would see little benefit
from going to native code. The particular code I'm interested in would,
but its hard to justify the effort and non-portability just for that.

:My recommendations would be more complete if I were done, but here's the
:advice I'm giving myself:
:
:1) Test the virtual machine carefully starting early on, so fewer bugs need
:  to be laboriously traced by single-stepping an interpreter.

Hmm. I'd planned on testing by fire. My byte-code machine is going to be
quite low level, so visual inspection is feasible. Also, it would be extra
work to create an 'assembler' for it.

:2) Design so that no matter how perverse the byte codes you get fed are,
:  you don't crash or violate security assumptions.  Going from an interpreted
:  language to byte codes or machine code makes demonstrating correctness
:  much harder.

That would slow the system down too much. I've found, for example, that
even having a 'default' in the byte-code case statement adds noticeable
overhead. I have made a simple disassembler that lets me see the byte-
code for functions. Since the only source of byte-code will be the simple
compiler, my current view is that checking the byte-code is not needed.
There will be some processing required to set it up for execution (linking
to other bytecode), but I think that's about it.

You have reminded me that I forgot about my security model in this,
however. I might just punt by deciding that any function that changes
the security settings from that of its caller will not be compiled. I
have the luxury of falling back on the full parse tree interpreter.

Why does going from an interpreted language make things harder? In my case,
it makes things a lot easier. I already have correct parse trees for the
code, and can just traverse them to emit the code. My language is strongly
typed, so I don't have any of those nasty issues to worry about. The one
non-strongly typed construct (call of action retrieved as a value, rather
than by name), can be handled, or, I might just disallow compilation of
routines that do that. I can do that, since I still have the original
parse tree interpreter.

:3) Pick carefully what the simple primitives are.  Missing a vital one
:  can cost lots of performance, but too many bloats your
:  interpreter/compiler/security model.

Agreed. I've been fiddling as I go along. I expect I'll end up with around
100 opcodes (considerably less than Java has).

:4) Don't expect to be done soon.  A compiler can be a lot of work.

Ah, but most of it is already done. I expect to be running some simple
byte-code today. I haven't even specified all of the byte-codes yet, but
doing things incrementally lets me cycle the design with little cost. As
long as I have enough for at least function entry and exit, I can run things.

Oh yes, AmigaOS has the 'load' and 'unload' calls, so the scheme of
compiling via an external compiler could be made to work. The big issue
would be resolution of references to the already-loaded code. You'd have
to do that with a jump vector passed to the loaded code. (I did that on
a game system on CP/M, and I also use it in my current AmigaMUD system.)

--
Chris Gray   cg#ami-cg,GraySage.Edmonton.AB.CA

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00539" HREF="msg00539.html">Re: [MUD-Dev] byte-code anyone?</A></strong>
<ul compact><li><em>From:</em> Jon Leonard &lt;jleonard#divcom,umop-ap.com&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00491.html">Re: [MUD-Dev] Moore's Law sucks (was: 3D graphics)</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00493.html">Re: [MUD-Dev] 3D graphics (Was: The impact of the web on muds)</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00561.html">Re: [MUD-Dev] Re: Version Control (was: DBs and Events)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00539.html">Re: [MUD-Dev] byte-code anyone?</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00492"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00492"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>Re: [MUD-Dev] Unique items</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00568" HREF="msg00568.html">Re: [MUD-Dev] Unique items</A></strong>, 
Nathan F Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Mon 23 Feb 1998, 20:11 GMT
</LI>
</ul>
</ul>
</LI>
<LI><strong><A NAME="00528" HREF="msg00528.html">[MUD-Dev] Re: Version Control (was: DBs and Events)</A></strong>, 
Raph &amp; Kristen Koster <a href="mailto:koster#eden,com">koster#eden,com</a>, Wed 18 Feb 1998, 19:28 GMT
<UL>
<LI><strong><A NAME="00559" HREF="msg00559.html">Re: [MUD-Dev] Re: Version Control (was: DBs and Events)</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 23 Feb 1998, 17:31 GMT
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00561" HREF="msg00561.html">Re: [MUD-Dev] Re: Version Control (was: DBs and Events)</A></strong>, 
Felix A. Croes <a href="mailto:felix#xs1,simplex.nl">felix#xs1,simplex.nl</a>, Mon 23 Feb 1998, 18:19 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00492" HREF="msg00492.html">Re: [MUD-Dev]	byte-code anyone?</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Mon 16 Feb 1998, 18:27 GMT
<UL>
<LI><strong><A NAME="00539" HREF="msg00539.html">Re: [MUD-Dev] byte-code anyone?</A></strong>, 
Jon Leonard <a href="mailto:jleonard#divcom,umop-ap.com">jleonard#divcom,umop-ap.com</a>, Fri 20 Feb 1998, 16:13 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00458" HREF="msg00458.html">[MUD-Dev] Moore's Law sucks (was: 3D graphics)</A></strong>, 
Brandon J. Rickman <a href="mailto:ashes#pc4,zennet.com">ashes#pc4,zennet.com</a>, Sat 14 Feb 1998, 04:16 GMT
<UL>
<LI><strong><A NAME="00459" HREF="msg00459.html">Re: [MUD-Dev] Moore's Law sucks (was: 3D graphics)</A></strong>, 
Adam Wiggins <a href="mailto:nightfall#user2,inficad.com">nightfall#user2,inficad.com</a>, Sat 14 Feb 1998, 09:49 GMT
<UL>
<LI><strong><A NAME="00483" HREF="msg00483.html">Re: [MUD-Dev] Moore's Law sucks (was: 3D graphics)</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 16 Feb 1998, 07:38 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>