History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/tools/j2d/java.h (1 of 18352 files). Show all

Unified · Split

java/tools/j2d/java.h+452−0
@@ -0,0 +1,452 @@
1#include "lib9.h"
2#include "bio.h"
3#include "isa.h"
4
5enum {
6 /* Java constant pool tags */
7
8 CON_Utf8 = 1,
9 /* CON_Unicode = 2, */ /* obsolete */
10 CON_Integer = 3,
11 CON_Float = 4,
12 CON_Long = 5,
13 CON_Double = 6,
14 CON_Class = 7,
15 CON_String = 8,
16 CON_Fieldref = 9,
17 CON_Methodref = 10,
18 CON_InterfaceMref = 11,
19 CON_NameAndType = 12,
20
21 /* Java access flags */
22
23 ACC_PUBLIC = 0x0001,
24 ACC_PRIVATE = 0x0002,
25 ACC_PROTECTED = 0x0004,
26 ACC_STATIC = 0x0008,
27 ACC_FINAL = 0x0010,
28 ACC_SUPER = 0x0020,
29 ACC_SYNCHRONIZED = 0x0020, /* sic */
30 ACC_VOLATILE = 0x0040,
31 ACC_TRANSIENT = 0x0080,
32 ACC_NATIVE = 0x0100,
33 ACC_INTERFACE = 0x0200,
34 ACC_ABSTRACT = 0x0400,
35
36 _MUSTCOMPILE = MUSTCOMPILE<<16,
37 _DONTCOMPILE = DONTCOMPILE<<16,
38
39 /* basic block flags */
40
41 BB_LDR = 1 << 0, /* set for all leaders */
42 BB_ENTRY = 1 << 1, /* method entry point */
43 BB_FINALLY = 1 << 2, /* finally block entry point */
44 BB_HANDLER = 1 << 3, /* EH entry point */
45 BB_REACHABLE = 1 << 4, /* reachable basic block */
46
47 /* basic block states */
48
49 BB_PRESIM = 1 << 0, /* not simulated yet */
50 BB_ACTIVE = 1 << 1, /* simulating or being unified */
51 BB_POSTSIM = 1 << 2, /* simulated */
52 BB_POSTUNIFY = 1 << 3, /* unified */
53
54 /* Dis operand classification */
55
56 Anone = 0,
57 Aimm,
58 Amp,
59 Ampind,
60 Afp,
61 Afpind,
62 Aend,
63
64 /* Dis n(fp) types */
65
66 DIS_X = 0, /* not yet typed */
67 DIS_W, /* 'B', 'Z', 'C', 'S', 'I' */
68 DIS_L, /* 'F', 'J', 'D' */
69 DIS_P, /* 'L', '[' */
70
71 /* inferno/vm/Array */
72
73 ARY_DATA = IBY2WD, /* Array data (Dis array) */
74 ARY_NDIM = 2*IBY2WD, /* number of dimensions */
75 ARY_ADT = 3*IBY2WD, /* 'ref Class' of element type */
76 ARY_ETYPE = 4*IBY2WD, /* primitive element type code */
77
78 /* java/lang/String */
79
80 STR_DISSTR = IBY2WD, /* offset to Dis string in a String */
81
82 /* miscellaneous */
83
84 REFSYSEX = 24, /* 24(fp) is a 'ref Sys->Exception' */
85 EXOBJ = 28, /* 28(fp) is exception object */
86 THISOFF = 32, /* 32(fp) is "this" pointer */
87 REGSIZE = 32, /* 32(fp) is first usable frame cell */
88 Hashsize = 31,
89 ALLOCINCR = 16
90};
91
92typedef struct Attr Attr;
93typedef struct Field Field;
94typedef struct Method Method;
95typedef union Const Const;
96typedef struct Class Class;
97typedef struct Jinst Jinst;
98typedef struct StkSnap StkSnap;
99typedef struct BB BB;
100typedef struct BBList BBList;
101typedef struct Code Code;
102typedef struct PCode PCode;
103typedef struct Handler Handler;
104
105typedef struct Addr Addr;
106typedef struct Inst Inst;
107
108union Const {
109 double tdouble; /* CONSTANT_[Float|Double]_info */
110 vlong tvlong; /* CONSTANT_Long_info */
111 int tint; /* CONSTANT_Integer_info */
112 ushort string_index; /* CONSTANT_String_info */
113 struct { /* CONSTANT_Class_info */
114 ushort name_index;
115 } ci;
116 /* CONSTANT_[Fieldref|Methodref|InterfaceMethodref]_info */
117 struct {
118 ushort class_index;
119 ushort name_type_index;
120 } fmiref;
121 struct { /* CONSTANT_NameAndType */
122 ushort name_index;
123 ushort sig_index;
124 } nat;
125 struct { /* CONSTANT_Utf8_info */
126 ushort ln;
127 char *utf8;
128 } utf8;
129};
130
131struct Attr { /* attribute_info */
132 ushort name;
133 uint ln;
134 uchar *info;
135};
136
137struct Field { /* field_info */
138 ushort access_flags;
139 ushort name_index;
140 ushort sig_index;
141 ushort attr_count;
142 Attr *attr_info; /* ConstantValue attributes */
143};
144
145struct Method { /* method_info */
146 ushort access_flags;
147 ushort name_index;
148 ushort sig_index;
149 ushort attr_count;
150 Attr *attr_info; /* Code, Exceptions attributes */
151};
152
153struct Class { /* ClassFile */
154 /* uint magic; */ /* 0xcafebabe */
155 ushort min;
156 ushort maj;
157 ushort cp_count;
158 Const *cps;
159 char *cts;
160 ushort access_flags;
161 ushort this_class;
162 ushort super_class;
163 ushort interfaces_count;
164 ushort *interfaces;
165 ushort fields_count;
166 Field *fields;
167 ushort methods_count;
168 Method *methods;
169 ushort source_file;
170};
171
172struct Addr { /* Dis operand */
173 uchar mode; /* Anone, Aimm, Amp, etc. */
174 union {
175 int ival; /* immediate, $ival */
176 int offset; /* single indirect, offset(fp) */
177 struct { /* double indirect, si(fi(fp)) */
178 ushort fi;
179 ushort si;
180 } b;
181 } u;
182};
183
184struct Jinst { /* Java instruction */
185 uchar op; /* op code */
186 uchar jtype; /* Java type of dst ('I', '[', etc.) */
187 int pc; /* pc offset */
188 int line; /* source line number */
189 int size; /* size of this instruction */
190 Inst *dis; /* Dis code for this instruction */
191 BB *bb; /* the instruction's basic block */
192 int nsrc; /* 0 or more source operands */
193 int *src;
194 Addr dst; /* usual destination operand */
195 Addr movsrc; /* source operand if mov generated for load */
196 union {
197 int i; /* AT, X1, X2, B2, B4, V1, V2 */
198 struct { /* iinc */
199 uint ix;
200 int icon;
201 } x1c;
202 struct { /* invokeinterface */
203 uint ix;
204 uint narg;
205 uint zero;
206 } x2c0;
207 struct { /* multianewarray */
208 uint ix;
209 uint dim;
210 } x2d;
211 struct { /* tableswitch */
212 int dflt;
213 int lb;
214 int hb;
215 int *tbl;
216 } t1;
217 struct { /* lookupswitch */
218 int dflt;
219 int np;
220 int *tbl;
221 } t2;
222 struct { /* wide */
223 uchar op;
224 uint ix;
225 int icon;
226 } w;
227 } u;
228};
229
230struct Handler { /* exception_table entry */
231 ushort start_pc;
232 ushort end_pc;
233 ushort handler_pc;
234 ushort catch_type;
235};
236
237struct Code { /* one Java method */
238 int max_stack;
239 int max_locals;
240 int code_length;
241 Jinst *j;
242 int nex;
243 Handler **ex;
244};
245
246struct PCode {
247 Code *code;
248 char *name;
249 char *sig;
250};
251
252struct StkSnap { /* snapshot of simulated Java VM stack */
253 uchar jtype;
254 int npc;
255 int *pc;
256};
257
258struct BB { /* basic block */
259 int id; /* unique identifier */
260 Jinst *js; /* first instruction in basic block */
261 Jinst *je; /* last instruction in basic block */
262 BBList *succ; /* successors */
263 BBList *pred; /* predecessors */
264 uchar *dom; /* bit-vector of dominators */
265 uchar flags; /* basic block leader flags */
266 uchar state; /* BB_PRESIM, etc. */
267 int entrysz; /* size of saved entry stack */
268 StkSnap *entrystk; /* snapshot of entry stack */
269 int exitsz; /* size of saved exit stack */
270 StkSnap *exitstk; /* snapshot of exit stack */
271};
272
273struct BBList {
274 BB *bb;
275 BBList *next;
276};
277
278struct Inst { /* Dis instruction */
279 uchar op; /* op code */
280 Addr s; /* source */
281 Addr m; /* middle */
282 Addr d; /* destination */
283 int pc; /* 0-based instruction offset */
284 Jinst *j;
285 Inst *next;
286};
287
288/* asm.c */
289extern int Aconv(va_list*, Fconv*);
290extern int Iconv(va_list*, Fconv*);
291extern void asminst(void);
292extern void sblinst(Biobuf*);
293extern Inst *clinitclone;
294
295/* bb.c */
296extern void flowgraph(void);
297extern void bbfree(void);
298extern void bbinit(void);
299extern void bbput(BB*);
300extern BB *bbget(void);
301extern void crefseed(void);
302extern void crefenter(char*, BB*);
303extern int crefstate(char*, BB*, int);
304extern void creffree(void);
305
306/* desc.c */
307extern int descid(int, int, uchar*);
308extern void mpdescid(int, int, uchar*);
309extern void asmdesc(void);
310extern void disndesc(void);
311extern void disdesc(void);
312
313/* dis.c */
314extern void discon(int);
315extern void disword(int);
316extern void disdata(int, int);
317extern void disflush(int, int, int);
318extern void disbyte(int, int);
319extern void disint(int, int);
320extern void dislong(int, vlong);
321extern void disreal(int, double);
322extern void disstring(int, char*);
323extern void disarray(int, int, int);
324extern void disapop(void);
325extern void disout(void);
326extern Inst *ihead;
327extern Inst *itail;
328
329/* entry.c */
330extern void setentry(int, int);
331extern void asmentry(void);
332extern void disentry(void);
333
334/* finally.c */
335extern void finallyentry(int);
336extern void finallyalloc(void);
337extern void jsrfixup(Addr*, Addr*, int, int);
338extern void retfixup(Addr*, Addr*, int);
339extern void finallyfree(void);
340
341/* frame.c */
342extern void openframe(char*, int);
343extern int closeframe(void);
344extern int localix(uchar, int);
345extern void reservereg(StkSnap*, int);
346extern int getreg(uchar);
347extern void acqreg(Addr*);
348extern void relreg(Addr*);
349extern void clearreg(void);
350extern void disstackext(void);
351
352/* javadas.c */
353extern int Jconv(va_list*, Fconv*);
354extern Code *javadas(Attr*);
355
356/* javatbl.c */
357extern int isload(Jinst*);
358extern int isstore(Jinst*);
359
360/* links.c */
361extern void xtrnlink(int, int, char*, char*);
362extern void addfcpatch(Inst*, Inst*, char*, char*);
363extern void dofcpatch(void);
364extern void asmlinks(void);
365extern void disnlinks(void);
366extern void dislinks(void);
367extern void sbllinks(Biobuf*);
368
369/* loader.c */
370extern void ClassLoader(char*);
371extern void dumpcpool(void);
372extern char *CLASSNAME(int);
373extern char *STRING(int);
374extern Class *class;
375extern PCode *pcode;
376extern char *THISCLASS;
377extern char *SUPERCLASS;
378
379/* main.c */
380extern int compileflag;
381extern int gensbl;
382extern int verbose;
383extern Biobuf *bout;
384extern char *ofile;
385
386/* mdata.c */
387extern int mpint(int);
388extern int mplong(vlong);
389extern int mpreal(double);
390extern int mpstring(char*);
391extern int mpcase(int, int*);
392extern void mpdesc(void);
393extern int mpgoto(int, int*);
394extern void asmarray(int, int, int, int);
395extern void asmint(int, int);
396extern void asmstring(int, char*);
397extern void asmvar(void);
398extern void disnvar(void);
399extern void disvar(void);
400
401/* module.c */
402extern void asmmod(void);
403extern void dismod(void);
404
405/* patch.c */
406extern void patchop(Inst*);
407extern void patchcase(Inst*, int, int*);
408extern void patchmethod(int);
409extern void patchfree(void);
410
411/* sbl.c */
412extern void sblout(char*);
413
414/* simjvm.c */
415extern void simjvm(char*);
416
417/* unify.c */
418extern void unify(void);
419
420/* util.c */
421extern void uSet(uchar*);
422extern void uN(int);
423extern uchar u1(void);
424extern ushort u2(void);
425extern uint u4(void);
426extern void getattr(Attr*);
427extern int CVattrindex(Field*);
428extern char *uPtr(void);
429extern int align(int, int);
430extern void pstring(char*);
431extern void fatal(char*, ...);
432extern void verifycpindex(Jinst*, int, int);
433extern void verifyerror(Jinst*);
434extern void verifyerrormess(char*);
435extern char *nextjavatype(char*);
436extern uchar j2dtype(uchar);
437extern void addrimm(Addr*, int);
438extern int notimmable(int);
439extern void addrsind(Addr*, uchar, int);
440extern void addrdind(Addr*, uchar, uint, uint);
441extern void dstreg(Addr*, uchar);
442extern void setbit(uchar*, int);
443extern int hashval(char*);
444extern void *Malloc(uint);
445extern void *Mallocz(uint);
446extern void *Realloc(void*, uint);
447extern int cellsize[];
448
449/* xlate.c */
450extern void xlate(void);
451extern Code *code;
452#pragma varargck type "A" Addr*