cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 04/11/27 08:53:12 Modified:jit/sun4 jit_emit.h Log: native sqrt op Revision ChangesPath 1.33 +3 -1 parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- jit_emit.h22 Nov 2004 16:00:27 - 1.32 +++ jit_emit.h27 Nov 2004 16:53:12 - 1.33 @@ -3,7 +3,7 @@ ** ** SPARC ** -** $Id: jit_emit.h,v 1.32 2004/11/22 16:00:27 leo Exp $ +** $Id: jit_emit.h,v 1.33 2004/11/27 16:53:12 stephane Exp $ **/ #if !defined(PARROT_SUN4_JIT_EMIT_H_GUARD) @@ -249,6 +249,8 @@ #define emitm_fabss(pc, rs, rd) emitm_3c(pc, 2, rd, 064, 0, 0011, rs) #define emitm_fnegs(pc, rs, rd) emitm_3c(pc, 2, rd, 064, 0, 0005, rs) +#define emitm_fsqrtd(pc, rs, rd) emitm_3c(pc, 2, rd, 064, 0, 0052, rs) + /* Floating - Integer Conversion */ #define emitm_fitod(pc, rs, rd) emitm_3c(pc, 2, rd, 064, 0, 0310, rs) #define emitm_fdtoi(pc, rs, rd) emitm_3c(pc, 2, rd, 064, 0, 0322, rs)
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 04/11/22 08:00:28 Modified:jit/sun4 jit_emit.h Log: [perl #32535] [PATCH] jitted vtables for sparc This patch implements (some) jitted vtables for the sun4/sparc platform. That is all of them except the ones on conditions or handling return values, these are: Parrot_jit_vtable1_op Parrot_jit_vtable_111_op Parrot_jit_vtable_112_op Parrot_jit_vtable_221_op Parrot_jit_vtable_1121_op Parrot_jit_vtable_1123_op Parrot_jit_vtable_2231_op ! :) Courtesy of Stephane Peiry [EMAIL PROTECTED] Revision ChangesPath 1.32 +172 -10 parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- jit_emit.h29 Oct 2004 08:58:04 - 1.31 +++ jit_emit.h22 Nov 2004 16:00:27 - 1.32 @@ -3,7 +3,7 @@ ** ** SPARC ** -** $Id: jit_emit.h,v 1.31 2004/10/29 08:58:04 leo Exp $ +** $Id: jit_emit.h,v 1.32 2004/11/22 16:00:27 leo Exp $ **/ #if !defined(PARROT_SUN4_JIT_EMIT_H_GUARD) @@ -772,32 +772,194 @@ } # ifndef NO_JIT_VTABLE_OPS -/* -#undef Parrot_jit_vtable1_op -#undef Parrot_jit_vtable1r_op -#undef Parrot_jit_vtable2rk_op -#undef Parrot_jit_vtable3k_op +#undef Parrot_jit_vtable1_op +/* #undef Parrot_jit_vtable1r_op */ + +#undef Parrot_jit_vtable_111_op #undef Parrot_jit_vtable_112_op #undef Parrot_jit_vtable_221_op #undef Parrot_jit_vtable_1121_op #undef Parrot_jit_vtable_1123_op #undef Parrot_jit_vtable_2231_op - +/* #undef Parrot_jit_vtable_1r223_op #undef Parrot_jit_vtable_1r332_op - + #undef Parrot_jit_vtable_ifp_op #undef Parrot_jit_vtable_unlessp_op #undef Parrot_jit_vtable_newp_ic_op +*/ +/* emit a call to a vtable func + * $X-vtable(interp, $X [, $Y...] ) + */ +static void +Parrot_jit_vtable_n_op(Parrot_jit_info_t *jit_info, + Interp *interpreter, int n, int *args) +{ +intnvtable = op_jit[*jit_info-cur_op].extcall; +op_info_t *op_info = interpreter-op_info_table[*jit_info-cur_op]; + +intpmc = 0; /* pmc saves the left most Pi */ +intrdx = 1; /* native (outgoing) register index */ + +intidx, pi, i; +size_t offset; + +offset = offsetof(struct _vtable, init); +offset += nvtable * sizeof(void *); +for (idx = 1; idx = n; idx++) { +i = args[idx - 1]; +pi = *(jit_info-cur_op + i); +switch (op_info-types[i]) { +case PARROT_ARG_S: +emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, + REG_OFFS_STR(pi), emitm_o(rdx)); +break; +case PARROT_ARG_K: +case PARROT_ARG_P: +emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, + REG_OFFS_PMC(pi), emitm_o(rdx)); +if (! pmc) { pmc = rdx; } +break; +case PARROT_ARG_KI: +case PARROT_ARG_I: +emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, + REG_OFFS_INT(pi), emitm_o(rdx)); +break; +case PARROT_ARG_KIC: +case PARROT_ARG_IC: +if (emitm_simm13_const(pi)) { +emitm_mov_i(jit_info-native_ptr, pi, emitm_o(rdx)); +} else { +emitm_sethi(jit_info-native_ptr, emitm_hi22(pi), emitm_o(rdx)); +emitm_or_i(jit_info-native_ptr, emitm_o(rdx), emitm_lo10(pi), emitm_o(rdx)); +} +break; +case PARROT_ARG_N: +emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, + REG_OFFS_NUM(pi), emitm_o(rdx)); +emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, + REG_OFFS_NUM(pi) + 4, emitm_o(++rdx)); +break; +case PARROT_ARG_NC: +#define NC_addr interpreter-code-const_table-constants[pi]-u.number +emitm_sethi(jit_info-native_ptr, emitm_hi22(NC_addr), XSR1); +emitm_or_i(jit_info-native_ptr, XSR1, emitm_lo10(NC_addr), XSR1); + +emitm_ld_i(jit_info-native_ptr, XSR1, 0, emitm_o(rdx)); +emitm_ld_i(jit_info-native_ptr, XSR1, 4, emitm_o(++rdx)); +break; +case PARROT_ARG_SC: +#define SC_addr interpreter-code-const_table-constants[pi]-u.string +emitm_sethi(jit_info-native_ptr, emitm_hi22(SC_addr), XSR1); +emitm_or_i(jit_info-native_ptr, XSR1,
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 03/01/21 07:35:04 Modified:jit/sun4 jit_emit.h Log: constants union Revision ChangesPath 1.20 +3 -3 parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -r1.19 -r1.20 --- jit_emit.h7 Jan 2003 22:30:35 - 1.19 +++ jit_emit.h21 Jan 2003 15:35:04 - 1.20 @@ -3,7 +3,7 @@ ** ** SPARC ** -** $Id: jit_emit.h,v 1.19 2003/01/07 22:30:35 grunblatt Exp $ +** $Id: jit_emit.h,v 1.20 2003/01/21 15:35:04 leo Exp $ **/ /* @@ -378,7 +378,7 @@ break; case PARROT_ARG_NC: val = (int)interpreter-code-const_table- -constants[val]-number; +constants[val]-u.number; /* Load double into integer registers */ emitm_sethi(jit_info-native_ptr, emitm_hi22(val), Parrot_jit_tmp);
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 03/01/07 14:30:36 Modified:jit/sun4 jit_emit.h Log: # New Ticket Created by Jason Gloudon # Please include the string: [perl #19729] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19729 This patch adds JIT support for restart and similar ops. Revision ChangesPath 1.19 +55 -16parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- jit_emit.h1 Dec 2002 12:51:23 - 1.18 +++ jit_emit.h7 Jan 2003 22:30:35 - 1.19 @@ -3,7 +3,7 @@ ** ** SPARC ** -** $Id: jit_emit.h,v 1.18 2002/12/01 12:51:23 leo Exp $ +** $Id: jit_emit.h,v 1.19 2003/01/07 22:30:35 grunblatt Exp $ **/ /* @@ -287,7 +287,7 @@ #define Parrot_jit_intrp emitm_i(0) /* The register holding the address of I0 */ -#define Parrot_jit_regbase emitm_i(1) +#define Parrot_jit_regbase emitm_i(2) /* The register containing the address of the opmap */ #define Parrot_jit_opmap emitm_i(3) @@ -300,6 +300,32 @@ /* The offset of a Parrot register from the base register */ #define Parrot_jit_regoff(a, i) (unsigned)(a) - (unsigned)(Parrot_jit_regbase_ptr(i)) +/* Generate a jump to a bytecode address - uses the temporary register */ +static void +Parrot_jit_bytejump(Parrot_jit_info_t *jit_info, +struct Parrot_Interp *interpreter, int reg_num) +{ + +/* Construct the starting address of the byte code */ +emitm_sethi(jit_info-native_ptr, emitm_hi22(interpreter-code-byte_code), +Parrot_jit_tmp); +emitm_or_i(jit_info-native_ptr, Parrot_jit_tmp, +emitm_lo10(interpreter-code-byte_code), Parrot_jit_tmp); + +/* Calculates the offset into op_map shadow array + * assuming sizeof(opcode_t) == sizeof(opmap array entry) */ +emitm_sub_r(jit_info-native_ptr, reg_num, Parrot_jit_tmp, +Parrot_jit_tmp); + +/* Load the address of the native code from op_map */ +emitm_ld_r(jit_info-native_ptr, Parrot_jit_opmap, Parrot_jit_tmp, + Parrot_jit_tmp); + +/* This jumps to the address from op_map */ +emitm_jumpl_i(jit_info-native_ptr, Parrot_jit_tmp, 0, Parrot_jit_tmp); +emitm_nop(jit_info-native_ptr); +} + /* Generate conditional branch to offset from current parrot op */ static void Parrot_jit_bicc(Parrot_jit_info_t *jit_info, int cond, int annul, opcode_t disp) @@ -505,9 +531,14 @@ } } -void Parrot_jit_begin(Parrot_jit_info_t *jit_info, +void +Parrot_jit_begin(Parrot_jit_info_t *jit_info, struct Parrot_Interp * interpreter) { +/* generated code is called as jit_code(interpreter, pc) + * so interpreter is in i0 and pc in i1. + * i1 is reusable once past the jump. interpreter is preserved in i0 + */ int ireg0_offset; /* Standard Prolog */ @@ -531,8 +562,10 @@ emitm_sethi(jit_info-native_ptr, emitm_hi22(jit_info-arena.op_map), Parrot_jit_opmap); emitm_or_i(jit_info-native_ptr, -emitm_i(3), emitm_lo10(jit_info-arena.op_map), Parrot_jit_opmap); -/* TODO emit restart code s. i386 */ +Parrot_jit_opmap, emitm_lo10(jit_info-arena.op_map), Parrot_jit_opmap); + +/* Jump to the current pc */ +Parrot_jit_bytejump(jit_info, interpreter, emitm_i(1)); } void Parrot_jit_normal_op(Parrot_jit_info_t *jit_info, @@ -555,21 +588,27 @@ struct Parrot_Interp * interpreter) { Parrot_jit_normal_op(jit_info, interpreter); +Parrot_jit_bytejump(jit_info, interpreter, emitm_o(0)); +} -emitm_sethi(jit_info-native_ptr, emitm_hi22(interpreter-code-byte_code), -emitm_l(1)); -emitm_or_i(jit_info-native_ptr, emitm_l(1), -emitm_lo10(interpreter-code-byte_code), emitm_l(1)); - -/* This calculates offset into op_map shadow array */ -emitm_sub_r(jit_info-native_ptr, emitm_o(0), emitm_l(1), emitm_o(0)); +#undef Parrot_jit_restart_op +void Parrot_jit_restart_op(Parrot_jit_info_t *jit_info, +struct Parrot_Interp * interpreter) +{ +Parrot_jit_normal_op(jit_info, interpreter); -/* Load the address of the native code from op_map */ -emitm_ld_r(jit_info-native_ptr, emitm_i(3), emitm_o(0), emitm_o(0)); +/* Test whether the return value is 0 */ +emitm_subcc_r(jit_info-native_ptr, emitm_o(0), emitm_g(0), emitm_g(0)); -/* This jumps to the address from op_map */ -emitm_jumpl_i(jit_info-native_ptr, emitm_o(0), 0, emitm_g(0)); +/* If the return pc is not zero skip the next 3
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/11/22 12:51:51 Modified:.jit.c include/parrot jit.h jit/alpha jit_emit.h jit/arm jit_emit.h jit/i386 jit_emit.h jit/ppc jit_emit.h jit/sun4 jit_emit.h Log: jit_info is part of interpreter Revision ChangesPath 1.45 +5 -5 parrot/jit.c Index: jit.c === RCS file: /cvs/public/parrot/jit.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -w -r1.44 -r1.45 --- jit.c 22 Nov 2002 20:04:29 - 1.44 +++ jit.c 22 Nov 2002 20:51:05 - 1.45 @@ -1,7 +1,7 @@ /* * jit.c * - * $Id: jit.c,v 1.44 2002/11/22 20:04:29 nicholas Exp $ + * $Id: jit.c,v 1.45 2002/11/22 20:51:05 grunblatt Exp $ */ #include parrot/parrot.h @@ -465,13 +465,13 @@ for (i = sect-int_registers_used-1; i = 0; --i) if (sect-int_reg_dir[sect-int_reg_usage[i]] PARROT_ARGDIR_IN) - Parrot_jit_emit_mov_rm(jit_info, interpreter, jit_info-intval_map[i], + Parrot_jit_emit_mov_rm(interpreter, jit_info-intval_map[i], (char*)interpreter-ctx.int_reg.registers[sect-int_reg_usage[i]]); #if FLOAT_REGISTERS_TO_MAP for (i = sect-float_registers_used-1; i = 0; --i) if (sect-float_reg_dir[sect-float_reg_usage[i]] PARROT_ARGDIR_IN) - Parrot_jit_emit_mov_rm_n(jit_info, interpreter, + Parrot_jit_emit_mov_rm_n(interpreter, jit_info-floatval_map[i], (char*) interpreter-ctx.num_reg.registers[ sect-float_reg_usage[i]]); @@ -496,13 +496,13 @@ for (i = 0; i sect-int_registers_used; ++i) if (sect-int_reg_dir[sect-int_reg_usage[i]] PARROT_ARGDIR_OUT) -Parrot_jit_emit_mov_mr(jit_info, interpreter, +Parrot_jit_emit_mov_mr(interpreter, (char*)interpreter-ctx.int_reg.registers[ sect-int_reg_usage[i]], jit_info-intval_map[i]); #if FLOAT_REGISTERS_TO_MAP for (i = 0; i sect-float_registers_used; ++i) if (sect-float_reg_dir[sect-float_reg_usage[i]] PARROT_ARGDIR_OUT) -Parrot_jit_emit_mov_mr_n(jit_info, interpreter, +Parrot_jit_emit_mov_mr_n(interpreter, (char*)interpreter-ctx.num_reg.registers[ sect-float_reg_usage[i]], jit_info-floatval_map[i]); #endif 1.25 +5 -5 parrot/include/parrot/jit.h Index: jit.h === RCS file: /cvs/public/parrot/include/parrot/jit.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -r1.24 -r1.25 --- jit.h 22 Nov 2002 13:43:55 - 1.24 +++ jit.h 22 Nov 2002 20:51:14 - 1.25 @@ -1,7 +1,7 @@ /* * jit.h * - * $Id: jit.h,v 1.24 2002/11/22 13:43:55 grunblatt Exp $ + * $Id: jit.h,v 1.25 2002/11/22 20:51:14 grunblatt Exp $ */ #ifndef JIT_H_GUARD @@ -224,13 +224,13 @@ Parrot_jit_optimizer_t *optimize_jit(struct Parrot_Interp *interpreter, opcode_t *pc, opcode_t *code_start, opcode_t *code_end); -void Parrot_jit_emit_mov_mr_n(Parrot_jit_info_t *, +void Parrot_jit_emit_mov_mr_n( struct Parrot_Interp *interpreter, char *mem, int); -void Parrot_jit_emit_mov_mr(Parrot_jit_info_t *, +void Parrot_jit_emit_mov_mr( struct Parrot_Interp *interpreter, char *mem, int); -void Parrot_jit_emit_mov_rm_n(Parrot_jit_info_t *, +void Parrot_jit_emit_mov_rm_n( struct Parrot_Interp *interpreter, int reg, char *mem); -void Parrot_jit_emit_mov_rm(Parrot_jit_info_t *, +void Parrot_jit_emit_mov_rm( struct Parrot_Interp *interpreter, int reg, char *mem); #endif /* JIT_H_GUARD */ 1.17 +9 -11 parrot/jit/alpha/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/alpha/jit_emit.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- jit_emit.h22 Nov 2002 13:48:39 - 1.16 +++ jit_emit.h22 Nov 2002 20:51:27 - 1.17 @@ -3,7 +3,7 @@ * * ALPHA * - * $Id: jit_emit.h,v 1.16 2002/11/22 13:48:39 grunblatt Exp $ + * $Id: jit_emit.h,v 1.17 2002/11/22 20:51:27 grunblatt Exp $ */ /* Register usage: @@ -475,31 +475,29 @@ /* move reg to mem (i.e. intreg) */ void -Parrot_jit_emit_mov_mr(Parrot_jit_info_t *jit_info, -struct Parrot_Interp * interpreter, char *mem, int reg) +Parrot_jit_emit_mov_mr(struct Parrot_Interp * interpreter, char *mem, int reg) { -jit_emit_mov_mr_i(jit_info-native_ptr, mem, reg); +jit_emit_mov_mr_i( +((Parrot_jit_info_t *)(interpreter-jit_info))-native_ptr, mem, reg); }
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/11/16 02:36:11 Modified:.interpreter.c jit.c include/parrot jit.h jit/alpha jit_emit.h jit/arm jit_emit.h jit/i386 jit_emit.h jit/ppc jit_emit.h jit/sun4 jit_emit.h Log: JIT restart code Revision ChangesPath 1.117 +2 -8 parrot/interpreter.c Index: interpreter.c === RCS file: /cvs/public/parrot/interpreter.c,v retrieving revision 1.116 retrieving revision 1.117 diff -u -w -r1.116 -r1.117 --- interpreter.c 15 Nov 2002 05:26:36 - 1.116 +++ interpreter.c 16 Nov 2002 10:35:58 - 1.117 @@ -1,7 +1,7 @@ /* interpreter.c * Copyright: (When this is determined...it will go here) * CVS Info - * $Id: interpreter.c,v 1.116 2002/11/15 05:26:36 sfink Exp $ + * $Id: interpreter.c,v 1.117 2002/11/16 10:35:58 leo Exp $ * Overview: * The interpreter api handles running the operations * Data Structure and Algorithms: @@ -229,13 +229,7 @@ code_end = interpreter-code-byte_code + code_size; jit_code = build_asm(interpreter, pc, code_start, code_end); -(jit_code) (interpreter); -/* if we fall out of runloop with restart, there is - * currently no way, to continue in JIT, so stop it - * - * This is broken too, but better as endless loops - */ -/*Interp_flags_CLEAR(interpreter, PARROT_JIT_FLAG); */ +(jit_code) (interpreter, pc); #endif } 1.39 +3 -2 parrot/jit.c Index: jit.c === RCS file: /cvs/public/parrot/jit.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -w -r1.38 -r1.39 --- jit.c 13 Nov 2002 11:07:25 - 1.38 +++ jit.c 16 Nov 2002 10:35:58 - 1.39 @@ -1,7 +1,7 @@ /* * jit.c * - * $Id: jit.c,v 1.38 2002/11/13 11:07:25 leo Exp $ + * $Id: jit.c,v 1.39 2002/11/16 10:35:58 leo Exp $ */ #include parrot/parrot.h @@ -445,8 +445,9 @@ opcode_t cur_opcode_byte; +/* XXX assume, we restart */ if (pc != code_start interpreter-jit_info) -return Parrot_jit_restart(interpreter, pc - code_start); +return (jit_f)D2FPTR(jit_info.arena.start); interpreter-jit_info = jit_info; jit_info.optimizer = optimize_jit(interpreter, pc, code_start, code_end); 1.21 +2 -3 parrot/include/parrot/jit.h Index: jit.h === RCS file: /cvs/public/parrot/include/parrot/jit.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- jit.h 12 Nov 2002 14:47:15 - 1.20 +++ jit.h 16 Nov 2002 10:36:02 - 1.21 @@ -1,17 +1,16 @@ /* * jit.h * - * $Id: jit.h,v 1.20 2002/11/12 14:47:15 leo Exp $ + * $Id: jit.h,v 1.21 2002/11/16 10:36:02 leo Exp $ */ #ifndef JIT_H_GUARD #define JIT_H_GUARD -typedef void (*jit_f)(struct Parrot_Interp *interpreter); +typedef void (*jit_f)(struct Parrot_Interp *interpreter, opcode_t *pc); jit_f build_asm(struct Parrot_Interp *interpreter, opcode_t *pc, opcode_t *code_start, opcode_t *code_end); -jit_f Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc); /* Parrot_jit_fixup_t * Platform generic fixup information 1.10 +2 -6 parrot/jit/alpha/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/alpha/jit_emit.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -r1.9 -r1.10 --- jit_emit.h12 Nov 2002 14:47:20 - 1.9 +++ jit_emit.h16 Nov 2002 10:36:04 - 1.10 @@ -3,7 +3,7 @@ * * ALPHA * - * $Id: jit_emit.h,v 1.9 2002/11/12 14:47:20 leo Exp $ + * $Id: jit_emit.h,v 1.10 2002/11/16 10:36:04 leo Exp $ */ /* Register usage: @@ -366,11 +366,7 @@ emit_lda_b(jit_info-native_ptr, REG15_s6, -0x7ff8, REG15_s6); emit_lc(jit_info-native_ptr, REG10_s1, interpreter-code-byte_code); emit_lc(jit_info-native_ptr, REG11_s2, jit_info-arena.op_map); -} - -jit_f -Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc) -{ +/* TODO emit restart code, s. i386 */ } void 1.13 +6 -6 parrot/jit/arm/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/arm/jit_emit.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -r1.12 -r1.13 --- jit_emit.h12 Nov 2002 14:47:22 - 1.12 +++ jit_emit.h16 Nov 2002 10:36:05 - 1.13 @@ -3,7 +3,7 @@
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/11/12 06:47:42 Modified:include/parrot interpreter.h jit.h .interpreter.c jit.c jit/alpha jit_emit.h jit/arm jit_emit.h jit/i386 jit_emit.h jit/ppc jit_emit.h jit/sun4 jit_emit.h Log: make JIT restartable - i386 Revision ChangesPath 1.57 +2 -1 parrot/include/parrot/interpreter.h Index: interpreter.h === RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v retrieving revision 1.56 retrieving revision 1.57 diff -u -w -r1.56 -r1.57 --- interpreter.h 3 Nov 2002 21:15:17 - 1.56 +++ interpreter.h 12 Nov 2002 14:47:15 - 1.57 -1,7 +1,7 /* interpreter.h * Copyright: (When this is determined...it will go here) * CVS Info - * $Id: interpreter.h,v 1.56 2002/11/03 21:15:17 leo Exp $ + * $Id: interpreter.h,v 1.57 2002/11/12 14:47:15 leo Exp $ * Overview: * The interpreter api handles running the operations * Data Structure and Algorithms: -137,6 +137,7 struct PackFile *code; /* The code we are executing */ void **prederef_code; /* The predereferenced code */ +void *jit_info; /* JITs data */ size_t current_line;/* Which line we're executing in the * source */ String *current_file; /* The file we're currently in */ 1.20 +24 -23parrot/include/parrot/jit.h Index: jit.h === RCS file: /cvs/public/parrot/include/parrot/jit.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -r1.19 -r1.20 --- jit.h 13 Aug 2002 18:01:06 - 1.19 +++ jit.h 12 Nov 2002 14:47:15 - 1.20 -1,7 +1,7 /* * jit.h * - * $Id: jit.h,v 1.19 2002/08/13 18:01:06 grunblatt Exp $ + * $Id: jit.h,v 1.20 2002/11/12 14:47:15 leo Exp $ */ #ifndef JIT_H_GUARD -11,6 +11,7 jit_f build_asm(struct Parrot_Interp *interpreter, opcode_t *pc, opcode_t *code_start, opcode_t *code_end); +jit_f Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc); /* Parrot_jit_fixup_t * Platform generic fixup information 1.115 +4 -5 parrot/interpreter.c Index: interpreter.c === RCS file: /cvs/public/parrot/interpreter.c,v retrieving revision 1.114 retrieving revision 1.115 diff -u -w -r1.114 -r1.115 --- interpreter.c 10 Nov 2002 11:16:16 - 1.114 +++ interpreter.c 12 Nov 2002 14:47:16 - 1.115 -1,7 +1,7 /* interpreter.c * Copyright: (When this is determined...it will go here) * CVS Info - * $Id: interpreter.c,v 1.114 2002/11/10 11:16:16 leo Exp $ + * $Id: interpreter.c,v 1.115 2002/11/12 14:47:16 leo Exp $ * Overview: * The interpreter api handles running the operations * Data Structure and Algorithms: -215,8 +215,6 } -/*=for api interpreter runops_jit - */ static void runops_jit(struct Parrot_Interp *interpreter, opcode_t *pc) { -237,7 +235,7 * * This is borken too, but better as endless loops */ -Interp_flags_CLEAR(interpreter, PARROT_JIT_FLAG); +/*Interp_flags_CLEAR(interpreter, PARROT_JIT_FLAG); */ #endif } -370,7 +368,7 runops_prederef(interpreter, pc, interpreter-prederef_code + offset); } -else if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) { +else if (!slow Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) { #if !JIT_CAPABLE internal_exception(JIT_UNAVAILABLE, Error: PARROT_JIT_FLAG is set, but interpreter is not JIT_CAPABLE!\n); -518,6 +516,7 SET_NULL_P(interpreter-code, struct PackFile *); SET_NULL_P(interpreter-profile, ProfData *); SET_NULL_P(interpreter-predref_code, void **); +SET_NULL(interpreter-jit_info); /* Done. Return and be done with it */ 1.37 +8 -2 parrot/jit.c Index: jit.c === RCS file: /cvs/public/parrot/jit.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -w -r1.36 -r1.37 --- jit.c 9 Nov 2002 11:10:17 - 1.36 +++ jit.c 12 Nov 2002 14:47:16 - 1.37 -1,7 +1,7 /* * jit.c * - * $Id: jit.c,v 1.36 2002/11/09 11:10:17 leo Exp $ + * $Id: jit.c,v 1.37 2002/11/12 14:47:16 leo Exp $ */ #include parrot/parrot.h -421,9 +421,15 UINTVAL i; char *new_arena; void *prev_address; -Parrot_jit_info_t jit_info; +/* FIXME
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/08/13 11:03:44 Modified:.jit.c include/parrot jit.h jit/alpha jit_emit.h jit/arm jit_emit.h jit/i386 jit_emit.h jit/ppc core.jit jit_emit.h jit/sun4 jit_emit.h Log: Extends the register allocator to allocate float registers. Revision ChangesPath 1.28 +89 -13parrot/jit.c Index: jit.c === RCS file: /cvs/public/parrot/jit.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -r1.27 -r1.28 --- jit.c 9 Aug 2002 04:26:46 - 1.27 +++ jit.c 13 Aug 2002 18:00:34 - 1.28 -1,7 +1,7 /* * jit.c * - * $Id: jit.c,v 1.27 2002/08/09 04:26:46 grunblatt Exp $ + * $Id: jit.c,v 1.28 2002/08/13 18:00:34 grunblatt Exp $ */ #include parrot/parrot.h -122,8 +122,12 cur_section-begin = code_start; cur_section-jit_op_count = 0; /* Init the register usage */ -for (i = 0; i NUM_REGISTERS; i++) +for (i = 0; i NUM_REGISTERS; i++) { cur_section-int_reg_usage[i] = i; +#if FLOAT_REGITERS_TO_MAP +cur_section-float_reg_usage[i] = i; +#endif +} cur_op = code_start; while (cur_op code_end) { -155,6 +159,17 cur_section-int_reg_dir[*(cur_op + argn)] |= PARROT_ARGDIR_OUT; } +#if FLOAT_REGITERS_TO_MAP +else if (op_info-types[argn] == PARROT_ARG_N) { +if ((!cur_section-float_reg_count[*(cur_op + argn)]++) +(op_info-dirs[argn] PARROT_ARGDIR_IN)) +cur_section-float_reg_dir[*(cur_op + argn)] |= +PARROT_ARGDIR_IN; +if (op_info-dirs[argn] PARROT_ARGDIR_OUT) +cur_section-float_reg_dir[*(cur_op + argn)] |= +PARROT_ARGDIR_OUT; +} +#endif } /* If we are here means the current section is jitted, so if the next opcode is not end the section. */ -194,13 +209,21 /* Set to 0 the register count, just in case ... */ memset(cur_section-int_reg_count, 0, NUM_REGISTERS * sizeof(INTVAL)); +#if FLOAT_REGITERS_TO_MAP +memset(cur_section-float_reg_count, 0, +NUM_REGISTERS * sizeof(INTVAL)); +#endif /* No next section yet */ cur_section-next=NULL; /* 0 jitted opcodes */ cur_section-jit_op_count = 0; /* Init the register usage */ -for (i = 0; i NUM_REGISTERS; i++) +for (i = 0; i NUM_REGISTERS; i++) { cur_section-int_reg_usage[i] = i; +#if FLOAT_REGITERS_TO_MAP +cur_section-float_reg_usage[i] = i; +#endif +} } /* Move to the next opcode */ -220,18 +243,26 while (cur_section) { /* Test register 0 first */ if (cur_section-int_reg_count[0]) -cur_section-registers_used = 1; +cur_section-int_registers_used = 1; +#if FLOAT_REGITERS_TO_MAP +if (cur_section-float_reg_count[0]) +cur_section-float_registers_used = 1; +#endif /* Sort the registers by the usage, Start from the register number 1 since we compare it with the previous one */ for (i = 1; i NUM_REGISTERS; i++) { /* If the register is not used continue to the next one */ -if (!cur_section-int_reg_count[i]) +if (!cur_section-int_reg_count[i] !cur_section-float_reg_count[i]) continue; /* Count the number of hardware registers that is going to be used in this section */ -if (cur_section-registers_used MAX_REGITERS_TO_MAP) -cur_section-registers_used++; +if (cur_section-int_registers_used INT_REGITERS_TO_MAP) +cur_section-int_registers_used++; +#if FLOAT_REGITERS_TO_MAP +if (cur_section-float_registers_used FLOAT_REGITERS_TO_MAP) +cur_section-float_registers_used++; +#endif /* Any register before this one */ for (j = 0; j i; j++) { -251,6 +282,22 /* Continue with the next register */ break; } +#if FLOAT_REGITERS_TO_MAP +if (cur_section-float_reg_count[i] + cur_section-float_reg_count[cur_section-float_reg_usage[j]]) +{ +/* Move all the registers from the j'th position to +
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/08/13 11:13:50 Modified:jit/arm jit_emit.h jit/sun4 jit_emit.h Log: register_map - intval_map Revision ChangesPath 1.9 +2 -2 parrot/jit/arm/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/arm/jit_emit.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- jit_emit.h13 Aug 2002 18:02:09 - 1.8 +++ jit_emit.h13 Aug 2002 18:13:19 - 1.9 -3,7 +3,7 * * ARM (I think this is all ARM2 or later, although it is APCS-32) * - * $Id: jit_emit.h,v 1.8 2002/08/13 18:02:09 grunblatt Exp $ + * $Id: jit_emit.h,v 1.9 2002/08/13 18:13:19 grunblatt Exp $ */ #ifdef ARM -987,7 +987,7 # define INT_REGITERS_TO_MAP 10 # define FLOAT_REGITERS_TO_MAP 0 -char register_map[INT_REGITERS_TO_MAP] = +char intval_map[INT_REGITERS_TO_MAP] = { r0, r1, r2, r3, r4, r5, r6, r7, r8, r12 }; static void 1.11 +2 -2 parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -r1.10 -r1.11 --- jit_emit.h13 Aug 2002 18:03:44 - 1.10 +++ jit_emit.h13 Aug 2002 18:13:50 - 1.11 -3,7 +3,7 ** ** SPARC ** -** $Id: jit_emit.h,v 1.10 2002/08/13 18:03:44 grunblatt Exp $ +** $Id: jit_emit.h,v 1.11 2002/08/13 18:13:50 grunblatt Exp $ **/ /* -591,7 +591,7 # define INT_REGITERS_TO_MAP 1 # define FLOAT_REGITERS_TO_MAP 0 -char register_map[INT_REGITERS_TO_MAP] = { emitm_l(0) }; +char intval_map[INT_REGITERS_TO_MAP] = { emitm_l(0) }; #endif
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/08/01 12:58:41 Modified:docs jit.pod jit/i386 core.jit jit_emit.h jit/sun4 jit_emit.h Log: More Revisions of jit.doc as well as some more overview comments on the SPARC jit approach. Also included is a change to the way interpreter functions are invoked on x86. This uses the fact that the interpreter argument remains unchanged on the stack to avoid pushing it every time. Courtesty of Jason Gloudon Revision ChangesPath 1.5 +16 -10parrot/docs/jit.pod Index: jit.pod === RCS file: /cvs/public/parrot/docs/jit.pod,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- jit.pod 29 Jul 2002 21:13:38 - 1.4 +++ jit.pod 1 Aug 2002 19:57:24 - 1.5 -73,7 +73,9 =item jit/${jitcpuarch}/core.jit The functions to generate native code for core parrot opcodes are specified -here. +here. To simplify the maintenance of these functions, they are specified in a +format that is pre-processed by Bjit2h.pl to produce a valid C source file, +Bjit_cpu.c. See LFormat of .jit Files below. =item jit/${jitcpuarch}/string.jit -116,7 +118,7 =item jit2h.pl -Reads the .jit files and prints the struct opcode_assembly_t. +Preprocesses the .jit files to produce and prints the struct opcode_assembly_t. =back -129,12 +131,18 =item Iop-name { Ibody } -Where Iop-name is the name of the Parrot opcode, and Ibody consists -of a sequence of the following forms: - -=item Assembly instruction. - -Which may have one of this BIdentifiers as an argument: +Where Iop-name is the name of the Parrot opcode, and Ibody consists of C +syntax code which may contain any of the identifiers listed in the following +section. + +=item Identifiers + +In general, prefixing an identifier with I yields the address of the +referenced Parrot register or constant. If an identifier is given without a +prefix, the value is returned by default. To emphasis the use of the value, +the I* prefix may be used. Since Parrot register values vary during code +execution, their values can not be obtained through identifier substitution +alone. BINT_REG[n] -207,8 +215,6 BTEMP_CHAR[n] Gets replaced by the Inth temporary char array. - -You must preside all the identifiers with I requesting the address of that identifier, or I* requesting the value, I* can be used only with constants since the replacement is done before start running. BINTERPRETER[n] 1.21 +3 -1 parrot/jit/i386/core.jit Index: core.jit === RCS file: /cvs/public/parrot/jit/i386/core.jit,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- core.jit 5 Jul 2002 11:15:42 - 1.20 +++ core.jit 1 Aug 2002 19:58:03 - 1.21 -1,11 +1,13 ; ; i386/core.jit ; -; $Id: core.jit,v 1.20 2002/07/05 11:15:42 tom Exp $ +; $Id: core.jit,v 1.21 2002/08/01 19:58:03 dan Exp $ ; Parrot_end { +emitm_addl_i_r(jit_info-native_ptr, 4, emit_ESP); NATIVECODE = emit_popl_r(NATIVECODE, emit_ESI); +NATIVECODE = emit_popl_r(NATIVECODE, emit_EBP); emitm_ret(NATIVECODE); } 1.5 +21 -6 parrot/jit/i386/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- jit_emit.h5 Jul 2002 11:11:09 - 1.4 +++ jit_emit.h1 Aug 2002 19:58:03 - 1.5 -3,7 +3,7 ** ** i386 ** -** $Id: jit_emit.h,v 1.4 2002/07/05 11:11:09 tom Exp $ +** $Id: jit_emit.h,v 1.5 2002/08/01 19:58:03 dan Exp $ **/ /* Register codes */ -98,7 +98,7 break; default : internal_exception(JIT_ERROR, Invalid scale factor %d\n, scale); -break; +return; } *pc = scale_byte | (i == emit_None ? emit_Index_None : emit_reg_Index(i)) | -108,7 +108,7 static char *emit_r_X(char *pc, int reg_opcode, int base, int i, int scale, long disp) { -if((i !scale) || (scale !i)){ +if(i !scale){ internal_exception(JIT_ERROR, emit_r_X passed invalid scale+index combo\n); } -341,6 +341,8 #define emitm_alul_i_r(pc, op1, op2, imm, reg) { *(pc++) = op1; *(pc++) = emit_alu_X_r(op2, reg); *(long *)((pc)) = (long)(imm); (pc) += 4; } +#define emitm_alub_i_r(pc, op1, op2, imm, reg) { *(pc++) = op1; *(pc++) = emit_alu_X_r(op2, reg); *(pc++) = (char)(imm); } + #define emitm_alul_i_m(pc, op1, op2, imm, b, i,
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/08/01 20:25:37 Modified:.jit.c config/auto jit.pl jit/sun4 jit_emit.h Added: jit/arm core.jit jit_emit.h Log: ARM JIT Here goes. This *isn't* functional - it's the least amount of work I could get away with (before midnight) that gets the inner loop of mops.pasm JITted. Courtesy of: Nicholas Clark [EMAIL PROTECTED] Revision ChangesPath 1.21 +67 -1 parrot/jit.c Index: jit.c === RCS file: /cvs/public/parrot/jit.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- jit.c 23 Jul 2002 02:09:27 - 1.20 +++ jit.c 2 Aug 2002 03:24:02 - 1.21 @@ -1,12 +1,18 @@ /* ** jit.c ** -** $Id: jit.c,v 1.20 2002/07/23 02:09:27 josh Exp $ +** $Id: jit.c,v 1.21 2002/08/02 03:24:02 grunblatt Exp $ */ #include parrot/parrot.h #include parrot/jit.h +#ifdef ARM +#ifdef __linux +#include asm/unistd.h +#endif +#endif + /* ** optimize_jit() ** XXX Don't pay much attention to this yet. @@ -128,6 +134,63 @@ return optimizer; } +#ifdef ARM +static void +arm_sync_d_i_cache (void *start, void *end) { +/* Strictly this is only needed for StrongARM and later (not sure about ARM8) + because earlier cores don't have separate D and I caches. + However there aren't that many ARM7 or earlier devices around that we'll be + running on. */ +#ifdef __linux +#ifdef __GNUC__ +int result; +/* swi call based on code snippet from Russell King. Description + verbatim: */ +/* + * Flush a region from virtual address 'r0' to virtual address 'r1' + * _inclusive_. There is no alignment requirement on either address; + * user space does not need to know the hardware cache layout. + * + * r2 contains flags. It should ALWAYS be passed as ZERO until it + * is defined to be something else. For now we ignore it, but may + * the fires of hell burn in your belly if you break this rule. ;) + * + * (at a later date, we may want to allow this call to not flush + * various aspects of the cache. Passing '0' will guarantee that + * everything necessary gets flushed to maintain consistency in + * the specified region). + */ + +/* The value of the SWI is actually available by in + __ARM_NR_cacheflush defined in asm/unistd.h, but quite how to + get that to interpolate as a number into the ASM string is beyond + me. */ +/* I'm actually passing in exclusive end address, so subtract 1 from + it inside the assembler. */ +__asm__ __volatile__ ( +mov r0, %1\n +sub r1, %2, #1\n +mov r2, #0\n +swi __sys1(__ARM_NR_cacheflush) \n +mov %0, r0\n +: =r (result) +: r ((long)start), r ((long)end) +: r0,r1,r2); + +if (result 0) { +internal_exception(JIT_ERROR, + Synchronising I and D caches failed with errno=%d\n, + -result); +} +#else +#error ARM needs to sync D and I caches, and I don't know how to embed assmbler on this C compiler +#endif +#else +/* Not strictly true - on RISC OS it's OS_SynchroniseCodeAreas */ +#error ARM needs to sync D and I caches, and I don't know how to on this OS +#endif +} +#endif /* ** build_asm() @@ -214,6 +277,9 @@ } } +#ifdef ARM +arm_sync_d_i_cache (jit_info.arena_start, jit_info.native_ptr); +#endif return (jit_f)jit_info.arena_start; } 1.5 +3 -0 parrot/config/auto/jit.pl Index: jit.pl === RCS file: /cvs/public/parrot/config/auto/jit.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- jit.pl30 Jul 2002 17:04:33 - 1.4 +++ jit.pl2 Aug 2002 03:24:34 - 1.5 @@ -42,11 +42,14 @@ $cpuarch = 'i386'; } + $cpuarch =~ s/armv[34]l?/arm/i; + Configure::Data-set( archname= $archname, cpuarch = $cpuarch, osname = $osname, ); + $cpuarch =~ s/i[456]86/i386/i; my $jitarchname = $cpuarch-$osname; 1.1 parrot/jit/arm/core.jit Index: core.jit === ; ; arm/core.jit ; ; $Id: core.jit,v 1.1 2002/08/02 03:25:05 grunblatt Exp $ ; Parrot_noop { jit_info-native_ptr = emit_nop(jit_info-native_ptr); } ; ldmea fp, {r4, r5, r6, r7, fp, sp, pc ; but K bug Grr if I load pc direct. Parrot_end { #ifndef ARM_K_BUG
cvs commit: parrot/jit/sun4 jit_emit.h
cvsuser 02/07/04 14:34:06 Modified:jit/sun4 jit_emit.h Log: Moved regs to Parrot_Context Revision ChangesPath 1.2 +9 -9 parrot/jit/sun4/jit_emit.h Index: jit_emit.h === RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- jit_emit.h20 May 2002 05:33:01 - 1.1 +++ jit_emit.h4 Jul 2002 21:34:06 - 1.2 -3,7 +3,7 ** ** SPARC ** -** $Id: jit_emit.h,v 1.1 2002/05/20 05:33:01 grunblatt Exp $ +** $Id: jit_emit.h,v 1.2 2002/07/04 21:34:06 mrjoltcola Exp $ **/ /* Sparc register numbers */ -333,13 +333,13 break; case PARROT_ARG_I: -val = (int)interpreter-int_reg.registers[val]; +val = (int)interpreter-ctx.int_reg.registers[val]; emitm_ld_i(jit_info-native_ptr, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter), hwreg); break; case PARROT_ARG_N: -val = (int)interpreter-num_reg.registers[val]; +val = (int)interpreter-ctx.num_reg.registers[val]; emitm_ldd_i(jit_info-native_ptr, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter), hwreg); break; -364,13 +364,13 switch(op_type){ case PARROT_ARG_I: -val = (int)interpreter-int_reg.registers[val]; +val = (int)interpreter-ctx.int_reg.registers[val]; emitm_st_i(jit_info-native_ptr, hwreg, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter)); break; case PARROT_ARG_N: -val = (int)interpreter-num_reg.registers[val]; +val = (int)interpreter-ctx.num_reg.registers[val]; emitm_std_i(jit_info-native_ptr, hwreg, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter)); break; -394,13 +394,13 switch(op_type){ case PARROT_ARG_I: -val = (int)interpreter-int_reg.registers[val]; +val = (int)interpreter-ctx.int_reg.registers[val]; emitm_ldf_i(jit_info-native_ptr, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter), hwreg); break; case PARROT_ARG_N: -val = (int)interpreter-num_reg.registers[val]; +val = (int)interpreter-ctx.num_reg.registers[val]; emitm_lddf_i(jit_info-native_ptr, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter), hwreg); break; -424,13 +424,13 switch(op_type){ case PARROT_ARG_I: -val = (int)interpreter-int_reg.registers[val]; +val = (int)interpreter-ctx.int_reg.registers[val]; emitm_stf_i(jit_info-native_ptr, hwreg, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter)); break; case PARROT_ARG_N: -val = (int)interpreter-num_reg.registers[val]; +val = (int)interpreter-ctx.num_reg.registers[val]; emitm_stdf_i(jit_info-native_ptr, hwreg, Parrot_jit_regbase, Parrot_jit_regoff(val, interpreter)); break;