ref: 7f3673fee2f872d78c3ffad3c50ee7196f2a5862
parent: 62fea907a6a488285e58a5aa3daec72e51696f0f
author: Tor Andersson <tor.andersson@artifex.com>
date: Sun Jan 12 09:11:08 EST 2014
Document some trickier byte codes.
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
ar cru $@ $^
opnames.h : jscompile.h
- grep 'OP_' jscompile.h | sed 's/OP_/"/;s/,/",/' | tr A-Z a-z > opnames.h
+ grep 'OP_' jscompile.h | sed 's/OP_/"/;s/,.*/",/' | tr A-Z a-z > opnames.h
jsdump.c : opnames.h
--- a/jscompile.c
+++ b/jscompile.c
@@ -160,7 +160,7 @@
static void assignop(JF, js_Ast *exp, int opcode)
{
clval(J, F, exp->a);
- emit(J, F, OP_DUP_LOAD);
+ emit(J, F, OP_LOAD);
cexp(J, F, exp->b);
emit(J, F, opcode);
emit(J, F, OP_STORE);
--- a/jscompile.h
+++ b/jscompile.h
@@ -22,28 +22,29 @@
OP_FUNDEC,
OP_FUNEXP,
- OP_LOADVAR,
- OP_LOADINDEX,
- OP_LOADMEMBER,
- OP_AVAR,
- OP_AINDEX,
- OP_AMEMBER,
+ OP_LOADVAR, /* -(name)- <value> */
+ OP_LOADINDEX, /* <obj> <idx> -- <value> */
+ OP_LOADMEMBER, /* <obj> -(name)- <value> */
- OP_LOAD,
- OP_DUP_LOAD,
- OP_STORE,
+ OP_AVAR, /* -(name)- <addr> */
+ OP_AINDEX, /* <obj> <idx> -- <addr> */
+ OP_AMEMBER, /* <obj> -(name)- <addr> */
- OP_CALL,
- OP_TCALL,
+ OP_LOAD, /* <addr> -- <addr> <value> */
+ OP_STORE, /* <addr> <value> -- <value> */
+
+ OP_CALL, /* <fun> <args...> -(numargs)- <return value> */
+ OP_TCALL, /* <obj> <fun> <args...> -(numargs)- <return value> */
OP_NEW,
- OP_DELETE,
+ OP_DELETE, /* <addr> -- <success> */
+ OP_PREINC, /* <addr> -- <value+1> */
+ OP_PREDEC, /* <addr> -- <value-1> */
+ OP_POSTINC, /* <addr> -- <value> */
+ OP_POSTDEC, /* <addr> -- <value> */
+
OP_VOID,
OP_TYPEOF,
- OP_PREINC,
- OP_POSTINC,
- OP_PREDEC,
- OP_POSTDEC,
OP_POS,
OP_NEG,
OP_BITNOT,