Showing the changes to java/tools/j2d/java.h (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,452 @@ | |||
| 1 | #include "lib9.h" | ||
| 2 | #include "bio.h" | ||
| 3 | #include "isa.h" | ||
| 4 | |||
| 5 | enum { | ||
| 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 | |||
| 92 | typedef struct Attr Attr; | ||
| 93 | typedef struct Field Field; | ||
| 94 | typedef struct Method Method; | ||
| 95 | typedef union Const Const; | ||
| 96 | typedef struct Class Class; | ||
| 97 | typedef struct Jinst Jinst; | ||
| 98 | typedef struct StkSnap StkSnap; | ||
| 99 | typedef struct BB BB; | ||
| 100 | typedef struct BBList BBList; | ||
| 101 | typedef struct Code Code; | ||
| 102 | typedef struct PCode PCode; | ||
| 103 | typedef struct Handler Handler; | ||
| 104 | |||
| 105 | typedef struct Addr Addr; | ||
| 106 | typedef struct Inst Inst; | ||
| 107 | |||
| 108 | union 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 | |||
| 131 | struct Attr { /* attribute_info */ | ||
| 132 | ushort name; | ||
| 133 | uint ln; | ||
| 134 | uchar *info; | ||
| 135 | }; | ||
| 136 | |||
| 137 | struct 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 | |||
| 145 | struct 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 | |||
| 153 | struct 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 | |||
| 172 | struct 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 | |||
| 184 | struct 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 | |||
| 230 | struct Handler { /* exception_table entry */ | ||
| 231 | ushort start_pc; | ||
| 232 | ushort end_pc; | ||
| 233 | ushort handler_pc; | ||
| 234 | ushort catch_type; | ||
| 235 | }; | ||
| 236 | |||
| 237 | struct 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 | |||
| 246 | struct PCode { | ||
| 247 | Code *code; | ||
| 248 | char *name; | ||
| 249 | char *sig; | ||
| 250 | }; | ||
| 251 | |||
| 252 | struct StkSnap { /* snapshot of simulated Java VM stack */ | ||
| 253 | uchar jtype; | ||
| 254 | int npc; | ||
| 255 | int *pc; | ||
| 256 | }; | ||
| 257 | |||
| 258 | struct 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 | |||
| 273 | struct BBList { | ||
| 274 | BB *bb; | ||
| 275 | BBList *next; | ||
| 276 | }; | ||
| 277 | |||
| 278 | struct 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 */ | ||
| 289 | extern int Aconv(va_list*, Fconv*); | ||
| 290 | extern int Iconv(va_list*, Fconv*); | ||
| 291 | extern void asminst(void); | ||
| 292 | extern void sblinst(Biobuf*); | ||
| 293 | extern Inst *clinitclone; | ||
| 294 | |||
| 295 | /* bb.c */ | ||
| 296 | extern void flowgraph(void); | ||
| 297 | extern void bbfree(void); | ||
| 298 | extern void bbinit(void); | ||
| 299 | extern void bbput(BB*); | ||
| 300 | extern BB *bbget(void); | ||
| 301 | extern void crefseed(void); | ||
| 302 | extern void crefenter(char*, BB*); | ||
| 303 | extern int crefstate(char*, BB*, int); | ||
| 304 | extern void creffree(void); | ||
| 305 | |||
| 306 | /* desc.c */ | ||
| 307 | extern int descid(int, int, uchar*); | ||
| 308 | extern void mpdescid(int, int, uchar*); | ||
| 309 | extern void asmdesc(void); | ||
| 310 | extern void disndesc(void); | ||
| 311 | extern void disdesc(void); | ||
| 312 | |||
| 313 | /* dis.c */ | ||
| 314 | extern void discon(int); | ||
| 315 | extern void disword(int); | ||
| 316 | extern void disdata(int, int); | ||
| 317 | extern void disflush(int, int, int); | ||
| 318 | extern void disbyte(int, int); | ||
| 319 | extern void disint(int, int); | ||
| 320 | extern void dislong(int, vlong); | ||
| 321 | extern void disreal(int, double); | ||
| 322 | extern void disstring(int, char*); | ||
| 323 | extern void disarray(int, int, int); | ||
| 324 | extern void disapop(void); | ||
| 325 | extern void disout(void); | ||
| 326 | extern Inst *ihead; | ||
| 327 | extern Inst *itail; | ||
| 328 | |||
| 329 | /* entry.c */ | ||
| 330 | extern void setentry(int, int); | ||
| 331 | extern void asmentry(void); | ||
| 332 | extern void disentry(void); | ||
| 333 | |||
| 334 | /* finally.c */ | ||
| 335 | extern void finallyentry(int); | ||
| 336 | extern void finallyalloc(void); | ||
| 337 | extern void jsrfixup(Addr*, Addr*, int, int); | ||
| 338 | extern void retfixup(Addr*, Addr*, int); | ||
| 339 | extern void finallyfree(void); | ||
| 340 | |||
| 341 | /* frame.c */ | ||
| 342 | extern void openframe(char*, int); | ||
| 343 | extern int closeframe(void); | ||
| 344 | extern int localix(uchar, int); | ||
| 345 | extern void reservereg(StkSnap*, int); | ||
| 346 | extern int getreg(uchar); | ||
| 347 | extern void acqreg(Addr*); | ||
| 348 | extern void relreg(Addr*); | ||
| 349 | extern void clearreg(void); | ||
| 350 | extern void disstackext(void); | ||
| 351 | |||
| 352 | /* javadas.c */ | ||
| 353 | extern int Jconv(va_list*, Fconv*); | ||
| 354 | extern Code *javadas(Attr*); | ||
| 355 | |||
| 356 | /* javatbl.c */ | ||
| 357 | extern int isload(Jinst*); | ||
| 358 | extern int isstore(Jinst*); | ||
| 359 | |||
| 360 | /* links.c */ | ||
| 361 | extern void xtrnlink(int, int, char*, char*); | ||
| 362 | extern void addfcpatch(Inst*, Inst*, char*, char*); | ||
| 363 | extern void dofcpatch(void); | ||
| 364 | extern void asmlinks(void); | ||
| 365 | extern void disnlinks(void); | ||
| 366 | extern void dislinks(void); | ||
| 367 | extern void sbllinks(Biobuf*); | ||
| 368 | |||
| 369 | /* loader.c */ | ||
| 370 | extern void ClassLoader(char*); | ||
| 371 | extern void dumpcpool(void); | ||
| 372 | extern char *CLASSNAME(int); | ||
| 373 | extern char *STRING(int); | ||
| 374 | extern Class *class; | ||
| 375 | extern PCode *pcode; | ||
| 376 | extern char *THISCLASS; | ||
| 377 | extern char *SUPERCLASS; | ||
| 378 | |||
| 379 | /* main.c */ | ||
| 380 | extern int compileflag; | ||
| 381 | extern int gensbl; | ||
| 382 | extern int verbose; | ||
| 383 | extern Biobuf *bout; | ||
| 384 | extern char *ofile; | ||
| 385 | |||
| 386 | /* mdata.c */ | ||
| 387 | extern int mpint(int); | ||
| 388 | extern int mplong(vlong); | ||
| 389 | extern int mpreal(double); | ||
| 390 | extern int mpstring(char*); | ||
| 391 | extern int mpcase(int, int*); | ||
| 392 | extern void mpdesc(void); | ||
| 393 | extern int mpgoto(int, int*); | ||
| 394 | extern void asmarray(int, int, int, int); | ||
| 395 | extern void asmint(int, int); | ||
| 396 | extern void asmstring(int, char*); | ||
| 397 | extern void asmvar(void); | ||
| 398 | extern void disnvar(void); | ||
| 399 | extern void disvar(void); | ||
| 400 | |||
| 401 | /* module.c */ | ||
| 402 | extern void asmmod(void); | ||
| 403 | extern void dismod(void); | ||
| 404 | |||
| 405 | /* patch.c */ | ||
| 406 | extern void patchop(Inst*); | ||
| 407 | extern void patchcase(Inst*, int, int*); | ||
| 408 | extern void patchmethod(int); | ||
| 409 | extern void patchfree(void); | ||
| 410 | |||
| 411 | /* sbl.c */ | ||
| 412 | extern void sblout(char*); | ||
| 413 | |||
| 414 | /* simjvm.c */ | ||
| 415 | extern void simjvm(char*); | ||
| 416 | |||
| 417 | /* unify.c */ | ||
| 418 | extern void unify(void); | ||
| 419 | |||
| 420 | /* util.c */ | ||
| 421 | extern void uSet(uchar*); | ||
| 422 | extern void uN(int); | ||
| 423 | extern uchar u1(void); | ||
| 424 | extern ushort u2(void); | ||
| 425 | extern uint u4(void); | ||
| 426 | extern void getattr(Attr*); | ||
| 427 | extern int CVattrindex(Field*); | ||
| 428 | extern char *uPtr(void); | ||
| 429 | extern int align(int, int); | ||
| 430 | extern void pstring(char*); | ||
| 431 | extern void fatal(char*, ...); | ||
| 432 | extern void verifycpindex(Jinst*, int, int); | ||
| 433 | extern void verifyerror(Jinst*); | ||
| 434 | extern void verifyerrormess(char*); | ||
| 435 | extern char *nextjavatype(char*); | ||
| 436 | extern uchar j2dtype(uchar); | ||
| 437 | extern void addrimm(Addr*, int); | ||
| 438 | extern int notimmable(int); | ||
| 439 | extern void addrsind(Addr*, uchar, int); | ||
| 440 | extern void addrdind(Addr*, uchar, uint, uint); | ||
| 441 | extern void dstreg(Addr*, uchar); | ||
| 442 | extern void setbit(uchar*, int); | ||
| 443 | extern int hashval(char*); | ||
| 444 | extern void *Malloc(uint); | ||
| 445 | extern void *Mallocz(uint); | ||
| 446 | extern void *Realloc(void*, uint); | ||
| 447 | extern int cellsize[]; | ||
| 448 | |||
| 449 | /* xlate.c */ | ||
| 450 | extern void xlate(void); | ||
| 451 | extern Code *code; | ||
| 452 | #pragma varargck type "A" Addr* | ||