Check-in [884f494de5]

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

Overview
Comment:Store monitor into a higher register rather than one that is dedicated for use.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:884f494de57fc469dbb0ea41474bf7400fa89e04
User & Date: stephanie.gawroriski 2019-05-24 18:03:47
Context
2019-05-24
18:10
Remove thistype; Put exceptionranges into ByteCodeState. check-in: cd11608154 user: stephanie.gawroriski tags: trunk
18:03
Store monitor into a higher register rather than one that is dedicated for use. check-in: 884f494de5 user: stephanie.gawroriski tags: trunk
17:51
Remove WhereIsThis, line debug, JOp debug, and JInst debug (they are inlined with the code now rather than separate). check-in: c2cc24e90d user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
						spec = "volb";
						break;
					
					case NativeCode.VOLATILE_S_REGISTER:
						spec = "vols";
						break;
					
					case NativeCode.MONITOR_TARGET_REGISTER:
						spec = "monitor";
						break;
					
					case NativeCode.ARGUMENT_REGISTER_BASE:
						spec = "a0/this";
						break;
				}
			
			// Print special register
			if (spec != null)







<
<
<
<







802
803
804
805
806
807
808




809
810
811
812
813
814
815
						spec = "volb";
						break;
					
					case NativeCode.VOLATILE_S_REGISTER:
						spec = "vols";
						break;
					




					case NativeCode.ARGUMENT_REGISTER_BASE:
						spec = "a0/this";
						break;
				}
			
			// Print special register
			if (spec != null)

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeCode.java.

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
		9;
	
	/** The register which contains the next pool pointer to use. */
	public static final int NEXT_POOL_REGISTER =
		10;
	
	/** Volatile A register. */

	public static final int VOLATILE_A_REGISTER =
		12;
	
	/** Volatile B register. */

	public static final int VOLATILE_B_REGISTER =
		13;
	
	/** Volatile S register (sticky). */

	public static final int VOLATILE_S_REGISTER =
		14;
	
	/** Copy of this for synchronized method purposes. */
	public static final int MONITOR_TARGET_REGISTER =
		15;
	
	/** The register of the first argument. */
	public static final int ARGUMENT_REGISTER_BASE =
		16;
	
	/** This bit XORed NEG bit == set, means memory access is volatile. */
	@Deprecated
	public static final int MEMORY_OFF_VOLATILE_BIT =







>




>




>



<
<
<
<







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
		9;
	
	/** The register which contains the next pool pointer to use. */
	public static final int NEXT_POOL_REGISTER =
		10;
	
	/** Volatile A register. */
	@Deprecated
	public static final int VOLATILE_A_REGISTER =
		12;
	
	/** Volatile B register. */
	@Deprecated
	public static final int VOLATILE_B_REGISTER =
		13;
	
	/** Volatile S register (sticky). */
	@Deprecated
	public static final int VOLATILE_S_REGISTER =
		14;
	




	/** The register of the first argument. */
	public static final int ARGUMENT_REGISTER_BASE =
		16;
	
	/** This bit XORed NEG bit == set, means memory access is volatile. */
	@Deprecated
	public static final int MEMORY_OFF_VOLATILE_BIT =

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NearNativeByteCodeHandler.java.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83






84
85
86
87
88
89
90
...
126
127
128
129
130
131
132






133
134
135
136
137
138
139
....
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
....
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
....
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
	
	/** Exception tracker. */
	protected final ExceptionHandlerRanges exceptionranges;
	
	/** Default field access type, to determine how fields are accessed. */
	protected final FieldAccessTime defaultfieldaccesstime;
	
	/** The type of the current class being processed. */
	@Deprecated
	protected final ClassName thistype;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	






	/** Standard exception handler table. */
	private final Map<ExceptionHandlerTransition, __EData__> _ehtable =
		new LinkedHashMap<>();
	
	/** Made exception table. */
	private final Map<ClassAndLabel, __EData__> _metable =
		new LinkedHashMap<>();
................................................................................
		this.exceptionranges = new ExceptionHandlerRanges(__bc);
		this.defaultfieldaccesstime = ((__bc.isInstanceInitializer() ||
			__bc.isStaticInitializer()) ? FieldAccessTime.INITIALIZER :
			FieldAccessTime.NORMAL);
		this.thistype = __bc.thisType();
		this.issynchronized = __bc.isSynchronized();
		this.isinstance = __bc.isInstance();






	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
................................................................................
			
			// Setup monitor entry
			if (this.issynchronized)
			{
				// Copy instance to monitor target
				if (this.isinstance)
					codebuilder.addCopy(state.stack.getLocal(0).register,
						NativeCode.MONITOR_TARGET_REGISTER);
				
				// Load class object to monitor
				else
					this.__loadClassObject(this.thistype,
						NativeCode.MONITOR_TARGET_REGISTER);
				
				// Enter monitor on this
				this.__refCount(NativeCode.MONITOR_TARGET_REGISTER);
				this.__monitor(true, NativeCode.MONITOR_TARGET_REGISTER);
			}
		}
		
		// Debug single instruction point
		codebuilder.add(NativeInstructionType.DEBUG_POINT,
			state.line & 0x7FFF, state.instruction.operation() & 0xFF,
			state.instruction.address() & 0x7FFF);
