DEADSOFTWARE

Patched for Linux
[mp3cc.git] / MPC.3.5.LINUX / preverifier / check_code.h
1 /*
2 * @(#)check_code.h 1.3 02/09/27
3 *
4 * Copyright 1995-1999 by Sun Microsystems, Inc.,
5 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
6 * All rights reserved.
7 *
8 * This software is the confidential and proprietary information
9 * of Sun Microsystems, Inc. ("Confidential Information"). You
10 * shall not disclose such Confidential Information and shall use
11 * it only in accordance with the terms of the license agreement
12 * you entered into with Sun.
13 * Use is subject to license terms.
14 */
16 #include <setjmp.h>
18 #include "oobj.h"
19 #include "opcodes.h"
20 #include "tree.h"
21 #include "sys_api.h"
23 #define MAX_ARRAY_DIMENSIONS 255
26 #define UNKNOWN_STACK_SIZE -1
27 #define UNKNOWN_REGISTER_COUNT -1
28 #define UNKNOWN_RET_INSTRUCTION -1
30 #undef MAX
31 #undef MIN
32 #define MAX(a, b) ((a) > (b) ? (a) : (b))
33 #define MIN(a, b) ((a) < (b) ? (a) : (b))
35 #define BITS_PER_INT (CHAR_BIT * sizeof(int)/sizeof(char))
36 #define SET_BIT(flags, i) (flags[(i)/BITS_PER_INT] |= \
37 ((unsigned)1 << ((i) % BITS_PER_INT)))
38 #define IS_BIT_SET(flags, i) (flags[(i)/BITS_PER_INT] & \
39 ((unsigned)1 << ((i) % BITS_PER_INT)))
41 typedef unsigned long fullinfo_type;
42 typedef unsigned int *bitvector;
44 #define GET_ITEM_TYPE(thing) ((thing) & 0x1F)
45 #define GET_INDIRECTION(thing) (((thing) & 0xFFFF) >> 5)
46 #define GET_EXTRA_INFO(thing) ((unsigned short)((thing) >> 16))
47 #define WITH_ZERO_INDIRECTION(thing) ((thing) & ~(0xFFE0))
48 #define WITH_ZERO_EXTRA_INFO(thing) ((thing) & 0xFFFF)
50 #define MAKE_FULLINFO(type, indirect, extra) \
51 ((fullinfo_type)((type) + ((indirect) << 5) + ((extra) << 16)))
52 #define MAKE_CLASSNAME_INFO(context, classname, addr) \
53 MAKE_FULLINFO(ITEM_Object, 0, \
54 Str2ID_Local(context, &context->classHash, (classname), (addr), FALSE))
55 #define MAKE_CLASSNAME_INFO_WITH_COPY(context, classname, addr) \
56 MAKE_FULLINFO(ITEM_Object, 0, \
57 Str2ID_Local(context, &context->classHash, (classname), (addr), TRUE))
58 #define MAKE_Object_ARRAY(indirect) \
59 (context->object_info + ((indirect) << 5))
61 #define NULL_FULLINFO MAKE_FULLINFO(ITEM_Object, 0, 0)
63 /* opc_invokespecial calls to <init> need to be treated special */
64 #define opc_invokeinit 0x100
66 struct context_type {
67 /* these fields are per class */
68 ClassClass *class; /* current class */
69 struct StrIDhash *classHash;
70 fullinfo_type object_info; /* fullinfo for java/lang/Object */
71 fullinfo_type string_info; /* fullinfo for java/lang/String */
72 fullinfo_type throwable_info; /* fullinfo for java/lang/Throwable */
74 fullinfo_type currentclass_info; /* fullinfo for context->class */
75 fullinfo_type superclass_info; /* fullinfo for superclass */
77 /* these fields are per method */
78 struct methodblock *mb; /* current method */
79 unsigned char *code; /* current code object */
80 short *code_data; /* offset to instruction number */
81 struct instruction_data_type *instruction_data; /* info about each */
82 struct handler_info_type *handler_info;
83 fullinfo_type *superClasses; /* null terminated superclasses */
84 int instruction_count; /* number of instructions */
85 fullinfo_type return_type; /* function return type */
86 fullinfo_type swap_table[4]; /* used for passing information */
87 int bitmask_size; /* words needed to hold bitmap of arguments */
89 /* Used by inliner */
90 bool_t redoJsr;
92 /* Used by the space allocator */
93 struct CCpool *CCroot, *CCcurrent;
94 char *CCfree_ptr;
95 int CCfree_size;
97 /* Jump here on any error. */
98 jmp_buf jump_buffer;
99 };
101 struct stack_info_type {
102 struct stack_item_type *stack;
103 int stack_size;
104 };
106 struct register_info_type {
107 int register_count; /* number of registers used */
108 fullinfo_type *registers;
109 int mask_count; /* number of masks in the following */
110 struct mask_type *masks;
111 };
113 struct mask_type {
114 int entry;
115 int *modifies;
116 };
118 typedef unsigned short flag_type;
120 struct instruction_data_type {
121 opcode_type opcode; /* may turn into "canonical" opcode */
122 unsigned changed:1; /* has it changed */
123 unsigned protected:1; /* must accessor be a subclass of "this" */
124 unsigned is_target:1;
126 union {
127 int i; /* operand to the opcode */
128 int *ip;
129 fullinfo_type fi;
130 } operand, operand2;
131 fullinfo_type p;
132 struct stack_info_type stack_info;
133 struct register_info_type register_info;
134 #define FLAG_REACHED 0x01 /* instruction reached */
135 #define FLAG_NEED_CONSTRUCTOR 0x02 /* must call this.<init> or super.<init> */
136 #define FLAG_NO_RETURN 0x04 /* must throw out of method */
137 flag_type or_flags; /* true for at least one path to this inst */
138 #define FLAG_CONSTRUCTED 0x01 /* this.<init> or super.<init> called */
139 flag_type and_flags; /* true for all paths to this instruction */
140 unsigned short offset;
141 unsigned short length;
142 };
144 struct handler_info_type {
145 int start, end, handler;
146 struct stack_info_type stack_info;
147 };
149 struct stack_item_type {
150 fullinfo_type item;
151 struct stack_item_type *next;
152 };
155 typedef struct context_type context_type;
156 typedef struct instruction_data_type instruction_data_type;
157 typedef struct stack_item_type stack_item_type;
158 typedef struct register_info_type register_info_type;
159 typedef struct stack_info_type stack_info_type;
160 typedef struct mask_type mask_type;