Check-in [a8dff38e8b]

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

Overview
Comment:Corrections to compilation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a8dff38e8b899a27cb2567b50e2d8e75186a587b
User & Date: stephanie.gawroriski 2019-02-05 20:39:27
Context
2019-02-05
20:57
Minor work. check-in: 29f98c01b8 user: stephanie.gawroriski tags: trunk
20:39
Corrections to compilation. check-in: a8dff38e8b user: stephanie.gawroriski tags: trunk
20:06
Some reworking of register things to make it easier to do things. check-in: ba413d128b user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/libs/tool-classfile-scrf-compiler/net/multiphasicapps/scrf/compiler/PrimitiveByteCodeProcessor.java.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
...
115
116
117
118
119
120
121
122

123
124
125
126

127
128
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;

import net.multiphasicapps.scrf.RegisterCode;

/**
 * This is a primitive byte code processor which just performs direct
 * translation of stack based operations to a register based format but does
 * not perform any optimizations.
 *
................................................................................
			// Depends on the instruction itself
			int vop;
			switch ((vop = PrimitiveByteCodeProcessor.__aliasOp(
				inst.operation())))
			{
					// Null reference
				case InstructionIndex.ACONST_NULL:
					cb.addConstPointer(registers.virtualPush(), 0);

					break;
					
					// Load reference
				case InstructionIndex.ALOAD:

					cb.addCopyPointer(inst.<Integer>argument(0, Integer.class),
						registers.virtualPush());
					break;
					
					// Load reference (quick)
				case InstructionIndex.ALOAD_0:
				case InstructionIndex.ALOAD_1:
				case InstructionIndex.ALOAD_2:
				case InstructionIndex.ALOAD_3:

					cb.addCopyPointer(vop - InstructionIndex.ALOAD_0,
						registers.virtualPush());
					break;
					
					// Load static field
				case InstructionIndex.GETSTATIC:
					FieldReference sfr = inst.<FieldReference>argument(0,
						FieldReference.class);
					switch (MemoryType.of(sfr))
					{
						case POINTER:
							if (true)
								throw new todo.TODO();
							break;
						
						default:
							throw new todo.TODO(sfr.toString());
					}
					break;
				
					// Nop
				case InstructionIndex.NOP:
					cb.addNop();
					break;
					
					// Load from indexed local
				case JavaInstructionAlias.XLOAD:

					cb.addCopy(inst.<Integer>argument(0, Integer.class),
						registers.virtualPush());
					break;
					
					// Load from quick indexed local
				case JavaInstructionAlias.XLOAD_0:
				case JavaInstructionAlias.XLOAD_1:
				case JavaInstructionAlias.XLOAD_2:
				case JavaInstructionAlias.XLOAD_3:

					cb.addCopy(vop - JavaInstructionAlias.XLOAD_0,
						registers.virtualPush());
					break;
				
					// Unhandled, needs to be supported
				default:
					throw new todo.TODO(inst.toString());
			}







>







 







|
>




>
|








>
|







<
<
<
|
|
<
<
<
<
<









>
|








>
|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147



148
149





150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;
import net.multiphasicapps.scrf.MemoryType;
import net.multiphasicapps.scrf.RegisterCode;

/**
 * This is a primitive byte code processor which just performs direct
 * translation of stack based operations to a register based format but does
 * not perform any optimizations.
 *
................................................................................
			// Depends on the instruction itself
			int vop;
			switch ((vop = PrimitiveByteCodeProcessor.__aliasOp(
				inst.operation())))
			{
					// Null reference
				case InstructionIndex.ACONST_NULL:
					cb.addConst(MemoryType.POINTER, registers.virtualPush(),
						0);
					break;
					
					// Load reference
				case InstructionIndex.ALOAD:
					cb.addCopy(MemoryType.POINTER,
						inst.<Integer>argument(0, Integer.class),
						registers.virtualPush());
					break;
					
					// Load reference (quick)
				case InstructionIndex.ALOAD_0:
				case InstructionIndex.ALOAD_1:
				case InstructionIndex.ALOAD_2:
				case InstructionIndex.ALOAD_3:
					cb.addCopy(MemoryType.POINTER,
						vop - InstructionIndex.ALOAD_0,
						registers.virtualPush());
					break;
					
					// Load static field
				case InstructionIndex.GETSTATIC:
					FieldReference sfr = inst.<FieldReference>argument(0,
						FieldReference.class);



					if (true)
						throw new todo.TODO();





					break;
				
					// Nop
				case InstructionIndex.NOP:
					cb.addNop();
					break;
					
					// Load from indexed local
				case JavaInstructionAlias.XLOAD:
					cb.addCopy(MemoryType.INTEGER,
						inst.<Integer>argument(0, Integer.class),
						registers.virtualPush());
					break;
					
					// Load from quick indexed local
				case JavaInstructionAlias.XLOAD_0:
				case JavaInstructionAlias.XLOAD_1:
				case JavaInstructionAlias.XLOAD_2:
				case JavaInstructionAlias.XLOAD_3:
					cb.addCopy(MemoryType.INTEGER,
						vop - JavaInstructionAlias.XLOAD_0,
						registers.virtualPush());
					break;
				
					// Unhandled, needs to be supported
				default:
					throw new todo.TODO(inst.toString());
			}

Changes to runt/libs/tool-classfile-scrf-compiler/net/multiphasicapps/scrf/compiler/RegisterCodeBuilder.java.

8
9
10
11
12
13
14

15
16


17
18
19
20
21
22
23
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
..
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
...
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132
133
134
135
136
137
138
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf.compiler;

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

import net.multiphasicapps.scrf.RegisterInstruction;
import net.multiphasicapps.scrf.RegisterInstructionType;



/**
 * This is used to build the register based code which is for later execution.
 *
 * @since 2019/01/22
 */
