diff options
| author | Cliff Click <cliffc@acm.org> | 2026-08-10 11:11:18 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-15 11:20:40 -0800 |
| commit | 658289861e8d971cd9e449e66a749c9c2d65f623 (patch) | |
| tree | 209a32ef7fab1d27222121bc8b53a968ff4b6796 /src/test/java/com/seaofnodes/simple/codegen | |
| parent | 77ae05305a5653a2353709564705819f201e587f (diff) | |
| download | Simple-linear.tar.gz Simple-linear.zip | |
Chapter 31: Software Drawing, Time, and Graphical Gameslinear
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: Symious <14933944+symious@users.noreply.github.com>
Co-authored-by: Jun Kawasaki <jun784@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/codegen')
| -rw-r--r-- | src/test/java/com/seaofnodes/simple/codegen/PrintRegTestSupport.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/java/com/seaofnodes/simple/codegen/PrintRegTestSupport.java b/src/test/java/com/seaofnodes/simple/codegen/PrintRegTestSupport.java index b255bcf7..190cf17c 100644 --- a/src/test/java/com/seaofnodes/simple/codegen/PrintRegTestSupport.java +++ b/src/test/java/com/seaofnodes/simple/codegen/PrintRegTestSupport.java @@ -3,6 +3,30 @@ import com.seaofnodes.simple.node.*; import com.seaofnodes.simple.type.TypeInteger; import static org.junit.Assert.*; public class PrintRegTestSupport { + public static void checkDataAliases(java.nio.file.Path file, int size, String... names) { + ElfReader elf=ElfReader.load(file.toFile(),null); + assertNotNull(elf); + ElfReader.Section symbols=java.util.Arrays.stream(elf._sections) + .filter(s -> ".symtab".equals(s._name)).findFirst().orElseThrow(); + ElfReader.Section strings=elf._sections[symbols._link]; + var bytes=java.nio.ByteBuffer.wrap(elf._buf).order(java.nio.ByteOrder.LITTLE_ENDIAN); + var wanted=new java.util.HashSet<>(java.util.Arrays.asList(names)); + Long address=null; + for( int i=0; i<symbols._size/symbols._esize; i++ ) { + int off=(int)symbols._offset+i*symbols._esize; + String name=strings.str(bytes.getInt(off)); + if( !wanted.remove(name) ) continue; + assertTrue("Debug aliases precede global symbols",i<symbols._info); + assertEquals("Local object symbol",1,bytes.get(off+4)&255); + assertEquals(".rodata",elf._sections[bytes.getShort(off+6)&65535]._name); + assertEquals(size,bytes.getLong(off+16)); + long value=bytes.getLong(off+8); + if( address!=null ) assertEquals("Aliases share storage",address.longValue(),value); + address=value; + } + assertTrue("Missing debug symbols: "+wanted,wanted.isEmpty()); + } + public static void check() throws Exception { var code = new CodeGen("return 0;").parse(); var alloc = new RegAlloc(code); @@ -61,7 +85,7 @@ public class PrintRegTestSupport { visit.put(marker,t); var method = com.seaofnodes.simple.print.ASMPrinter.class.getDeclaredMethod( "printConstantPool",int.class,com.seaofnodes.simple.util.SB.class, - com.seaofnodes.simple.util.BAOS.class,java.util.HashMap.class,boolean.class,String.class); + com.seaofnodes.simple.util.BAOS.class,java.util.Map.class,boolean.class,String.class); method.setAccessible(true); try { var sb = new com.seaofnodes.simple.util.SB(); |
