Check-in [e4720d6e8a]

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

Overview
Comment:Do not make ATOMIC_INT_DECREMENT_AND_GET not fail in SummerCoat if the value falls below zero (like RatufaCoat); In the GC check, only perform GC if the value is not-positive; Only make BREAKPOINT fail in RatufaCoat if debugging is enabled to match SummerCoat; Add debug printing to over-GC (not sure how this is happening yet)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e4720d6e8a560f19f062faee8a68aa6cbd16b2e1
User & Date: stephanie.gawroriski 2019-11-30 20:52:17
Context
2019-11-30
21:36
Use forwarded entries when decoding class names. check-in: ff27d4c1fa user: stephanie.gawroriski tags: trunk
20:52
Do not make ATOMIC_INT_DECREMENT_AND_GET not fail in SummerCoat if the value falls below zero (like RatufaCoat); In the GC check, only perform GC if the value is not-positive; Only make BREAKPOINT fail in RatufaCoat if debugging is enabled to match SummerCoat; Add debug printing to over-GC (not sure how this is happening yet) check-in: e4720d6e8a user: stephanie.gawroriski tags: trunk
20:34
Print stack traces when a Throwable is made. check-in: ce45e65d52 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ratufacoat/sjmerc.c.

1303
1304
1305
1306
1307
1308
1309
1310
1311


1312
1313
1314
1315



1316
1317
1318
1319
1320
1321
1322
					
					/* Modify the value accordingly. */
					sjme_vmmatomicintaddandget(jvm->vmem, ia, ib,
						SJME_JINT_C(1), error);
				}
				break;
				
				/* Breakpoint. */
			case SJME_OP_BREAKPOINT:


				sjme_seterror(error, SJME_ERROR_CPUBREAKPOINT,
					jvm->totalinstructions);
				
				return cycles;



			
				/* Copy value. */
			case SJME_OP_COPY:
				{
					ia = sjme_opdecodereg(jvm->vmem, &nextpc, error);
					ib = sjme_opdecodereg(jvm->vmem, &nextpc, error);
					







|

>
>
|
|
|
|
>
>
>







1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
					
					/* Modify the value accordingly. */
					sjme_vmmatomicintaddandget(jvm->vmem, ia, ib,
						SJME_JINT_C(1), error);
				}
				break;
				
				/* Breakpoint, only if debugging enabled. */
			case SJME_OP_BREAKPOINT:
				if (jvm->enabledebug != 0)
				{
					sjme_seterror(error, SJME_ERROR_CPUBREAKPOINT,
						jvm->totalinstructions);
					
					return cycles;
				}
				
				break;
			
				/* Copy value. */
			case SJME_OP_COPY:
				{
					ia = sjme_opdecodereg(jvm->vmem, &nextpc, error);
					ib = sjme_opdecodereg(jvm->vmem, &nextpc, error);
					

Changes to ratufacoat/sjmevdef.h.

162
163
164
165
166
167
168



169
170
171
172
173
174
175
	sjme_vmemptr syscallsfp;
	
	/** System call code pointer. */
	sjme_vmemptr syscallcode;
	
	/** System call pool pointer. */
	sjme_vmemptr syscallpool;



};

/****************************************************************************/

/** Anti-C++. */
#ifdef __cplusplus
#ifdef SJME_cXRATUFACOATSJMFHSJMEVDEFH







>
>
>







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	sjme_vmemptr syscallsfp;
	
	/** System call code pointer. */
	sjme_vmemptr syscallcode;
	
	/** System call pool pointer. */
	sjme_vmemptr syscallpool;
	
	/** Is debugging enabled? */
	sjme_jint enabledebug;
};

/****************************************************************************/

/** Anti-C++. */
#ifdef __cplusplus
#ifdef SJME_cXRATUFACOATSJMFHSJMEVDEFH

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

101
102
103
104
105
106
107



