Check-in [c04fe0c5c9]

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

Overview
Comment:Add JVMFunction.jvmLoadStringNoIntern().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c04fe0c5c9e23cd9da6bdedfe5e8f60c4d44b5e2
User & Date: stephanie.gawroriski 2019-06-14 18:23:55
Context
2019-06-14
19:20
Base for boot libraries. check-in: fbe1cde25c user: stephanie.gawroriski tags: trunk
18:23
Add JVMFunction.jvmLoadStringNoIntern(). check-in: c04fe0c5c9 user: stephanie.gawroriski tags: trunk
18:20
Remove a bunch of notes except from the GC. check-in: 4a34560d8e user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

275
276
277
278
279
280
281

282
283
284
285












286
287
288
289
290
291
292
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
		throw new todo.TODO();
	}
	
	/**
	 * Loads a string from memory and returns an `intern()` string value.
	 *
	 * @param __p The pointer to load the string bytes from.

	 * @since 2019/05/26
	 */
	public static final String jvmLoadString(int __p)
	{












		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		
		// Cannot load from a null string
		if (__p == 0)
			throw new VirtualMachineError();
................................................................................
		
		// Load the string data into bytes
		byte[] bytes = new byte[rawlen];
		for (int i = 0, base = __p + 2; i < rawlen; i++)
			bytes[i] = (byte)Assembly.memReadByte(base, i);
		
		// Initialize and intern string
		return new String(bytes).intern();
	}
	
	/**
	 * Reads a long value from the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.







>




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







 







|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
...
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
		throw new todo.TODO();
	}
	
	/**
	 * Loads a string from memory and returns an `intern()` string value.
	 *
	 * @param __p The pointer to load the string bytes from.
	 * @return The resulting and interned string.
	 * @since 2019/05/26
	 */
	public static final String jvmLoadString(int __p)
	{
		return JVMFunction.jvmLoadStringNoIntern(__p).intern();
	}
	
	/**
	 * Loads a string from memory and returns it.
	 *
	 * @param __p The pointer to load the string bytes from.
	 * @return The loaded string.
	 * @since 2019/06/14
	 */
	public static final String jvmLoadStringNoIntern(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		
		// Cannot load from a null string
		if (__p == 0)
			throw new VirtualMachineError();
................................................................................
		
		// Load the string data into bytes
		byte[] bytes = new byte[rawlen];
		for (int i = 0, base = __p + 2; i < rawlen; i++)
			bytes[i] = (byte)Assembly.memReadByte(base, i);
		
		// Initialize and intern string
		return new String(bytes);
	}
	
	/**
	 * Reads a long value from the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.