From 0b3efa1620ad89fe3de2a83c6734cbea4e9d441b Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 1 Jul 2004 01:53:22 -0700 Subject: [PATCH] gcclass hints (YOU NEED TO UPDATE upstream/build/gcclass) darcs-hash:20040701085322-24bed-801fc66615d086ab0db61763d35382affdc3e8f4.gz --- Makefile | 19 +++++++------------ src/org/ibex/nestedvm/ClassFileCompiler.java | 18 ++++++++++++++++-- src/org/ibex/nestedvm/util/Platform.java | 7 +++++++ upstream/Makefile | 2 +- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index d0b20c4..3cdb291 100644 --- a/Makefile +++ b/Makefile @@ -221,18 +221,16 @@ nestedvm.jar: $(java_classes) .manifest cd build && jar cfm ../$@ ../.manifest $(java_classes:build/%.class=%*.class) cd $(CLASSGEN_PATH) && jar uf $(mips2java_root)/$@ . -compact_runtime_compiler.jar: $(java_classes) .manifest $(tasks)/build_darcs_gcclass +.gcclass_hints: $(java_sources) + sed -n 's/.*GCCLASS_HINT: \([^ ]*\) \([^ ]*\).*/hint:\1:\2/p' $(java_sources) > $@ + +compact_runtime_compiler.jar: $(java_classes) .manifest $(tasks)/build_darcs_gcclass .gcclass_hints mkdir -p tmp/pruned rm -rf tmp/pruned/* java -cp \ upstream/build/gcclass/build:upstream/build/gcclass/upstream/bcel-5.1/bcel-5.1.jar \ com.brian_web.gcclass.GCClass \ - "$(classpath)" tmp/pruned \ - org.ibex.nestedvm.RuntimeCompiler.main 'org.ibex.nestedvm.Runtime.decodeData' \ - 'org.ibex.nestedvm.UnixRuntime.' 'org.ibex.nestedvm.Runtime.initPages' \ - 'org.ibex.nestedvm.Runtime.clearPages' 'org.ibex.nestedvm.Runtime.syscall' \ - 'org.ibex.nestedvm.Runtime$$CPUState.dup' \ - org.ibex.nestedvm.util.Platform\$$Jdk{11,12,13,14}.'' + "$(classpath)" tmp/pruned org.ibex.nestedvm.RuntimeCompiler.main `cat .gcclass_hints` cd tmp/pruned && jar cfm ../../$@ ../../.manifest . sizecheck: compact_runtime_compiler.jar @@ -399,15 +397,12 @@ ntlmtest: build/tests/NtlmAuth.class @test -e smb.conf || cp upstream/build/samba/examples/smb.conf.default smb.conf $(JAVA) -cp "$(classpath)" tests.NtlmAuth --username=brian --password=test --diagnostics -d 5 -ntlmauth.jar: build/tests/NtlmAuth.class $(tasks)/build_darcs_gcclass +ntlmauth.jar: build/tests/NtlmAuth.class $(tasks)/build_darcs_gcclass .gcclass_hints mkdir -p tmp/pruned rm -rf tmp/pruned/* java -cp \ upstream/build/gcclass/build:upstream/build/gcclass/upstream/bcel-5.1/bcel-5.1.jar \ - com.brian_web.gcclass.GCClass \ - "$(classpath)" tmp/pruned \ - tests.NtlmAuth.main \ - $(patsubst %,org.ibex.nestedvm.util.Platform\$$Jdk%.'', 11 12 13 14) + com.brian_web.gcclass.GCClass "$(classpath)" tmp/pruned tests.NtlmAuth.main `cat .gcclass_hints` printf "Manifest-Version: 1.0\nMain-Class: tests.NtlmAuth\n" > .manifest.ntlm cd tmp/pruned && jar cfm ../../$@ ../../.manifest.ntlm . rm -f .manifest.ntlm diff --git a/src/org/ibex/nestedvm/ClassFileCompiler.java b/src/org/ibex/nestedvm/ClassFileCompiler.java index 20652b6..47f7bed 100644 --- a/src/org/ibex/nestedvm/ClassFileCompiler.java +++ b/src/org/ibex/nestedvm/ClassFileCompiler.java @@ -90,7 +90,9 @@ public class ClassFileCompiler extends Compiler implements CGConst { // clinit = cg.addMethod("",Type.VOID,Type.NO_ARGS,ACC_PRIVATE|ACC_STATIC); - + + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.UnixRuntime. + // init = cg.addMethod("",Type.VOID,Type.NO_ARGS,ACC_PUBLIC); init.add(ALOAD_0); @@ -235,6 +237,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { tramp.add(LDC,")"); tramp.add(INVOKEVIRTUAL,new MethodRef(Type.STRINGBUFFER,"append",Type.STRINGBUFFER,new Type[]{Type.STRING})); tramp.add(INVOKEVIRTUAL,new MethodRef(Type.STRINGBUFFER,"toString",Type.STRING,Type.NO_ARGS)); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime$ExecutionException. tramp.add(INVOKESPECIAL,new MethodRef(new Type.Object("org.ibex.nestedvm.Runtime$ExecutionException"),"",Type.VOID,new Type[]{Type.STRING})); tramp.add(ATHROW); @@ -274,6 +277,8 @@ public class ClassFileCompiler extends Compiler implements CGConst { ls.add(IRETURN); } + // Kind of a hack, referencing dup() gets us all the fields for free + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime$CPUState.dup Type.Object cpuStateType = new Type.Object("org.ibex.nestedvm.Runtime$CPUState"); MethodGen setCPUState = cg.addMethod("setCPUState",Type.VOID,new Type[]{cpuStateType},ACC_PROTECTED); MethodGen getCPUState = cg.addMethod("getCPUState",Type.VOID,new Type[]{cpuStateType},ACC_PROTECTED); @@ -350,6 +355,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { execute.add(NEW, new Type.Object("org.ibex.nestedvm.Runtime$FaultException")); execute.add(DUP); execute.add(ALOAD_1); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime$FaultException. execute.add(INVOKESPECIAL,new MethodRef("org.ibex.nestedvm.Runtime$FaultException","",Type.VOID,new Type[]{new Type.Object("java.lang.RuntimeException")})); execute.add(ATHROW); @@ -364,8 +370,10 @@ public class ClassFileCompiler extends Compiler implements CGConst { main.add(ALOAD_0); if(unixRuntime) { Type.Object ur = new Type.Object("org.ibex.nestedvm.UnixRuntime"); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.runAndExec main.add(INVOKESTATIC,new MethodRef(ur,"runAndExec",Type.INT,new Type[]{ur,Type.STRING,Type.arrayType(Type.STRING)})); } else { + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.run main.add(INVOKEVIRTUAL,new MethodRef(me,"run",Type.INT,new Type[]{Type.STRING,Type.arrayType(Type.STRING)})); } main.add(INVOKESTATIC,new MethodRef(new Type.Object("java.lang.System"),"exit",Type.VOID,new Type[]{Type.INT})); @@ -407,13 +415,14 @@ public class ClassFileCompiler extends Compiler implements CGConst { clinit.add(LDC,sb.toString()); clinit.add(LDC,segSize/4); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.decodeData clinit.add(INVOKESTATIC,new MethodRef(new Type.Object("org.ibex.nestedvm.Runtime"),"decodeData",Type.arrayType(Type.INT),new Type[]{Type.STRING,Type.INT})); clinit.add(PUTSTATIC,new FieldRef(me,fieldname,Type.arrayType(Type.INT))); - init.add(ALOAD_0); init.add(GETSTATIC,new FieldRef(me,fieldname,Type.arrayType(Type.INT))); init.add(LDC,addr); init.add(LDC,readOnly ? 1 : 0); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.initPages init.add(INVOKEVIRTUAL,new MethodRef(me,"initPages",Type.VOID,new Type[]{Type.arrayType(Type.INT),Type.INT,Type.BOOLEAN})); addr += segSize; @@ -430,6 +439,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { init.add(ALOAD_0); init.add(LDC,addr); init.add(LDC,count); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.clearPages init.add(INVOKEVIRTUAL,new MethodRef(me,"clearPages",Type.VOID,new Type[]{Type.INT,Type.INT})); } @@ -751,6 +761,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { pushRegZ(R+A3); pushRegZ(R+T0); pushRegZ(R+T1); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.syscall mg.add(INVOKEVIRTUAL,new MethodRef(me,"syscall",Type.INT,new Type[]{Type.INT,Type.INT,Type.INT,Type.INT,Type.INT,Type.INT,Type.INT})); setReg(); @@ -1962,6 +1973,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { mg.add(DUP); mg.add(ALOAD_0); mg.add(SWAP); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.nullPointerCheck mg.add(INVOKEVIRTUAL,new MethodRef(me,"nullPointerCheck",Type.VOID,new Type[]{Type.INT})); } @@ -1995,6 +2007,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { } else if(fastMem) { mg.add(IASTORE); } else { + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.unsafeMemWrite mg.add(INVOKEVIRTUAL,new MethodRef(me,"unsafeMemWrite",Type.VOID,new Type[]{Type.INT,Type.INT})); } @@ -2066,6 +2079,7 @@ public class ClassFileCompiler extends Compiler implements CGConst { } else { if(preMemReadDoPreWrite) mg.add(DUP2); + // GCCLASS_HINT: org.ibex.nestedvm.RuntimeCompiler.compile org.ibex.nestedvm.Runtime.unsafeMemRead mg.add(INVOKEVIRTUAL,new MethodRef(me,"unsafeMemRead",Type.INT,new Type[]{Type.INT})); } } diff --git a/src/org/ibex/nestedvm/util/Platform.java b/src/org/ibex/nestedvm/util/Platform.java index 9277b16..f7eea1e 100644 --- a/src/org/ibex/nestedvm/util/Platform.java +++ b/src/org/ibex/nestedvm/util/Platform.java @@ -6,6 +6,13 @@ import java.util.*; import java.text.DateFormatSymbols; +/* + GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk11. + GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk12. + GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk13. + GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk14. +*/ + public abstract class Platform { Platform() { } private static final Platform p; diff --git a/upstream/Makefile b/upstream/Makefile index fa28cc0..5885009 100644 --- a/upstream/Makefile +++ b/upstream/Makefile @@ -85,7 +85,7 @@ update_darcs_%: tasks/extract_darcs_% else \ cd "build/$*" && wget -np -nH --cut-dirs=1 -rl 16 -N -X _darcs $(darcs_$*); \ fi - rm "tasks/build_darcs_$*" # to force a rebuild + rm -f "tasks/build_darcs_$*" # to force a rebuild tasks/build_darcs_%: tasks/extract_darcs_% cd "build/$*" && $(MAKE) -- 1.7.10.4