-/* jit/loop/tracing.c - trace functions
+/* vm/jit/loop/tracing.c - trace functions
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
- R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
- M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
- P. Tomsich, J. Wenninger
+ Copyright (C) 1996-2005 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
This file is part of CACAO.
instruction. For more details see function tracing(basicblock, int,
int) below.
- $Id: tracing.c 1141 2004-06-05 23:19:24Z twisti $
+ $Id: tracing.c 1735 2004-12-07 14:33:27Z twisti $
*/
-#include <stdio.h>
-#include "jit/loop/tracing.h"
-#include "jit/loop/loop.h"
-#include "toolbox/memory.h"
+/* #include <stdio.h> */
+
+#include "mm/memory.h"
+#include "vm/jit/loop/loop.h"
+#include "vm/jit/loop/tracing.h"
/* Test function -> will be removed in final release
/* A function that creates a new trace structure and initializes its values
*/
-struct Trace* create_trace(int type, int var, int constant, int nr)
+Trace* create_trace(int type, int var, int constant, int nr)
{
- struct Trace *t;
-/* if ((t = (struct Trace *) malloc(sizeof(struct Trace))) == NULL) */
-/* c_mem_error(); */
- t = DNEW(struct Trace);
+ Trace *t;
+
+ t = DNEW(Trace);
t->type = type;
backward scan over the instructions, it trys to identify the source of the
arguments of this add function. The following function performs this task.
*/
-struct Trace* add(struct Trace* a, struct Trace* b)
+Trace* add(Trace* a, Trace* b)
{
switch (a->type) { /* check the first argument of add. when it */
case TRACE_UNKNOWN: /* is unknown or array-address, return unknown */
backward scan over the instructions, it trys to identify the source of the
argument of this neg function. The following function performs this task.
*/
-struct Trace* negate(struct Trace* a)
+Trace* negate(Trace* a)
{
switch (a->type) { /* check argument type */
case TRACE_IVAR: /* when it is variable/array length value */
this sub function. The following function performs this task, by applaying the
negate function on the second argument and then adds the values.
*/
-struct Trace* sub(struct Trace* a, struct Trace* b)
+Trace* sub(Trace* a, Trace* b)
{
- struct Trace *c = negate(b);
+ Trace *c = negate(b);
return add(a, c);
}
the argument ofthis array length function. The following function performs
this task.
*/
-struct Trace* array_length(struct Trace* a)
+Trace* array_length(Trace* a)
{
if (a->type == TRACE_AVAR) /* if argument is an array ref., mark the type */
a->type = TRACE_ALENGTH; /* as array length of this array reference */
}
-/* This function is used to identify the types of operands of an intermediate
- code instruction.It is needed by functions, that analyze array accesses. If
- something is stored into or loaded from an array, we have to find out, which
- array really has been accessed. When a compare instruction is encountered at
- a loop header, the type of its operands have to be detected to construct
- dynamic bounds for some variables in the loop. This function returns a struct
- Trace (see loop.h for more details about this structure). block is the basic
- block to be examined, index holds the offset of the examined instruction in
- this block. The arguments are retrieved by using the stack structure, the
- compilation process sets up. During the backwards scan of the code, it is
- possible, that other instructions temporaray put or get values from the stack
- and hide the value, we are interested in below them. The value temp counts
- the number of values on the stack, the are located beyond the target value.
-*/
-struct Trace* tracing(basicblock *block, int index, int temp)
+/* tracing *********************************************************************
+
+ This function is used to identify the types of operands of an intermediate
+ code instruction. It is needed by functions, that analyze array accesses. If
+ something is stored into or loaded from an array, we have to find out,
+ which array really has been accessed. When a compare instruction is
+ encountered at a loop header, the type of its operands have to be detected
+ to construct dynamic bounds for some variables in the loop. This function
+ returns a struct Trace (see loop.h for more details about this structure).
+ block is the basic block to be examined, index holds the offset of the
+ examined instruction in this block. The arguments are retrieved by using
+ the stack structure, the compilation process sets up. During the backwards
+ scan of the code, it is possible, that other instructions temporary put or
+ get values from the stack and hide the value, we are interested in below
+ them. The value temp counts the number of values on the stack, the are
+ located beyond the target value.
+
+*******************************************************************************/
+
+Trace* tracing(basicblock *block, int index, int temp)
{
int args, retval;
instruction *ip;
case ICMD_LUSHRCONST: /* ..., value ==> ..., value >>> constant */
case ICMD_IANDCONST: /* ..., value ==> ..., value & constant */
case ICMD_IREMPOW2: /* ..., value ==> ..., value % constant */
- case ICMD_IREM0X10001: /* ..., value ==> ..., value % 0x100001 */
case ICMD_LANDCONST: /* ..., value ==> ..., value & constant */
case ICMD_LREMPOW2: /* ..., value ==> ..., value % constant */
- case ICMD_LREM0X10001: /* ..., value ==> ..., value % 0x10001 */
case ICMD_IORCONST: /* ..., value ==> ..., value | constant */
case ICMD_LORCONST: /* ..., value ==> ..., value | constant */
case ICMD_IXORCONST: /* ..., value ==> ..., value ^ constant */