GNU header update.
[cacao.git] / src / vm / jit / loop / tracing.c
index 7df83eb91bec61a7270e9f4130ade49499623fb6..a4eb20dc764a954529f32deb55bca9cbac0ca32a 100644 (file)
@@ -1,9 +1,9 @@
-/* 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 557 2003-11-02 22:51:59Z twisti $
+   $Id: tracing.c 1735 2004-12-07 14:33:27Z twisti $
 
 */
 
 
-#include <stdio.h>
-#include "tracing.h"
-#include "loop.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
@@ -71,11 +73,11 @@ void printTraceResult(struct Trace *p)
     
 /*     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();
+       Trace *t;
+
+       t = DNEW(Trace);
 
        t->type = type;
 
@@ -93,7 +95,7 @@ struct Trace* create_trace(int type, int var, int constant, int nr)
        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  */
@@ -141,7 +143,7 @@ struct Trace* add(struct Trace* a, struct Trace* b)
        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       */
@@ -168,9 +170,9 @@ struct Trace* negate(struct Trace* a)
        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);
 }
 
@@ -180,7 +182,7 @@ struct Trace* sub(struct Trace* a, struct Trace* b)
        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      */
@@ -191,21 +193,26 @@ struct Trace* array_length(struct Trace* a)
 }
 
 
-/*     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;
@@ -463,10 +470,8 @@ struct Trace* tracing(basicblock *block, int index, int temp)
                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        */