Check-in [abf8424601]

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

Overview
Comment:When doing reference counting, use the new volatile register stuff instead of a fixed register position.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: abf842460161e2522fa30424dd8b7aa9ebd7becd
User & Date: stephanie.gawroriski 2019-06-13 19:02:16
Context
2019-06-13
19:03
In RatufaCoat, ignore writes to ROM. check-in: a39677c16d user: stephanie.gawroriski tags: trunk
19:02
When doing reference counting, use the new volatile register stuff instead of a fixed register position. check-in: abf8424601 user: stephanie.gawroriski tags: trunk
18:39
Add check to fail if ROM is attempted to be written to. check-in: 1daf2f812f user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
....
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770

2771
2772





2773




2774
2775
2776
2777
2778
2779
2780
....
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840







2841
2842
2843









2844
2845
2846
2847
2848
2849
2850
2851
	/** Reference clearing and jumping to label. */
	private final Map<EnqueueAndLabel, __EData__> _refcljumps =
		new LinkedHashMap<>();
	
	/** Last registers enqueued. */
	private JavaStackEnqueueList _lastenqueue;
	
	/** Reference queue base, register wise. */
	private int _refqbase;
	
	/** Next reference count/uncount ID number for jump. */
	private int _refclunk;
	
	/**
	 * Initializes the byte code handler.
	 *
	 * @param __bc The byte code.
................................................................................
		JavaStackEnqueueList lastenqueue = this._lastenqueue;
		if (lastenqueue == null)
			return;
		
		// No need to clear anymore
		this._lastenqueue = null;
		
		// Position where all the enqueued values were stored
		int refqbase = this._refqbase;
		
		// Un-count all of them accordingly

		NativeCodeBuilder codebuilder = this.codebuilder;
		for (int i = 0, n = lastenqueue.size(); i < n; i++)





			this.__refUncount(refqbase + i);




	}
	
	/**
	 * Generates code to reference count the given register.
	 *
	 * @param __r The register to reference to count.
	 * @since 2019/04/25
................................................................................
		// Nothing to enqueue?
		if (__r.isEmpty())
		{
			this._lastenqueue = null;
			return false;
		}
		
		// Register base to use for the reference queue
		int refqbase = this.state.stack.usedregisters + 4;
		this._refqbase = refqbase;
		
		// Copy all references to the temporary spots
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (int i = 0, n = __r.size(); i < n; i++)







			codebuilder.addCopy(__r.get(i), refqbase + i);
		
		// These will be uncounted accordingly









		this._lastenqueue = __r;
		
		// Did enqueue something
		return true;
	}
	
	/**
	 * Generates code to reference uncount the given register.







<
<
<







 







<
<
<

>


>
>
>
>
>
|
>
>
>
>







 







|
|
|

|
<
|
>
>
>
>
>
>
>
|
|
<
>
>
>
>
>
>
>
>
>
|







107
108
109
110
111
112
113



114
115
116
117
118
119
120
....
2757
2758
2759
2760
2761
2762
2763



2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
....
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842

2843
2844
2845
2846
2847
2848
2849
2850
2851
2852

2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
	/** Reference clearing and jumping to label. */
	private final Map<EnqueueAndLabel, __EData__> _refcljumps =
		new LinkedHashMap<>();
	
	/** Last registers enqueued. */
	private JavaStackEnqueueList _lastenqueue;
	



	/** Next reference count/uncount ID number for jump. */
	private int _refclunk;
	
	/**
	 * Initializes the byte code handler.
	 *
	 * @param __bc The byte code.
................................................................................
		JavaStackEnqueueList lastenqueue = this._lastenqueue;
		if (lastenqueue == null)
			return;
		
		// No need to clear anymore
		this._lastenqueue = null;
		



		// Un-count all of them accordingly
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (int i = 0, n = lastenqueue.size(); i < n; i++)
		{
			// Get the volatile to clear
			int v = lastenqueue.get(i);
			
			// Uncount this one
			this.__refUncount(v);
			
			// Free it for later usage
			volatiles.remove(v);
		}
	}
	
	/**
	 * Generates code to reference count the given register.
	 *
	 * @param __r The register to reference to count.
	 * @since 2019/04/25
................................................................................
		// Nothing to enqueue?
		if (__r.isEmpty())
		{
			this._lastenqueue = null;
			return false;
		}
		
		// Place anything that is referenced into volatile registers
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Get a volatile register and copy into it, store the volatile

		int n = __r.size();
		int[] use = new int[n];
		for (int i = 0; i < n; i++)
		{
			// Get the volatile register to copy into
			int v = volatiles.get();
			
			// Copy to the volatile
			codebuilder.addCopy(__r.get(i), v);
			

			// Use this volatile register
			use[i] = v;
		}
		
		// We completely lose our original registers and instead use our new
		// set of volatiles for later clearing and removing
		// Note that we keep the same stack offset because it will match
		// exactly as the input (needed for exception handlers), even though
		// the registers might be all over the place.
		this._lastenqueue = new JavaStackEnqueueList(__r.stackstart, use);
		
		// Did enqueue something
		return true;
	}
	
	/**
	 * Generates code to reference uncount the given register.