cvsuser 04/10/23 06:21:39
Modified: build_tools jit2h.pl
jit/i386 core.jit jit_emit.h
t/op jit.t
Log:
indirect register frame 7 - JIT i386: interp and frame pointer split
* slightly different code for INDIRECT_REGS
* set extern, if JIT code calls a function - i386 hack currently
Revision Changes Path
1.73 +3 -1 parrot/build_tools/jit2h.pl
Index: jit2h.pl
===================================================================
RCS file: /cvs/public/parrot/build_tools/jit2h.pl,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -w -r1.72 -r1.73
--- jit2h.pl 22 Oct 2004 10:26:23 -0000 1.72
+++ jit2h.pl 23 Oct 2004 13:21:35 -0000 1.73
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: jit2h.pl,v 1.72 2004/10/22 10:26:23 leo Exp $
+# $Id: jit2h.pl,v 1.73 2004/10/23 13:21:35 leo Exp $
=head1 NAME
@@ -165,6 +165,8 @@
$asm =~ s/CUR_OPCODE/jit_info->cur_op/g;
$asm =~ s/cur_opcode/jit_info->cur_op/g;
$asm =~ s/MAP\[(\d)\]/MAP($1)/g;
+ # XXX set extern if the code calls a function
+ $extern = 1 if $asm =~ /call_func/;
unless ($jit_cpu) {
# no address of
$asm =~ s/&([INSP])REG/$1REG/g;
1.63 +11 -6 parrot/jit/i386/core.jit
Index: core.jit
===================================================================
RCS file: /cvs/public/parrot/jit/i386/core.jit,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -w -r1.62 -r1.63
--- core.jit 21 Oct 2004 14:50:20 -0000 1.62
+++ core.jit 23 Oct 2004 13:21:37 -0000 1.63
@@ -1,7 +1,7 @@
;
; i386/core.jit
;
-; $Id: core.jit,v 1.62 2004/10/21 14:50:20 leo Exp $
+; $Id: core.jit,v 1.63 2004/10/23 13:21:37 leo Exp $
;
# TODO complete this
@@ -1264,8 +1264,9 @@
; string funcs
;
Parrot_set_s_sc {
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
emitm_pushl_i(NATIVECODE, CONST(2)->u.string);
- emitm_pushl_r(NATIVECODE, emit_EBX);
+ emitm_pushl_r(NATIVECODE, emit_ECX);
call_func(jit_info, (void*) string_copy);
emitm_addb_i_r(NATIVECODE, 8, emit_ESP);
jit_emit_mov_MR_i(NATIVECODE, ROFFS_STR(1), emit_EAX );
@@ -1279,7 +1280,8 @@
push_<typ2>(2);
push_<typ1>(1);
- emitm_pushl_r(NATIVECODE, emit_EBX);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
+ emitm_pushl_r(NATIVECODE, emit_ECX);
call_func(jit_info, (void*)string_compare);
emitm_addb_i_r(NATIVECODE, 12, emit_ESP);
jit_emit_test_r_i(NATIVECODE, emit_EAX);
@@ -1295,7 +1297,8 @@
# define push_c(i) emitm_pushl_i(NATIVECODE, CONST(i)->u.string)
push_<typ2>(2);
push_<typ1>(1);
- emitm_pushl_r(NATIVECODE, emit_EBX);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
+ emitm_pushl_r(NATIVECODE, emit_ECX);
call_func(jit_info, (void*)string_equal);
emitm_addb_i_r(NATIVECODE, 12, emit_ESP);
jit_emit_test_r_i(NATIVECODE, emit_EAX);
@@ -1409,7 +1412,8 @@
# define push_c(i) emitm_pushl_i(NATIVECODE, CONST(i)->u.string)
push_<typ>(1);
- emitm_pushl_r(NATIVECODE, emit_EBX);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
+ emitm_pushl_r(NATIVECODE, emit_ECX);
call_func(jit_info, (void*)string_bool);
emitm_addb_i_r(NATIVECODE, 8, emit_ESP);
jit_emit_test_r_i(NATIVECODE, emit_EAX);
@@ -1444,7 +1448,8 @@
emitm_pushl_i(NATIVECODE, 0);
push_<typ>(2);
- emitm_pushl_r(NATIVECODE, emit_EBX);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
+ emitm_pushl_r(NATIVECODE, emit_ECX);
call_func(jit_info, (void*)string_ord);
emitm_addb_i_r(NATIVECODE, 12, emit_ESP);
if (MAP[1]) {
1.139 +40 -27 parrot/jit/i386/jit_emit.h
Index: jit_emit.h
===================================================================
RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -w -r1.138 -r1.139
--- jit_emit.h 22 Oct 2004 13:29:35 -0000 1.138
+++ jit_emit.h 23 Oct 2004 13:21:38 -0000 1.139
@@ -3,7 +3,7 @@
*
* i386
*
- * $Id: jit_emit.h,v 1.138 2004/10/22 13:29:35 leo Exp $
+ * $Id: jit_emit.h,v 1.139 2004/10/23 13:21:38 leo Exp $
*/
#if !defined(PARROT_I386_JIT_EMIT_H_GUARD)
@@ -16,6 +16,23 @@
#endif
/*
+ * get the register frame pointer
+ */
+# define Parrot_jit_emit_get_base_reg_no(pc) \
+ emit_EBX
+
+/*
+ * get the *runtime* interpreter
+ */
+#if INDIRECT_REGS
+# define Parrot_jit_emit_get_INTERP(pc, dest) \
+ emitm_movl_m_r(pc, dest, emit_EBP, emit_None, 1, INTERP_BP_OFFS)
+#else
+# define Parrot_jit_emit_get_INTERP(pc, dest) \
+ jit_emit_mov_rr_i(pc, dest, emit_EBX)
+#endif
+
+/*
* if we have a delegated method like typeof_i_p, that returns an INTVAL
* and that is all in a sequence of JITted opcodes, and when these INTVAL
* is MAPped, we got a problem. So the EXT_CALL flag is disabled - mapped
@@ -1972,6 +1989,11 @@
offsetof(Parrot_jit_info_t, arena));
emitm_movl_m_r(jit_info->native_ptr, emit_EDX, emit_EDX, 0, 1,
offsetof(Parrot_jit_arena_t, op_map));
+#if INDIRECT_REGS
+ /* get base pointer */
+ emitm_movl_m_r(jit_info->native_ptr, emit_EBX, emit_EBX, 0, 1,
+ offsetof(Interp, ctx.bp));
+#endif
}
# if EXEC_CAPABLE
@@ -2374,11 +2396,10 @@
if (i2 <= 0 || i2 >= enum_class_max)
internal_exception(1, "Illegal PMC enum (%d) in new\n", i2);
/* get interpreter */
- emitm_movl_m_r(jit_info->native_ptr,
- emit_EBX, emit_EBP, emit_None, 1, INTERP_BP_OFFS);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
/* push pmc enum and interpreter */
emitm_pushl_i(jit_info->native_ptr, i2);
- emitm_pushl_r(jit_info->native_ptr, emit_EBX);
+ emitm_pushl_r(jit_info->native_ptr, emit_ECX);
# if EXEC_CAPABLE
if (jit_info->objfile) {
CALL("pmc_new_noinit");
@@ -2394,7 +2415,8 @@
emitm_movl_r_m(jit_info->native_ptr,
emit_EAX, emit_EBX, emit_None, 1, REG_OFFS_PMC(p1));
/* push interpreter */
- emitm_pushl_r(jit_info->native_ptr, emit_EBX);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_ECX);
+ emitm_pushl_r(jit_info->native_ptr, emit_ECX);
/* mov (offs)%eax, %eax i.e. $1->vtable */
emitm_movl_m_r(jit_info->native_ptr, emit_EAX, emit_EAX, emit_None, 1,
offsetof(struct PMC, vtable));
@@ -2873,6 +2895,11 @@
emitm_pushl_r(pc, emit_EBX);
/* get interp into %ebx */
emitm_movl_m_r(pc, emit_EBX, emit_EBP, 0, 1, 8);
+#if INDIRECT_REGS
+ /* get base pointer */
+ emitm_movl_m_r(pc, emit_EBX, emit_EBX, 0, 1,
+ offsetof(struct parrot_interp_t, ctx.bp));
+#endif
/* get rightmost param, assume ascii chars */
sig = (char *)signature->strstart + signature->bufused - 1;
@@ -2996,7 +3023,8 @@
emitm_pushl_r(pc, emit_EAX);
break;
case 'I':
- emitm_pushl_r(pc, emit_EBX);
+ emitm_movl_m_r(pc, emit_ECX, emit_EBP, 0, 1, 8);
+ emitm_pushl_r(pc, emit_ECX);
break;
default:
/*
@@ -3066,10 +3094,11 @@
break;
case 'p': /* make a new unmanaged struct */
/* save return value on stack */
+ emitm_movl_m_r(pc, emit_ECX, emit_EBP, 0, 1, 8);
emitm_pushl_r(pc, emit_EAX);
/* make new pmc */
emitm_pushl_i(pc, enum_class_UnManagedStruct);
- emitm_pushl_r(pc, emit_EBX);
+ emitm_pushl_r(pc, emit_ECX);
emitm_calll(pc, (char*)pmc_new - pc - 4);
emitm_addb_i_r(pc, 8, emit_ESP);
/* eax = PMC, get return value into edx */
@@ -3091,8 +3120,9 @@
break;
case 'b': /* (void *) = PObj_bufstart(new_buffer_header) */
/* preserve return value */
+ emitm_movl_m_r(pc, emit_ECX, emit_EBP, 0, 1, 8);
emitm_pushl_r(pc, emit_EAX);
- emitm_pushl_r(pc, emit_EBX);
+ emitm_pushl_r(pc, emit_ECX);
emitm_calll(pc, (char*)new_buffer_header - pc - 4);
emitm_addb_i_r(pc, 4, emit_ESP);
/* *eax = buffer_header */
@@ -3113,8 +3143,9 @@
case 't': /* string */
/* EAX is char* */
emitm_pushl_i(pc, 0); /* len */
+ emitm_movl_m_r(pc, emit_ECX, emit_EBP, 0, 1, 8);
emitm_pushl_r(pc, emit_EAX); /* string */
- emitm_pushl_r(pc, emit_EBX); /* interpreter */
+ emitm_pushl_r(pc, emit_ECX); /* interpreter */
emitm_calll(pc, (char*)string_from_cstring - pc - 4);
emitm_addb_i_r(pc, 12, emit_ESP);
jit_emit_mov_MR_i(pc, REG_OFFS_STR(next_s++), emit_EAX);
@@ -3218,24 +3249,6 @@
# define INTERP_BP_OFFS -16
# endif
-/*
- * get the register frame pointer
- */
-# define Parrot_jit_emit_get_base_reg_no(pc) \
- emit_EBX
-
-/*
- * get the *runtime* interpreter
- */
-#if 0
-# define Parrot_jit_emit_get_INTERP(pc) \
- (emitm_movl_m_r(pc, emit_EAX, emit_EBP, emit_None, 1, INTERP_BP_OFFS), \
- emit_EAX
-#else
-# define Parrot_jit_emit_get_INTERP(pc) \
- emit_EBX
-#endif
-
#endif /* JIT_EMIT */
#endif /* PARROT_I386_JIT_EMIT_H_GUARD */
1.10 +26 -2 parrot/t/op/jit.t
Index: jit.t
===================================================================
RCS file: /cvs/public/parrot/t/op/jit.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- jit.t 1 Oct 2004 21:16:49 -0000 1.9
+++ jit.t 23 Oct 2004 13:21:39 -0000 1.10
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: jit.t,v 1.9 2004/10/01 21:16:49 jrieks Exp $
+# $Id: jit.t,v 1.10 2004/10/23 13:21:39 leo Exp $
=head1 NAME
@@ -17,7 +17,7 @@
=cut
# test WRT JIT register allocation
-use Parrot::Test tests => 58;
+use Parrot::Test tests => 59;
output_is(<<'CODE', <<'OUTPUT', "add_i_i_i 1,2,3 mapped");
set I0,0
@@ -1153,4 +1153,28 @@
done
OUTPUT
+output_is(<<'CODE', <<'OUTPUT', "volatile clobbered by function call");
+ add I4, I5, I6
+ add I4, I5, I6
+ add I4, I5, I6
+ add I4, I5, I3
+ add I4, I5, I3
+ add I4, I5, I3
+ set I3, 2
+ set I1, 2
+ set S0, "Hi"
+ mul I5, I1, 77
+ print I3
+ print "\n"
+ print I4
+ print "\n"
+ print I5
+ print "\n"
+ end
+CODE
+2
+0
+154
+OUTPUT
+
1;