108
109
110
111
112
113
114
			todo.DEBUG.note("Inline execution main task...");
			mainthread[0].inlineExecute();
		}
		
		// It crashes
		catch (Throwable t)
		{



			// Print the trace
			try
			{
				// Print stack trace for this class
				t.printStackTrace();
			}
			







>
>
>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
			todo.DEBUG.note("Inline execution main task...");
			mainthread[0].inlineExecute();
		}
		
		// It crashes
		catch (Throwable t)
		{
			// Put code in saying this happened
			todo.DEBUG.code('X', 'X');
			
			// Print the trace
			try
			{
				// Print stack trace for this class
				t.printStackTrace();
			}
			

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

97
98
99
100
101
102
103















104
105
106
107
108
109
110
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		// Access of invalid object?
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			Assembly.breakpoint();















		
		// Attempt to garbage collect object with no class or is invalid
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// {@squirreljme.error SV0i Garbage collecting an object which is







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		// Access of invalid object?
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Report this code!
		int nref = Assembly.memReadInt(__p, Constants.OBJECT_COUNT_OFFSET);
		if (nref < 0)
		{
			// Report to the console this happened
			todo.DEBUG.code('G', 'C', __p);
			todo.DEBUG.code('G', '#', nref);
			
			// Break here, since this is not good
			Assembly.breakpoint();
			
			// Stop here
			return;
		}
		
		// Attempt to garbage collect object with no class or is invalid
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// {@squirreljme.error SV0i Garbage collecting an object which is

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

565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
						// Read, increment, and store
						int newval;
						memory.memWriteInt(addr + off,
							(newval = memory.memReadInt(addr + off) - 1));
						
						// Store the value after the decrement
						lr[args[0]] = newval;
						
						// {@squirreljme.error AE05 Atomic decremented to
						// negative value! (The address and offset; The
						// old value; The new value)}
						if (newval < 0)
							throw new VMException(String.format(
								"AE05 %08x+%d %d %d", addr, off, newval + 1,
								newval));
						
						// Debug
						/*if (ENABLE_DEBUG)
							todo.DEBUG.note("%08x(%d) -= %d - 1 = %d",
								addr, off, newval + 1, newval);*/
					}
					break;
					
					// Atomic increment
				case NativeInstructionType.ATOMIC_INT_INCREMENT:
					synchronized (memory)
					{







<
<
<
<
<
<
<
<
<
<
<
<
<







565
566
567
568
569
570
571













572
573
574
575
576
577
578
						// Read, increment, and store
						int newval;
						memory.memWriteInt(addr + off,
							(newval = memory.memReadInt(addr + off) - 1));
						
						// Store the value after the decrement
						lr[args[0]] = newval;













					}
					break;
					
					// Atomic increment
				case NativeInstructionType.ATOMIC_INT_INCREMENT:
					synchronized (memory)
					{

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

182
183
184
185
186
187
188


















189
190
191
192
193
194
195
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.NOT_EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}


















	
	/**
	 * Adds a jump if the given register is zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.NOT_EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is positive.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	public final NativeInstruction addIfPositive(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.GREATER_THAN, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.

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

3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
		codebuilder.addIfZero(__r, ncj);
		
		// Add uncount
		codebuilder.add(NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
			volnowcount, __r, Constants.OBJECT_COUNT_OFFSET);
		
		// If the count is still positive, we do not GC
		codebuilder.addIfNonZero(volnowcount, ncj);
		
		// Call garbage collect on object via helper
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmGarbageCollectObject", "(I)V", __r);
		
		// Reset the variable to zero to prevent it from being used again
		codebuilder.addCopy(NativeCode.ZERO_REGISTER, __r);







|







3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
		codebuilder.addIfZero(__r, ncj);
		
		// Add uncount
		codebuilder.add(NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
			volnowcount, __r, Constants.OBJECT_COUNT_OFFSET);
		
		// If the count is still positive, we do not GC
		codebuilder.addIfPositive(volnowcount, ncj);
		
		// Call garbage collect on object via helper
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmGarbageCollectObject", "(I)V", __r);
		
		// Reset the variable to zero to prevent it from being used again
		codebuilder.addCopy(NativeCode.ZERO_REGISTER, __r);