................................................................................
		// is generate a return instruction
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__eq.isEmpty())
		{
			// If this is synchronized, we need to exit the monitor
			if (this.issynchronized)
			{
				this.__monitor(false, NativeCode.MONITOR_TARGET_REGISTER);
				this.__refUncount(NativeCode.MONITOR_TARGET_REGISTER);
			}
			
			// Debug exit
			codebuilder.add(NativeInstructionType.DEBUG_EXIT);
			
			// Since there is nothing to uncount, just return
			codebuilder.add(NativeInstructionType.RETURN);
................................................................................
			throw new NullPointerException("NARG");
		
		// Setup state
		ByteCodeState state = this.state;
		state.addr = __ed.addr;
		state.line = __ed.line;
		
		// Setup code builder
		NativeCodeBuilder codebuilder = this.codebuilder;
		/*codebuilder.setSourceLine(__ed.line);
		codebuilder.setByteCodeAddress(__ed.jpc);
		codebuilder.setByteCodeOperation(__ed.jop);*/
		
		// And return the label
		return __ed.label;
	}
}








|
<








>
>
>
>
>
>







 







>
>
>
>
>
>







 







|




|


|
|







 







|
|







 







<
<
<
<
<
<





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
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
....
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
....
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
....
2283
2284
2285
2286
2287
2288
2289






2290
2291
2292
2293
2294
	
	/** Exception tracker. */
	protected final ExceptionHandlerRanges exceptionranges;
	
	/** Default field access type, to determine how fields are accessed. */
	protected final FieldAccessTime defaultfieldaccesstime;
	
	/** The type of the current class being processed (needed for monitor). */

	protected final ClassName thistype;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	
	/** Monitor target register used. */
	protected final int monitortarget;
	
	/** Volatile registers to use. */
	protected final VolatileRegisterStack volatiles;
	
	/** Standard exception handler table. */
	private final Map<ExceptionHandlerTransition, __EData__> _ehtable =
		new LinkedHashMap<>();
	
	/** Made exception table. */
	private final Map<ClassAndLabel, __EData__> _metable =
		new LinkedHashMap<>();
................................................................................
		this.exceptionranges = new ExceptionHandlerRanges(__bc);
		this.defaultfieldaccesstime = ((__bc.isInstanceInitializer() ||
			__bc.isStaticInitializer()) ? FieldAccessTime.INITIALIZER :
			FieldAccessTime.NORMAL);
		this.thistype = __bc.thisType();
		this.issynchronized = __bc.isSynchronized();
		this.isinstance = __bc.isInstance();
		
		// Determine monitor target register and the volatile base
		int volbase = NativeCode.ARGUMENT_REGISTER_BASE + 2 +
			__bc.maxLocals() + __bc.maxStack();
		this.monitortarget = volbase;
		this.volatiles = new VolatileRegisterStack(volbase + 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
................................................................................
			
			// Setup monitor entry
			if (this.issynchronized)
			{
				// Copy instance to monitor target
				if (this.isinstance)
					codebuilder.addCopy(state.stack.getLocal(0).register,
						this.monitortarget);
				
				// Load class object to monitor
				else
					this.__loadClassObject(this.thistype,
						this.monitortarget);
				
				// Enter monitor on this
				this.__refCount(this.monitortarget);
				this.__monitor(true, this.monitortarget);
			}
		}
		
		// Debug single instruction point
		codebuilder.add(NativeInstructionType.DEBUG_POINT,
			state.line & 0x7FFF, state.instruction.operation() & 0xFF,
			state.instruction.address() & 0x7FFF);
................................................................................
		// is generate a return instruction
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__eq.isEmpty())
		{
			// If this is synchronized, we need to exit the monitor
			if (this.issynchronized)
			{
				this.__monitor(false, this.monitortarget);
				this.__refUncount(this.monitortarget);
			}
			
			// Debug exit
			codebuilder.add(NativeInstructionType.DEBUG_EXIT);
			
			// Since there is nothing to uncount, just return
			codebuilder.add(NativeInstructionType.RETURN);
................................................................................
			throw new NullPointerException("NARG");
		
		// Setup state
		ByteCodeState state = this.state;
		state.addr = __ed.addr;
		state.line = __ed.line;
		






		// And return the label
		return __ed.label;
	}
}

Added runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/VolatileRegisterStack.java.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

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

/**
 * This is a stack which is used to manage which volatile registers are used.
 *
 * @since 2019/05/24
 */
public final class VolatileRegisterStack
{
	/** The base register. */
	protected final int base;
	
	/** Registers being used. */
	private final List<Integer> _used =
		new ArrayList<>();
	
	/**
	 * Initializes the volatile stack.
	 *
	 * @param __b The base register.
	 * @since 2019/05/25
	 */
	public VolatileRegisterStack(int __b)
	{
		this.base = __b;
	}
	
	/**
	 * Clears all of the used volatile reisters.
	 *
	 * @since 2019/05/25
	 */
	public final void clear()
	{
		this._used.clear();
	}
}