Check-in [8f2394f21a]

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

Overview
Comment:Add methods to help for the allocation of objects and arrays.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8f2394f21a780fe018d5dd769a42d51f1c510b95
User & Date: stephanie.gawroriski 2019-12-01 15:44:40
Context
2019-12-01
15:46
Force objects to be allocated to at least the base size. check-in: b853c133f7 user: stephanie.gawroriski tags: trunk
15:44
Add methods to help for the allocation of objects and arrays. check-in: 8f2394f21a user: stephanie.gawroriski tags: trunk
15:35
Setting of various class properties. check-in: 8fd9c6daec user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/klib/supervisor/cc/squirreljme/jvm/task/TaskAllocator.java.

6
7
8
9
10
11
12


13
14
15
16
17
18
19
..
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
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.task;

import cc.squirreljme.jvm.Allocator;



/**
 * This is an allocator which uses a pre-set tag value for any allocations.
 *
 * @since 2019/09/23
 */
public final class TaskAllocator
................................................................................
		
		// Ran out of memory?
		if (rv == 0)
			throw new TaskOutOfMemoryError();
		
		return rv;
	}































	
	/**
	 * Allocates an object type.
	 *
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @since 2019/10/26
	 */
	public final int allocateObject(int __sz)
	{
		return this.allocate(Allocator.CHUNK_BIT_IS_OBJECT, __sz);

























	}
	
	/**
	 * Allocates a region that can fit a constant pool with the given number
	 * of entries.
	 *
	 * @param __n The number of entries to use.







>
>







 







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










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







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
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
85
86
87
88
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
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.task;

import cc.squirreljme.jvm.Allocator;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;

/**
 * This is an allocator which uses a pre-set tag value for any allocations.
 *
 * @since 2019/09/23
 */
public final class TaskAllocator
................................................................................
		
		// Ran out of memory?
		if (rv == 0)
			throw new TaskOutOfMemoryError();
		
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values.
	 *
	 * @param __cl The class to set it as.
	 * @param __v The values to store.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayInt(TaskClass __cl, int... __v)
		throws NullPointerException
	{
		if (__cl == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Count used to store the array size
		int count = __v.length;
		
		// Allocate array pointer
		int rv = this.allocateObject(__cl,
			Constants.ARRAY_BASE_SIZE + (count * 4));
		
		// Copy pointer values to the array
		int bp = rv + Constants.ARRAY_BASE_SIZE;
		for (int i = 0, wp = 0; i < count; i++, wp += 4)
			Assembly.memWriteInt(bp, wp, __v[i]);
		
		// Return the result of it
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @since 2019/10/26
	 */
	public final int allocateObject(int __sz)
	{
		int rv = this.allocate(Allocator.CHUNK_BIT_IS_OBJECT, __sz);
		
		// Set initial count to one, to match new
		Assembly.memWriteInt(rv, Constants.OBJECT_COUNT_OFFSET,
			1);
		
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __cl The class type.
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @since 2019/12/01
	 */
	public final int allocateObject(TaskClass __cl, int __sz)
	{
		int rv = this.allocateObject(__sz);
		
		// Store class type here
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl.infoPointer());
		
		return rv;
	}
	
	/**
	 * Allocates a region that can fit a constant pool with the given number
	 * of entries.
	 *
	 * @param __n The number of entries to use.