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/module/classloader.m (1 of 18352 files). Show all

Unified · Split

java/module/classloader.m+420−0
@@ -0,0 +1,420 @@
1include "draw.m";
2#
3# Java Class Loader.
4#
5
6JavaClassLoader: module
7{
8 PATH: con "/dis/java/classloader.dis";
9 ROOT: con "/dis/java/java/";
10 PROG: con "#p";
11 LOADER: con "@Loader";
12 CLASS: con "@Class";
13 MP: con "@mp";
14 ADT: con "@adt";
15 NP: con "@np";
16 OBJ: con "@obj";
17 JEX: con "@jex";
18 SYS: con "@sys";
19 EXIST: con "does not exist";
20 MAINFIELD: con "main";
21 MAINSIGNATURE: con "([Ljava/lang/String;)V";
22 VOIDSIGNATURE: con "()V";
23 ARRAYCLASS: con "inferno/vm/Array";
24 STRINGCLASS: con "java/lang/String";
25 EXCEPTIONPATH: con "java/lang/";
26 JAVAEXCEPTION: con "java ex";
27 SPECIALINIT: con "<init>";
28 SPECIALCLINIT: con "<clinit>";
29 SPECIALCLONE: con "<clone>";
30 SUXV: con '4';
31 JAVA: con ('J'<<24)|('a'<<16)|('v'<<8)|'a';
32 SUX: con ('S'<<24)|('u'<<16)|('x'<<8)|SUXV;
33 NEW, HIER, RESOLVE, LOADED, INITED:
34 con iota;
35 MAGIC, VERSION, NAME, SUPER, INTERFACES, RELOC, DSIZE, DRELOC, CLASSREF:
36 con (iota * 4);
37 CMP, CADT, CNP, COBJ, CJEX, CSYS:
38 con iota;
39 VVAL, VMP, VNP, VOBJ: con iota;
40 PVALUE, PEXTRA, PMETHOD, PSTATIC:
41 con iota;
42 WORDZ: con 4;
43 BIGZ: con 8;
44 MAPZ: con WORDZ * 8;
45 STACKSIZE: con 1024;
46 METHODOFFSET: con 2;
47 RTCLASSOFFSET: con 1 * WORDZ;
48 RTRELOCOFFSET: con 2 * WORDZ;
49 RTTHISOFFSET: con 3 * WORDZ;
50 RTFIRSTRELOC: con 4 * WORDZ;
51 CLASSADTOFFSET: con 1 * WORDZ;
52 MAXUNENCODED: con Sys->NAMEMAX - 7;
53 ENCODEDLEN: con 21;
54 RDELTA: con 16r80;
55
56 T_BOOLEAN: con 4;
57 T_CHAR: con 5;
58 T_FLOAT: con 6;
59 T_DOUBLE: con 7;
60 T_BYTE: con 8;
61 T_SHORT: con 9;
62 T_INT: con 10;
63 T_LONG: con 11;
64 T_OBJECT: con 12;
65 T_ARRAY: con 13;
66
67 ACC_PUBLIC: con 16r0001;
68 ACC_PRIVATE: con 16r0002;
69 ACC_PROTECTED: con 16r0004;
70 ACC_STATIC: con 16r0008;
71 ACC_FINAL: con 16r0010;
72 ACC_SUPER: con 16r0020;
73 ACC_SYNCHRONIZED: con 16r0020;
74 ACC_VOLATILE: con 16r0040;
75 ACC_TRANSIENT: con 16r0080;
76 ACC_NATIVE: con 16r0100;
77 ACC_INTERFACE: con 16r0200;
78 ACC_ABSTRACT: con 16r0400;
79
80 JCL_INTEREXT: con 16r4000;
81 JCL_INTERWORK: con 16r8000;
82
83 MUSTCOMPILE: con 16r10000;
84 DONTCOMPILE: con 16r20000;
85
86 Rgetputfield: con 16r1 << 16;
87 Rgetputstatic: con 16r2 << 16;
88 Rinvokeinterface: con 16r3 << 16;
89 Rinvokespecial: con 16r4 << 16;
90 Rinvokestatic: con 16r5 << 16;
91 Rinvokevirtual: con 16r6 << 16;
92 Rmask: con 16r7 << 16;
93
94 Rstaticmp: con 16r08 << 16;
95 Rspecialmp: con 16r10 << 16;
96
97 POP: con 16r3 << 2; # operand
98 PSRC: con 16r1 << 2; # patch source operand
99 PDST: con 16r2 << 2; # destination
100 PMID: con 16r3 << 2; # middle
101
102 PTYPE: con 16r3; # Operand type
103 PIMM: con 16r0; # patch immediate operand
104 PSIND: con 16r1; # single indirect offset
105 PDIND1: con 16r2; # first offset of double indirect
106 PDIND2: con 16r3; # second offset of double indirect
107
108 ISHIFT: con 4; # instr index shift
109
110 jninil: Nilmod;
111 jnisig: int;
112
113 Extra: adt
114 {
115 what: int;
116 class: cyclic ref Class;
117 };
118
119 Field: adt
120 {
121 field: string;
122 signature: string;
123 flags: int;
124 value: int;
125 };
126
127 Method: adt
128 {
129 field: ref Field;
130 class: cyclic ref Class;
131 };
132
133 Patch: adt
134 {
135 what: int;
136 value: int;
137 };
138
139 Reloc: adt
140 {
141 field: string;
142 signature: string;
143 flags: int;
144 patch: array of byte;
145 };
146
147 RTReloc: adt
148 {
149 field: string;
150 signature: string;
151 flags: int;
152 };
153
154 Interface: adt
155 {
156 class: cyclic ref Class;
157 methods: array of int;
158 };
159
160 Ldinfo: adt
161 {
162 links: array of Loader->Link;
163 nlinks: array of Loader->Link;
164 types: array of Loader->Typedesc;
165 extraoffset: int;
166 extrabase: int;
167 extras: cyclic array of Extra;
168 reloc: array of Patch;
169 };
170
171 ClassObject: adt
172 {
173 mod: ref Loader->Niladt;
174 class: cyclic ref Class;
175 aryname: string;
176 };
177
178 Object: adt
179 {
180 mod: ref Loader->Niladt;
181
182 class: fn(o: self ref Object): ref Class;
183 };
184
185 Array: adt
186 {
187 mod: ref Loader->Niladt;
188 holder: array of ref JavaString;
189 dims: int;
190 class: ref Class;
191 primitive: int;
192 };
193
194 JavaString: adt
195 {
196 mod: ref Loader->Niladt;
197 str: string;
198 };
199
200 JavaThrowable: adt
201 {
202 mod: ref Loader->Niladt;
203 trace: array of byte;
204 msg: ref JavaString;
205 };
206
207 ThreadData: adt
208 {
209 BLOCKED, SUSPENDED, ACKSUSP, WAITSUSP, WAITSTOP, INTERRUPTED, EXITED, DAEMON:
210 con (1 << iota);
211 SHUTDOWN, BLOCK, UNBLOCK, SUSPEND, RESUME, STOP:
212 con iota;
213
214 pid: int;
215 wchan: chan of int;
216 flags: int;
217 ctlfile: string;
218 control: ref Sys->FD;
219 culprit: ref Object;
220 this: ref Object;
221 };
222
223 Class: adt
224 {
225 state: int;
226 name: string;
227 encoding: string;
228 ownname: string;
229 file: string;
230 version: int;
231 flags: int;
232 mod: Nilmod;
233 native: Nilmod;
234 super: cyclic ref Class;
235 this: cyclic ref ClassObject;
236 info: cyclic ref Ldinfo;
237 refs: cyclic array of ref Class;
238 staticdata: array of ref Field;
239 objectdata: list of ref Field;
240 privatemethods: array of ref Field;
241 staticmethods: array of ref Field;
242 virtualmethods: cyclic array of Method;
243 initmethods: array of ref Field;
244 classinit: ref Field;
245 cloneindex: int;
246 interfaces: cyclic array of Interface;
247 interindex: int;
248 intercache: cyclic list of (ref Class, array of int);
249 interextends: cyclic list of ref Class;
250 interdirect: cyclic list of ref Class;
251 objectsize: int;
252 staticoffset: int;
253 staticsize: int;
254 nextra: int;
255 dataoffset: int;
256 datasize: int;
257 datareloc: int;
258 moddata: ref Loader->Niladt;
259 modsize: int;
260 modmap: array of byte;
261 objmap: array of byte;
262 objtype: int;
263 mlinks: int;
264
265 loadclass: fn(c: self ref Class);
266 resolve: fn(c: self ref Class);
267 loadinterfaces: fn(c: self ref Class);
268 extinterfaces: fn(c: self ref Class);
269 linkinterfaces: fn(c: self ref Class);
270 makeobjtype: fn(c: self ref Class);
271 makevmtable: fn(c: self ref Class, m: list of ref Field, z: int): array of Method;
272 relocate: fn(c: self ref Class);
273 instrpatch: fn(c: self ref Class, i: array of Loader->Inst);
274 modpatch: fn(c: self ref Class);
275 getmethod: fn(c: self ref Class, f, s: string, flag: int): int;
276 override: fn(c: self ref Class, f, s: string): int;
277 findimethod: fn(c: self ref Class, s: string): ref Field;
278 findpmethod: fn(c: self ref Class, f, s: string): ref Field;
279 findsfield: fn(c: self ref Class, f: string): ref Field;
280 findsmethod: fn(c: self ref Class, f, s: string): ref Field;
281 findofield: fn(c: self ref Class, f: string): ref Field;
282 findvmethod: fn(c: self ref Class, f, s: string): int;
283 extra: fn(c: self ref Class, w, n: int, r: ref Class);
284 extras: fn(c: self ref Class, a: array of Reloc, n: int, r: ref Class): int;
285 special: fn(c: self ref Class, f, s: string, flags: int, r: ref Class): (int, ref Class, int);
286 copymap: fn(c: self ref Class, m: array of byte, dr: int);
287 copymd: fn(c: self ref Class, md: ref Loader->Niladt, dr: int, om: Nilmod);
288 relocref: fn(c: self ref Class, t: ref Class, i: array of Loader->Inst, a: array of Reloc, x: int): int;
289 resolvereloc: fn(c: self ref Class, r, s: string, flags: int): (int, int);
290 addinterface: fn(c: self ref Class);
291 getinterface: fn(c: self ref Class, k: ref Class): array of int;
292 interlook: fn(c: self ref Class, a: array of Interface): array of int;
293 initjni: fn(c: self ref Class);
294 loadnative: fn(c: self ref Class);
295
296 # runtime entry points
297 run: fn(c: self ref Class, args: list of string);
298 new: fn(c: self ref Class): ref Object;
299 call: fn(c: self ref Class, x: int, a: ref Object): ref Object;
300 clone: fn(c: self ref Class, o: ref Object): ref Object;
301 };
302
303 init: fn(j: JavaClassLoader, ctxt: ref Draw->Context);
304 shutdown: fn();
305 info: fn(name: string);
306 loader: fn(name: string): ref Class;
307 encodename: fn(name: string): string;
308 getclass: fn(name: string): ref Class;
309 getmodclass: fn(mod: Nilmod): ref Class;
310 runmain: fn( j: JavaClassLoader, classname : string, argv : list of string );
311 sysexception: fn( ex : string ) : ref Object;
312 setflags: fn( flags : list of (string,int) );
313
314 # runtime entry points
315 compatclass: fn(who, what: ref Class): int;
316 checkcast: fn(who: ref Object, what: ref Class);
317 instanceof: fn(who: ref Object, what: ref Class): int;
318 acheckcast: fn(who: ref Array, what: ref Class, dims: int);
319 ainstanceof: fn(who: ref Array, what: ref Class, dims: int): int;
320 pcheckcast: fn(who: ref Array, what, dims: int);
321 pinstanceof: fn(who: ref Array, what, dims: int): int;
322 aastorecheck: fn(who: ref Object, what: ref Array);
323 arraycopy: fn(src: ref Array, sx: int, dst: ref Array, dx: int, n: int);
324 multianewarray: fn(ndim: int, c: ref Class, etype: int, bounds: array of int): ref Array;
325 error: fn(s: string);
326 delthreaddata: fn();
327 getthreaddata: fn(): ref ThreadData;
328 getcontext: fn(): ref Draw->Context;
329 daemonize: fn();
330 culprit: fn(e: string): ref Object;
331 throw: fn(c: ref Object);
332 rtload: fn(addr: int);
333 getinterface: fn(c: ref Class, cookie: int): int;
334 monitorenter: fn(o: ref Object);
335 monitorexit: fn(o: ref Object);
336 monitorwait: fn(o: ref Object, l: int);
337 monitornotify: fn(o: ref Object, f: int);
338 sleep: fn(l: int);
339 interrupt: fn(t: ref ThreadData);
340 suspend: fn(t: ref ThreadData);
341 resume: fn(t: ref ThreadData);
342 stop: fn(t: ref ThreadData, o: ref Object);
343
344 # math
345 lcmp: fn(x: big, y: big): int;
346
347 d2i: fn(x: real): int;
348 d2l: fn(x: real): big;
349 dcmpg: fn(x, y: real): int;
350 dcmpl: fn(x, y: real): int;
351 drem: fn(x, y: real): real;
352};
353
354JavaNative: module
355{
356 PATH: con "/dis/java/javanative.dis";
357
358 init: fn(sys: Sys, ld: Loader, jldr: JavaClassLoader, jass: JavaAssist): string;
359};
360
361JavaAssist: module
362{
363 PATH: con "/dis/java/javaassist.dis";
364
365 getint: fn(mod: Nilmod, index: int): int;
366 getbytearray: fn(mod: Nilmod, index: int): array of byte;
367 getintarray: fn(mod: Nilmod, index: int): array of int;
368 getstrarray: fn(mod: Nilmod, index: int): array of string;
369 getptr: fn(mod: Nilmod, index: int): ref Loader->Niladt;
370 getreloc: fn(mod: Nilmod, index: int): array of JavaClassLoader->Reloc;
371 getrtreloc: fn(data: ref Loader->Niladt, index: int): array of JavaClassLoader->RTReloc;
372 getclassadt: fn(data: ref Loader->Niladt, index: int): ref JavaClassLoader->Class;
373 getabsint: fn(addr: int): int;
374 getadtstring: fn(data: ref Loader->Niladt, index: int): string;
375 getstring: fn(mod: Nilmod, index: int): string;
376 putclass: fn(data: ref Loader->Niladt, index: int, value: ref JavaClassLoader->Class);
377 putint: fn(data: ref Loader->Niladt, index: int, value: int);
378 putmod: fn(data: ref Loader->Niladt, index: int, value: Nilmod);
379 putobj: fn(data: ref Loader->Niladt, index: int, value: ref JavaClassLoader->ClassObject);
380 putptr: fn(data: ref Loader->Niladt, index: int, value: ref Loader->Niladt);
381 putstring: fn(data: ref Loader->Niladt, index: int, value: string);
382 little_endian: fn(): int;
383 jclnilmod: fn(j: JavaClassLoader): Nilmod;
384 sysnilmod: fn(s: Sys): Nilmod;
385 new: fn(mod: Nilmod, index: int): ref JavaClassLoader->Object;
386 getobjclass: fn(j: ref JavaClassLoader->Object): ref JavaClassLoader->Class;
387 modhash: fn(mod: Nilmod): int;
388 objhash: fn(j: ref JavaClassLoader->Object): int;
389 mcall0: fn(mod: Nilmod, index: int): int;
390 mcall1: fn(mod: Nilmod, index: int, arg: ref JavaClassLoader->Object): ref JavaClassLoader->Object;
391 mcalla: fn(mod: Nilmod, index: int, arg: ref JavaClassLoader->Array): int;
392 mcallm: fn(mod: Nilmod, index: int, arg: Nilmod): int;
393 getmd: fn(mod: Nilmod): ref Loader->Niladt;
394 arrayof: fn(o: ref JavaClassLoader->Object): ref JavaClassLoader->Array;
395 bytearraytoJS: fn(a: array of byte): array of ref JavaClassLoader->JavaString;
396 intarraytoJS: fn(a: array of int): array of ref JavaClassLoader->JavaString;
397 bigarraytoJS: fn(a: array of big): array of ref JavaClassLoader->JavaString;
398 realarraytoJS: fn(a: array of real): array of ref JavaClassLoader->JavaString;
399 ArraytoJS: fn(a: ref JavaClassLoader->Array): ref JavaClassLoader->JavaString;
400 JStoObject: fn(j: ref JavaClassLoader->JavaString): ref JavaClassLoader->Object;
401 ObjecttoJT: fn(o: ref JavaClassLoader->Object): ref JavaClassLoader->JavaThrowable;
402 makeadt: fn(addr: int): ref Loader->Niladt;
403};
404
405JavaTrace: module
406{
407 PATH: con "/dis/java/javatrace.dis";
408
409 JVERBOSE,
410 JDEBUG: con iota;
411
412 init: fn(a: JavaAssist);
413 info: fn(c: ref JavaClassLoader->Class);
414 pr_reloc: fn(r: JavaClassLoader->Reloc);
415 pr_relocs: fn(r: array of JavaClassLoader->Reloc);
416 trace: fn(c: int, s: string);
417
418 level: int;
419 outfd: ref Sys->FD;
420};