* src/vm/jit/alpha/emit.c [ENABLE_THREADS] (threads/native/lock.h):
[cacao.git] / src / vm / jit / stack.c
index ea1502e828cba21006fe1f8fae1ab0dac62c146e..beb5a6c8f78c77646fdccea52c6831e80c9f3053 100644 (file)
@@ -30,7 +30,7 @@
             Christian Thalinger
             Christian Ullrich
 
-   $Id: stack.c 5221 2006-08-08 13:25:33Z twisti $
+   $Id: stack.c 5251 2006-08-18 13:01:00Z twisti $
 
 */
 
@@ -2615,11 +2615,11 @@ icmd_BUILTIN:
 
 #if defined(SPECIALMEMUSE)
 # if defined(__DARWIN__)
-                                               if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
-                                                       rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
+                                               if (rd->memuse < (i + INT_ARG_CNT + LA_SIZE_IN_POINTERS))
+                                                       rd->memuse = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
 # else
-                                               if (rd->memuse < (i + LA_WORD_SIZE + 3))
-                                                       rd->memuse = i + LA_WORD_SIZE + 3;
+                                               if (rd->memuse < (i + LA_SIZE_IN_POINTERS + 3))
+                                                       rd->memuse = i + LA_SIZE_IN_POINTERS + 3;
 # endif
 #else
 # if defined(__I386__)
@@ -2643,9 +2643,9 @@ icmd_BUILTIN:
                                                                copy->flags |= INMEMORY;
 #if defined(SPECIALMEMUSE)
 # if defined(__DARWIN__)
-                                                               copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
+                                                               copy->regoff = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
 # else
-                                                               copy->regoff = i + LA_WORD_SIZE + 3;
+                                                               copy->regoff = i + LA_SIZE_IN_POINTERS + 3;
 # endif
 #else
 # if defined(__I386__)
@@ -2873,10 +2873,6 @@ bool stack_analyse(jitdata *jd)
        cd   = jd->cd;
        rd   = jd->rd;
 
-#if defined(ENABLE_LSRA)
-       m->maxlifetimes = 0;
-#endif
-
        last_store = DMNEW(s4 , cd->maxlocals * 5);
        
        new = m->stack;
@@ -2944,10 +2940,18 @@ bool stack_analyse(jitdata *jd)
                                while (--len >= 0)  {
                                        opcode = iptr->opc;
 
+                                       /* check if ICMD opcode could throw an exception        */
+                                       /* and if so remember the instruction index in last_pei */
+
+                                       if (op_data[opcode][PEI])
+                                               last_pei = bptr->icount - len - 1;
+
 #if defined(USEBUILTINTABLE)
 # if defined(ENABLE_INTRP)
                                        if (!opt_intrp) {
 # endif
+                                               /* check for opcodes to replace */
+
                                                bte = builtintable_get_automatic(opcode);
 
                                                if (bte && bte->opcode == opcode) {
@@ -2962,6 +2966,12 @@ bool stack_analyse(jitdata *jd)
 # endif
 #endif /* defined(USEBUILTINTABLE) */
 
+                                       /* Check for functions to replace with builtin
+                                          functions. */
+
+                                       if (builtintable_replace_function(iptr))
+                                               goto builtin;
+
                                        /* this is the main switch */
 
                                        switch (opcode) {
@@ -4878,9 +4888,7 @@ bool stack_analyse(jitdata *jd)
                                        /* pop many push any */
 
                                        case ICMD_BUILTIN:
-#if defined(USEBUILTINTABLE)
                                        builtin:
-#endif
                                                bte = (builtintable_entry *) iptr->val.a;
                                                md = bte->md;
                                                goto _callhandling;
@@ -4896,7 +4904,7 @@ bool stack_analyse(jitdata *jd)
 
                                        _callhandling:
 
-                                               last_pei = bptr->icount - len - 1;
+/*                                             last_pei = bptr->icount - len - 1; */
 
                                                i = md->paramcount;
 
@@ -4985,11 +4993,11 @@ bool stack_analyse(jitdata *jd)
                                                REQUIRE(i);
 #if defined(SPECIALMEMUSE)
 # if defined(__DARWIN__)
-                                               if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
-                                                       rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
+                                               if (rd->memuse < (i + INT_ARG_CNT + LA_SIZE_IN_POINTERS))
+                                                       rd->memuse = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
 # else
-                                               if (rd->memuse < (i + LA_WORD_SIZE + 3))
-                                                       rd->memuse = i + LA_WORD_SIZE + 3;
+                                               if (rd->memuse < (i + LA_SIZE_IN_POINTERS + 3))
+                                                       rd->memuse = i + LA_SIZE_IN_POINTERS + 3;
 # endif
 #else
 # if defined(__I386__)
@@ -5012,9 +5020,9 @@ bool stack_analyse(jitdata *jd)
                                                                copy->flags |= INMEMORY;
 #if defined(SPECIALMEMUSE)
 # if defined(__DARWIN__)
-                                                               copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
+                                                               copy->regoff = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
 # else
-                                                               copy->regoff = i + LA_WORD_SIZE + 3;
+                                                               copy->regoff = i + LA_SIZE_IN_POINTERS + 3;
 # endif
 #else
 # if defined(__I386__)
@@ -5179,7 +5187,7 @@ throw_stack_overflow:
        return false;
 
 throw_stack_depth_error:
-       exceptions_throw_verifyerror(m,"Stack depth mismatch");
+       exceptions_throw_verifyerror(m, "Stack depth mismatch");
        return false;
 
 throw_stack_type_error: