From: adam Date: Thu, 26 Feb 2004 20:52:56 +0000 (+0000) Subject: this does not work X-Git-Tag: RC3~14 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=a6c4f7b784acf2269c33188982b0d479cc11a0f4;hp=15801ed8984e7463b3fbe517e13d86cd08db9b15 this does not work darcs-hash:20040226205256-5007d-8dc3a26874056e1c6dd4e9afc70713db0e353838.gz --- diff --git a/Makefile b/Makefile index b376eba..fc64298 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ gcc_optimizations := -O2 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls #gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections -gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src -Iupstream/jpeg-6b/build-$(target) +gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src -Iupstream/jpeg-6b/build-$(target) -g gcc_flags += -Iupstream/install/lib/gcc-lib/$(target)/3.3/include -Iupstream/install/$(target)/include gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) -fCLASSPATH=build/java gcjh := $(shell pwd)/upstream/install/bin/$(shell test -e upstream/install/bin/$(target)-gcjh && echo $(target)-)gcjh @@ -205,7 +205,6 @@ upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target) # note: binaries appear in a different order in the dependency line vs the link line build/$(platform)/$(target_bin): upstream/jpeg-6b/build-$(target)/libjpeg.a @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m" - rm -rf build/$(platform)/* make build/$(platform)/org/ibex/plat/$(platform).cc.o make build/$(platform)/builtin.o @@ -259,29 +258,30 @@ build/$(platform)/$(target_bin): upstream/jpeg-6b/build-$(target)/libjpeg.a ../../upstream/install/bin/$(target)-gcj \ -w -c -Os \ -fCLASSPATH=../../build/$(platform)/ibex.jar \ - -fassume-compiled \ $$A && \ (mkdir -p ../../build/$(platform)/`dirname $$A`; mv *.o ../../build/$(platform)/`dirname $$A`); \ done +# -fassume-compiled \ cd build/pruned; rm -rf gnu/gcj java/lang java/net cd build/pruned; \ for A in `find . -name \*.class -or -name \*.java`; do \ echo compiling $$A....; \ ../../upstream/install/bin/$(target)-gcj \ -w -c -Os \ - -fassume-compiled \ - -ffunction-sections \ - -fdata-sections \ - -fomit-frame-pointer \ - -fno-force-mem \ - -fno-force-addr \ - -fmerge-all-constants \ -fCLASSPATH=../../build/$(platform)/ibex.jar \ $$A && \ (mkdir -p ../../build/$(platform)/`dirname $$A`; mv *.o ../../build/$(platform)/`dirname $$A`); \ done +# -fassume-compiled \ +# -finhibit-reflection \ # -fnew-ra \ +# -ffunction-sections \ +# -fdata-sections \ +# -fomit-frame-pointer \ +# -fno-force-mem \ +# -fno-force-addr \ +# -fmerge-all-constants \ rm -f build/$(platform)/ibex.a diff --git a/src/org/ibex/Main.java b/src/org/ibex/Main.java index 267f706..ed5199d 100644 --- a/src/org/ibex/Main.java +++ b/src/org/ibex/Main.java @@ -94,6 +94,7 @@ public class Main { scarImage = Picture.load((Stream)Main.builtin.get("org/ibex/builtin/scar.png"), new Scheduler.Task() { public void perform() throws JSExn, UnknownHostException { + if (Log.on) Log.info(Main.class, "invoking initial template"); ibex.resolveString(startupTemplate, false).call(new Box(), null, null, null, 1); } }); diff --git a/src/org/ibex/Picture.java b/src/org/ibex/Picture.java index d3ab4e9..afde3bb 100644 --- a/src/org/ibex/Picture.java +++ b/src/org/ibex/Picture.java @@ -40,8 +40,8 @@ public class Picture { InputStream in = null; try { in = b == null ? Stream.getInputStream(stream) : b.getImage(); - } catch (IOException e) { Log.error(Picture.class, stream); - } catch (JSExn e) { Log.error(Picture.class, stream); + } catch (IOException e) { Log.error(Picture.class, e); + } catch (JSExn e) { Log.error(Picture.class, e); } if (in == null) { Log.warn(Picture.class, "couldn't load image for stream " + stream); return; } try { diff --git a/src/org/ibex/plat/X11.cc b/src/org/ibex/plat/X11.cc index 004d2a3..53e20de 100644 --- a/src/org/ibex/plat/X11.cc +++ b/src/org/ibex/plat/X11.cc @@ -397,7 +397,7 @@ void org::ibex::plat::X11$X11Surface::natInit() { XTextProperty tp; tp.value = (unsigned char*)"Ibex"; - tp.nitems = 3; + tp.nitems = 4; tp.encoding = XA_STRING; tp.format = 8; XSetTextProperty(display, (*((Window*)window)), &tp, XA_WM_CLASS); diff --git a/src/org/ibex/util/BytecodePruner.java b/src/org/ibex/util/BytecodePruner.java index d8aff54..a61c84d 100644 --- a/src/org/ibex/util/BytecodePruner.java +++ b/src/org/ibex/util/BytecodePruner.java @@ -92,6 +92,11 @@ public class BytecodePruner { // to ensure we get all the stuff that might be called from CNI bcp.loadAllMethods("org.ibex.plat.Linux"); bcp.loadAllMethods("org.ibex.plat.X11"); + bcp.loadAllMethods("org.ibex.plat.GCJ"); + bcp.loadAllMethods("org.ibex.plat.POSIX"); + bcp.loadAllMethods("org.ibex.plat.X11$X11Surface"); + bcp.loadAllMethods("org.ibex.plat.X11$X11PixelBuffer"); + bcp.loadAllMethods("org.ibex.plat.X11$X11Picture"); bcp.loadAllMethods("org.ibex.Surface"); bcp.loadAllMethods("org.ibex.Picture"); bcp.loadAllMethods("org.ibex.PixelBuffer"); @@ -100,9 +105,7 @@ public class BytecodePruner { bcp.loadMethod("org.ibex.plat.Linux.main"); System.out.println(); - // FIXME: insert "the null class" when eliminating? System.out.println("Dumping..."); - StringTokenizer st = new StringTokenizer(s[0], ":"); while(st.hasMoreTokens()) { ZipFile zf = new ZipFile(st.nextToken()); @@ -160,6 +163,7 @@ public class BytecodePruner { } else { System.out.println(" pruning " +(constructed?"":"unconstructed")+ " method " + clazz.getClassName() + "." + methods[i].getName()); + // FIXME: try deleteMethods if (deleteMethods) { cg.removeMethod(methods[i]); continue; } MethodGen mg = new MethodGen(methods[i], clazz.getClassName(), newcpg); mg.removeExceptions(); @@ -247,6 +251,9 @@ public class BytecodePruner { if (dest.contains(method)) return; dest.add(method); + + if (method.isStatic()) loadMethod(jc.getClassName() + "."); + level += 2; for(int i=0; i"); + } if (instr instanceof CPInstruction) load(((CPInstruction)instr).getType(cpg)); if (instr instanceof TypedInstruction) { try { load(((TypedInstruction)instr).getType(cpg)); } catch (Exception e) { /* DELIBERATE */ } @@ -307,7 +317,9 @@ public class BytecodePruner { } } - public void visitJavaField(Field field) throws Exception { if (!dest.contains(field)) dest.add(field); } + public void visitJavaField(Field field) throws Exception { + if (!dest.contains(field)) dest.add(field); + } public void visitJavaClass(JavaClass clazz) throws Exception { if (dest.contains(clazz)) return; @@ -336,9 +348,18 @@ public class BytecodePruner { remarkMethods(interfaces[i], clazz, cpg); } + Field[] fields = clazz.getFields(); + for(int i=0; i")) visitJavaMethod(clazz, methods[i]); + //if (methods[i].getName().equals("")) visitJavaMethod(clazz, methods[i]); if (methods[i].getName().equals("equals")) visitJavaMethod(clazz, methods[i]); if (methods[i].getName().equals("hashCode")) visitJavaMethod(clazz, methods[i]); if (methods[i].getName().equals("finalize")) visitJavaMethod(clazz, methods[i]); diff --git a/upstream/gcc-3.3/patches/zzz-disable-reflection.patch b/upstream/gcc-3.3/patches/zzz-disable-reflection.patch new file mode 100644 index 0000000..4c1fd67 --- /dev/null +++ b/upstream/gcc-3.3/patches/zzz-disable-reflection.patch @@ -0,0 +1,259 @@ +diff -ru gcc/java/class.c gcc/java/class.c +--- gcc/java/class.c Fri Feb 28 12:53:07 2003 ++++ gcc/java/class.c Wed Feb 25 23:19:58 2004 +@@ -1254,25 +1254,32 @@ + if (DECL_RTL_SET_P (mdecl)) + code = build1 (ADDR_EXPR, nativecode_ptr_type_node, mdecl); + START_RECORD_CONSTRUCTOR (minit, method_type_node); +- PUSH_FIELD_VALUE (minit, "name", +- build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ? +- init_identifier_node +- : DECL_NAME (mdecl))); +- { ++ ++ // FIXME: should walk up the tree looking to see if this method ++ // overrides one declared in an interface ++ if (!flag_inhibit_reflection || !METHOD_STATIC(mdecl) || DECL_CLINIT_P(mdecl) || ++ (METHOD_STATIC(mdecl) && (strcmp(IDENTIFIER_POINTER(DECL_NAME(mdecl)),"main") == 0))) { ++ PUSH_FIELD_VALUE (minit, "name", ++ build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ? ++ init_identifier_node ++ : DECL_NAME (mdecl))); + tree signature = build_java_signature (TREE_TYPE (mdecl)); + PUSH_FIELD_VALUE (minit, "signature", +- (build_utf8_ref +- (unmangle_classname +- (IDENTIFIER_POINTER(signature), +- IDENTIFIER_LENGTH(signature))))); ++ (build_utf8_ref ++ (unmangle_classname ++ (IDENTIFIER_POINTER(signature), ++ IDENTIFIER_LENGTH(signature))))); ++ } else { ++ PUSH_FIELD_VALUE (minit, "name", null_pointer_node); ++ PUSH_FIELD_VALUE (minit, "signature", null_pointer_node); + } + PUSH_FIELD_VALUE (minit, "accflags", build_int_2 (accflags, 0)); + PUSH_FIELD_VALUE (minit, "index", index); + PUSH_FIELD_VALUE (minit, "ncode", code); +- + { + /* Compute the `throws' information for the method. */ + tree table = null_pointer_node; ++ if (!flag_inhibit_reflection) + if (DECL_FUNCTION_THROWS (mdecl) != NULL_TREE) + { + int length = 1 + list_length (DECL_FUNCTION_THROWS (mdecl)); +@@ -1454,6 +1461,7 @@ + field = TYPE_FIELDS (type); + if (DECL_NAME (field) == NULL_TREE) + field = TREE_CHAIN (field); /* Skip dummy field for inherited data. */ ++ + for ( ; field != NULL_TREE; field = TREE_CHAIN (field)) + { + if (! DECL_ARTIFICIAL (field)) +@@ -1462,8 +1470,11 @@ + if (FIELD_STATIC (field)) + { + tree initial = DECL_INITIAL (field); ++ if (!flag_inhibit_reflection) ++ { + static_field_count++; + static_fields = tree_cons (NULL_TREE, init, static_fields); ++ } + /* If the initial value is a string constant, + prevent output_constant from trying to assemble the value. */ + if (initial != NULL_TREE +@@ -1473,6 +1484,7 @@ + DECL_INITIAL (field) = initial; + } + else ++ if (!flag_inhibit_reflection) + { + instance_field_count++; + instance_fields = tree_cons (NULL_TREE, init, instance_fields); +diff -ru gcc/java/java-tree.h gcc/java/java-tree.h +--- gcc/java/java-tree.h Mon Nov 18 10:13:35 2002 ++++ gcc/java/java-tree.h Wed Feb 25 19:49:44 2004 +@@ -225,6 +225,9 @@ + /* Encoding used for source files. */ + extern const char *current_encoding; + ++/** don't emit reflection information */ ++extern int flag_inhibit_reflection; ++ + /* The Java .class file that provides main_class; the main input file. */ + extern struct JCF *current_jcf; + +diff -ru gcc/java/lang.c gcc/java/lang.c +--- gcc/java/lang.c Sun Jan 5 07:03:25 2003 ++++ gcc/java/lang.c Wed Feb 25 19:49:49 2004 +@@ -171,6 +171,9 @@ + /* The encoding of the source file. */ + const char *current_encoding = NULL; + ++/** don't emit reflection information */ ++int flag_inhibit_reflection = 0; ++ + /* When nonzero, report the now deprecated empty statements. */ + int flag_extraneous_semicolon; + +@@ -431,6 +434,13 @@ + { + flag_inline_functions = 1; + flag_really_inline = 1; ++ return 1; ++ } ++#undef ARG ++#define ARG "-finhibit-reflection" ++ if (strncmp (p, ARG, sizeof (ARG) - 1) == 0) ++ { ++ flag_inhibit_reflection = 1; + return 1; + } + #undef ARG +diff -ru libjava/boehm.cc libjava/boehm.cc +--- libjava/boehm.cc Thu Jan 2 21:19:53 2003 ++++ libjava/boehm.cc Wed Feb 25 23:43:44 2004 +@@ -17,6 +17,7 @@ + + #include + #include ++#include + #include + + // More nastiness: the GC wants to define TRUE and FALSE. We don't +@@ -147,6 +148,7 @@ + for (int i = 0; i < c->method_count; ++i) + { + p = (ptr_t) c->methods[i].name; ++ if (p == NULL) continue; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, + cm1label); + p = (ptr_t) c->methods[i].signature; +@@ -164,9 +166,11 @@ + + #ifndef COMPACT_FIELDS + p = (ptr_t) field->name; ++ if (p == NULL) continue; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8alabel); + #endif + p = (ptr_t) field->type; ++ if (p == NULL) continue; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8blabel); + + // For the interpreter, we also need to mark the memory +@@ -258,6 +262,7 @@ + // Note: occasionally `klass' can be null. For instance, this + // can happen if a GC occurs between the point where an object + // is allocated and where the vtbl slot is set. ++ throw new java::lang::VirtualMachineError(); + while (klass && klass != &java::lang::Object::class$) + { + jfieldID field = JvGetFirstInstanceField (klass); +diff -ru libjava/gnu/gcj/convert/BytesToUnicode.java libjava/gnu/gcj/convert/BytesToUnicode.java +--- libjava/gnu/gcj/convert/BytesToUnicode.java Mon Jul 30 13:24:17 2001 ++++ libjava/gnu/gcj/convert/BytesToUnicode.java Wed Feb 25 22:53:54 2004 +@@ -65,7 +65,7 @@ + } + catch (Throwable ex) + { +- return new Input_8859_1(); ++ throw new UnsatisfiedLinkError(); + } + } + +diff -ru libjava/gnu/gcj/convert/UnicodeToBytes.java libjava/gnu/gcj/convert/UnicodeToBytes.java +--- libjava/gnu/gcj/convert/UnicodeToBytes.java Fri Aug 17 20:56:01 2001 ++++ libjava/gnu/gcj/convert/UnicodeToBytes.java Wed Feb 25 22:53:48 2004 +@@ -63,7 +63,8 @@ + } + catch (Throwable ex) + { +- return new Output_8859_1(); ++ throw new UnsatisfiedLinkError(); ++ //return new Output_8859_1(); + } + } + +diff -ru libjava/java/lang/Class.h libjava/java/lang/Class.h +--- libjava/java/lang/Class.h Sun Jan 19 22:49:28 2003 ++++ libjava/java/lang/Class.h Wed Feb 25 21:34:30 2004 +@@ -80,7 +80,6 @@ + // NULL-terminated list of exception class names; can be NULL if + // there are none such. + _Jv_Utf8Const **throws; +- + _Jv_Method *getNextMethod () + { return this + 1; } + }; +diff -ru libjava/java/lang/natClass.cc libjava/java/lang/natClass.cc +--- libjava/java/lang/natClass.cc Thu May 1 14:52:35 2003 ++++ libjava/java/lang/natClass.cc Wed Feb 25 22:59:34 2004 +@@ -808,10 +808,12 @@ + // Steps 8, 9, 10, 11. + try + { ++ /* + _Jv_Method *meth = _Jv_GetMethodLocal (this, clinit_name, + void_signature); + if (meth) + ((void (*) (void)) meth->ncode) (); ++ */ + } + catch (java::lang::Throwable *except) + { +@@ -1326,13 +1328,13 @@ + if (meth) + break; + } +- ++ /* + if (meth && (meth->name->data[0] == '<')) + { + // leave a placeholder in the itable for hidden init methods. + itable[pos] = NULL; + } +- else if (meth) ++ else*/ if (meth) + { + if (Modifier::isStatic(meth->accflags)) + throw new java::lang::IncompatibleClassChangeError +diff -ru libjava/libgcj.spec.in libjava/libgcj.spec.in +--- libjava/libgcj.spec.in Wed Feb 12 18:09:27 2003 ++++ libjava/libgcj.spec.in Wed Feb 25 19:51:22 2004 +@@ -4,6 +4,6 @@ + # to link with libgcj. + # + %rename lib liborig +-*lib: -lgcj -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig) ++*lib: -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig) + + *jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @CHECKREFSPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ @BACKTRACESPEC@ @IEEESPEC@ -fkeep-inline-functions +diff -ru libjava/prims.cc libjava/prims.cc +--- libjava/prims.cc Fri Apr 25 09:02:21 2003 ++++ libjava/prims.cc Wed Feb 25 23:16:52 2004 +@@ -165,6 +165,7 @@ + { + int len; + _Jv_ushort *aptr, *bptr; ++ if (a == NULL || b == NULL) return false; + if (a == b) + return true; + if (a->hash != b->hash) +@@ -188,6 +189,7 @@ + jboolean + _Jv_equal (Utf8Const* a, jstring str, jint hash) + { ++ if (a == NULL) return false; + if (a->hash != (_Jv_ushort) hash) + return false; + jint len = str->length(); +@@ -210,6 +212,7 @@ + jboolean + _Jv_equaln (Utf8Const *a, jstring str, jint n) + { ++ if (a == NULL) return false; + jint len = str->length(); + jint i = 0; + jchar *sptr = _Jv_GetStringChars (str);