Check-in [a11d27d936]

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

Overview
Comment:Add conversion for system calls.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a11d27d936af9a02df1950766e495cba383a8faa
User & Date: stephanie.gawroriski 2019-05-24 17:30:26
Context
2019-05-24
17:51
Remove WhereIsThis, line debug, JOp debug, and JInst debug (they are inlined with the code now rather than separate). check-in: c2cc24e90d user: stephanie.gawroriski tags: trunk
17:30
Add conversion for system calls. check-in: a11d27d936 user: stephanie.gawroriski tags: trunk
17:09
Move ObjectAccess.arrayLength() to Assembly. check-in: 61e90ad12e user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

295
296
297
298
299
300
301

302
303
304
305
306
307
308
...
351
352
353
354
355
356
357






358
359
360
361
362
363
364
...
627
628
629
630
631
632
633

634
635
636
637
638
639
640
			
			case NativeInstructionType.ARRAYLEN:
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
			case NativeInstructionType.CONVERSION:
			case NativeInstructionType.INVOKE:
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.NEW:

				return 2;
					
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
			case NativeInstructionType.CONVERSION_TO_WIDE:
			case NativeInstructionType.CONVERSION_FROM_WIDE:
			case NativeInstructionType.DEBUG_ENTRY:
			case NativeInstructionType.DEBUG_POINT:
................................................................................
		{
				// []
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return ArgumentFormat.of();
				






				// [u16, u16]
			case NativeInstructionType.ARRAYLEN:
				return ArgumentFormat.of(
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT);
					
				// [u16, u16]
................................................................................
			case NativeInstructionType.DEBUG_POINT:		return "DEBUG_POINT";
			case NativeInstructionType.IFEQ_CONST:		return "IFEQ_CONST";
			case NativeInstructionType.INVOKE:			return "INVOKE";
			case NativeInstructionType.LOAD_POOL:		return "LOAD_POOL";
			case NativeInstructionType.LOAD_TABLE:		return "LOAD_TABLE";
			case NativeInstructionType.NEW:				return "NEW";
			case NativeInstructionType.RETURN:			return "RETURN";

			
			default:
				return String.format("UNKNOWN_%02x", __op);
		}
	}
}








>







 







>
>
>
>
>
>







 







>







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
...
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
			
			case NativeInstructionType.ARRAYLEN:
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
			case NativeInstructionType.CONVERSION:
			case NativeInstructionType.INVOKE:
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.NEW:
			case NativeInstructionType.SYSTEM_CALL:
				return 2;
					
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
			case NativeInstructionType.CONVERSION_TO_WIDE:
			case NativeInstructionType.CONVERSION_FROM_WIDE:
			case NativeInstructionType.DEBUG_ENTRY:
			case NativeInstructionType.DEBUG_POINT:
................................................................................
		{
				// []
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return ArgumentFormat.of();
				
				// System call
			case NativeInstructionType.SYSTEM_CALL:
				return ArgumentFormat.of(
					ArgumentFormat.VUINT,
					ArgumentFormat.REGLIST);
				
				// [u16, u16]
			case NativeInstructionType.ARRAYLEN:
				return ArgumentFormat.of(
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT);
					
				// [u16, u16]
................................................................................
			case NativeInstructionType.DEBUG_POINT:		return "DEBUG_POINT";
			case NativeInstructionType.IFEQ_CONST:		return "IFEQ_CONST";
			case NativeInstructionType.INVOKE:			return "INVOKE";
			case NativeInstructionType.LOAD_POOL:		return "LOAD_POOL";
			case NativeInstructionType.LOAD_TABLE:		return "LOAD_TABLE";
			case NativeInstructionType.NEW:				return "NEW";
			case NativeInstructionType.RETURN:			return "RETURN";
			case NativeInstructionType.SYSTEM_CALL:		return "SYSTEM_CALL";
			
			default:
				return String.format("UNKNOWN_%02x", __op);
		}
	}
}

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

195
196
197
198
199
200
201




