Permalink
Browse files

JIT/i386 ord_i_s*

* clear integer array memory
* all opocdes of MD5 are now JITted on i386


git-svn-id: https://svn.parrot.org/parrot/trunk@7672 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
Leopold Toetsch
Leopold Toetsch committed Mar 22, 2005
1 parent 4051902 commit d1f7c985c03cca1c33f8a377b98b6f2b6047cfda
Showing with 75 additions and 16 deletions.
  1. +10 −9 classes/fixedintegerarray.pmc
  2. +43 −6 jit/i386/core.jit
  3. +22 −1 t/pmc/object-meths.t
@@ -22,7 +22,7 @@ it uses Integer PMCs for all of the conversions
#include "parrot/parrot.h"
pmclass FixedIntegerArray need_ext does array {
-
+
/*
=back
@@ -89,12 +89,12 @@ Creates and returns a copy of the array.
PMC* clone () {
INTVAL size;
PMC * dest = pmc_new(INTERP, SELF->vtable->base_type);
-
+
if (!PMC_data(SELF))
return dest;
size = PMC_int_val(SELF);
PMC_int_val(dest) = size;
-
+
PMC_data(dest) = mem_sys_allocate(size * sizeof(INTVAL));
mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), size*sizeof(INTVAL));
PObj_active_destroy_SET(dest);
@@ -156,9 +156,9 @@ Returns the integer value of the element at index C<key>.
INTVAL get_integer_keyed_int (INTVAL key) {
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ internal_exception(OUT_OF_BOUNDS,
"FixedIntegerArray: index out of bounds!");
-
+
data = (INTVAL *)PMC_data(SELF);
return data[key];
}
@@ -288,9 +288,10 @@ Resizes the array to C<size> elements.
void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
- internal_exception(OUT_OF_BOUNDS, "FixedIntegerArray: Can't resize!");
+ internal_exception(OUT_OF_BOUNDS,
+ "FixedIntegerArray: Can't resize!");
PMC_int_val(SELF) = size;
- PMC_data(SELF) = mem_sys_allocate(size * sizeof(INTVAL));
+ PMC_data(SELF) = mem_sys_allocate_zeroed(size * sizeof(INTVAL));
PObj_active_destroy_SET(SELF);
}
@@ -307,7 +308,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed_int (INTVAL key, INTVAL value) {
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
- internal_exception(OUT_OF_BOUNDS,
+ internal_exception(OUT_OF_BOUNDS,
"FixedIntegerArray: index out of bounds!");
data = (INTVAL*)PMC_data(SELF);
@@ -361,7 +362,7 @@ C<value>.
k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
-
+
/*
=item C<void set_string_keyed_int(INTVAL key, STRING *value)>
View
@@ -1257,13 +1257,50 @@ TEMPLATE Parrot_ord_i_sx {
#undef push_r
#undef push_c
}
-;Parrot_ord_i_s {
-; Parrot_ord_i_sx s/<typ>/r/
-;}
-;Parrot_ord_i_sc {
-; Parrot_ord_i_sx s/<typ>/c/
-;}
+Parrot_ord_i_s {
+ Parrot_ord_i_sx s/<typ>/r/
+}
+
+Parrot_ord_i_sc {
+ Parrot_ord_i_sx s/<typ>/c/
+}
+
+TEMPLATE Parrot_ord_i_sx_i {
+# define push_r(i) \
+ jit_emit_mov_RM_i(NATIVECODE, emit_EAX, ROFFS_STR(i)); \
+ emitm_pushl_r(NATIVECODE, emit_EAX)
+# define push_c(i) emitm_pushl_i(NATIVECODE, CONST(i)->u.string)
+
+ if (MAP[3]) {
+ emitm_pushl_r(NATIVECODE, MAP[3]);
+ }
+ else {
+ jit_emit_mov_RM_i(NATIVECODE, ISR1, ROFFS_INT(3));
+ emitm_pushl_r(NATIVECODE, ISR1);
+ }
+ push_<typ>(2);
+ Parrot_jit_emit_get_INTERP(jit_info->native_ptr, emit_EAX);
+ emitm_pushl_r(NATIVECODE, emit_EAX);
+ CALL_FUNCTION(jit_info, (void*)string_ord);
+ emitm_addb_i_r(NATIVECODE, 12, emit_ESP);
+ if (MAP[1]) {
+ jit_emit_mov_rr_i(NATIVECODE, MAP[1], ISR1);
+ }
+ else {
+ jit_emit_mov_MR_i(NATIVECODE, ROFFS_INT(1), ISR1);
+ }
+#undef push_r
+#undef push_c
+}
+
+Parrot_ord_i_s_i {
+ Parrot_ord_i_sx_i s/<typ>/r/
+}
+
+Parrot_ord_i_sc_i {
+ Parrot_ord_i_sx_i s/<typ>/c/
+}
; TODO or,and,not,cmp
View
@@ -16,7 +16,7 @@ Tests PMC object methods.
=cut
-use Parrot::Test tests => 28;
+use Parrot::Test tests => 29;
use Test::More;
output_like(<<'CODE', <<'OUTPUT', "callmethod - unknown method");
@@ -935,3 +935,24 @@ class method 0.540302
bound class m 0.540302
bound obj met 0.540302
OUTPUT
+
+pir_output_is(<<'CODE', <<'OUTPUT', "ParrotIO.puts");
+.sub main @MAIN
+ .local pmc o, m, cl
+ o = getstdout
+ $I0 = o."puts"("ok 1\n")
+ puts $I0, o, "ok 2\n"
+ $I0 = "puts"(o, "ok 3\n")
+ m = getattribute o, "puts"
+ $I0 = m("ok 4\n")
+ cl = getclass "ParrotIO"
+ $I0 = cl."puts"(o, "ok 5\n")
+.end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUTPUT
+

0 comments on commit d1f7c98

Please sign in to comment.