Check-in [8679f7a02e]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Store the actual super class in the instance check; Add interfaces and self pointer to the class information; Have memory issues read bad constants.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8679f7a02e7245faf42e10a77f6da1da225e2d61
User & Date: stephanie.gawroriski 2019-06-12 13:13:12
Context
2019-06-12
13:38
Do not check for compatibility in virtual invoke if the type is exactly known and matches the stack; Add more debug marks check-in: 68f007bc1f user: stephanie.gawroriski tags: trunk
13:13
Store the actual super class in the instance check; Add interfaces and self pointer to the class information; Have memory issues read bad constants. check-in: 8679f7a02e user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: 815952d341 user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/klib/supervisor/cc/squirreljme/jvm/ClassInfo.java.

17
18
19
20
21
22
23



24
25
26
27
28
29
30
..
44
45
46
47
48
49
50






51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70


71
72
73
74
75
76
77
78
79
80
81
82
83

84
85
86
87
88
89
90
91


92
93
94
95
96
97
 */
public final class ClassInfo
{
	/** The magic number which should be used. */
	public static final int MAGIC_NUMBER =
		0x4C6F7665;
	



	/** Magic number used to detect corruption. */
	public final int magic;
	
	/** Class information flags. */
	public final int flags;
	
	/** The pointer to the minimized class file. */
................................................................................
	
	/** The cell size of components if this is an array. */
	public final int cellsize;
	
	/** The super class data. */
	public final ClassInfo superclass;
	






	/** Pointer to the class object. */
	public final Class<?> classobjptr;
	
	/** Virtual invoke VTable. */
	public final int[] vtablevirtual;
	
	/** Virtual invoke VTable pool entries. */
	public final int[] vtablepool;
	
	/**
	 * Class information constructor.
	 *

	 * @param __fl Class information flags.
	 * @param __minip Pointer to the hardware class data in ROM.
	 * @param __sz The size of this class.
	 * @param __bz The base offset for fields.
	 * @param __no The number of objects in the field instance.
	 * @param __dim Dimensions.
	 * @param __csz Cell size.
	 * @param __scl The super class data.


	 * @param __cop Pointer to the class object.
	 * @param __vtv Virtual invoke VTable address.
	 * @param __vtp Virtual invoke VTable pool addresses.
	 * @since 2019/04/26
	 */
	public ClassInfo(int __fl, int __minip, int __sz, int __bz, int __no,
		int __dim, int __csz, ClassInfo __scl, Class<?> __cop, int[] __vtv,
		int[] __vtp)
	{
		// Always implicitly set magic
		this.magic = MAGIC_NUMBER;
		
		// Set

		this.flags = __fl;
		this.miniptr = __minip;
		this.size = __sz;
		this.base = __bz;
		this.numobjects = __no;
		this.dimensions = __dim;
		this.cellsize = __csz;
		this.superclass = __scl;


		this.classobjptr = __cop;
		this.vtablevirtual = __vtv;
		this.vtablepool = __vtp;
	}
}








>
>
>







 







>
>
>
>
>
>












>








>
>





|
|
|





>








>
>

|
|



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 */
public final class ClassInfo
{
	/** The magic number which should be used. */
	public static final int MAGIC_NUMBER =
		0x4C6F7665;
	
	/** Self pointer. */
	public final int selfptr;
	
	/** Magic number used to detect corruption. */
	public final int magic;
	
	/** Class information flags. */
	public final int flags;
	
	/** The pointer to the minimized class file. */
................................................................................
	
	/** The cell size of components if this is an array. */
	public final int cellsize;
	
	/** The super class data. */
	public final ClassInfo superclass;
	
	/** Interfaces. */
	public final ClassInfo[] interfaceclasses;
	
	/** The component class. */
	public final ClassInfo componentclass;
	
	/** Pointer to the class object. */
	public final Class<?> classobjptr;
	
	/** Virtual invoke VTable. */
	public final int[] vtablevirtual;
	
	/** Virtual invoke VTable pool entries. */
	public final int[] vtablepool;
	