public final class RegisterCodeBuilder
................................................................................
	 */
	public final int addConst(MemoryType __t, int __dest, long __v)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return this.add(new RegisterInstruction(
			RegisterInstructionType.CONST, __t, __dest, , __v));
	}
	
	/**
	 * Adds a copy from one register to another.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The source.
................................................................................
	public final int addCopy(MemoryType __t, int __from, int __to)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return this.add(new RegisterInstruction(
			RegisterInstructionType.COPY, __t, __from, __to));

	}
	
	/**
	 * Adds a load from memory instruction.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The memory source to read from.
................................................................................
	public final int addLoad(MemoryType __t, MemorySource __from, int __to)
		throws NullPointerException
	{
		if (__t == null || __from == null)
			throw new NullPointerException("NARG");
	
		return this.add(new RegisterInstruction(
			RegisterInstructionType.LOAD, __t, __from, __to));

	}
	
	/**
	 * Adds a NOP instruction.
	 *
	 * @return The instruction index.
	 * @since 2019/01/23
	 */
	public final int addNop()
	{
		return this.add(new RegisterInstruction(RegisterInstructionIndex.NOP));
	}
}








>


>
>







 







|
|







 







|
>







 







|
>










|



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf.compiler;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.scrf.RegisterIndex;
import net.multiphasicapps.scrf.RegisterInstruction;
import net.multiphasicapps.scrf.RegisterInstructionType;
import net.multiphasicapps.scrf.MemorySource;
import net.multiphasicapps.scrf.MemoryType;

/**
 * This is used to build the register based code which is for later execution.
 *
 * @since 2019/01/22
 */
public final class RegisterCodeBuilder
................................................................................
	 */
	public final int addConst(MemoryType __t, int __dest, long __v)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return this.add(new RegisterInstruction(RegisterInstructionType.CONST,
			__t, new RegisterIndex(__dest), __v));
	}
	
	/**
	 * Adds a copy from one register to another.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The source.
................................................................................
	public final int addCopy(MemoryType __t, int __from, int __to)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return this.add(new RegisterInstruction(
			RegisterInstructionType.COPY, __t, new RegisterIndex(__from),
			new RegisterIndex(__to)));
	}
	
	/**
	 * Adds a load from memory instruction.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The memory source to read from.
................................................................................
	public final int addLoad(MemoryType __t, MemorySource __from, int __to)
		throws NullPointerException
	{
		if (__t == null || __from == null)
			throw new NullPointerException("NARG");
	
		return this.add(new RegisterInstruction(
			RegisterInstructionType.LOAD, __t, __from,
			new RegisterIndex(__to)));
	}
	
	/**
	 * Adds a NOP instruction.
	 *
	 * @return The instruction index.
	 * @since 2019/01/23
	 */
	public final int addNop()
	{
		return this.add(new RegisterInstruction(RegisterInstructionType.NOP));
	}
}

Changes to runt/libs/tool-scrf/net/multiphasicapps/scrf/RegisterInstruction.java.

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	 * @throws IllegalArgumentException If the operation is not valid.
	 * @since 2019/01/23
	 */
	public RegisterInstruction(int __op, Object... __args)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AV01 Invalid operation. (The operation)}
		if (__op < 0 || __op >= RegisterInstructionIndex.NUM_INSTRUCTIONS)
			throw new IllegalArgumentException("AV01 " + __op);
		
		this.op = __op;
		this._args = (__args = (__args == null ? new Object[0] :
			__args.clone()));
		
		// Check arguments for null
		for (Object a : __args)
			if (a == null)
				throw new NullPointerException("NARG");
	}
}








|













31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	 * @throws IllegalArgumentException If the operation is not valid.
	 * @since 2019/01/23
	 */
	public RegisterInstruction(int __op, Object... __args)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AV01 Invalid operation. (The operation)}
		if (__op < 0 || __op >= RegisterInstructionType.NUM_INSTRUCTIONS)
			throw new IllegalArgumentException("AV01 " + __op);
		
		this.op = __op;
		this._args = (__args = (__args == null ? new Object[0] :
			__args.clone()));
		
		// Check arguments for null
		for (Object a : __args)
			if (a == null)
				throw new NullPointerException("NARG");
	}
}

Changes to runt/libs/tool-scrf/net/multiphasicapps/scrf/VTableIndex.java.

12
13
14
15
16
17
18
19
20


21


22




































/**
 * This represents an index a VTable for the current class.
 *
 * @since 2019/02/05
 */
public class VTableIndex
	implements MemorySource
{


}













































|

>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
51
52
53
54
55
56
57
58
59
60
61

/**
 * This represents an index a VTable for the current class.
 *
 * @since 2019/02/05
 */
public class VTableIndex
	implements Comparable<VTableIndex>, MemorySource
{
	/** The vtable index. */
	protected final int index;
	
	/**
	 * Initializes the index.
	 *
	 * @param __i The index of the vtable entry.
	 * @since 2019/02/05
	 */
	public VTableIndex(int __i)
	{
		this.index = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/05
	 */
	@Override
	public final int compareTo(VTableIndex __o)
	{
		return this.index - __o.index;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof VTableIndex))
			return false;
		
		return this.index == ((VTableIndex)__o).index;
	}
}