* src/vm/jit/jit.h (jitdata): Removed isleafmethod.
[cacao.git] / src / vm / jit / alpha / codegen.c
index 4e7b247acdc57c1e950581b4e93959494f1bf34e..f352bdb59925d1b78ecd923cb1671f3dc61aff9f 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 8187 2007-07-05 23:52:19Z michi $
-
 */
 
 
@@ -43,6 +41,7 @@
 #include "mm/memory.h"
 
 #include "native/jni.h"
+#include "native/localref.h"
 #include "native/native.h"
 
 #include "threads/lock-common.h"
@@ -119,7 +118,7 @@ bool codegen_emit(jitdata *jd)
        s4 i, p, t, l;
        s4 savedregs_num;
 
-       savedregs_num = (jd->isleafmethod) ? 0 : 1;       /* space to save the RA */
+       savedregs_num = code_is_leafmethod(code) ? 0 : 1; /* space to save the RA */
 
        /* space to save used callee saved registers */
 
@@ -155,7 +154,13 @@ bool codegen_emit(jitdata *jd)
 #endif
                (void) dseg_add_unique_s4(cd, 0);                          /* IsSync  */
 
-       (void) dseg_add_unique_s4(cd, jd->isleafmethod);               /* IsLeaf  */
+       /* REMOVEME: We still need it for exception handling in assembler. */
+
+       if (code_is_leafmethod(code))
+               (void) dseg_add_unique_s4(cd, 1);
+       else
+               (void) dseg_add_unique_s4(cd, 0);
+
        (void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
        (void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
 
@@ -180,7 +185,7 @@ bool codegen_emit(jitdata *jd)
        /* save return address and used callee saved registers */
 
        p = cd->stackframesize;
-       if (!jd->isleafmethod) {
+       if (!code_is_leafmethod(code)) {
                p--; M_AST(REG_RA, REG_SP, p * 8);
        }
        for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
@@ -1418,7 +1423,7 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
-                       M_ILD(d, s1, OFFSET(java_arrayheader, size));
+                       M_ILD(d, s1, OFFSET(java_array_t, size));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1431,13 +1436,13 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_BLDU(d, REG_ITMP1, OFFSET (java_bytearray, data[0]));
+                               M_BLDU(d, REG_ITMP1, OFFSET (java_bytearray_t, data[0]));
                                M_BSEXT(d, d);
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0])+1);
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray_t, data[0])+1);
                                M_EXTQH(REG_ITMP2, REG_ITMP1, d);
                                M_SRA_IMM(d, 56, d);
                        }
@@ -1454,13 +1459,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SLDU(d, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_SLDU(d, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                        }
                        else {
                                M_LADD (s2, s1, REG_ITMP1);
                                M_LADD (s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray, data[0]));
-                               M_LDA  (REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
+                               M_LDA  (REG_ITMP1, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                                M_EXTWL(REG_ITMP2, REG_ITMP1, d);
                        }
                        emit_store_dst(jd, iptr, d);
@@ -1476,13 +1481,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SLDU( d, REG_ITMP1, OFFSET (java_shortarray, data[0]));
+                               M_SLDU( d, REG_ITMP1, OFFSET (java_shortarray_t, data[0]));
                                M_SSEXT(d, d);
                        } else {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0])+2);
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray_t, data[0])+2);
                                M_EXTQH(REG_ITMP2, REG_ITMP1, d);
                                M_SRA_IMM(d, 48, d);
                        }
