summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/inst.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/inst.h')
-rw-r--r--Build/source/utils/asymptote/inst.h54
1 files changed, 26 insertions, 28 deletions
diff --git a/Build/source/utils/asymptote/inst.h b/Build/source/utils/asymptote/inst.h
index b1b0511f660..fbbe6d873d8 100644
--- a/Build/source/utils/asymptote/inst.h
+++ b/Build/source/utils/asymptote/inst.h
@@ -23,48 +23,46 @@ struct inst; class stack; class program;
// A function "lambda," that is, the code that runs a function.
// It also needs the closure of the enclosing module or function to run.
struct lambda : public gc {
-#ifdef DEBUG_FRAME
- lambda()
- : name("<unnamed>") {}
- virtual ~lambda() {}
- string name;
-#endif
-
// The instructions to follow.
program *code;
- // The number of parameters of the function. This does not include the
- // closure of the enclosing module or function.
- size_t params;
+ // The index of the link to the parent closure in the frame corresponding to
+ // this function.
+ size_t parentIndex;
// The total number of items that will be stored in the closure of this
- // function. Includes the higher closure, the parameters, and the local
- // variables.
+ // function. Includes a link to the higher closure, the parameters, and the
+ // local variables.
// NOTE: In order to help garbage collection, this could be modified to
// have one array store escaping items, and another to store non-
// escaping items.
- size_t vars;
+ size_t framesize;
+
+ // States whether any of the variables escape the function, in which case a
+ // closure needs to be allocated when the function is called. It is
+ // initially set to "maybe" and it is computed the first time the function
+ // is called.
+ enum { NEEDS_CLOSURE, DOESNT_NEED_CLOSURE, MAYBE_NEEDS_CLOSURE} closureReq;
+
+#ifdef DEBUG_FRAME
+ string name;
+
+ lambda()
+ : closureReq(MAYBE_NEEDS_CLOSURE), name("<unnamed>") {}
+ virtual ~lambda() {}
+#else
+ lambda()
+ : closureReq(MAYBE_NEEDS_CLOSURE) {}
+#endif
};
// The code run is just a string of instructions. The ops are actual commands
// to be run, but constants, labels, and other objects can be in the code.
struct inst : public gc {
enum opcode {
- pop, intpush, constpush,
- varpush, varsave, fieldpush, fieldsave,
- builtin, jmp, cjmp, njmp, popcall,
- pushclosure, makefunc, ret,
- alloc, pushframe, popframe,
-
-#ifdef COMBO
- // Combo instructions:
- // varpop = varsave+pop and fieldpop = fieldsave+pop
- varpop, fieldpop,
-
- // gejmp = bltin greater-than-equal (for ints) + cjmp OR
- // = bltin less-than-equal + njmp
- gejmp
-#endif
+#define OPCODE(name,type) name,
+#include "opcodes.h"
+#undef OPCODE
};
opcode op;
position pos;