Check-in [78ebebc5a6]

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

Overview
Comment:Remove exception throwing in JVMFunctions and instead breakpoint if those conditions are met.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:78ebebc5a659f9554f0793499c23bf78b8f70400
User & Date: stephanie.gawroriski 2019-06-16 13:19:03
Context
2019-06-16
14:12
Add print of static field pointer; Clear the percent flag so that formatted strings are printed correctly. check-in: c249eafd1f user: stephanie.gawroriski tags: trunk
13:19
Remove exception throwing in JVMFunctions and instead breakpoint if those conditions are met. check-in: 78ebebc5a6 user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: 529c51a164 user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
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
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
	 * be returned, otherwise {@code 0} will.
	 * @since 2019/04/27
	 */
	public static final int jvmCanArrayStore(int __p, int __v)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC || __v == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Can always store null values
		if (__v == 0)
			return 1;
		
		// Load the component for this array
		ClassInfo pci = Assembly.pointerToClassInfo(
................................................................................
	 * array.
	 * @since 2019/04/27
	 */
	public static final int jvmComponentType(int __clid)
	{
		// Access of invalid class?
		if (__clid == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Performs aggressive garbage collection of the JVM heap to free as much
................................................................................
	 * @param __p The object to garbage collect.
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		// Access of invalid object?
		if (__p == 0 || __p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// 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();
			throw new VirtualMachineError();
		}
		
		// Debug
		todo.DEBUG.code('G', 'C', __p);
		
		// Get class info for this type
		ClassInfo pinfo = Assembly.pointerToClassInfo(pcl);
		
................................................................................
	 * @return The pointer to the code to be invoked.
	 * @since 2019/04/30
	 */
	public static final int jvmInterfacePointer(int __p, int __icl, int __mdx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an array.
................................................................................
	 * @return Either {@code 1} if it is an array or {@code 0} if it is not.
	 * @since 2019/04/27
	 */
	public static final int jvmIsArray(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an instance of the given class.
................................................................................
	 * it is not.
	 * @since 2019/04/22
	 */
	public static final int jvmIsInstance(int __p, int __cldx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Not instance of null class
		if (__p == 0)
			return 0;
		
		// If the object's class type is a direct match then quickly return
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == __cldx)
			return 1;
		
		// Corrupted object?
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Scan through super classes and check
		ClassInfo mine = Assembly.pointerToClassInfo(pcl);
		for (ClassInfo seek = mine; seek != null; seek = seek.superclass)
		{
			// Get self pointer
			int selfptr = seek.selfptr;
................................................................................
	 * @param __cldx The class index pointer.
	 * @since 2019/05/26
	 */
	public static final Class<?> jvmLoadClass(int __cldx)
	{
		// Access of invalid class?
		if (__cldx == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		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)
	{
		String rv = JVMFunction.jvmLoadStringNoIntern(__p);
		return rv.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)
	{
		// Note
		todo.DEBUG.code('J', 'S', __p);
		
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Cannot load from a null string
		if (__p == 0)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Read length of the raw bytes
		int rawlen = Assembly.memReadJavaShort(__p, 0) & 0xFFFF;
		
		// 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.
................................................................................
	 * @param __p The object to enter.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorEnter(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Exits the monitor for the given object.
................................................................................
	 * @param __p The object to exit.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorExit(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new object.
................................................................................
	 * @return The resulting class pointer.
	 * @since 2019/05/24
	 */
	public static final int jvmNew(int __cl)
	{
		// Access of invalid class?
		if (__cl == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Cannot allocate a null class
		if (__cl == 0)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Get the class information for the object to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__cl);
		
		// Allocate the memory
		int rv = Allocator.allocate(info.size);
		if (rv == 0)
................................................................................
	 * @since 2019/04/24
	 */
	public static final int jvmNewArray(int __at, int __len)
		throws NegativeArraySizeException, OutOfMemoryError
	{
		// Access of invalid class?
		if (__at == Constants.BAD_MAGIC)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Do not initialize null class
		if (__at == 0)
		{
			Assembly.breakpoint();
			throw new VirtualMachineError();
		}
		
		// Cannot allocate negative length
		if (__len < 0)
			throw new NegativeArraySizeException();
		
		// Get the class information for the array we want to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__at);







<

<
<







 







<

<
<







 







<

<
<




<

<
<







 







<

<
<







 







<

<
<







 







<

<
<












<

<
<







 







<

<
<







 







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


<

<
<



<

<
<










|







 







<

<
<







 







<

<
<







 







<

<
<



<

<
<







 







<

<
<



<

<
<







34
35
36
37
38
39
40

41


42
43
44
45
46
47
48
..
70
71
72
73
74
75
76

77


78
79
80
81
82
83
84
..
98
99
100
101
102
103
104

105


106
107
108
109

110


111
112
113
114
115
116
117
...
168
169
170
171
172
173
174

175


176
177
178
179
180
181
182
...
185
186
187
188
189
190
191

192


193
194
195
196
197
198
199
...
204
205
206
207
208
209
210

211


212
213
214
215
216
217
218
219
220
221
222
223

224


225
226
227
228
229
230
231
...
271
272
273
274
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
306
307
308
309
310
311
312
313
314
315
316
317
...
360
361
362
363
364
365
366

367


368
369
370
371
372
373
374
...
376
377
378
379
380
381
382

383


384
385
386
387
388
389
390
...
393
394
395
396
397
398
399

400


401
402
403

404


405
406
407
408
409
410
411
...
433
434
435
436
437
438
439

440


441
442
443

444


445
446
447
448
449
450
451
	 * be returned, otherwise {@code 0} will.
	 * @since 2019/04/27
	 */
	public static final int jvmCanArrayStore(int __p, int __v)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC || __v == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Can always store null values
		if (__v == 0)
			return 1;
		
		// Load the component for this array
		ClassInfo pci = Assembly.pointerToClassInfo(
................................................................................
	 * array.
	 * @since 2019/04/27
	 */
	public static final int jvmComponentType(int __clid)
	{
		// Access of invalid class?
		if (__clid == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Performs aggressive garbage collection of the JVM heap to free as much
................................................................................
	 * @param __p The object to garbage collect.
	 * @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();


		
		// Debug
		todo.DEBUG.code('G', 'C', __p);
		
		// Get class info for this type
		ClassInfo pinfo = Assembly.pointerToClassInfo(pcl);
		
................................................................................
	 * @return The pointer to the code to be invoked.
	 * @since 2019/04/30
	 */
	public static final int jvmInterfacePointer(int __p, int __icl, int __mdx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an array.
................................................................................
	 * @return Either {@code 1} if it is an array or {@code 0} if it is not.
	 * @since 2019/04/27
	 */
	public static final int jvmIsArray(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an instance of the given class.
................................................................................
	 * it is not.
	 * @since 2019/04/22
	 */
	public static final int jvmIsInstance(int __p, int __cldx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Not instance of null class
		if (__p == 0)
			return 0;
		
		// If the object's class type is a direct match then quickly return
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == __cldx)
			return 1;
		
		// Corrupted object?
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Scan through super classes and check
		ClassInfo mine = Assembly.pointerToClassInfo(pcl);
		for (ClassInfo seek = mine; seek != null; seek = seek.superclass)
		{
			// Get self pointer
			int selfptr = seek.selfptr;
................................................................................
	 * @param __cldx The class index pointer.
	 * @since 2019/05/26
	 */
	public static final Class<?> jvmLoadClass(int __cldx)
	{
		// Access of invalid class?
		if (__cldx == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		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)
	{
















		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Cannot load from a null string
		if (__p == 0)

			Assembly.breakpoint();


		
		// Read length of the raw bytes
		int rawlen = Assembly.memReadJavaShort(__p, 0) & 0xFFFF;
		
		// 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.
................................................................................
	 * @param __p The object to enter.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorEnter(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Exits the monitor for the given object.
................................................................................
	 * @param __p The object to exit.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorExit(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new object.
................................................................................
	 * @return The resulting class pointer.
	 * @since 2019/05/24
	 */
	public static final int jvmNew(int __cl)
	{
		// Access of invalid class?
		if (__cl == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Cannot allocate a null class
		if (__cl == 0)

			Assembly.breakpoint();


		
		// Get the class information for the object to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__cl);
		
		// Allocate the memory
		int rv = Allocator.allocate(info.size);
		if (rv == 0)
................................................................................
	 * @since 2019/04/24
	 */
	public static final int jvmNewArray(int __at, int __len)
		throws NegativeArraySizeException, OutOfMemoryError
	{
		// Access of invalid class?
		if (__at == Constants.BAD_MAGIC)

			Assembly.breakpoint();


		
		// Do not initialize null class
		if (__at == 0)

			Assembly.breakpoint();


		
		// Cannot allocate negative length
		if (__len < 0)
			throw new NegativeArraySizeException();
		
		// Get the class information for the array we want to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__at);