@@ -1497,7 +1502,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S4ADDQ(s2, s1, REG_ITMP1);
-                       M_ILD(d, REG_ITMP1, OFFSET(java_intarray, data[0]));
+                       M_ILD(d, REG_ITMP1, OFFSET(java_intarray_t, data[0]));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1509,7 +1514,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S8ADDQ(s2, s1, REG_ITMP1);
-                       M_LLD(d, REG_ITMP1, OFFSET(java_longarray, data[0]));
+                       M_LLD(d, REG_ITMP1, OFFSET(java_longarray_t, data[0]));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1521,7 +1526,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S4ADDQ(s2, s1, REG_ITMP1);
-                       M_FLD(d, REG_ITMP1, OFFSET(java_floatarray, data[0]));
+                       M_FLD(d, REG_ITMP1, OFFSET(java_floatarray_t, data[0]));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1533,7 +1538,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S8ADDQ(s2, s1, REG_ITMP1);
-                       M_DLD(d, REG_ITMP1, OFFSET(java_doublearray, data[0]));
+                       M_DLD(d, REG_ITMP1, OFFSET(java_doublearray_t, data[0]));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1545,7 +1550,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_SAADDQ(s2, s1, REG_ITMP1);
-                       M_ALD(d, REG_ITMP1, OFFSET(java_objectarray, data[0]));
+                       M_ALD(d, REG_ITMP1, OFFSET(java_objectarray_t, data[0]));
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1559,12 +1564,12 @@ bool codegen_emit(jitdata *jd)
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_BST(s3, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+                               M_BST(s3, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
                                M_INSBL(s3, REG_ITMP1, REG_ITMP3);
                                M_MSKBL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1582,13 +1587,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SST(s3, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_SST(s3, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                                M_INSWL(s3, REG_ITMP1, REG_ITMP3);
                                M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1606,13 +1611,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SST(s3, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+                               M_SST(s3, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
                                M_INSWL(s3, REG_ITMP1, REG_ITMP3);
                                M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1628,7 +1633,7 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        M_S4ADDQ(s2, s1, REG_ITMP1);
-                       M_IST(s3, REG_ITMP1, OFFSET(java_intarray, data[0]));
+                       M_IST(s3, REG_ITMP1, OFFSET(java_intarray_t, data[0]));
                        break;
 
                case ICMD_LASTORE:    /* ..., arrayref, index, value  ==> ...         */
@@ -1639,7 +1644,7 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        M_S8ADDQ(s2, s1, REG_ITMP1);
-                       M_LST(s3, REG_ITMP1, OFFSET(java_longarray, data[0]));
+                       M_LST(s3, REG_ITMP1, OFFSET(java_longarray_t, data[0]));
                        break;
 
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
@@ -1650,7 +1655,7 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_FTMP3);
                        M_S4ADDQ(s2, s1, REG_ITMP1);
-                       M_FST(s3, REG_ITMP1, OFFSET(java_floatarray, data[0]));
+                       M_FST(s3, REG_ITMP1, OFFSET(java_floatarray_t, data[0]));
                        break;
 
                case ICMD_DASTORE:    /* ..., arrayref, index, value  ==> ...         */
@@ -1661,7 +1666,7 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_FTMP3);
                        M_S8ADDQ(s2, s1, REG_ITMP1);
-                       M_DST(s3, REG_ITMP1, OFFSET(java_doublearray, data[0]));
+                       M_DST(s3, REG_ITMP1, OFFSET(java_doublearray_t, data[0]));
                        break;
 
                case ICMD_AASTORE:    /* ..., arrayref, index, value  ==> ...         */
@@ -1675,18 +1680,18 @@ bool codegen_emit(jitdata *jd)
                        M_INTMOVE(s1, REG_A0);
                        M_INTMOVE(s3, REG_A1);
 
-                       disp = dseg_add_functionptr(cd, BUILTIN_canstore);
+                       disp = dseg_add_functionptr(cd, BUILTIN_FAST_canstore);
                        M_ALD(REG_PV, REG_PV, disp);
                        M_JSR(REG_RA, REG_PV);
                        disp = (s4) (cd->mcodeptr - cd->mcodebase);
                        M_LDA(REG_PV, REG_RA, -disp);
-                       emit_exception_check(cd, iptr);
+                       emit_arraystore_check(cd, iptr);
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        M_SAADDQ(s2, s1, REG_ITMP1);
-                       M_AST(s3, REG_ITMP1, OFFSET(java_objectarray, data[0]));
+                       M_AST(s3, REG_ITMP1, OFFSET(java_objectarray_t, data[0]));
                        break;
 
 
@@ -1698,12 +1703,12 @@ bool codegen_emit(jitdata *jd)
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_BST(REG_ZERO, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+                               M_BST(REG_ZERO, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray_t, data[0]));
                                M_INSBL(REG_ZERO, REG_ITMP1, REG_ITMP3);
                                M_MSKBL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1720,13 +1725,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray_t, data[0]));
                                M_INSWL(REG_ZERO, REG_ITMP1, REG_ITMP3);
                                M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1743,13 +1748,13 @@ bool codegen_emit(jitdata *jd)
                        if (has_ext_instr_set) {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+                               M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
                        }
                        else {
                                M_LADD(s2, s1, REG_ITMP1);
                                M_LADD(s2, REG_ITMP1, REG_ITMP1);
-                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray, data[0]));
-                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+                               M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
+                               M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray_t, data[0]));
                                M_INSWL(REG_ZERO, REG_ITMP1, REG_ITMP3);
                                M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
                                M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
