diff options
author | Damien Doligez <damien.doligez-inria.fr> | 1996-11-02 18:00:46 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 1996-11-02 18:00:46 +0000 |
commit | 312cfbddfd988fb1b74299ff90e19b1b6ef30043 (patch) | |
tree | 54250fbbfc3056c052edb0c680a6171c2f690beb /byterun/fix_code.c | |
parent | 1aaf9a118aef383c39ff7424ae8814c836bda771 (diff) |
Portage Mac/MPW:
Makefile: clean: eviter d'effacer interp.a
config.h: #include pour Mac
fix_code.c: version sans switch
interp.c: ajout action periodique, suppression de quelques ++ inutiles
main.c: initialisation action periodique
major_gc.c: return 0 pour calmer le compilo C
misc.c: ui_gc_message et ui_fatal_error -> ui_print_stderr
signals.h: include "mlvalues.h"
startup.c: donne la chaine pour uncaught exception Failure
sys.c: diverses modifs Mac
terminfo.c: return Val_unit pour calmer le compilo C
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1134 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/fix_code.c')
-rw-r--r-- | byterun/fix_code.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/byterun/fix_code.c b/byterun/fix_code.c index 7ce94095f..54bc53771 100644 --- a/byterun/fix_code.c +++ b/byterun/fix_code.c @@ -43,6 +43,54 @@ void fixup_endianness(code, len) void ** instr_table; +#if macintosh + +void thread_code (code_t code, asize_t len) +{ + code_t p; + int l [STOP + 1]; + int i; + + for (i = 0; i <= STOP; i++){ + l [i] = 0; + } + + /* Instructions with one operand */ + l[PUSHACC] = l[ACC] = l[POP] = l[ASSIGN] = + l[PUSHENVACC] = l[ENVACC] = l[PUSH_RETADDR] = l[APPLY] = + l[APPTERM1] = l[APPTERM2] = l[APPTERM3] = l[RETURN] = + l[GRAB] = l[PUSHGETGLOBAL] = l[GETGLOBAL] = l[SETGLOBAL] = + l[PUSHATOM] = l[ATOM] = l[MAKEBLOCK1] = l[MAKEBLOCK2] = + l[MAKEBLOCK3] = l[GETFIELD] = l[SETFIELD] = l[DUMMY] = + l[BRANCH] = l[BRANCHIF] = l[BRANCHIFNOT] = l[PUSHTRAP] = + l[C_CALL1] = l[C_CALL2] = l[C_CALL3] = l[C_CALL4] = l[C_CALL5] = + l[CONSTINT] = l[PUSHCONSTINT] = l[OFFSETINT] = l[OFFSETREF] = 1; + + /* Instructions with two operands */ + l[APPTERM] = l[CLOSURE] = l[CLOSUREREC] = l[PUSHGETGLOBALFIELD] = + l[GETGLOBALFIELD] = l[MAKEBLOCK] = l[C_CALLN] = 2; + + len /= sizeof(opcode_t); + for (p = code; p < code + len; /*nothing*/) { + opcode_t instr = *p; + if (instr < 0 || instr > STOP){ + fatal_error_arg ("Fatal error: bad opcode (%lx)\n", (void *) instr); + } + *p++ = (opcode_t)((unsigned long)(instr_table[instr])); + if (instr == SWITCH){ + uint32 sizes = *p++; + uint32 const_size = sizes & 0xFFFF; + uint32 block_size = sizes >> 16; + p += const_size + block_size; + }else{ + p += l[instr]; + } + } + Assert(p == code + len); +} + +#else + void thread_code(code, len) code_t code; asize_t len; @@ -81,4 +129,6 @@ void thread_code(code, len) Assert(p == code + len); } -#endif +#endif /* macintosh */ + +#endif /* THREAD_CODE */ |