Check-in [a0f2f0263a]

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

Overview
Comment:Printing of base execution slices.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a0f2f0263a9f5a43b7d1aad05998a16683656739
User & Date: stephanie.gawroriski 2019-11-03 11:42:42
Context
2019-11-03
11:52
Make the CPU registers print out a bit nicer. check-in: 747fc8a67f user: stephanie.gawroriski tags: trunk
11:42
Printing of base execution slices. check-in: a0f2f0263a user: stephanie.gawroriski tags: trunk
11:17
Initialization of execution slices but not printing of them yet. check-in: 324a3f395e user: stephanie.gawroriski tags: trunk, x-date-201911
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

11
12
13
14
15
16
17

18
19
20
21
22
23
24
..
88
89
90
91
92
93
94
95




















































































































96
97
98
99
100
101
102

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import java.io.PrintStream;


/**
 * This represents a single slice of execution.
 *
 * @since 2019/10/27
 */
public final class ExecutionSlice
................................................................................
	 */
	public final void print(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();




















































































































		
		/*
		PrintStream out = System.err;
		
		// Limit class name
		CallTraceElement trace = this.trace(__nf);
		String cname = "" + trace.className();







>







 







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







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
180
181
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
218
219

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import java.io.PrintStream;
import net.multiphasicapps.classfile.InstructionMnemonics;

/**
 * This represents a single slice of execution.
 *
 * @since 2019/10/27
 */
public final class ExecutionSlice
................................................................................
	 */
	public final void print(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// We need all of these!
		CallTraceElement trace = this.trace;
		int op = this.op;
		int[] opargs = this._opargs,
			cpuregs = this._cpuregs,
			callargs = this._callargs;
		
		// Print CPU operation state
		__ps.printf("$$$$$$$$ @%08x (%s/%s)%n", trace.address(),
			NativeInstruction.mnemonic(op),
			InstructionMnemonics.toString(trace.byteCodeInstruction()));
		
		// Print normal trace info
		__ps.printf("  - InFrm: %s%n", trace.toString());
		
		// Print CPU registers
		__ps.print("  - CPU+g:[");
		boolean didstar = false;
		for (int i = 0, n = cpuregs.length, lastval = -1; i < n; i++)
		{
			// Put local registers on a new line
			if (i == NativeCode.LOCAL_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+l:[");
				lastval = -1;
			}
			
			// Start the arguments as well
			else if (i == NativeCode.ARGUMENT_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+a:[");
				lastval = -1;
			}
			
			// Use comma here
			else if (i > 0 && !didstar)
				__ps.print(", ");
			
			// Known register name?
			String knownreg = null;
			switch (i)
			{
				case NativeCode.ZERO_REGISTER:
					knownreg = "zero";
					break;
				
				case NativeCode.RETURN_REGISTER:
					knownreg = "return1";
					break;
				
				case NativeCode.RETURN_REGISTER + 1:
					knownreg = "return2";
					break;
				
				case NativeCode.EXCEPTION_REGISTER:
					knownreg = "exception";
					break;
				
				case NativeCode.STATIC_FIELD_REGISTER:
					knownreg = "sfieldptr";
					break;
				
				case NativeCode.THREAD_REGISTER:
					knownreg = "thread";
					break;
				
				case NativeCode.POOL_REGISTER:
					knownreg = "pool";
					break;
				
				case NativeCode.NEXT_POOL_REGISTER:
					knownreg = "nextpool";
					break;
				
				case NativeCode.ARGUMENT_REGISTER_BASE:
					knownreg = "a0/this";
					break;
			}
			
			// Show a value
			int val = cpuregs[i];
			if (i == 0 || val != 0 || val != lastval)
			{
				// Print out
				__ps.printf("%s=%xh", (knownreg != null ? knownreg :
				String.format("r%d", i)), cpuregs[i]);
				
				// Never do a star!
				didstar = false;
			}
			
			// Zero value and last was zero as well
			else
			{
				__ps.print("*");
				
				didstar = true;
			}
			
			// Used to skip blanks
			lastval = val;
		}
		__ps.println("]");
		
		// Print call arguments, if any
		if (callargs != null)
		{
			__ps.print("  - CallA: (");
			for (int i = 0, n = callargs.length; i < n; i++)
			{
				if (i > 0)
					__ps.print(", ");
				
				__ps.printf("%xh", callargs[i]);
			}
			__ps.println(")");
		}
		
		/*
		PrintStream out = System.err;
		
		// Limit class name
		CallTraceElement trace = this.trace(__nf);
		String cname = "" + trace.className();

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

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.classfile.InstructionMnemonics;
import net.multiphasicapps.collections.IntegerList;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.profiler.ProfiledThread;

/**
 * This represents a native CPU which may run within its own thread to







<







28
29
30
31
32
33
34

35
36
37
38
39
40
41
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

import net.multiphasicapps.collections.IntegerList;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.profiler.ProfiledThread;

/**
 * This represents a native CPU which may run within its own thread to