From: brian Date: Fri, 16 Apr 2004 23:54:06 +0000 (-0700) Subject: org.xwt.mips -> org.ibex.nestedvm X-Git-Tag: merge~36 X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=commitdiff_plain;h=c2b2704764af1ade923ba8f15d517b87f9d16189 org.xwt.mips -> org.ibex.nestedvm darcs-hash:20040416235406-24bed-c557be79adad6541a282cc40506e263afdf7d2c6.gz --- diff --git a/Makefile b/Makefile index e1b6531..7f30324 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ +.SECONDARY: + # # What to build # # Java sources that are part of the compiler/interpreter -java_sources = $(wildcard src/org/xwt/mips/*.java) $(wildcard src/org/xwt/mips/util/*.java) +java_sources = $(wildcard src/org/ibex/nestedvm/*.java) $(wildcard src/org/ibex/nestedvm/util/*.java) # C sources that are part of the compiler/interpreter mips_sources = crt0.c support_aux.c @@ -34,8 +36,8 @@ mips_optflags = -O3 -g \ MIPS_CFLAGS = $(mips_optflags) $(flags) -I. -Wall -Wno-unused -Werror MIPS_LD = mips-unknown-elf-gcc MIPS_LDFLAGS= \ - $(flags) -L$(build)/org/xwt/mips --static \ - -T $(mips2java_root)/src/org/xwt/mips/linker.ld -Wl,--gc-sections + $(flags) -L$(build)/org/ibex/nestedvm --static \ + -T $(mips2java_root)/src/org/ibex/nestedvm/linker.ld -Wl,--gc-sections MIPS_STRIP = mips-unknown-elf-strip # Java compiler/VM settings @@ -56,7 +58,7 @@ EXE_EXT = ##### java_classes = $(java_sources:src/%.java=build/%.class) -mips_objects = $(mips_sources:%.c=build/org/xwt/mips/%.o) $(mips_asm_sources:%.s=build/org/xwt/mips/%.o) +mips_objects = $(mips_sources:%.c=build/org/ibex/nestedvm/%.o) $(mips_asm_sources:%.s=build/org/ibex/nestedvm/%.o) usr = $(mips2java_root)/upstream/install PATH := $(usr)/bin:$(PATH) @@ -88,10 +90,10 @@ $(unistd_h): $(tasks)/build_newlib # This works around a gcj -C bug ifeq ($(firstword $(JAVAC)),gcj) -build/org/xwt/mips/util/.Dummy.class: +build/org/ibex/nestedvm/util/.Dummy.class: mkdir -p `dirname $@` touch $@ -$(java_classes): build/org/xwt/mips/util/.Dummy.class +$(java_classes): build/org/ibex/nestedvm/util/.Dummy.class endif $(java_classes): $(java_sources) $(bcel_jar) @@ -104,7 +106,7 @@ $(bcel_jar): upstream/tasks/extract_bcel # FIXME: We're cramming more than we need into the binary here build/mips2java$(EXE_EXT): $(java_sources) $(java_gen_sources) @mkdir -p `dirname $@` - $(GCJ) -s -o $@ --main=org.xwt.mips.Compiler $(java_sources) $(java_gen_sources) + $(GCJ) -s -o $@ --main=org.ibex.nestedvm.Compiler $(java_sources) $(java_gen_sources) # # MIPS Binary compilation @@ -134,15 +136,15 @@ build/%.mips.stripped: build/%.mips # MIPS Compiler generated class compilation ifdef DO_JAVASOURCE -build/%.java: build/%.mips build/org/xwt/mips/JavaSourceCompiler.class - $(JAVA) -cp $(classpath) org.xwt.mips.Compiler -outformat javasource $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< > build/$*.java +build/%.java: build/%.mips build/org/ibex/nestedvm/JavaSourceCompiler.class + $(JAVA) -cp $(classpath) org.ibex.nestedvm.Compiler -outformat javasource $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< > build/$*.java -build/%.class: build/%.java build/org/xwt/mips/Runtime.class +build/%.class: build/%.java build/org/ibex/nestedvm/Runtime.class $(JAVAC) $(JAVAC_NODEBUG_FLAGS) -classpath build -d build $< else -build/%.class: build/%.mips build/org/xwt/mips/ClassFileCompiler.class - $(JAVA) -cp $(classpath) org.xwt.mips.Compiler -outformat class -outfile $@ $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< +build/%.class: build/%.mips build/org/ibex/nestedvm/ClassFileCompiler.class + $(JAVA) -cp $(classpath) org.ibex.nestedvm.Compiler -outformat class -outfile $@ $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< endif @@ -152,12 +154,12 @@ build/%.class: src/%.java $(JAVAC) -classpath build -d build $< clean: - rm -rf build/tests build/org/xwt/mips *.jar build/mips2java$(EXE_EXT) + rm -rf build/tests build/org/ibex/nestedvm *.jar build/mips2java$(EXE_EXT) # # env.sh # -env.sh: Makefile $(tasks)/full_toolchain build/org/xwt/mips/Compiler.class +env.sh: Makefile $(tasks)/full_toolchain build/org/ibex/nestedvm/Compiler.class @rm -f "$@~" @echo 'PATH="$(mips2java_root)/build:$(usr)/bin:$$PATH"; export PATH' >> $@~ @echo 'CC=mips-unknown-elf-gcc; export CC' >> $@~ @@ -181,26 +183,26 @@ runtime_util_classes = SeekableData SeekableByteArray SeekableFile SeekableInput runtime_classes = Runtime Registers UsermodeConstants $(runtime_util_classes:%=util/%) unixruntime_classes = $(runtime_classes) UnixRuntime -runtime.jar: $(runtime_classes:%=build/org/xwt/mips/%.class) - cd build && jar cf ../$@ $(runtime_classes:%=org/xwt/mips/%*.class) +runtime.jar: $(runtime_classes:%=build/org/ibex/nestedvm/%.class) + cd build && jar cf ../$@ $(runtime_classes:%=org/ibex/nestedvm/%*.class) -unixruntime.jar: $(unixruntime_classes:%=build/org/xwt/mips/%.class) - cd build && jar cf ../$@ $(unixruntime_classes:%=org/xwt/mips/%*.class) +unixruntime.jar: $(unixruntime_classes:%=build/org/ibex/nestedvm/%.class) + cd build && jar cf ../$@ $(unixruntime_classes:%=org/ibex/nestedvm/%*.class) # This is only for Brian to use... don't mess with it -rebuild-constants: src/org/xwt/mips/syscalls.h $(errno_h) $(unistd_h) +rebuild-constants: src/org/ibex/nestedvm/syscalls.h $(errno_h) $(unistd_h) @mkdir -p `dirname $@` cat $^ | ( \ echo "// THIS FILE IS AUTOGENERATED! DO NOT EDIT!"; \ echo "// run \"make rebuild-constants\" if it needs to be updated"; \ echo ""; \ - echo "package org.xwt.mips;"; \ + echo "package org.ibex.nestedvm;"; \ echo "public interface UsermodeConstants {"; \ tr '\t' ' ' | sed -n ' \ s/ */ /g; \ s/ *# *define \([A-Z_][A-Za-z0-9_]*\) \([0-9][0-9x]*\)/ public static final int \1 = \2;/p'; \ echo "}"; \ - ) > src/org/xwt/mips/UsermodeConstants.java + ) > src/org/ibex/nestedvm/UsermodeConstants.java # # Tests @@ -208,13 +210,13 @@ rebuild-constants: src/org/xwt/mips/syscalls.h $(errno_h) $(unistd_h) # to build or run mips2java # -build/tests/Env.class: build/org/xwt/mips/Runtime.class build/org/xwt/mips/Interpreter.class +build/tests/Env.class: build/org/ibex/nestedvm/Runtime.class build/org/ibex/nestedvm/Interpreter.class # Generic Hello Worldish test test: build/tests/Test.class $(JAVA) -cp build tests.Test "arg 1" "arg 2" "arg 3" -inttest: build/tests/Test.mips build/org/xwt/mips/Interpreter.class - $(JAVA) -cp build org.xwt.mips.Interpreter build/tests/Test.mips "arg 1" "arg 2" "arg 3" +inttest: build/tests/Test.mips build/org/ibex/nestedvm/Interpreter.class + $(JAVA) -cp build org.ibex.nestedvm.Interpreter build/tests/Test.mips "arg 1" "arg 2" "arg 3" cxxtest: build/tests/CXXTest.class $(JAVA) -cp build tests.CXXTest @@ -307,7 +309,7 @@ boehmgctest: build/tests/Env.class build/tests/GCTest.class # Speed tests # -build/tests/SpeedTest.class: build/org/xwt/mips/Runtime.class +build/tests/SpeedTest.class: build/org/ibex/nestedvm/Runtime.class tmp/thebride_1280.jpg: @mkdir -p tmp @@ -345,8 +347,8 @@ speedtest: build/tests/SpeedTest.class build/tests/DJpeg.class build/tests/FTBen echo "Run \"make check\" to get the MS True Type fonts for the MSPackBench test"; \ fi -intspeed: build/tests/DJpeg.mips build/org/xwt/mips/Interpreter.class tmp/thebride_1280.jpg - time $(JAVA) -cp build org.xwt.mips.Interpreter build/tests/DJpeg.mips -targa -outfile tmp/thebride_1280.tga tmp/thebride_1280.jpg +intspeed: build/tests/DJpeg.mips build/org/ibex/nestedvm/Interpreter.class tmp/thebride_1280.jpg + time $(JAVA) -cp build org.ibex.nestedvm.Interpreter build/tests/DJpeg.mips -targa -outfile tmp/thebride_1280.tga tmp/thebride_1280.jpg @echo "e90f6b915aee2fc0d2eb9fc60ace6203 tmp/thebride_1280.tga" | md5sum -c && echo "MD5 is OK" # diff --git a/src/org/xwt/mips/ClassFileCompiler.java b/src/org/ibex/nestedvm/ClassFileCompiler.java similarity index 96% rename from src/org/xwt/mips/ClassFileCompiler.java rename to src/org/ibex/nestedvm/ClassFileCompiler.java index fe212c3..0d48aba 100644 --- a/src/org/xwt/mips/ClassFileCompiler.java +++ b/src/org/ibex/nestedvm/ClassFileCompiler.java @@ -1,7 +1,7 @@ -package org.xwt.mips; +package org.ibex.nestedvm; import java.io.*; -import org.xwt.mips.util.*; +import org.ibex.nestedvm.util.*; import org.apache.bcel.generic.*; @@ -66,8 +66,8 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const return new MethodGen(flags,ret,args,null,name,fullClassName,new FixedInstructionList(),cp); } - public ClassFileCompiler(String path, String className, OutputStream os) throws IOException { this(new SeekableFile(path),className,os); } - public ClassFileCompiler(SeekableData binary, String className, OutputStream os) throws IOException { + public ClassFileCompiler(String path, String className, OutputStream os) throws IOException { this(new Seekable.File(path),className,os); } + public ClassFileCompiler(Seekable binary, String className, OutputStream os) throws IOException { super(binary,className); this.os = os; } @@ -133,7 +133,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const // Trampoline MethodGen tramp = newMethod(ACC_PRIVATE,Type.VOID, Type.NO_ARGS, "trampoline"); - tramp.addException("org.xwt.mips.Runtime$ExecutionException"); + tramp.addException("org.ibex.nestedvm.Runtime$ExecutionException"); selectMethod(tramp); InstructionHandle start = a(InstructionConstants.ALOAD_0); @@ -162,7 +162,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const } ts.setTarget(a(InstructionConstants.POP)); // default case - a(fac.createNew("org.xwt.mips.Runtime$ExecutionException")); + a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException")); a(InstructionConstants.DUP); a(fac.createNew("java.lang.StringBuffer")); a(InstructionConstants.DUP); @@ -179,7 +179,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const a(new PUSH(cp,')')); a(fac.createInvoke("java.lang.StringBuffer","append",Type.STRINGBUFFER,new Type[]{Type.CHAR},INVOKEVIRTUAL)); a(fac.createInvoke("java.lang.StringBuffer","toString",Type.STRING,Type.NO_ARGS,INVOKEVIRTUAL)); - a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); a(InstructionConstants.ATHROW); stateCheck.setTarget(a(InstructionConstants.RETURN)); @@ -280,10 +280,10 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const cl.addMethod(lookupSymbol.getMethod()); } - MethodGen setCPUState = newMethod(ACC_PROTECTED,Type.VOID,new Type[]{Type.getType("Lorg/xwt/mips/Runtime$CPUState;")},"setCPUState"); + MethodGen setCPUState = newMethod(ACC_PROTECTED,Type.VOID,new Type[]{Type.getType("Lorg/ibex/nestedvm/Runtime$CPUState;")},"setCPUState"); selectMethod(setCPUState); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD)); a(InstructionConstants.ASTORE_2); for(int i=1;i<32;i++) { a(InstructionConstants.ALOAD_0); @@ -293,7 +293,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const a(fac.createFieldAccess(fullClassName,"r"+i,Type.INT, PUTFIELD)); } a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD)); a(InstructionConstants.ASTORE_2); for(int i=0;i<32;i++) { a(InstructionConstants.ALOAD_0); @@ -304,34 +304,34 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const } a(InstructionConstants.ALOAD_0); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","hi",Type.INT,GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","hi",Type.INT,GETFIELD)); a(fac.createFieldAccess(fullClassName,"hi",Type.INT, PUTFIELD)); a(InstructionConstants.ALOAD_0); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","lo",Type.INT,GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","lo",Type.INT,GETFIELD)); a(fac.createFieldAccess(fullClassName,"lo",Type.INT, PUTFIELD)); a(InstructionConstants.ALOAD_0); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","fcsr",Type.INT,GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","fcsr",Type.INT,GETFIELD)); a(fac.createFieldAccess(fullClassName,"fcsr",Type.INT, PUTFIELD)); a(InstructionConstants.ALOAD_0); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","pc",Type.INT,GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","pc",Type.INT,GETFIELD)); a(fac.createFieldAccess(fullClassName,"pc",Type.INT, PUTFIELD)); a(InstructionConstants.RETURN); setCPUState.setMaxLocals(); setCPUState.setMaxStack(); cl.addMethod(setCPUState.getMethod()); - MethodGen getCPUState = newMethod(ACC_PROTECTED,Type.getType("Lorg/xwt/mips/Runtime$CPUState;"),Type.NO_ARGS,"getCPUState"); + MethodGen getCPUState = newMethod(ACC_PROTECTED,Type.getType("Lorg/ibex/nestedvm/Runtime$CPUState;"),Type.NO_ARGS,"getCPUState"); selectMethod(getCPUState); - a(fac.createNew("org.xwt.mips.Runtime$CPUState")); + a(fac.createNew("org.ibex.nestedvm.Runtime$CPUState")); a(InstructionConstants.DUP); - a(fac.createInvoke("org.xwt.mips.Runtime$CPUState","",Type.VOID,Type.NO_ARGS,INVOKESPECIAL)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime$CPUState","",Type.VOID,Type.NO_ARGS,INVOKESPECIAL)); a(InstructionConstants.ASTORE_1); a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD)); a(InstructionConstants.ASTORE_2); for(int i=1;i<32;i++) { a(InstructionConstants.ALOAD_2); @@ -342,7 +342,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const } a(InstructionConstants.ALOAD_1); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD)); a(InstructionConstants.ASTORE_2); for(int i=0;i<32;i++) { a(InstructionConstants.ALOAD_2); @@ -354,19 +354,19 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const a(InstructionConstants.ALOAD_1); a(InstructionConstants.ALOAD_0); a(fac.createFieldAccess(fullClassName,"hi",Type.INT, GETFIELD)); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","hi",Type.INT,PUTFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","hi",Type.INT,PUTFIELD)); a(InstructionConstants.ALOAD_1); a(InstructionConstants.ALOAD_0); a(fac.createFieldAccess(fullClassName,"lo",Type.INT, GETFIELD)); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","lo",Type.INT,PUTFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","lo",Type.INT,PUTFIELD)); a(InstructionConstants.ALOAD_1); a(InstructionConstants.ALOAD_0); a(fac.createFieldAccess(fullClassName,"fcsr",Type.INT, GETFIELD)); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","fcsr",Type.INT,PUTFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","fcsr",Type.INT,PUTFIELD)); a(InstructionConstants.ALOAD_1); a(InstructionConstants.ALOAD_0); a(fac.createFieldAccess(fullClassName,"pc",Type.INT, GETFIELD)); - a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","pc",Type.INT,PUTFIELD)); + a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","pc",Type.INT,PUTFIELD)); a(InstructionConstants.ALOAD_1); a(InstructionConstants.ARETURN); @@ -425,7 +425,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const selectList(clinitExtras); a(new PUSH(cp,sb.toString())); a(new PUSH(cp,segSize/4)); - a(fac.createInvoke("org.xwt.mips.Runtime","decodeData",new ArrayType(Type.INT,1),new Type[]{Type.STRING,Type.INT},INVOKESTATIC)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime","decodeData",new ArrayType(Type.INT,1),new Type[]{Type.STRING,Type.INT},INVOKESTATIC)); a(fac.createPutStatic(fullClassName,fieldname,new ArrayType(Type.INT,1))); selectList(initExtras); @@ -566,7 +566,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const // move the default jump target (lookupswitch) to before the throw insnList.move(defaultHandle,insnList.getEnd()); if(debugCompiler) { - a(fac.createNew("org.xwt.mips.Runtime$ExecutionException")); + a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException")); a(InstructionConstants.DUP); a(fac.createNew("java.lang.StringBuffer")); a(InstructionConstants.DUP); @@ -576,13 +576,13 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const a(fac.createFieldAccess(fullClassName,"pc",Type.INT, GETFIELD)); a(fac.createInvoke("java.lang.StringBuffer","append",Type.STRINGBUFFER,new Type[]{Type.INT},INVOKEVIRTUAL)); a(fac.createInvoke("java.lang.StringBuffer","toString",Type.STRING,Type.NO_ARGS,INVOKEVIRTUAL)); - a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); a(InstructionConstants.ATHROW); } else { - a(fac.createNew("org.xwt.mips.Runtime$ExecutionException")); + a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException")); a(InstructionConstants.DUP); a(new PUSH(cp,"Jumped to invalid address")); - a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); a(InstructionConstants.ATHROW); } @@ -769,10 +769,10 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const break; case 13: // BREAK - a(fac.createNew("org.xwt.mips.Runtime$ExecutionException")); + a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException")); a(InstructionConstants.DUP); a(new PUSH(cp,"BREAK Code " + toHex(breakCode))); - a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); + a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL)); a(InstructionConstants.ATHROW); unreachable = true; break; diff --git a/src/org/xwt/mips/ClassLoader.java b/src/org/ibex/nestedvm/ClassLoader.java similarity index 98% rename from src/org/xwt/mips/ClassLoader.java rename to src/org/ibex/nestedvm/ClassLoader.java index 510d309..f51cd51 100644 --- a/src/org/xwt/mips/ClassLoader.java +++ b/src/org/ibex/nestedvm/ClassLoader.java @@ -1,4 +1,4 @@ -package org.xwt.mips; +package org.ibex.nestedvm; import java.io.*; diff --git a/src/org/xwt/mips/Compiler.java b/src/org/ibex/nestedvm/Compiler.java similarity index 98% rename from src/org/xwt/mips/Compiler.java rename to src/org/ibex/nestedvm/Compiler.java index de457e7..de5a048 100644 --- a/src/org/xwt/mips/Compiler.java +++ b/src/org/ibex/nestedvm/Compiler.java @@ -1,12 +1,11 @@ // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] -package org.xwt.mips; +package org.ibex.nestedvm; import java.util.*; import java.io.*; -import org.xwt.mips.util.SeekableData; -import org.xwt.mips.util.SeekableFile; +import org.ibex.nestedvm.util.*; public abstract class Compiler implements Registers { /** The ELF binary being read */ @@ -64,7 +63,7 @@ public abstract class Compiler implements Registers { protected boolean nullPointerCheck = false; - protected String runtimeClass = "org.xwt.mips.Runtime"; + protected String runtimeClass = "org.ibex.nestedvm.Runtime"; protected String hashClass = "java.util.Hashtable"; @@ -144,7 +143,7 @@ public abstract class Compiler implements Registers { } if(className == null || mipsBinaryFileName == null) usage(); - SeekableData mipsBinary = new SeekableFile(mipsBinaryFileName); + Seekable mipsBinary = new Seekable.File(mipsBinaryFileName); Writer w = null; OutputStream os = null; @@ -185,7 +184,7 @@ public abstract class Compiler implements Registers { } } - public Compiler(SeekableData binary, String fullClassName) throws IOException { + public Compiler(Seekable binary, String fullClassName) throws IOException { this.fullClassName = fullClassName; elf = new ELF(binary); @@ -249,7 +248,7 @@ public abstract class Compiler implements Registers { findBranchesInText(text.addr,new DataInputStream(text.getInputStream()),text.size,jumpableAddresses); } - if(unixRuntime && runtimeClass.startsWith("org.xwt.mips.")) runtimeClass = "org.xwt.mips.UnixRuntime"; + if(unixRuntime && runtimeClass.startsWith("org.ibex.nestedvm.")) runtimeClass = "org.ibex.nestedvm.UnixRuntime"; for(int i=0;i 1.1, however, it is only used for debugging diff --git a/src/org/xwt/mips/JavaSourceCompiler.java b/src/org/ibex/nestedvm/JavaSourceCompiler.java similarity index 99% rename from src/org/xwt/mips/JavaSourceCompiler.java rename to src/org/ibex/nestedvm/JavaSourceCompiler.java index 85295e6..d71bee8 100644 --- a/src/org/xwt/mips/JavaSourceCompiler.java +++ b/src/org/ibex/nestedvm/JavaSourceCompiler.java @@ -1,8 +1,8 @@ -package org.xwt.mips; +package org.ibex.nestedvm; import java.util.*; import java.io.*; -import org.xwt.mips.util.SeekableData; +import org.ibex.nestedvm.util.*; public class JavaSourceCompiler extends Compiler { /** Stores the "case r XXX: ... run_YYYY();" blocks generated by the emitText method/ */ @@ -27,7 +27,7 @@ public class JavaSourceCompiler extends Compiler { private static String indents[] = new String[16]; static { String s=""; for(int i=0;i= bytesRead && !eof) readTo(pos + 1); + len = Math.min(len,bytesRead-pos); + if(len <= 0) return -1; + System.arraycopy(buffer,pos,outbuf,off,len); + pos += len; + return len; + } + + private void readTo(int target) throws IOException { + if(target >= buffer.length) { + byte[] buf2 = new byte[Math.max(buffer.length+Math.min(buffer.length,65536),target)]; + System.arraycopy(buffer,0,buf2,0,bytesRead); + buffer = buf2; + } + while(bytesRead < target) { + int n = is.read(buffer,bytesRead,buffer.length-bytesRead); + if(n == -1) { + eof = true; + break; + } + bytesRead += n; + } + } + + public int length() throws IOException { + while(!eof) readTo(bytesRead+4096); + return bytesRead; + } + + public int write(byte[] buf, int off, int len) throws IOException { throw new IOException("read-only"); } + public void seek(int pos) { this.pos = pos; } + public int pos() { return pos; } + public void close() throws IOException { is.close(); } + } + +} diff --git a/src/org/xwt/mips/util/SeekableByteArray.java b/src/org/xwt/mips/util/SeekableByteArray.java deleted file mode 100644 index 807dd68..0000000 --- a/src/org/xwt/mips/util/SeekableByteArray.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.xwt.mips.util; - -import java.io.IOException; - -public class SeekableByteArray implements SeekableData { - protected byte[] data; - protected int pos; - private final boolean writable; - - public SeekableByteArray(byte[] data, boolean writable) { - this.data = data; - this.pos = 0; - this.writable = writable; - } - - public int read(byte[] buf, int off, int len) { - len = Math.min(len,data.length-pos); - if(len <= 0) return -1; - System.arraycopy(data,pos,buf,off,len); - pos += len; - return len; - } - - public int write(byte[] buf, int off, int len) throws IOException { - if(!writable) throw new IOException("read-only data"); - len = Math.min(len,data.length-pos); - if(len <= 0) throw new IOException("no space"); - System.arraycopy(buf,off,data,pos,len); - pos += len; - return len; - } - - public int length() { return data.length; } - public int pos() { return pos; } - public void seek(int pos) { this.pos = pos; } - public void close() { /*noop*/ } -} diff --git a/src/org/xwt/mips/util/SeekableData.java b/src/org/xwt/mips/util/SeekableData.java deleted file mode 100644 index 2603aba..0000000 --- a/src/org/xwt/mips/util/SeekableData.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.xwt.mips.util; - -import java.io.IOException; - -public interface SeekableData { - public int read(byte[] buf, int offset, int length) throws IOException; - public int write(byte[] buf, int offset, int length) throws IOException; - public int length() throws IOException; - public void seek(int pos) throws IOException; - public void close() throws IOException; - public int pos() throws IOException; -} diff --git a/src/org/xwt/mips/util/SeekableFile.java b/src/org/xwt/mips/util/SeekableFile.java deleted file mode 100644 index 168d43a..0000000 --- a/src/org/xwt/mips/util/SeekableFile.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.xwt.mips.util; - -import java.io.*; - -public class SeekableFile implements SeekableData { - private final RandomAccessFile raf; - - public SeekableFile(String fileName) throws IOException { this(fileName,false); } - public SeekableFile(String fileName, boolean writable) throws IOException { this(new File(fileName),writable); } - - public SeekableFile(File file, boolean writable) throws IOException { - raf = new RandomAccessFile(file,writable ? "rw" : "r"); - } - - // NOTE: RandomAccessFile.setLength() is a Java2 function - public void setLength(int n) throws IOException { raf.setLength(n); } - - public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); } - public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; } - public void seek(int pos) throws IOException{ raf.seek(pos); } - public int pos() throws IOException { return (int) raf.getFilePointer(); } - public int length() throws IOException { return (int)raf.length(); } - public void close() throws IOException { raf.close(); } -} diff --git a/src/org/xwt/mips/util/SeekableInputStream.java b/src/org/xwt/mips/util/SeekableInputStream.java deleted file mode 100644 index 1dc0b0d..0000000 --- a/src/org/xwt/mips/util/SeekableInputStream.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.xwt.mips.util; - -import java.io.*; - -public class SeekableInputStream implements SeekableData { - private byte[] buffer = new byte[4096]; - private int bytesRead = 0; - private boolean eof = false; - private int pos; - private InputStream is; - - public SeekableInputStream(InputStream is) { this.is = is; } - - public int read(byte[] outbuf, int off, int len) throws IOException { - if(pos >= bytesRead && !eof) readTo(pos + 1); - len = Math.min(len,bytesRead-pos); - if(len <= 0) return -1; - System.arraycopy(buffer,pos,outbuf,off,len); - pos += len; - return len; - } - - private void readTo(int target) throws IOException { - if(target >= buffer.length) { - byte[] buf2 = new byte[Math.max(buffer.length+Math.min(buffer.length,65536),target)]; - System.arraycopy(buffer,0,buf2,0,bytesRead); - buffer = buf2; - } - while(bytesRead < target) { - int n = is.read(buffer,bytesRead,buffer.length-bytesRead); - if(n == -1) { - eof = true; - break; - } - bytesRead += n; - } - } - - public int length() throws IOException { - while(!eof) readTo(bytesRead+4096); - return bytesRead; - } - - public int write(byte[] buf, int off, int len) throws IOException { throw new IOException("read-only"); } - public void seek(int pos) { this.pos = pos; } - public int pos() { return pos; } - public void close() throws IOException { is.close(); } -} diff --git a/upstream/Makefile b/upstream/Makefile index e633ef7..73f3a11 100644 --- a/upstream/Makefile +++ b/upstream/Makefile @@ -42,8 +42,10 @@ tasks/build_gcc: tasks/build_binutils tasks/build_newlib: tasks/build_gcc tasks/build_libc: tasks/build_newlib tasks/build_regex tasks/build_openbsdglob + # HACK rm -f $(usr)/mips-unknown-elf/lib/crt0.o - ln -s $(root)/build/org/xwt/mips/crt0.o $(usr)/mips-unknown-elf/lib/crt0.o + ln -s $(root)/build/org/ibex/nestedvm/crt0.o $(usr)/mips-unknown-elf/lib/crt0.o + echo '#include ' > $(usr)/mips-unknown-elf/include/getopt.h touch $@