202
203
204
205
206
207
208
	/** Atomically decrements a memory addres and gets the value. */
	public static final int ATOMIC_INT_DECREMENT_AND_GET =
		0xF9;
	
	/** Atomically increments a memory address. */
	public static final int ATOMIC_INT_INCREMENT =
		0xFA;




	
	/** Load from table that is of native int/pointer size. */
	public static final int LOAD_TABLE =
		0xFC;
	
	/**
	 * Load from pool, note that at code gen time this is aliased.







>
>
>
>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
	/** Atomically decrements a memory addres and gets the value. */
	public static final int ATOMIC_INT_DECREMENT_AND_GET =
		0xF9;
	
	/** Atomically increments a memory address. */
	public static final int ATOMIC_INT_INCREMENT =
		0xFA;
	
	/** System call. */
	public static final int SYSTEM_CALL =
		0xFB;
	
	/** Load from table that is of native int/pointer size. */
	public static final int LOAD_TABLE =
		0xFC;
	
	/**
	 * Load from pool, note that at code gen time this is aliased.

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

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
519
...
729
730
731
732
733
734
735












































736
737
738
739
740
741
742
			// Force exception cancel for these operations
			this.state.canexception = false;
			
			// Depends on the assembly function
			String asmfunc;
			switch ((asmfunc = __r.handle().name().toString()))
			{





					// Breakpoint
				case "breakpoint":
					codebuilder.add(NativeInstructionType.BREAKPOINT);
					break;








					
					// Exception handling
				case "exceptionHandle":
					// This generates no actual codes to check the exception,
					// it just makes the exception check run so that they are
					// checked
					this.state.canexception = true;
					break;







					
					// Invoke method, no return value is read
				case "invoke":
					{
						// Invoked methods can thrown an exception, so do
						// checks! Otherwise the behavior we expect might not
						// happen
................................................................................
					break;
					
					// Set thread register
				case "specialSetThreadRegister":
					codebuilder.addCopy(__in[0].register,
						NativeCode.THREAD_REGISTER);
					break;












































				
				default:
					throw new todo.OOPS(asmfunc);
			}
		}
		
		// Normal invoke







>
>
>
>
>




>
>
>
>
>
>
>
>








>
>
>
>
>
>
>







 







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







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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
...
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
			// Force exception cancel for these operations
			this.state.canexception = false;
			
			// Depends on the assembly function
			String asmfunc;
			switch ((asmfunc = __r.handle().name().toString()))
			{
					// Read lenght of array
				case "arrayLength":
					this.doArrayLength(__in[0], __out);
					break;
					
					// Breakpoint
				case "breakpoint":
					codebuilder.add(NativeInstructionType.BREAKPOINT);
					break;
					
					// Long/Double bits
				case "doubleToRawLongBits":
				case "longBitsToDouble":
					if (__in[0].register != __out.register)
						codebuilder.addCopyWide(__in[0].register,
							__out.register);
					break;
					
					// Exception handling
				case "exceptionHandle":
					// This generates no actual codes to check the exception,
					// it just makes the exception check run so that they are
					// checked
					this.state.canexception = true;
					break;
					
					// Integer/Float bits
				case "floatToRawIntBits":
				case "intBitsToFloat":
					if (__in[0].register != __out.register)
						codebuilder.addCopy(__in[0].register, __out.register);
					break;
					
					// Invoke method, no return value is read
				case "invoke":
					{
						// Invoked methods can thrown an exception, so do
						// checks! Otherwise the behavior we expect might not
						// happen
................................................................................
					break;
					
					// Set thread register
				case "specialSetThreadRegister":
					codebuilder.addCopy(__in[0].register,
						NativeCode.THREAD_REGISTER);
					break;
					
					// System call
				case "sysCall":
					{
						// Invoked methods can thrown an exception, so do
						// checks! Otherwise the behavior we expect might not
						// happen
						this.state.canexception = true;
						
						// Build the register List
						List<Integer> args = new ArrayList<>();
						int n = __in.length;
						for (int i = 1; i < n; i++)
							args.add(__in[i].register);
						
						// Invoke pointer with arguments
						codebuilder.add(NativeInstructionType.SYSTEM_CALL,
							__in[0].register, new RegisterList(args));
					}
					break;
					
					// System call with return value
				case "sysCallV":
					{
						// Invoked methods can thrown an exception, so do
						// checks! Otherwise the behavior we expect might not
						// happen
						this.state.canexception = true;
						
						// Build the register List
						List<Integer> args = new ArrayList<>();
						int n = __in.length;
						for (int i = 1; i < n; i++)
							args.add(__in[i].register);
						
						// Invoke pointer with arguments
						codebuilder.add(NativeInstructionType.SYSTEM_CALL,
							__in[0].register, new RegisterList(args));
						
						// Copy return value
						codebuilder.addCopy(NativeCode.RETURN_REGISTER,
							__out.register);
					}
					break;
				
				default:
					throw new todo.OOPS(asmfunc);
			}
		}
		
		// Normal invoke