	/**
	 * Class information constructor.
	 *
	 * @param __sp Self pointer.
	 * @param __fl Class information flags.
	 * @param __minip Pointer to the hardware class data in ROM.
	 * @param __sz The size of this class.
	 * @param __bz The base offset for fields.
	 * @param __no The number of objects in the field instance.
	 * @param __dim Dimensions.
	 * @param __csz Cell size.
	 * @param __scl The super class data.
	 * @param __icl Interface classes.
	 * @param __ccl Component class.
	 * @param __cop Pointer to the class object.
	 * @param __vtv Virtual invoke VTable address.
	 * @param __vtp Virtual invoke VTable pool addresses.
	 * @since 2019/04/26
	 */
	public ClassInfo(int __sp, int __fl, int __minip, int __sz, int __bz,
		int __no, int __dim, int __csz, ClassInfo __scl, ClassInfo[] __icl,
		ClassInfo __ccl, Class<?> __cop, int[] __vtv, int[] __vtp)
	{
		// Always implicitly set magic
		this.magic = MAGIC_NUMBER;
		
		// Set
		this.selfptr = __sp;
		this.flags = __fl;
		this.miniptr = __minip;
		this.size = __sz;
		this.base = __bz;
		this.numobjects = __no;
		this.dimensions = __dim;
		this.cellsize = __csz;
		this.superclass = __scl;
		this.interfaceclasses = (__icl == null ? new ClassInfo[0] : __icl);
		this.componentclass = __ccl;
		this.classobjptr = __cop;
		this.vtablevirtual = (__vtv == null ? new int[0] : __vtv);
		this.vtablepool = (__vtp == null ? new int[0] : __vtp);
	}
}

Changes to runt/klib/supervisor/cc/squirreljme/jvm/JVMFunction.java.

182
183
184
185
186
187
188




189






190










