Check-in [7434d31525]

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

Overview
Comment:Add GARBAGE_COLLECT system call and remove MemoryAccess (not used anymore).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7434d3152516f19439d8e168308b0a3bf9fbeb8f
User & Date: stephanie.gawroriski 2019-05-23 23:14:20
Context
2019-05-23
23:22
Make EXIT a system call. check-in: 5a68aa5516 user: stephanie.gawroriski tags: trunk
23:14
Add GARBAGE_COLLECT system call and remove MemoryAccess (not used anymore). check-in: 7434d31525 user: stephanie.gawroriski tags: trunk
23:07
Move memory information to system calls. check-in: d2e5d8e2e9 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/MemoryAccess.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class contains static methods which are replaced by the compiler to
 * provide native access to memory.
 *
 * @since 2017/12/27
 */
public final class MemoryAccess
{
	/**
	 * Not used.
	 *
	 * @since 2017/12/27
	 */
	private MemoryAccess()
	{
	}
	
	/**
	 * Returns the amount of memory that is available for the VM to use.
	 *
	 * @return The amount of free memory.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long freeMemory()
	{
		return Runtime.getRuntime().freeMemory();
	}
	
	/**
	 * Performs or hints to the garbage collector that it should run.
	 *
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void gc()
	{
		Runtime.getRuntime().gc();
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *
	 * @return The maximum amount of memory available to the virtual machine.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long maxMemory()
	{
		return Runtime.getRuntime().maxMemory();
	}
	
	/**
	 * Returns the total amount of memory that is being used by the virtual
	 * machine. This is a count of all the memory claimed by the virtual
	 * machine itself for its memory pools and such.
	 *
	 * @return The amount of memory being used by the virtual machine.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long totalMemory()
	{
		return Runtime.getRuntime().totalMemory();
	}
}

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








































































































































































Changes to bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/vki/Assembly.java.

1076
1077
1078
1079
1080
1081
1082










1083
1084
1085
1086
1087
1088
1089
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;










			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used







>
>
>
>
>
>
>
>
>
>







1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
				// Invoke the garbage collector
			case SystemCallIndex.GARBAGE_COLLECT:
				{
					Runtime.getRuntime().gc();
					
					rv = 0;
					err = 0;
				}
				break;
			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/MemoryAccess.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
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class contains static methods which are replaced by the compiler to
 * provide native access to memory.
 *
 * @since 2017/12/27
 */
public final class MemoryAccess
{
	/**
	 * Not used.
	 *
	 * @since 2017/12/27
	 */
	private MemoryAccess()
	{
	}
	
	/**
	 * Performs or hints to the garbage collector that it should run.
	 *
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void gc();
}

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


















































































Changes to runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/vki/SystemCallIndex.java.

64
65
66
67
68
69
70




71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	public static final short VMI_MEM_USED =
		8;
	
	/** VM Information: Max memory in bytes. */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final short VMI_MEM_MAX =
		9;




	
	/** System call count. */
	public static final int NUM_SYSCALLS =
		10;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallIndex()
	{
	}
}








>
>
>
>



|











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
	public static final short VMI_MEM_USED =
		8;
	
	/** VM Information: Max memory in bytes. */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final short VMI_MEM_MAX =
		9;
	
	/** Invoke the garbage collector. */
	public static final short GARBAGE_COLLECT =
		10;
	
	/** System call count. */
	public static final int NUM_SYSCALLS =
		11;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallIndex()
	{
	}
}

Changes to runt/apis/cldc-compact/java/lang/Runtime.java.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.MemoryAccess;
import cc.squirreljme.runtime.cldc.vki.Assembly;
import cc.squirreljme.runtime.cldc.vki.SystemCallError;
import cc.squirreljme.runtime.cldc.vki.SystemCallIndex;

/**
 * This class contains information about the host memory environment along
 * with providing methods to perform garbage collection and exit the
................................................................................
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public void gc()
	{
		MemoryAccess.gc();
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *







<







 







|







7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.SystemAccess;

import cc.squirreljme.runtime.cldc.vki.Assembly;
import cc.squirreljme.runtime.cldc.vki.SystemCallError;
import cc.squirreljme.runtime.cldc.vki.SystemCallIndex;

/**
 * This class contains information about the host memory environment along
 * with providing methods to perform garbage collection and exit the
................................................................................
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public void gc()
	{
		Assembly.sysCall(SystemCallIndex.GARBAGE_COLLECT);
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/MemoryAccess.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class contains static methods which are replaced by the compiler to
 * provide native access to memory.
 *
 * @since 2017/12/27
 */
public final class MemoryAccess
{
	/**
	 * Not used.
	 *
	 * @since 2017/12/27
	 */
	private MemoryAccess()
	{
	}
	
	/**
	 * Returns the amount of memory that is available for the VM to use.
	 *
	 * @return The amount of free memory.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long freeMemory()
	{
		return Runtime.getRuntime().freeMemory();
	}
	
	/**
	 * Performs or hints to the garbage collector that it should run.
	 *
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void gc()
	{
		Runtime.getRuntime().gc();
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *
	 * @return The maximum amount of memory available to the virtual machine.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long maxMemory()
	{
		return Runtime.getRuntime().maxMemory();
	}
	
	/**
	 * Returns the total amount of memory that is being used by the virtual
	 * machine. This is a count of all the memory claimed by the virtual
	 * machine itself for its memory pools and such.
	 *
	 * @return The amount of memory being used by the virtual machine.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final long totalMemory()
	{
		return Runtime.getRuntime().totalMemory();
	}
}

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








































































































































































Changes to runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringThreadWorker.java.

1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
....
4228
4229
4230
4231
4232
4233
4234










4235
4236
4237
4238
4239
4240
4241
					
				// Unresolve string pointer
			case "cc/squirreljme/runtime/cldc/asm/DebugAccess::" +
				"unresolveString:(Ljava/lang/String;)J":
				return this.machine.debugUnresolveString(
					this.<String>asNativeObject(String.class, __args[0]));
				
				// Garbage collect suggestion
			case "cc/squirreljme/runtime/cldc/asm/MemoryAccess::" +
				"gc:()V":
				Runtime.getRuntime().gc();
				return null;
				
				// Accelerated graphics
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"accelGfx:(I)Z":
				return this.machine.nativedisplay.accelGfx(
					(Integer)__args[0]);
				
				// Accelerated graphics operation
................................................................................
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;










			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used







<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>







1364
1365
1366
1367
1368
1369
1370






1371
1372
1373
1374
1375
1376
1377
....
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
					
				// Unresolve string pointer
			case "cc/squirreljme/runtime/cldc/asm/DebugAccess::" +
				"unresolveString:(Ljava/lang/String;)J":
				return this.machine.debugUnresolveString(
					this.<String>asNativeObject(String.class, __args[0]));
				






				// Accelerated graphics
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"accelGfx:(I)Z":
				return this.machine.nativedisplay.accelGfx(
					(Integer)__args[0]);
				
				// Accelerated graphics operation
................................................................................
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
				// Invoke the garbage collector
			case SystemCallIndex.GARBAGE_COLLECT:
				{
					Runtime.getRuntime().gc();
					
					rv = 0;
					err = 0;
				}
				break;
			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used