* src/vm/jit/arm/codegen.c (codegen_emit_stub_builtin): Removed.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Sat, 8 Sep 2007 13:57:35 +0000 (15:57 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Sat, 8 Sep 2007 13:57:35 +0000 (15:57 +0200)
(codegen_emit_stub_native): Deals with builtin stubs as well now.

--HG--
branch : michi

src/vm/jit/arm/codegen.c

index 0dbb7e3700e818ac4cdc2c35b8999d827d904482..d2c42dd0a281c44341c0de573f939eb6b967e753 100644 (file)
@@ -2907,143 +2907,6 @@ void codegen_emit_stub_compiler(jitdata *jd)
 }
 
 
-/* codegen_emit_stub_builtin ***************************************************
-
-   Emits a stub routine which calls a builtin function.
-
-*******************************************************************************/
-
-void codegen_emit_stub_builtin(jitdata *jd, builtintable_entry *bte)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       methoddesc  *md;
-       s4           i;
-       s4           disp;
-       s4           s1;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* set some variables */
-
-       md = bte->md;
-
-       /* calculate stack frame size */
-
-       cd->stackframesize =
-               SIZEOF_VOID_P +                                    /* return address  */
-               sizeof(stackframeinfo);                            /* stackframeinfo  */
-
-       /* align stack to 8-byte */
-
-       cd->stackframesize = (cd->stackframesize + 4) & ~4;
-
-       /* create method header */
-
-       (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
-       (void) dseg_add_unique_s4(cd, cd->stackframesize);     /* FrameSize       */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IsLeaf          */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IntSave         */
-       (void) dseg_add_unique_s4(cd, 0);                      /* FltSave         */
-       (void) dseg_addlinenumbertablesize(cd);
-       (void) dseg_add_unique_s4(cd, 0);                      /* ExTableSize     */
-
-       /* generate stub code */
-
-       M_SUB_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize / 4 - 1);
-       M_STMFD(1<<REG_LR, REG_SP);
-
-#if defined(ENABLE_GC_CACAO)
-       /* Save callee saved integer registers in stackframeinfo (GC may
-          need to recover them during a collection). */
-
-       disp = cd->stackframesize - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, intregs);
-
-       for (i = 0; i < INT_SAV_CNT; i++)
-               M_STR_INTERN(abi_registers_integer_saved[i], REG_SP, disp + i * 4);
-#endif
-
-       /* Save integer and float argument registers (these are 4
-          registers, stack is 8-byte aligned). */
-
-       M_STMFD(BITMASK_ARGS, REG_SP);
-
-       /* create builtin stackframe info */
-
-       assert(IS_IMM(4*4 + cd->stackframesize));
-       M_ADD_IMM(REG_A0, REG_SP, 4*4 + cd->stackframesize);
-       M_MOV(REG_A1, REG_PV);
-       M_ADD_IMM(REG_A2, REG_SP, 4*4 + cd->stackframesize);
-       M_LDR_INTERN(REG_A3, REG_SP, 4*4);
-       disp = dseg_add_functionptr(cd, codegen_stub_builtin_enter);
-       M_DSEG_BRANCH(disp);
-
-       s1 = (s4) (cd->mcodeptr - cd->mcodebase);
-       M_RECOMPUTE_PV(s1);
-
-       /* Restore integer and float argument registers (these are 4
-          registers, stack is 8-byte aligned). */
-
-       M_LDMFD(BITMASK_ARGS, REG_SP);
-
-       /* builtins are allowed to have 4 arguments max */
-
-       assert(md->paramcount <= 4);
-       for (i = 0; i < md->paramcount; i++) {
-               assert(!IS_2_WORD_TYPE(md->paramtypes[i].type));
-       }
-
-       /* call the builtin function */
-
-       disp = dseg_add_functionptr(cd, bte->fp);
-       M_DSEG_BRANCH(disp);
-
-       /* recompute pv */
-
-       s1 = (s4) (cd->mcodeptr - cd->mcodebase);
-       M_RECOMPUTE_PV(s1);
-
-       /* save return value */
-
-       assert(!IS_FLT_DBL_TYPE(md->returntype.type));
-       M_STMFD(BITMASK_RESULT, REG_SP);
-
-       /* remove builtin stackframe info */
-
-       M_ADD_IMM(REG_A0, REG_SP, 2*4 + cd->stackframesize);
-       disp = dseg_add_functionptr(cd, codegen_stub_builtin_exit);
-       M_DSEG_BRANCH(disp);
-       /*s1 = (s4) (cd->mcodeptr - cd->mcodebase);
-       M_RECOMPUTE_PV(s1);*/
-
-       /* restore return value */
-
-       M_LDMFD(BITMASK_RESULT, REG_SP);
-
-#if defined(ENABLE_GC_CACAO)
-       /* Restore callee saved integer registers from stackframeinfo (GC
-          might have modified them during a collection). */
-        
-       disp = cd->stackframesize - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, intregs);
-
-       for (i = 0; i < INT_SAV_CNT; i++)
-               M_LDR_INTERN(abi_registers_integer_saved[i], REG_SP, disp + i * 4);
-#endif
-
-       /* remove stackframe and return */
-
-       M_LDMFD(1<<REG_LR, REG_SP);
-       M_ADD_IMM_EXT_MUL4(REG_SP, REG_SP, cd->stackframesize / 4 - 1);
-       M_MOV(REG_PC, REG_LR);
-}
-
-
 /* codegen_emit_stub_native ****************************************************
 
    Emits a stub routine which calls a native method.
@@ -3070,7 +2933,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        /* initialize variables */
 
        md = m->parseddesc;
-       nativeparams = (m->flags & ACC_STATIC) ? 2 : 1;
+       nativeparams  = (m->flags & ACC_NATIVE) ? 1 : 0;
+       nativeparams += (m->flags & ACC_STATIC) ? 1 : 0;
 
        /* calculate stackframe size */
 
@@ -3209,8 +3073,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* put env into first argument register */
 
-       disp = dseg_add_address(cd, _Jv_env);
-       M_DSEG_LOAD(REG_A0, disp);
+       if (m->flags & ACC_NATIVE) {
+               disp = dseg_add_address(cd, _Jv_env);
+               M_DSEG_LOAD(REG_A0, disp);
+       }
 
        /* do the native function call */