@@ -1764,7 +1769,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S4ADDQ(s2, s1, REG_ITMP1);
-                       M_IST(REG_ZERO, REG_ITMP1, OFFSET(java_intarray, data[0]));
+                       M_IST(REG_ZERO, REG_ITMP1, OFFSET(java_intarray_t, data[0]));
                        break;
 
                case ICMD_LASTORECONST:   /* ..., arrayref, index  ==> ...            */
@@ -1774,7 +1779,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_S8ADDQ(s2, s1, REG_ITMP1);
-                       M_LST(REG_ZERO, REG_ITMP1, OFFSET(java_longarray, data[0]));
+                       M_LST(REG_ZERO, REG_ITMP1, OFFSET(java_longarray_t, data[0]));
                        break;
 
                case ICMD_AASTORECONST:   /* ..., arrayref, index  ==> ...            */
@@ -1784,7 +1789,7 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_SAADDQ(s2, s1, REG_ITMP1);
-                       M_AST(REG_ZERO, REG_ITMP1, OFFSET(java_objectarray, data[0]));
+                       M_AST(REG_ZERO, REG_ITMP1, OFFSET(java_objectarray_t, data[0]));
                        break;
 
 
@@ -1800,7 +1805,7 @@ bool codegen_emit(jitdata *jd)
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
                                fieldtype = fi->type;
-                               disp      = dseg_add_address(cd, &(fi->value));
+                               disp      = dseg_add_address(cd, fi->value);
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
                                        patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
@@ -1845,7 +1850,7 @@ bool codegen_emit(jitdata *jd)
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
                                fieldtype = fi->type;
-                               disp      = dseg_add_address(cd, &(fi->value));
+                               disp      = dseg_add_address(cd, fi->value);
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
                                        patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
@@ -1891,7 +1896,7 @@ bool codegen_emit(jitdata *jd)
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
                                fieldtype = fi->type;
-                               disp      = dseg_add_address(cd, &(fi->value));
+                               disp      = dseg_add_address(cd, fi->value);
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
                                        patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
@@ -2424,7 +2429,7 @@ nowperformreturn:
 
                        /* restore return address                                         */
 
-                       if (!jd->isleafmethod) {
+                       if (!code_is_leafmethod(code)) {
                                p--; M_LLD(REG_RA, REG_SP, p * 8);
                        }
 
@@ -2537,6 +2542,8 @@ nowperformreturn:
 
                case ICMD_BUILTIN:      /* ..., arg1, arg2, arg3 ==> ...              */
 
+                       REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr);
+
                        bte = iptr->sx.s23.s3.bte;
                        md  = bte->md;
                        goto gen_method;
@@ -2600,18 +2607,19 @@ gen_method:
 
                        switch (iptr->opc) {
                        case ICMD_BUILTIN:
-                               disp = dseg_add_functionptr(cd, bte->fp);
+                               if (bte->stub == NULL)
+                                       disp = dseg_add_functionptr(cd, bte->fp);
+                               else
+                                       disp = dseg_add_functionptr(cd, bte->stub);
 
                                M_ALD(REG_PV, REG_PV, disp);  /* Pointer to built-in-function */
 
                                /* generate the actual call */
 
                                M_JSR(REG_RA, REG_PV);
-                               REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
+                               REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr);
                                disp = (s4) (cd->mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, -disp);
