cvsuser 04/10/14 08:09:47
Modified: build_tools build_nativecall.pl
jit/i386 jit_emit.h
t/pmc nci.t
Log:
fix NCI return signatures
* nci functions returned I0 := 0 - no stacked items
* now its correctly I0 := 1 - prototyped return value
* start using the runtime interpreter in JIT/i386
Revision Changes Path
1.59 +18 -18 parrot/build_tools/build_nativecall.pl
Index: build_nativecall.pl
===================================================================
RCS file: /cvs/public/parrot/build_tools/build_nativecall.pl,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -w -r1.58 -r1.59
--- build_nativecall.pl 23 Sep 2004 15:25:56 -0000 1.58
+++ build_nativecall.pl 14 Oct 2004 15:09:45 -0000 1.59
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: build_nativecall.pl,v 1.58 2004/09/23 15:25:56 leo Exp $
+# $Id: build_nativecall.pl,v 1.59 2004/10/14 15:09:45 leo Exp $
=head1 NAME
@@ -28,20 +28,20 @@
my %ret_count;
-%ret_count = (p => [0,0,0,1,0], # Returning a pointer that we PMC stuff
- P => [0,0,0,1,0], # PMC
- S => [0,0,1,0,0], # STR
- i => [0,1,0,0,0], # Returning an int
- 3 => [0,1,0,0,0], # Returning an int pointer
- l => [0,1,0,0,0], # Returning a long
- c => [0,1,0,0,0], # returning a char
- s => [0,1,0,0,0], # returning a short
- f => [0,0,0,0,1], # returning a float
- d => [0,0,0,0,1], # returning a double
- t => [0,0,1,0,0], # returning a string
- v => [0,0,0,0,0], # void return
-# b => [0,0,1,0,0], # Returns a buffer
-# B => [0,0,1,0,0], # Returns a buffer
+%ret_count = (p => [1,0,0,1,0], # Returning a pointer that we PMC stuff
+ P => [1,0,0,1,0], # PMC
+ S => [1,0,1,0,0], # STR
+ i => [1,1,0,0,0], # Returning an int
+ 3 => [1,1,0,0,0], # Returning an int pointer
+ l => [1,1,0,0,0], # Returning a long
+ c => [1,1,0,0,0], # returning a char
+ s => [1,1,0,0,0], # returning a short
+ f => [1,0,0,0,1], # returning a float
+ d => [1,0,0,0,1], # returning a double
+ t => [1,0,1,0,0], # returning a string
+ v => [1,0,0,0,0], # void return
+# b => [1,0,1,0,0], # Returns a buffer
+# B => [1,0,1,0,0], # Returns a buffer
);
my $tempcounter = 0;
@@ -165,7 +165,7 @@
/* nci.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: build_nativecall.pl,v 1.58 2004/09/23 15:25:56 leo Exp $
+ * $Id: build_nativecall.pl,v 1.59 2004/10/14 15:09:45 leo Exp $
* Overview:
* Native Call Interface routines. The code needed to build a
* parrot to C call frame is in here
@@ -194,9 +194,9 @@
hackish, but that's just fine */
static void
-set_return_val(Interp *interpreter, int stack, int ints,
+set_return_val(Interp *interpreter, int proto, int ints,
int strings, int pmcs, int nums) {
- REG_INT(0) = stack;
+ REG_INT(0) = proto;
REG_INT(1) = ints;
REG_INT(2) = strings;
REG_INT(3) = pmcs;
1.121 +27 -41 parrot/jit/i386/jit_emit.h
Index: jit_emit.h
===================================================================
RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -w -r1.120 -r1.121
--- jit_emit.h 13 Aug 2004 09:15:28 -0000 1.120
+++ jit_emit.h 14 Oct 2004 15:09:46 -0000 1.121
@@ -3,7 +3,7 @@
*
* i386
*
- * $Id: jit_emit.h,v 1.120 2004/08/13 09:15:28 leo Exp $
+ * $Id: jit_emit.h,v 1.121 2004/10/14 15:09:46 leo Exp $
*/
#if !defined(PARROT_I386_JIT_EMIT_H_GUARD)
@@ -2535,6 +2535,10 @@
* 8 interpreter
* 4 retaddr
* 0 ebp <----- ebp
+ * -4 ebx .. preserved regs
+ * -8 esi ..
+ * -12 edi ..
+ * -16 interpreter
*/
/* Save all callee-saved registers (cdecl)
@@ -2546,16 +2550,10 @@
/* Cheat on op function calls by writing the interpreter arg on the stack
* just once. If an op function ever modifies the interpreter argument on
* the stack this will stop working !!! */
- if (!jit_info->objfile) {
- emitm_pushl_i(jit_info->native_ptr, interpreter);
- }
-# if EXEC_CAPABLE
- else {
- emitm_pushl_i(jit_info->native_ptr, 0x0);
- Parrot_exec_add_text_rellocation(jit_info->objfile,
- jit_info->native_ptr, RTYPE_COM, "interpre", -4);
- }
-# endif
+
+ /* get the interpreter from stack: mov 8(%ebp), %eax */
+ emitm_movl_m_r(jit_info->native_ptr, emit_EAX, emit_EBP, emit_None, 1, 8);
+ emitm_pushl_r(jit_info->native_ptr, emit_EAX);
/* get the pc from stack: mov 12(%ebp), %eax */
emitm_movl_m_r(jit_info->native_ptr, emit_EAX, emit_EBP, emit_None, 1, 12);
@@ -2642,20 +2640,16 @@
/* get the pc from stack: mov 12(%ebp), %ebx */
emitm_movl_m_r(jit_info->native_ptr, emit_EBX, emit_EBP, emit_None, 1, 12);
/* emit cgp_core(1, interpreter) */
- if (!jit_info->objfile) {
- emitm_pushl_i(jit_info->native_ptr, interpreter);
- }
-# if EXEC_CAPABLE
- else {
- emitm_pushl_i(jit_info->native_ptr, 0x0);
- Parrot_exec_add_text_rellocation(jit_info->objfile,
- jit_info->native_ptr, RTYPE_COM, "interpre", -4);
- }
-# endif
+ /* get the interpreter from stack: mov 8(%ebp), %eax */
+ emitm_movl_m_r(jit_info->native_ptr, emit_EAX, emit_EBP, emit_None, 1, 8);
+ emitm_pushl_r(jit_info->native_ptr, emit_EAX);
+ /*
+ * TODO define the offset of the interpreter on the stack
+ * relative to %ebp
+ */
emitm_pushl_i(jit_info->native_ptr, 1);
/* use EAX as flag, when jumping back on init, EAX==1 */
jit_emit_mov_ri_i(jit_info->native_ptr, emit_EAX, 1);
- /* TODO restart code */
if (!jit_info->objfile)
call_func(jit_info, (void (*)(void))cgp_core);
# if EXEC_CAPABLE
@@ -3095,21 +3089,13 @@
case 'S':
jit_emit_mov_mr_i(pc, &STR_REG(next_s++), emit_EAX);
break;
- case 't': /* string, determine length, make string */
- /* EAX is char */
- /* save it */
- jit_emit_mov_rr_i(pc, emit_EBX, emit_EAX);
- /* strlen(s) */
- emitm_pushl_r(pc, emit_EAX);
- emitm_calll(pc, (char*)strlen - pc - 4);
-
- emitm_pushl_i(pc, 0); /* flags */
- emitm_pushl_i(pc, encoding);
- emitm_pushl_r(pc, emit_EAX); /* len */
- emitm_pushl_r(pc, emit_EBX); /* string */
+ case 't': /* string */
+ /* EAX is char* */
+ emitm_pushl_i(pc, 0); /* len */
+ emitm_pushl_r(pc, emit_EAX); /* string */
emitm_pushl_i(pc, interpreter);
- emitm_calll(pc, (char*)string_make - pc - 4);
- emitm_addb_i_r(pc, 24, emit_ESP);
+ emitm_calll(pc, (char*)string_from_cstring - pc - 4);
+ emitm_addb_i_r(pc, 12, emit_ESP);
jit_emit_mov_mr_i(pc, &STR_REG(next_s++), emit_EAX);
break;
default:
@@ -3117,7 +3103,7 @@
return NULL;
}
/* set prototyped return */
- jit_emit_mov_mi_i(pc, &INT_REG(0), 0); /* XXX fix tests */
+ jit_emit_mov_mi_i(pc, &INT_REG(0), 1);
/* set return values in I,S,P,N regs */
jit_emit_mov_mi_i(pc, &INT_REG(1), next_i-5);
jit_emit_mov_mi_i(pc, &INT_REG(2), next_s-5);
1.58 +10 -10 parrot/t/pmc/nci.t
Index: nci.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/nci.t,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -w -r1.57 -r1.58
--- nci.t 14 Oct 2004 09:40:26 -0000 1.57
+++ nci.t 14 Oct 2004 15:09:47 -0000 1.58
@@ -1,7 +1,7 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: nci.t,v 1.57 2004/10/14 09:40:26 leo Exp $
+# $Id: nci.t,v 1.58 2004/10/14 15:09:47 leo Exp $
=head1 NAME
@@ -43,7 +43,7 @@
invoke
ne N5, 8.0, nok_1
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 0, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -125,7 +125,7 @@
invoke
ne N5, 4.0, nok_1
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 0, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -157,7 +157,7 @@
invoke
ne I5, 6, nok_1
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 1, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -189,7 +189,7 @@
invoke
ne I5, 6, nok_1
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 1, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -221,7 +221,7 @@
invoke
ne I5, 42, nok_1
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 1, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -261,7 +261,7 @@
set S5, "ko\n"
invoke
ne I5, 2, nok_1
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 1, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -291,7 +291,7 @@
set S5, "ko\n"
invoke
print S5
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 0, nok_2
ne I2, 1, nok_2
ne I3, 0, nok_2
@@ -326,7 +326,7 @@
dec I10
gt I10, 0, loop
print "ok 1\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 0, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2
@@ -366,7 +366,7 @@
invoke
ne N5, 8.0, nok_1
print "ok 3\n"
- ne I0, 0, nok_2 # test return value convention
+ ne I0, 1, nok_2 # test return value convention
ne I1, 0, nok_2
ne I2, 0, nok_2
ne I3, 0, nok_2