this does not work
[org.ibex.core.git] / upstream / gcc-3.3 / patches / zzz-disable-reflection.patch
1 diff -ru gcc/java/class.c gcc/java/class.c
2 --- gcc/java/class.c    Fri Feb 28 12:53:07 2003
3 +++ gcc/java/class.c    Wed Feb 25 23:19:58 2004
4 @@ -1254,25 +1254,32 @@
5    if (DECL_RTL_SET_P (mdecl))
6      code = build1 (ADDR_EXPR, nativecode_ptr_type_node, mdecl);
7    START_RECORD_CONSTRUCTOR (minit, method_type_node);
8 -  PUSH_FIELD_VALUE (minit, "name",
9 -                   build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ?
10 -                                   init_identifier_node
11 -                                   : DECL_NAME (mdecl)));
12 -  {
13 +
14 +  // FIXME: should walk up the tree looking to see if this method
15 +  //        overrides one declared in an interface
16 +  if (!flag_inhibit_reflection || !METHOD_STATIC(mdecl) || DECL_CLINIT_P(mdecl) ||
17 +      (METHOD_STATIC(mdecl) && (strcmp(IDENTIFIER_POINTER(DECL_NAME(mdecl)),"main") == 0))) {
18 +    PUSH_FIELD_VALUE (minit, "name",
19 +                      build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ?
20 +                                      init_identifier_node
21 +                                      : DECL_NAME (mdecl)));
22      tree signature = build_java_signature (TREE_TYPE (mdecl));
23      PUSH_FIELD_VALUE (minit, "signature", 
24 -                     (build_utf8_ref 
25 -                      (unmangle_classname 
26 -                       (IDENTIFIER_POINTER(signature),
27 -                        IDENTIFIER_LENGTH(signature)))));
28 +                      (build_utf8_ref 
29 +                       (unmangle_classname 
30 +                        (IDENTIFIER_POINTER(signature),
31 +                         IDENTIFIER_LENGTH(signature)))));
32 +  } else {
33 +    PUSH_FIELD_VALUE (minit, "name", null_pointer_node);
34 +    PUSH_FIELD_VALUE (minit, "signature", null_pointer_node);
35    }
36    PUSH_FIELD_VALUE (minit, "accflags", build_int_2 (accflags, 0));
37    PUSH_FIELD_VALUE (minit, "index", index);
38    PUSH_FIELD_VALUE (minit, "ncode", code);
39 -
40    {
41      /* Compute the `throws' information for the method.  */
42      tree table = null_pointer_node;
43 +    if (!flag_inhibit_reflection)
44      if (DECL_FUNCTION_THROWS (mdecl) != NULL_TREE)
45        {
46         int length = 1 + list_length (DECL_FUNCTION_THROWS (mdecl));
47 @@ -1454,6 +1461,7 @@
48    field = TYPE_FIELDS (type);
49    if (DECL_NAME (field) == NULL_TREE)
50      field = TREE_CHAIN (field);  /* Skip dummy field for inherited data. */
51 +
52    for ( ;  field != NULL_TREE;  field = TREE_CHAIN (field))
53      {
54        if (! DECL_ARTIFICIAL (field))
55 @@ -1462,8 +1470,11 @@
56           if (FIELD_STATIC (field))
57             {
58               tree initial = DECL_INITIAL (field);
59 +  if (!flag_inhibit_reflection)
60 +    {
61               static_field_count++;
62               static_fields = tree_cons (NULL_TREE, init, static_fields);
63 +    }
64               /* If the initial value is a string constant,
65                  prevent output_constant from trying to assemble the value. */
66               if (initial != NULL_TREE
67 @@ -1473,6 +1484,7 @@
68               DECL_INITIAL (field) = initial;
69             }
70           else
71 +  if (!flag_inhibit_reflection)
72             {
73               instance_field_count++;
74               instance_fields = tree_cons (NULL_TREE, init, instance_fields);
75 diff -ru gcc/java/java-tree.h gcc/java/java-tree.h
76 --- gcc/java/java-tree.h        Mon Nov 18 10:13:35 2002
77 +++ gcc/java/java-tree.h        Wed Feb 25 19:49:44 2004
78 @@ -225,6 +225,9 @@
79  /* Encoding used for source files.  */
80  extern const char *current_encoding;
81  
82 +/** don't emit reflection information */
83 +extern int flag_inhibit_reflection;
84 +
85  /* The Java .class file that provides main_class;  the main input file. */
86  extern struct JCF *current_jcf;
87  
88 diff -ru gcc/java/lang.c gcc/java/lang.c
89 --- gcc/java/lang.c     Sun Jan  5 07:03:25 2003
90 +++ gcc/java/lang.c     Wed Feb 25 19:49:49 2004
91 @@ -171,6 +171,9 @@
92  /* The encoding of the source file.  */
93  const char *current_encoding = NULL;
94  
95 +/** don't emit reflection information */
96 +int flag_inhibit_reflection = 0;
97 +
98  /* When nonzero, report the now deprecated empty statements.  */
99  int flag_extraneous_semicolon;
100  
101 @@ -431,6 +434,13 @@
102      {
103        flag_inline_functions = 1;
104        flag_really_inline = 1;
105 +      return 1;
106 +    }
107 +#undef ARG
108 +#define ARG "-finhibit-reflection"
109 +  if (strncmp (p, ARG, sizeof (ARG) - 1) == 0)
110 +    {
111 +      flag_inhibit_reflection = 1;
112        return 1;
113      }
114  #undef ARG
115 diff -ru libjava/boehm.cc libjava/boehm.cc
116 --- libjava/boehm.cc    Thu Jan  2 21:19:53 2003
117 +++ libjava/boehm.cc    Wed Feb 25 23:43:44 2004
118 @@ -17,6 +17,7 @@
119  
120  #include <java/lang/Class.h>
121  #include <java/lang/reflect/Modifier.h>
122 +#include <java/lang/VirtualMachineError.h>
123  #include <java-interp.h>
124  
125  // More nastiness: the GC wants to define TRUE and FALSE.  We don't
126 @@ -147,6 +148,7 @@
127           for (int i = 0; i < c->method_count; ++i)
128             {
129               p = (ptr_t) c->methods[i].name;
130 +              if (p == NULL) continue;
131               MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c,
132                              cm1label);
133               p = (ptr_t) c->methods[i].signature;
134 @@ -164,9 +166,11 @@
135  
136  #ifndef COMPACT_FIELDS
137           p = (ptr_t) field->name;
138 +          if (p == NULL) continue;
139           MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8alabel);
140  #endif
141           p = (ptr_t) field->type;
142 +          if (p == NULL) continue;
143           MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8blabel);
144  
145           // For the interpreter, we also need to mark the memory
146 @@ -258,6 +262,7 @@
147        // Note: occasionally `klass' can be null.  For instance, this
148        // can happen if a GC occurs between the point where an object
149        // is allocated and where the vtbl slot is set.
150 +      throw new java::lang::VirtualMachineError();
151        while (klass && klass != &java::lang::Object::class$)
152         {
153           jfieldID field = JvGetFirstInstanceField (klass);
154 diff -ru libjava/gnu/gcj/convert/BytesToUnicode.java libjava/gnu/gcj/convert/BytesToUnicode.java
155 --- libjava/gnu/gcj/convert/BytesToUnicode.java Mon Jul 30 13:24:17 2001
156 +++ libjava/gnu/gcj/convert/BytesToUnicode.java Wed Feb 25 22:53:54 2004
157 @@ -65,7 +65,7 @@
158        }
159      catch (Throwable ex)
160        {
161 -       return new Input_8859_1();
162 +          throw new UnsatisfiedLinkError();
163        }
164    }
165  
166 diff -ru libjava/gnu/gcj/convert/UnicodeToBytes.java libjava/gnu/gcj/convert/UnicodeToBytes.java
167 --- libjava/gnu/gcj/convert/UnicodeToBytes.java Fri Aug 17 20:56:01 2001
168 +++ libjava/gnu/gcj/convert/UnicodeToBytes.java Wed Feb 25 22:53:48 2004
169 @@ -63,7 +63,8 @@
170        }
171      catch (Throwable ex)
172        {
173 -       return new Output_8859_1();
174 +          throw new UnsatisfiedLinkError();
175 +          //return new Output_8859_1();
176        }
177    }
178  
179 diff -ru libjava/java/lang/Class.h libjava/java/lang/Class.h
180 --- libjava/java/lang/Class.h   Sun Jan 19 22:49:28 2003
181 +++ libjava/java/lang/Class.h   Wed Feb 25 21:34:30 2004
182 @@ -80,7 +80,6 @@
183    // NULL-terminated list of exception class names; can be NULL if
184    // there are none such.
185    _Jv_Utf8Const **throws;
186 -
187    _Jv_Method *getNextMethod ()
188    { return this + 1; }
189  };
190 diff -ru libjava/java/lang/natClass.cc libjava/java/lang/natClass.cc
191 --- libjava/java/lang/natClass.cc       Thu May  1 14:52:35 2003
192 +++ libjava/java/lang/natClass.cc       Wed Feb 25 22:59:34 2004
193 @@ -808,10 +808,12 @@
194    // Steps 8, 9, 10, 11.
195    try
196      {
197 +      /*
198        _Jv_Method *meth = _Jv_GetMethodLocal (this, clinit_name,
199                                              void_signature);
200        if (meth)
201         ((void (*) (void)) meth->ncode) ();
202 +      */
203      }
204    catch (java::lang::Throwable *except)
205      {
206 @@ -1326,13 +1328,13 @@
207           if (meth)
208             break;
209         }
210 -
211 +      /*
212        if (meth && (meth->name->data[0] == '<'))
213         {
214           // leave a placeholder in the itable for hidden init methods.
215            itable[pos] = NULL;  
216         }
217 -      else if (meth)
218 +        else*/ if (meth)
219          {
220           if (Modifier::isStatic(meth->accflags))
221             throw new java::lang::IncompatibleClassChangeError
222 diff -ru libjava/libgcj.spec.in libjava/libgcj.spec.in
223 --- libjava/libgcj.spec.in      Wed Feb 12 18:09:27 2003
224 +++ libjava/libgcj.spec.in      Wed Feb 25 19:51:22 2004
225 @@ -4,6 +4,6 @@
226  # to link with libgcj.
227  #
228  %rename lib liborig
229 -*lib: -lgcj -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
230 +*lib: -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
231  
232  *jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @CHECKREFSPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ @BACKTRACESPEC@ @IEEESPEC@ -fkeep-inline-functions
233 diff -ru libjava/prims.cc libjava/prims.cc
234 --- libjava/prims.cc    Fri Apr 25 09:02:21 2003
235 +++ libjava/prims.cc    Wed Feb 25 23:16:52 2004
236 @@ -165,6 +165,7 @@
237  {
238    int len;
239    _Jv_ushort *aptr, *bptr;
240 +  if (a == NULL || b == NULL) return false;
241    if (a == b)
242      return true;
243    if (a->hash != b->hash)
244 @@ -188,6 +189,7 @@
245  jboolean
246  _Jv_equal (Utf8Const* a, jstring str, jint hash)
247  {
248 +  if (a == NULL) return false;
249    if (a->hash != (_Jv_ushort) hash)
250      return false;
251    jint len = str->length();
252 @@ -210,6 +212,7 @@
253  jboolean
254  _Jv_equaln (Utf8Const *a, jstring str, jint n)
255  {
256 +  if (a == NULL) return false;
257    jint len = str->length();
258    jint i = 0;
259    jchar *sptr = _Jv_GetStringChars (str);