-
-                               emit_exception_check(cd, iptr);
                                break;
 
                        case ICMD_INVOKESPECIAL:
@@ -2649,7 +2657,7 @@ gen_method:
                                                sizeof(methodptr) * lm->vftblindex;
 
                                /* implicit null-pointer check */
-                               M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl));
+                               M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_PV, REG_METHODPTR, s1);
 
                                /* generate the actual call */
@@ -2675,7 +2683,7 @@ gen_method:
                                }
                                        
                                /* implicit null-pointer check */
-                               M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl));
+                               M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_METHODPTR, REG_METHODPTR, s1);
                                M_ALD(REG_PV, REG_METHODPTR, s2);
 
@@ -2758,7 +2766,7 @@ gen_method:
                                        else
                                                emit_label_beqz(cd, BRANCH_LABEL_3, s1);
 
-                                       M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
+                                       M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ILD(REG_ITMP3, REG_ITMP2,
                                                  OFFSET(vftbl_t, interfacetablelength));
                                        M_LDA(REG_ITMP3, REG_ITMP3, -superindex);
@@ -2794,7 +2802,7 @@ gen_method:
                                                emit_label_beqz(cd, BRANCH_LABEL_5, s1);
                                        }
 
-                                       M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
+                                       M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
 
                                        CODEGEN_CRITICAL_SECTION_START;
@@ -2931,7 +2939,7 @@ gen_method:
                                        emit_label_beqz(cd, BRANCH_LABEL_3, s1);
                                }
 
-                               M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
+                               M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
                                M_LDA(REG_ITMP3, REG_ITMP3, -superindex);
                                M_BLEZ(REG_ITMP3, 2);
@@ -2965,7 +2973,7 @@ gen_method:
                                        emit_label_beqz(cd, BRANCH_LABEL_5, s1);
                                }
 
-                               M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
+                               M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
 
                                CODEGEN_CRITICAL_SECTION_START;
@@ -3064,10 +3072,9 @@ gen_method:
 
        dseg_createlinenumbertable(cd);
 
-       /* generate stubs */
+       /* generate traps */
 
        emit_patcher_traps(jd);
-       REPLACEMENT_EMIT_STUBS(jd);
 
        /* everything's ok */
 
@@ -3075,43 +3082,18 @@ gen_method:
 }
 
 
-/* codegen_emit_stub_compiler **************************************************
-
-   Emits a stub routine which calls the compiler.
-       
-*******************************************************************************/
-
-void codegen_emit_stub_compiler(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       m  = jd->m;
-       cd = jd->cd;
-
-       /* code for the stub */
-
-       M_ALD(REG_ITMP1, REG_PV, -2 * 8);   /* load codeinfo pointer              */
-       M_ALD(REG_PV, REG_PV, -3 * 8);      /* load pointer to the compiler       */
-       M_JMP(REG_ZERO, REG_PV);            /* jump to the compiler               */
-}
-
-
 /* codegen_emit_stub_native ****************************************************
 
    Emits a stub routine which calls a native method.
 
 *******************************************************************************/
 
