/* src/vm/jit/stack.c - stack analysis
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "arch.h"
#include "md-abi.h"
-#include "mm/memory.h"
+#include "mm/memory.hpp"
-#include "native/native.h"
+#include "native/native.hpp"
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
#include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
#include "vm/types.h"
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
#include "vm/jit/abi.h"
#include "vm/jit/cfg.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/show.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/show.hpp"
#if defined(ENABLE_DISASSEMBLER)
# include "vm/jit/disass.h"
#endif
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
#include "vm/jit/stack.h"
#if 0
#endif
#endif
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
/*#define STACK_VERBOSE*/
#endif
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-
-
/* For returnAddresses we use a field of the typeinfo to store from which */
/* subroutine the returnAddress will return, if used. */
/* XXX It would be nicer to use typeinfo.typeclass, but the verifier seems */
struct stackdata_t {
basicblock *bptr; /* the current basic block being analysed */
- stackptr new; /* next free stackelement */
+ stackelement_t *new; /* next free stackelement */
s4 vartop; /* next free variable index */
s4 localcount; /* number of locals (at the start of var) */
s4 varcount; /* maximum number of variables expected */
bool repeat; /* if true, iterate the analysis again */
exception_entry **handlers; /* exception handlers for the current block */
exception_entry *extableend; /* points to the last exception entry */
- stackelement exstack; /* instack for exception handlers */
+ stackelement_t exstack; /* instack for exception handlers */
};
/* forward declarations *******************************************************/
static void stack_create_invars(stackdata_t *sd, basicblock *b,
- stackptr curstack, int stackdepth);
+ stackelement_t * curstack, int stackdepth);
static void stack_create_invars_from_outvars(stackdata_t *sd, basicblock *b);
#if defined(STACK_VERBOSE)
static void stack_verbose_block_enter(stackdata_t *sd, bool reanalyse);
static void stack_verbose_block_exit(stackdata_t *sd, bool superblockend);
static void stack_verbose_show_state(stackdata_t *sd, instruction *iptr,
- stackptr curstack);
+ stackelement_t * curstack);
#endif
*******************************************************************************/
static void stack_create_invars(stackdata_t *sd, basicblock *b,
- stackptr curstack, int stackdepth)
+ stackelement_t * curstack, int stackdepth)
{
- stackptr sp;
+ stackelement_t * sp;
int i;
int index;
varinfo *dv;
*******************************************************************************/
static basicblock * stack_check_invars(stackdata_t *sd, basicblock *b,
- stackptr curstack, int stackdepth)
+ stackelement_t * curstack, int stackdepth)
{
int i;
- stackptr sp;
+ stackelement_t * sp;
basicblock *orig;
bool separable;
varinfo *sv;
*******************************************************************************/
-static stackptr stack_create_instack(stackdata_t *sd)
+static stackelement_t * stack_create_instack(stackdata_t *sd)
{
- stackptr sp;
+ stackelement_t * sp;
int depth;
int index;
*******************************************************************************/
-static basicblock *stack_mark_reached(stackdata_t *sd, basicblock *b, stackptr curstack, int stackdepth)
+static basicblock *stack_mark_reached(stackdata_t *sd, basicblock *b, stackelement_t * curstack, int stackdepth)
{
assert(b != NULL);
*******************************************************************************/
-static void stack_change_to_tempvar(stackdata_t *sd, stackptr sp,
+static void stack_change_to_tempvar(stackdata_t *sd, stackelement_t * sp,
instruction *ilimit)
{
s4 newindex;
registerdata *rd;
stackdata_t sd;
int stackdepth;
- stackptr curstack; /* current stack top */
- stackptr copy;
+ stackelement_t *curstack; /* current stack top */
+ stackelement_t *copy;
int opcode; /* opcode of current instruction */
int i, varindex;
int javaindex;
basicblock *original;
exception_entry *ex;
- stackptr *last_store_boundary;
- stackptr coalescing_boundary;
+ stackelement_t **last_store_boundary;
+ stackelement_t *coalescing_boundary;
- stackptr src1, src2, src3, src4, dst1, dst2;
+ stackelement_t *src1, *src2, *src3, *src4, *dst1, *dst2;
branch_target_t *table;
lookup_target_t *lookup;
for (i = 0; i < m->maxstack * 5; i++)
jd->interface_map[i].flags = UNUSED;
- last_store_boundary = DMNEW(stackptr, m->maxlocals);
+ last_store_boundary = DMNEW(stackelement_t *, m->maxlocals);
/* initialize flags and invars (none) of first block */
sd.jd->returnblock = sd.bptr;
break;
+ case ICMD_BREAKPOINT:
+ OP0_0;
+ break;
+
/* pop 0 push 1 const */
if ((copy->varkind == LOCALVAR) &&
(jd->reverselocalmap[copy->varnum] == javaindex))
{
- copy->varkind = TEMPVAR;
assert(IS_LOCALVAR(copy));
SET_TEMPVAR(copy);
}
break;
normal_LCMP:
#endif /* SUPPORT_LONG_CMP_CONST */
- OP2_1(TYPE_LNG, TYPE_LNG, TYPE_INT);
+ bte = builtintable_get_internal(BUILTIN_lcmp);
+
+ iptr->opc = ICMD_BUILTIN;
+ iptr->flags.bits &= INS_FLAG_ID_MASK;
+ iptr->sx.s23.s3.bte = bte;
+ /* iptr->line is already set */
+ code_unflag_leafmethod(code);
+ goto icmd_BUILTIN;
+
break;
case ICMD_FCMPL:
printf("\n");
}
-static void stack_verbose_show_state(stackdata_t *sd, instruction *iptr, stackptr curstack)
+static void stack_verbose_show_state(stackdata_t *sd, instruction *iptr, stackelement_t *curstack)
{
- stackptr sp;
+ stackelement_t *sp;
s4 i;
s4 depth;
varinfo *v;
- stackptr *stack;
+ stackelement_t **stack;
printf(" javalocals ");
show_javalocals_array(sd->jd, sd->javalocals, sd->maxlocals, SHOW_STACK);
i++;
depth = i;
- stack = MNEW(stackptr, depth);
+ stack = MNEW(stackelement_t *, depth);
for(sp = curstack; sp; sp = sp->prev)
stack[--i] = sp;