191
192
193
194
195
196
197
		if (pcl == __cldx)
			return 1;
		
		// Corrupted object?
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		




		Assembly.breakpoint();






		throw new todo.TODO();










	}
	
	/**
	 * Returns the {@link Class} instance for the given class info pointer,
	 * if none has been created yet then it will be created as needed.
	 *
	 * @param __cldx The class index pointer.







>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
		if (pcl == __cldx)
			return 1;
		
		// Corrupted object?
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		
		// Scan through
		ClassInfo mine = Assembly.pointerToClassInfo(pcl);
		for (ClassInfo seek = mine; seek != null; seek = seek.superclass)
		{
			Assembly.breakpoint();
			
			// Get self pointer
			int selfptr = seek.selfptr;
			
			// Make sure we are not reading bad memory
			if (selfptr == Constants.BAD_MAGIC)
				throw new VirtualMachineError();
			
			// Same as this one?
			if (selfptr == __cldx)
				return 1;
			
			// Check interfaces, if any
		}
		
		// Not a match
		return 0;
	}
	
	/**
	 * Returns the {@link Class} instance for the given class info pointer,
	 * if none has been created yet then it will be created as needed.
	 *
	 * @param __cldx The class index pointer.

Changes to runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/VirtualMemory.java.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
70
71
72
73
74
75
76
77









78
79
80
81
82
83
84
85
86
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * This class contains the entirety of virtual memory, this includes access
 * to the various on-demand minification of suites and classes.
................................................................................
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
				return ((ReadableMemory)c).memReadByte(vaddr);
		}
		









		// Missed Read
		return 0xF0 | (__addr & 0x0F);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override







>







 








>
>
>
>
>
>
>
>
>

|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;

import cc.squirreljme.jvm.Constants;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * This class contains the entirety of virtual memory, this includes access
 * to the various on-demand minification of suites and classes.
................................................................................
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
				return ((ReadableMemory)c).memReadByte(vaddr);
		}
		
		switch (__addr & 0x3)
		{
			case 0:		return (Constants.BAD_MAGIC >> 24) & 0xFF;
			case 1:		return (Constants.BAD_MAGIC >> 16) & 0xFF;
			case 2:		return (Constants.BAD_MAGIC >> 8) & 0xFF;
			default:
			case 3:		return (Constants.BAD_MAGIC) & 0xFF;
		}
		
		// Missed Read
		/*return 0xF0 | (__addr & 0x0F);*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override

Changes to runt/libs/tool-jarfile/dev/shadowtail/jarfile/JarMinimizer.java.

287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
...
368
369
370
371
372
373
374






375
376
377
378
379
380
381
...
402
403
404
405
406
407
408





409











































410






411
412
413
414
415
416
417
	}
	
	/**
	 * Returns the ID of the class.
	 *
	 * @param __init The initializer.
	 * @param __cl The class to get the ID of.
	 * @return The ID of the class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	private final int __classId(Initializer __init, ClassName __cl)
		throws NullPointerException
	{
		if (__init == null || __cl == null)
................................................................................
						break;
						
						// Magic number
					case "magic:I":
						__init.memWriteInt(
							wp, ClassInfo.MAGIC_NUMBER);
						break;






						
						// Class info flags
					case "flags:I":
						{
							int flags = 0;
							
							// Is this array?
................................................................................
					case "miniptr:I":
						__init.memWriteInt(Modifier.JAR_OFFSET,
							wp, bi._classoffset);
						break;
						
						// Super class info
					case "superclass:Lcc/squirreljme/jvm/ClassInfo;":





						__init.memWriteInt(Modifier.RAM_OFFSET,











































							wp, this.__classId(__init, atsuper));






						break;
						
						// VTable for virtual calls
					case "vtablevirtual:[I":
						__init.memWriteInt(Modifier.RAM_OFFSET,
							wp, this.__classVTable(__init, __cl)[0]);
						break;







|







 







>
>
>
>
>
>







 







>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>







287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
...
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
	}
	
	/**
	 * Returns the ID of the class.
	 *
	 * @param __init The initializer.
	 * @param __cl The class to get the ID of.
	 * @return The pointer of the ClassInfo instance.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	private final int __classId(Initializer __init, ClassName __cl)
		throws NullPointerException
	{
		if (__init == null || __cl == null)
................................................................................
						break;
						
						// Magic number
					case "magic:I":
						__init.memWriteInt(
							wp, ClassInfo.MAGIC_NUMBER);
						break;
						
						// Self pointer
					case "selfptr:I":
						__init.memWriteInt(Modifier.RAM_OFFSET,
							wp, rv);
						break;
						
						// Class info flags
					case "flags:I":
						{
							int flags = 0;
							
							// Is this array?
................................................................................
					case "miniptr:I":
						__init.memWriteInt(Modifier.JAR_OFFSET,
							wp, bi._classoffset);
						break;
						
						// Super class info
					case "superclass:Lcc/squirreljme/jvm/ClassInfo;":
						{
							ClassName sn = bi._class.superName();
							if (sn == null)
								__init.memWriteInt(wp, 0);
							else
								__init.memWriteInt(Modifier.RAM_OFFSET,
									wp, this.__classId(__init, sn));
						}
						break;
						
						// Interface class information
					case "interfaceclasses:[Lcc/squirreljme/jvm/ClassInfo;":
						{
							// Get interfaces
							ClassNames ints = bi._class.interfaceNames();
							int numints = ints.size();
							
							// Allocate and set field array pointer
							int cip = __init.allocate(
								Constants.ARRAY_BASE_SIZE + (numints * 4));
							__init.memWriteInt(Modifier.RAM_OFFSET,
								wp, cip);
							
							// Write array details
							__init.memWriteInt(Modifier.RAM_OFFSET,
								cip + Constants.OBJECT_CLASS_OFFSET,
								this.__classId(__init, new ClassName(
									"[Lcc/squirreljme/jvm/ClassInfo;")));
							__init.memWriteInt(
								cip + Constants.OBJECT_COUNT_OFFSET,
								999999);
							__init.memWriteInt(
								cip + Constants.ARRAY_LENGTH_OFFSET,
								numints);
							
							// Write interface IDs
							for (int j = 0; j < numints; j++)
								__init.memWriteInt(Modifier.RAM_OFFSET,
									cip + Constants.ARRAY_BASE_SIZE + (j * 4),
									this.__classId(__init, ints.get(j)));
						}
						break;
						
						// Component class
					case "componentclass:Lcc/squirreljme/jvm/ClassInfo;":
						{
							// Write class ID of component type
							if (__cl.isArray())
								__init.memWriteInt(Modifier.RAM_OFFSET,
									wp, this.__classId(__init,
										__cl.componentType()));
							
							// Write null pointer
							else
								__init.memWriteInt(wp, 0);
						}
						break;
						
						// VTable for virtual calls
					case "vtablevirtual:[I":
						__init.memWriteInt(Modifier.RAM_OFFSET,
							wp, this.__classVTable(__init, __cl)[0]);
						break;