-void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
+void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams)
 {
        methodinfo  *m;
        codeinfo    *code;
        codegendata *cd;
        methoddesc  *md;
-       s4           nativeparams;
        s4           i, j;                 /* count variables                    */
        s4           t;
        s4           s1, s2, disp;
@@ -3126,7 +3108,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        /* initialize variables */
 
        md = m->parseddesc;
-       nativeparams = (m->flags & ACC_STATIC) ? 2 : 1;
 
        /* calculate stack frame size */
 
@@ -3154,21 +3135,12 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        M_LDA(REG_SP, REG_SP, -(cd->stackframesize * 8));
        M_AST(REG_RA, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
 
-       /* call trace function */
-
-#if !defined(NDEBUG)
-       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
-               emit_verbosecall_enter(jd);
-#endif
-
        /* get function address (this must happen before the stackframeinfo) */
 
        funcdisp = dseg_add_functionptr(cd, f);
 
-#if !defined(WITH_STATIC_CLASSPATH)
        if (f == NULL)
                patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
-#endif
 
 #if defined(ENABLE_GC_CACAO)
        /* Save callee saved integer registers in stackframeinfo (GC may
@@ -3194,6 +3166,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                                M_LST(s1, REG_SP, i * 8);
                                break;
                        case TYPE_FLT:
+                               M_FST(s1, REG_SP, i * 8);
+                               break;
                        case TYPE_DBL:
                                M_DST(s1, REG_SP, i * 8);
                                break;
@@ -3203,16 +3177,19 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* prepare data structures for native function call */
 
-       M_LDA(REG_A0, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_MOV(REG_SP, REG_A0);
        M_MOV(REG_PV, REG_A1);
-       M_LDA(REG_A2, REG_SP, cd->stackframesize * 8);
-       M_ALD(REG_A3, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
        disp = dseg_add_functionptr(cd, codegen_start_native_call);
        M_ALD(REG_PV, REG_PV, disp);
        M_JSR(REG_RA, REG_PV);
        disp = (s4) (cd->mcodeptr - cd->mcodebase);
        M_LDA(REG_PV, REG_RA, -disp);
 
+       /* remember class argument */
+
+       if (m->flags & ACC_STATIC)
+               M_MOV(REG_RESULT, REG_ITMP3);
+
        /* restore integer and float argument registers */
 
        for (i = 0; i < md->paramcount; i++) {
@@ -3226,6 +3203,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                                M_LLD(s1, REG_SP, i * 8);
                                break;
                        case TYPE_FLT:
+                               M_FLD(s1, REG_SP, i * 8);
+                               break;
                        case TYPE_DBL:
                                M_DLD(s1, REG_SP, i * 8);
                                break;
@@ -3235,7 +3214,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* copy or spill arguments to new locations */
 
-       for (i = md->paramcount - 1, j = i + nativeparams; i >= 0; i--, j--) {
+       for (i = md->paramcount - 1, j = i + skipparams; i >= 0; i--, j--) {
                t = md->paramtypes[i].type;
 
                if (IS_INT_LNG_TYPE(t)) {
@@ -3281,17 +3260,19 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                }
        }
 
-       /* put class into second argument register */
+       /* Handle native Java methods. */
 
-       if (m->flags & ACC_STATIC) {
-               disp = dseg_add_address(cd, m->class);
-               M_ALD(REG_A1, REG_PV, disp);
-       }
+       if (m->flags & ACC_NATIVE) {
+               /* put class into second argument register */
+
+               if (m->flags & ACC_STATIC)
+                       M_MOV(REG_ITMP3, REG_A1);
 
-       /* put env into first argument register */
+               /* put env into first argument register */
 
-       disp = dseg_add_address(cd, _Jv_env);
-       M_ALD(REG_A0, REG_PV, disp);
+               disp = dseg_add_address(cd, _Jv_env);
+               M_ALD(REG_A0, REG_PV, disp);
+       }
 
        /* do the native function call */
 
@@ -3309,6 +3290,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                M_LST(REG_RESULT, REG_SP, 0 * 8);
                break;
        case TYPE_FLT:
+               M_FST(REG_FRESULT, REG_SP, 0 * 8);
+               break;
        case TYPE_DBL:
                M_DST(REG_FRESULT, REG_SP, 0 * 8);
                break;
@@ -3316,16 +3299,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                break;
        }
 
-       /* call finished trace */
-
-#if !defined(NDEBUG)
-       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
-               emit_verbosecall_exit(jd);
-#endif
-
        /* remove native stackframe info */
 
-       M_LDA(REG_A0, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_MOV(REG_SP, REG_A0);
+       M_MOV(REG_PV, REG_A1);
        disp = dseg_add_functionptr(cd, codegen_finish_native_call);
        M_ALD(REG_PV, REG_PV, disp);
        M_JSR(REG_RA, REG_PV);
@@ -3342,6 +3319,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                M_LLD(REG_RESULT, REG_SP, 0 * 8);
                break;
        case TYPE_FLT:
+               M_FLD(REG_FRESULT, REG_SP, 0 * 8);
+               break;
        case TYPE_DBL:
                M_DLD(REG_FRESULT, REG_SP, 0 * 8);
                break;