aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog115
-rw-r--r--gcc/java/ChangeLog.lno4
-rw-r--r--gcc/java/Make-lang.in3
-rw-r--r--gcc/java/builtins.c10
-rw-r--r--gcc/java/class.c20
-rw-r--r--gcc/java/decl.c36
-rw-r--r--gcc/java/expr.c33
-rw-r--r--gcc/java/gcj.texi129
-rw-r--r--gcc/java/jcf-io.c10
-rw-r--r--gcc/java/lang.c50
-rw-r--r--gcc/java/verify-glue.c54
-rw-r--r--gcc/java/verify-impl.c262
-rw-r--r--gcc/java/verify.h4
13 files changed, 448 insertions, 282 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 02d12c161b9..8a88b9ff5eb 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,118 @@
+2005-04-20 Release Manager
+
+ * GCC 4.0.0 released.
+
+2005-04-07 Andrew Haley <aph@redhat.com>
+
+ * gcj.texi: Correct gcj-dbtool instructions.
+
+2005-04-06 Tom Tromey <tromey@redhat.com>
+
+ * gcj.texi (libgcj Runtime Properties): Document
+ gnu.gcj.runtime.endorsed.dirs.
+
+2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gcj.texi (Invoking gij): Add descriptions of new -X options.
+ Mention recognized-and-ignored compatibility options.
+ (Memory allocation): Add descriptions of JvMalloc, JvRealloc and
+ JvFree.
+ (About CNI): Add Memory allocation section.
+
+2005-04-01 Tom Tromey <tromey@redhat.com>
+
+ * decl.c (java_init_decl_processing): Fix types of
+ _Jv_MonitorEnter, _Jv_MonitorExit, _Jv_AllocObject,
+ _Jv_AllocObjectNoFinalizer, _Jv_Throw, _Jv_NewPrimArray,
+ _Jv_JNI_PopSystemFrame, _Jv_divI, _Jv_remI, _Jv_divJ, _Jv_remJ.
+
+2005-03-24 Anthony Green <green@redhat.com>
+
+ * gcj.texi (Invoking gcj-dbtool): Document new LIBDIR option to
+ 'gcj-dbtool -p'.
+
+2005-03-18 Andrew Haley <aph@redhat.com>
+
+ PR java/20522
+ * decl.c (update_aliases): Don't update variables that are about
+ to die.
+ (maybe_poplevels): Add comment.
+
+2005-03-16 Andrew Haley <aph@redhat.com>
+
+ * expr.c (expand_java_arrayload): Don't generate a
+ NullPointerException based on the type of the node.
+ (build_java_array_length_access): Likewise.
+
+2005-03-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * jcf-io.c (caching_stat): Use __extension__ to avoid pedantic
+ warning.
+ * Make-lang.in: Don't elide warnings in jcf-io.c.
+
+2005-03-10 Tom Tromey <tromey@redhat.com>
+
+ * gcj.texi (Invoking gcj-dbtool): Document 'gcj-dbtool -p'.
+ (libgcj Runtime Properties): Document the default .db.
+
+2005-03-07 Bryce McKinlay <mckinlay@redhat.com>
+
+ * verify-glue.c (vfy_is_assignable_from): Perform static check using
+ can_widen_reference_to if the C++ ABI is in use.
+ (vfy_get_interface_count, vfy_get_interface): Remove unused functions.
+ * verify-impl.c (debug_print, make_utf8_const, init_type, copy_type,
+ type_isresolved, init_state, set_pc, state_get_pc,
+ _Jv_BytecodeVerifier): Clean up unused and disabled functions.
+ (verify_fail): Report the current PC from the verifier context.
+ (free_state): Remove #if 0 block to enable this function.
+ (free_verifier_context): Call free_state on state_list iterator
+ values before freeing them.
+ * expr.c (pop_type_0): Pop correct type for error message when stack
+ contains a multi-word type.
+
+2005-03-07 Ranjit Mathew <rmathew@hotmail.com>
+
+ * expr.c (build_java_array_length_access): Remove !flag_new_verifier
+ for known NULL array length access.
+
+2005-03-07 Tom Tromey <tromey@redhat.com>
+
+ * gcj.texi (Invoking gcj-dbtool): Document '-f'.
+
+2005-03-04 Andrew Haley <aph@redhat.com>
+
+ PR java/18362
+ * class.c (set_method_index): Don't set method_index if it is
+ NULL_TREE.
+ (layout_class_method): Don't complain about "non-static method foo
+ overrides static method" in the case of indirect dispatch.
+
+2005-02-23 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ PR libgcj/16923
+ * gcj.texi (Invocation): Add descriptions of JvVMInitArgs and
+ JvVMOption.
+
+2005-02-22 Tom Tromey <tromey@redhat.com>
+
+ PR java/20056:
+ * verify-impl.c (EITHER): New define.
+ (types_compatible): Handle it.
+ (check_field_constant): Use it.
+
+2005-02-18 Tom Tromey <tromey@redhat.com>
+
+ PR java/20056:
+ * verify-impl.c (types_equal): Fixed test.
+
+ PR java/20056:
+ * verify-glue.c (vfy_class_has_field): New function.
+ * verify.h (vfy_class_has_field): Declare.
+ * verify-impl.c (check_field_constant): Added 'putfield'
+ argument.
+ (verify_instructions_0): Updated.
+ (types_equal): New function.
+
2005-02-14 Tom Tromey <tromey@redhat.com>
PR java/19921:
diff --git a/gcc/java/ChangeLog.lno b/gcc/java/ChangeLog.lno
new file mode 100644
index 00000000000..35f846515ff
--- /dev/null
+++ b/gcc/java/ChangeLog.lno
@@ -0,0 +1,4 @@
+2004-07-13 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ * builtins.c (initialize_builtins): Initialize
+ BUILT_IN_MAYBE_INFINITE_LOOP.
diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index 26970e8f1df..ccdc38e7a4f 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -129,9 +129,6 @@ jvspec.o-warn = -Wno-error
java/parse-scan.o-warn = -Wno-error
java/parse.o-warn = -Wno-error
-# Use of non-standardized scandir
-java/jcf-io.o-warn = -Wno-error
-
jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
rm -f $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c
index f4a8efb2a1b..850e797426e 100644
--- a/gcc/java/builtins.c
+++ b/gcc/java/builtins.c
@@ -161,6 +161,8 @@ initialize_builtins (void)
{
tree double_ftype_double, double_ftype_double_double;
tree float_ftype_float, float_ftype_float_float;
+ /* APPLE LOCAL lno */
+ tree void_ftype;
tree t;
int i;
@@ -185,6 +187,10 @@ initialize_builtins (void)
t = tree_cons (NULL_TREE, double_type_node, t);
double_ftype_double_double = build_function_type (double_type_node, t);
+ /* APPLE LOCAL begin lno */
+ void_ftype = build_function_type (void_type_node, NULL_TREE);
+ /* APPLE LOCAL end lno */
+
define_builtin (BUILT_IN_FMOD, "__builtin_fmod",
double_ftype_double_double, "fmod");
define_builtin (BUILT_IN_FMODF, "__builtin_fmodf",
@@ -216,6 +222,10 @@ initialize_builtins (void)
double_ftype_double, "_ZN4java4lang4Math4sqrtEd");
define_builtin (BUILT_IN_TAN, "__builtin_tan",
double_ftype_double, "_ZN4java4lang4Math3tanEd");
+ /* APPLE LOCAL begin lno */
+ define_builtin (BUILT_IN_MAYBE_INFINITE_LOOP, "__builtin_maybe_infinite_loop",
+ void_ftype, "__builtin_maybe_infinite_loop");
+ /* APPLE LOCAL end lno */
build_common_builtin_nodes ();
}
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 53a31e94031..5e2e535dbc9 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -1476,14 +1476,19 @@ get_dispatch_table (tree type, tree this_class_addr)
void
set_method_index (tree decl, tree method_index)
{
- method_index = fold (convert (sizetype, method_index));
+ if (method_index != NULL_TREE)
+ {
+ /* method_index is null if we're using indirect dispatch. */
+ method_index = fold (convert (sizetype, method_index));
- if (TARGET_VTABLE_USES_DESCRIPTORS)
- /* Add one to skip bogus descriptor for class and GC descriptor. */
- method_index = size_binop (PLUS_EXPR, method_index, size_int (1));
- else
- /* Add 1 to skip "class" field of dtable, and 1 to skip GC descriptor. */
- method_index = size_binop (PLUS_EXPR, method_index, size_int (2));
+ if (TARGET_VTABLE_USES_DESCRIPTORS)
+ /* Add one to skip bogus descriptor for class and GC descriptor. */
+ method_index = size_binop (PLUS_EXPR, method_index, size_int (1));
+ else
+ /* Add 1 to skip "class" field of dtable, and 1 to skip GC
+ descriptor. */
+ method_index = size_binop (PLUS_EXPR, method_index, size_int (2));
+ }
DECL_VINDEX (decl) = method_index;
}
@@ -2357,6 +2362,7 @@ layout_class_method (tree this_class, tree super_class,
tree method_index = get_method_index (super_method);
set_method_index (method_decl, method_index);
if (method_index == NULL_TREE
+ && ! flag_indirect_dispatch
&& !CLASS_FROM_SOURCE_P (this_class)
&& ! DECL_ARTIFICIAL (super_method))
error ("%Jnon-static method '%D' overrides static method",
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index b7aa61650d3..9ecd223b6b3 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -149,7 +149,10 @@ update_aliases (tree decl, int index, int pc)
&& LOCAL_SLOT_P (tmp) == 0
&& (pc == -1
|| (pc >= DECL_LOCAL_START_PC (tmp)
- && pc <= DECL_LOCAL_END_PC (tmp)))
+ && pc < DECL_LOCAL_END_PC (tmp)))
+ /* This test is < (rather than <=) because there's no point
+ updating an alias that's about to die at the end of this
+ instruction. */
&& (tmp_type == decl_type
|| (INTEGRAL_TYPE_P (tmp_type)
&& INTEGRAL_TYPE_P (decl_type)
@@ -663,6 +666,8 @@ java_init_decl_processing (void)
/* Define these next since types below may used them. */
integer_type_node = java_type_for_size (INT_TYPE_SIZE, 0);
+ /* APPLE LOCAL lno */
+ long_integer_type_node = java_type_for_size (LONG_TYPE_SIZE, 0);
integer_zero_node = build_int_cst (NULL_TREE, 0);
integer_one_node = build_int_cst (NULL_TREE, 1);
integer_two_node = build_int_cst (NULL_TREE, 2);
@@ -989,8 +994,7 @@ java_init_decl_processing (void)
endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
- t = tree_cons (NULL_TREE, class_ptr_type,
- tree_cons (NULL_TREE, int_type_node, endlink));
+ t = tree_cons (NULL_TREE, class_ptr_type, endlink);
alloc_object_node = builtin_function ("_Jv_AllocObject",
build_function_type (ptr_type_node, t),
0, NOT_BUILT_IN, NULL, NULL_TREE);
@@ -1008,31 +1012,33 @@ java_init_decl_processing (void)
0, NOT_BUILT_IN, NULL, NULL_TREE);
throw_node = builtin_function ("_Jv_Throw",
- build_function_type (ptr_type_node, t),
+ build_function_type (void_type_node, t),
0, NOT_BUILT_IN, NULL, NULL_TREE);
/* Mark throw_nodes as `noreturn' functions with side effects. */
TREE_THIS_VOLATILE (throw_node) = 1;
TREE_SIDE_EFFECTS (throw_node) = 1;
- t = build_function_type (int_type_node, endlink);
+ t = build_function_type (void_type_node, tree_cons (NULL_TREE, ptr_type_node,
+ endlink));
soft_monitorenter_node
= builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
soft_monitorexit_node
= builtin_function ("_Jv_MonitorExit", t, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
-
- t = tree_cons (NULL_TREE, int_type_node,
+
+ t = tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, int_type_node, endlink));
soft_newarray_node
= builtin_function ("_Jv_NewPrimArray",
- build_function_type(ptr_type_node, t),
+ build_function_type (ptr_type_node, t),
0, NOT_BUILT_IN, NULL, NULL_TREE);
DECL_IS_MALLOC (soft_newarray_node) = 1;
t = tree_cons (NULL_TREE, int_type_node,
tree_cons (NULL_TREE, class_ptr_type,
- tree_cons (NULL_TREE, object_ptr_type_node, endlink)));
+ tree_cons (NULL_TREE, object_ptr_type_node,
+ endlink)));
soft_anewarray_node
= builtin_function ("_Jv_NewObjectArray",
build_function_type (ptr_type_node, t),
@@ -1118,9 +1124,11 @@ java_init_decl_processing (void)
0, NOT_BUILT_IN, NULL, NULL_TREE);
soft_jnipopsystemframe_node
= builtin_function ("_Jv_JNI_PopSystemFrame",
- build_function_type (ptr_type_node, t),
+ build_function_type (void_type_node, t),
0, NOT_BUILT_IN, NULL, NULL_TREE);
+ t = tree_cons (NULL_TREE, int_type_node,
+ tree_cons (NULL_TREE, int_type_node, endlink));
soft_idiv_node
= builtin_function ("_Jv_divI",
build_function_type (int_type_node, t),
@@ -1131,6 +1139,8 @@ java_init_decl_processing (void)
build_function_type (int_type_node, t),
0, NOT_BUILT_IN, NULL, NULL_TREE);
+ t = tree_cons (NULL_TREE, long_type_node,
+ tree_cons (NULL_TREE, long_type_node, endlink));
soft_ldiv_node
= builtin_function ("_Jv_divJ",
build_function_type (long_type_node, t),
@@ -1741,6 +1751,12 @@ maybe_poplevels (int pc)
current_pc = pc;
#endif
+ /* FIXME: I'm pretty sure that this is wrong. Variable scopes are
+ inclusive, so a variable is live if pc == end_pc. Here, we
+ terminate a range if the current pc is equal to the end of the
+ range, and this is *before* we have generated code for the
+ instruction at end_pc. We're closing a binding level one
+ instruction too early. */
while (current_binding_level->end_pc <= pc)
poplevel (1, 0, 0);
}
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 7d515052ba0..30f67adfe5f 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -383,6 +383,10 @@ pop_type_0 (tree type, char **messagep)
fail:
{
char *temp = xstrdup (lang_printable_name (type, 0));
+ /* If the stack contains a multi-word type, keep popping the stack until
+ the real type is found. */
+ while (t == void_type_node)
+ t = stack_type_map[--stack_pointer];
*messagep = concat ("expected type '", temp,
"' but stack contains '", lang_printable_name (t, 0),
"'", NULL);
@@ -814,15 +818,6 @@ build_java_array_length_access (tree node)
tree array_type = TREE_TYPE (type);
HOST_WIDE_INT length;
- /* JVM spec: If the arrayref is null, the arraylength instruction
- throws a NullPointerException. The only way we could get a node
- of type ptr_type_node at this point is `aconst_null; arraylength'
- or something equivalent. */
- if (!flag_new_verifier && type == ptr_type_node)
- return build3 (CALL_EXPR, int_type_node,
- build_address_of (soft_nullpointer_node),
- NULL_TREE, NULL_TREE);
-
if (!is_array_type_p (type))
{
/* With the new verifier, we will see an ordinary pointer type
@@ -1225,21 +1220,11 @@ expand_java_arrayload (tree lhs_type_node)
index_node = save_expr (index_node);
array_node = save_expr (array_node);
- if (TREE_TYPE (array_node) == ptr_type_node)
- /* The only way we could get a node of type ptr_type_node at this
- point is `aconst_null; arraylength' or something equivalent, so
- unconditionally throw NullPointerException. */
- load_node = build3 (CALL_EXPR, lhs_type_node,
- build_address_of (soft_nullpointer_node),
- NULL_TREE, NULL_TREE);
- else
- {
- lhs_type_node = build_java_check_indexed_type (array_node,
- lhs_type_node);
- load_node = build_java_arrayaccess (array_node,
- lhs_type_node,
- index_node);
- }
+ lhs_type_node = build_java_check_indexed_type (array_node,
+ lhs_type_node);
+ load_node = build_java_arrayaccess (array_node,
+ lhs_type_node,
+ index_node);
if (INTEGRAL_TYPE_P (lhs_type_node) && TYPE_PRECISION (lhs_type_node) <= 32)
load_node = fold (build1 (NOP_EXPR, int_type_node, load_node));
push_value (load_node);
diff --git a/gcc/java/gcj.texi b/gcc/java/gcj.texi
index 68531560ff9..6fc85271a93 100644
--- a/gcc/java/gcj.texi
+++ b/gcc/java/gcj.texi
@@ -949,16 +949,26 @@ be retrieved at runtime using the @code{java.lang.System.getProperty}
method.
@item -ms=@var{number}
-This sets the initial heap size.
+Equivalent to @code{-Xms}.
@item -mx=@var{number}
-This sets the maximum heap size.
+Equivalent to @code{-Xmx}.
@item -X
@itemx -X@var{argument}
Supplying @code{-X} by itself will cause @code{gij} to list all the
-supported @code{-X} options. Currently there are none. Unrecognized
-@code{-X} options are ignored, for compatibility with other runtimes.
+supported @code{-X} options. Currently these options are supported:
+
+@table @gcctabopt
+@item -Xms@var{size}
+Set the initial heap size.
+
+@item -Xmx@var{size}
+Set the maximum heap size.
+@end table
+
+Unrecognized @code{-X} options are ignored, for compatibility with
+other runtimes.
@item -jar
This indicates that the name passed to @code{gij} should be interpreted
@@ -971,6 +981,9 @@ Print help, then exit.
@item --showversion
Print version number and continue.
+@item --fullversion
+Print detailed version information, then exit.
+
@item --version
Print version number, then exit.
@@ -979,6 +992,12 @@ Print version number, then exit.
Each time a class is initialized, print a short message on standard error.
@end table
+@code{gij} also recognizes and ignores the following options, for
+compatibility with existing application launch scripts:
+@code{-client}, @code{-server}, @code{-hotspot}, @code{-jrockit},
+@code{-agentlib}, @code{-agentpath}, @code{-debug}, @code{-d32},
+@code{-d64}, @code{-javaagent} and @code{-noclassgc}.
+
@c man end
@node Invoking gcj-dbtool
@@ -990,8 +1009,9 @@ Each time a class is initialized, print a short message on standard error.
@c man begin SYNOPSIS gcj-dbtool
gcj-dbtool @option{OPTION} @var{DBFILE} [@option{MORE}] @dots{}
-gcj-dbtool [@option{-n}] [@option{-a}] [@option{-t}] [@option{-l}]
- [@option{-v}] [@option{--version}] [@option{--help}]
+gcj-dbtool [@option{-0}] [@option{-}] [@option{-n}] [@option{-a}] [@option{-f}]
+ [@option{-t}] [@option{-l}] [@option{-p} [@var{LIBDIR}]]
+ [@option{-v}] [@option{-m}] [@option{--version}] [@option{--help}]
@c man end
@c man begin SEEALSO gij
@@ -1027,11 +1047,26 @@ you can choose a larger initial size if desired. The default size is
32,749.
@item -a @var{DBFILE} @var{JARFILE} @var{LIB}
+@itemx -f @var{DBFILE} @var{JARFILE} @var{LIB}
This adds a jar file to the database. For each class file in the jar,
a cryptographic signature of the bytecode representation of the class
is recorded in the database. At runtime, a class is looked up by its
signature and the compiled form of the class is looked for in the
-corresponding shared library.
+corresponding shared library. The @option{-a} option will verify
+that @var{LIB} exists before adding it to the database; @option{-f}
+skips this check.
+
+@item [@option{-}][@option{-0}] -m @var{DBFILE} @var{DBFILE},[@var{DBFILE}]
+Merge a number of databases. The output database overwrites any
+existing database. To add databases into an existing database,
+include the destination in the list of sources.
+
+If @option{-} or @option{-0} are used, the list of files to read is
+taken from standard input instead of the command line. For
+@option{-0}, Input filenames are terminated by a null character
+instead of by whitespace. Useful when arguments might contain white
+space. The GNU find -print0 option produces input suitable for this
+mode.
@item -t @var{DBFILE}
Test a database.
@@ -1039,6 +1074,12 @@ Test a database.
@item -l @var{DBFILE}
List the contents of a database.
+@item -p
+Print the name of the default database. If there is no default
+database, this prints a blank line. If @var{LIBDIR} is specified, use
+it instead of the default library directory component of the database
+name.
+
@item --help
Print a help message, then exit.
@@ -1240,6 +1281,7 @@ alternative to the standard JNI (Java Native Interface).
* Objects and Classes:: C++ and Java classes.
* Class Initialization:: How objects are initialized.
* Object allocation:: How to create Java objects in C++.
+* Memory allocation:: How to allocate and free memory.
* Arrays:: Dealing with Java arrays in C++.
* Methods:: Java methods in C++.
* Strings:: Information about Java Strings.
@@ -1620,6 +1662,27 @@ java::util::Hashtable *ht = new java::util::Hashtable(120);
@end example
+@node Memory allocation
+@section Memory allocation
+
+When allocting memory in @acronym{CNI} methods it is best to handle
+out-of-memory conditions by throwing a Java exception. These
+functions are provided for that purpose:
+
+@deftypefun void* JvMalloc (jsize @var{size})
+Calls malloc. Throws @code{java.lang.OutOfMemoryError} if allocation
+fails.
+@end deftypefun
+
+@deftypefun void* JvRealloc (void* @var{ptr}, jsize @var{size})
+Calls realloc. Throws @code{java.lang.OutOfMemoryError} if
+reallocation fails.
+@end deftypefun
+
+@deftypefun void JvFree (void* @var{ptr})
+Calls free.
+@end deftypefun
+
@node Arrays
@section Arrays
@@ -2110,7 +2173,8 @@ CNI permits C++ applications to make calls into Java classes, in addition to
allowing Java code to call into C++. Several functions, known as the
@dfn{invocation API}, are provided to support this.
-@deftypefun jint JvCreateJavaVM (void* @var{vm_args})
+@deftypefun jint JvCreateJavaVM (JvVMInitArgs* @var{vm_args})
+
Initializes the Java runtime. This function performs essential initialization
of the threads interface, garbage collector, exception handling and other key
aspects of the runtime. It must be called once by an application with
@@ -2119,11 +2183,40 @@ It is safe, but not recommended, to call @code{JvCreateJavaVM()} more than
once provided it is only called from a single thread.
The @var{vmargs} parameter can be used to specify initialization parameters
for the Java runtime. It may be @code{NULL}.
-This function returns @code{0} upon success, or @code{-1} if the runtime is
-already initialized.
-@emph{Note:} In GCJ 3.1, the @code{vm_args} parameter is ignored. It may be
-used in a future release.
+JvVMInitArgs represents a list of virtual machine initialization
+arguments. @code{JvCreateJavaVM()} ignores the version field.
+
+@example
+typedef struct JvVMOption
+@{
+ // a VM initialization option
+ char* optionString;
+ // extra information associated with this option
+ void* extraInfo;
+@} JvVMOption;
+
+typedef struct JvVMInitArgs
+@{
+ // for compatibility with JavaVMInitArgs
+ jint version;
+
+ // number of VM initialization options
+ jint nOptions;
+
+ // an array of VM initialization options
+ JvVMOption* options;
+
+ // true if the option parser should ignore unrecognized options
+ jboolean ignoreUnrecognized;
+@} JvVMInitArgs;
+@end example
+
+@code{JvCreateJavaVM()} returns @code{0} upon success, or @code{-1} if
+the runtime is already initialized.
+
+@emph{Note:} In GCJ 3.1, the @code{vm_args} parameter is ignored. It
+is recognized and used as of release 4.0.
@end deftypefun
@deftypefun java::lang::Thread* JvAttachCurrentThread (jstring @var{name}, java::lang::ThreadGroup* @var{group})
@@ -2475,6 +2568,15 @@ search is done for each requested class. If this property is set to
tried again. If this property is set to @samp{never}, then lookups
are never done. For more information, @xref{Extensions}.
+@item gnu.gcj.runtime.endorsed.dirs
+This is like the standard @code{java.endorsed.dirs}, property, but
+specifies some extra directories which are searched after the standard
+endorsed directories. This is primarily useful for telling
+@code{libgcj} about additional libraries which are ordinarily
+incorporated into the JDK, and which should be loaded by the bootstrap
+class loader, but which are not yet part of @code{libgcj} itself for
+some reason.
+
@item gnu.gcj.jit.compiler
@c FIXME we should probably have a whole node on this...
This is the full path to @command{gcj} executable which should be
@@ -2497,7 +2599,8 @@ be set to a directory that is writable by any other user.
This is a sequence of file names, each referring to a file created by
@command{gcj-dbtool}. These files will be used by @code{libgcj} to
find shared libraries corresponding to classes that are loaded from
-bytecode.
+bytecode. @code{libgcj} often has a built-in default database; it
+can be queried using @code{gcj-dbtool -p}.
@end table
diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c
index e0ab03e14cf..6588ef24441 100644
--- a/gcc/java/jcf-io.c
+++ b/gcc/java/jcf-io.c
@@ -376,11 +376,11 @@ caching_stat (char *filename, struct stat *buf)
particular, the type of the function pointer passed as the
third argument sometimes takes a "const struct dirent *"
parameter, and sometimes just a "struct dirent *". We cast
- to (void *) so that either way it is quietly accepted.
- FIXME: scandir is not in POSIX. */
- dent->num_files = scandir (filename, &dent->files,
- (void *) java_or_class_file,
- alphasort);
+ to (void *) and use __extension__ so that either way it is
+ quietly accepted. FIXME: scandir is not in POSIX. */
+ dent->num_files = __extension__ scandir (filename, &dent->files,
+ (void *) java_or_class_file,
+ alphasort);
*slot = dent;
}
else
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index b89bdf9b6d8..24c3d0b95ad 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -752,6 +752,56 @@ java_tree_inlining_walk_subtrees (tree *tp ATTRIBUTE_UNUSED,
#undef WALK_SUBTREE
}
+/* APPLE LOCAL begin AltiVec */
+/* Placeholders to make linking work, remove when altivec support is correct */
+
+int comptypes (tree type1, tree type2);
+
+int
+comptypes (tree type1, tree type2)
+{
+ register tree t1 = type1;
+ register tree t2 = type2;
+ if (t1 == t2 || !t1 || !t2
+ || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
+ return 1;
+ return 0;
+}
+
+tree default_conversion (tree exp);
+
+tree
+default_conversion (tree exp)
+{
+ return exp;
+}
+
+tree lang_build_type_variant (tree type, int constp ATTRIBUTE_UNUSED, int volatilep ATTRIBUTE_UNUSED);
+
+tree
+lang_build_type_variant (tree type, int constp ATTRIBUTE_UNUSED, int volatilep ATTRIBUTE_UNUSED)
+{
+ return type;
+}
+/* APPLE LOCAL end AltiVec */
+
+/* APPLE LOCAL begin constant cfstrings */
+enum { blabla } c_language;
+const char *constant_string_class_name = "die die";
+int flag_next_runtime = 1;
+/* APPLE LOCAL end constant cfstrings */
+
+/* APPLE LOCAL disable_typechecking_for_spec_flag */
+int disable_typechecking_for_spec_flag = 0;
+
+/* APPLE LOCAL begin CW asm blocks */
+/* Dummies needed because we use them from cpplib, yuck. */
+int flag_cw_asm_blocks;
+int cw_asm_state;
+int cw_asm_in_operands;
+/* APPLE LOCAL end CW asm blocks */
+
+
/* Every call to a static constructor has an associated boolean
variable which is in the outermost scope of the calling method.
This variable is used to avoid multiple calls to the static
diff --git a/gcc/java/verify-glue.c b/gcc/java/verify-glue.c
index b2cd9156cd0..b1664ba991a 100644
--- a/gcc/java/verify-glue.c
+++ b/gcc/java/verify-glue.c
@@ -1,5 +1,5 @@
/* Glue to interface gcj with bytecode verifier.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GCC.
@@ -231,17 +231,18 @@ vfy_get_class_name (vfy_jclass klass)
bool
vfy_is_assignable_from (vfy_jclass target, vfy_jclass source)
{
- /* At compile time, for the BC-ABI we assume that reference types are always
- compatible. However, a type assertion table entry is emitted so that the
- runtime can detect binary-incompatible changes. */
-
- /* FIXME: implement real test for old ABI. */
-
/* Any class is always assignable to itself, or java.lang.Object. */
if (source == target || target == object_type_node)
return true;
- /* Otherwise, a type assertion is required. */
+ /* For the C++ ABI, perform this test statically. */
+ if (! flag_indirect_dispatch)
+ return can_widen_reference_to (source, target);
+
+ /* For the BC-ABI, we assume at compile time that reference types are always
+ compatible. However, a type assertion table entry is emitted so that the
+ runtime can detect binary-incompatible changes. */
+
add_type_assertion (current_class, JV_ASSERT_TYPES_COMPATIBLE, source,
target);
return true;
@@ -257,28 +258,6 @@ vfy_get_primitive_char (vfy_jclass klass)
return (IDENTIFIER_POINTER (sig))[0];
}
-int
-vfy_get_interface_count (vfy_jclass klass ATTRIBUTE_UNUSED)
-{
- /* FIXME: Need to merge from mainline to get this. */
- #if 0
- return BINFO_N_BASE_BINFOS (klass);
- #endif
- return -1;
-}
-
-vfy_jclass
-vfy_get_interface (vfy_jclass klass ATTRIBUTE_UNUSED, int index ATTRIBUTE_UNUSED)
-{
- /* FIXME: Need to merge from mainline to get this. */
- #if 0
- vfy_jclass k;
- k = BINFO_BASE_BINFO (klass, index);
- return k;
- #endif
- return NULL;
-}
-
bool
vfy_is_array (vfy_jclass klass)
{
@@ -385,6 +364,21 @@ vfy_null_type (void)
return TYPE_NULL;
}
+bool
+vfy_class_has_field (vfy_jclass klass, vfy_string name,
+ vfy_string signature)
+{
+ tree field = TYPE_FIELDS (klass);
+ while (field != NULL_TREE)
+ {
+ if (DECL_NAME (field) == name
+ && build_java_signature (TREE_TYPE (field)) == signature)
+ return true;
+ field = TREE_CHAIN (field);
+ }
+ return false;
+}
+
int
vfy_fail (const char *message, int pc, vfy_jclass ignore1 ATTRIBUTE_UNUSED,
vfy_method *ignore2 ATTRIBUTE_UNUSED)
diff --git a/gcc/java/verify-impl.c b/gcc/java/verify-impl.c
index ee8f426e5a3..30d12209449 100644
--- a/gcc/java/verify-impl.c
+++ b/gcc/java/verify-impl.c
@@ -42,22 +42,6 @@ debug_print (const char *fmt ATTRIBUTE_UNUSED, ...)
}
#endif /* VERIFY_DEBUG */
-#if 0
-static void debug_print (const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-static void
-debug_print (const char *fmt, ...)
-{
-#ifdef VERIFY_DEBUG
- va_list ap;
- va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
- va_end (ap);
-#endif /* VERIFY_DEBUG */
-}
-#endif
-
/* This started as a fairly ordinary verifier, and for the most part
it remains so. It works in the obvious way, by modeling the effect
of each opcode as it is encountered. For most opcodes, this is a
@@ -224,22 +208,6 @@ static GTY(()) verifier_context *vfr;
bool type_initialized (type *t);
int ref_count_dimensions (ref_intersection *ref);
-#if 0
- /* Create a new Utf-8 constant and return it. We do this to avoid
- having our Utf-8 constants prematurely collected. */
- static vfy_string
- make_utf8_const (const char *s, int len)
- {
- vfy_string val = vfy_make_string (s, len);
- vfy_string_list *lu = vfy_alloc (sizeof (vfy_string_list));
- lu->val = val;
- lu->next = vfr->utf8_list;
- vfr->utf8_list = lu;
-
- return val;
- }
-#endif
-
static void
verify_fail_pc (const char *s, int pc)
{
@@ -249,7 +217,7 @@ verify_fail_pc (const char *s, int pc)
static void
verify_fail (const char *s)
{
- verify_fail_pc (s, -1);
+ verify_fail_pc (s, vfr->PC);
}
/* This enum holds a list of tags for all the different types we
@@ -539,29 +507,21 @@ struct type
First, when constructing a new object, it is the PC of the
`new' instruction which created the object. We use the special
- value UNINIT to mean that this is uninitialized, and the
- special value SELF for the case where the current method is
- itself the <init> method.
-
+ value UNINIT to mean that this is uninitialized. The special
+ value SELF is used for the case where the current method is
+ itself the <init> method. the special value EITHER is used
+ when we may optionally allow either an uninitialized or
+ initialized reference to match.
+
Second, when the key is return_address_type, this holds the PC
of the instruction following the `jsr'. */
int pc;
- #define UNINIT -2
- #define SELF -1
+#define UNINIT -2
+#define SELF -1
+#define EITHER -3
};
-#if 0
-/* Basic constructor. */
-static void
-init_type (type *t)
-{
- t->key = unsuitable_type;
- t->klass = NULL;
- t->pc = UNINIT;
-}
-#endif
-
/* Make a new instance given the type tag. We assume a generic
`reference_type' means Object. */
static void
@@ -623,26 +583,6 @@ make_type_from_string (vfy_string n)
return t;
}
-#if 0
- /* Make a new instance given the name of a class. */
- type (vfy_string n)
- {
- key = reference_type;
- klass = new ref_intersection (n, verifier);
- pc = UNINIT;
- }
-
- /* Copy constructor. */
- static type copy_type (type *t)
- {
- type copy;
- copy.key = t->key;
- copy.klass = t->klass;
- copy.pc = t->pc;
- return copy;
- }
-#endif
-
/* Promote a numeric type. */
static void
vfy_promote_type (type *t)
@@ -721,23 +661,52 @@ types_compatible (type *t, type *k)
if (k->klass == NULL)
verify_fail ("programmer error in type::compatible");
- /* An initialized type and an uninitialized type are not
- compatible. */
- if (type_initialized (t) != type_initialized (k))
- return false;
-
- /* Two uninitialized objects are compatible if either:
- * The PCs are identical, or
- * One PC is UNINIT. */
- if (type_initialized (t))
+ /* Handle the special 'EITHER' case, which is only used in a
+ special case of 'putfield'. Note that we only need to handle
+ this on the LHS of a check. */
+ if (! type_initialized (t) && t->pc == EITHER)
{
- if (t->pc != k->pc && t->pc != UNINIT && k->pc != UNINIT)
+ /* If the RHS is uninitialized, it must be an uninitialized
+ 'this'. */
+ if (! type_initialized (k) && k->pc != SELF)
return false;
}
+ else if (type_initialized (t) != type_initialized (k))
+ {
+ /* An initialized type and an uninitialized type are not
+ otherwise compatible. */
+ return false;
+ }
+ else
+ {
+ /* Two uninitialized objects are compatible if either:
+ * The PCs are identical, or
+ * One PC is UNINIT. */
+ if (type_initialized (t))
+ {
+ if (t->pc != k->pc && t->pc != UNINIT && k->pc != UNINIT)
+ return false;
+ }
+ }
return ref_compatible (t->klass, k->klass);
}
+/* Return true if two types are equal. Only valid for reference
+ types. */
+static bool
+types_equal (type *t1, type *t2)
+{
+ if ((t1->key != reference_type && t1->key != uninitialized_reference_type)
+ || (t2->key != reference_type
+ && t2->key != uninitialized_reference_type))
+ return false;
+ /* Only single-ref types are allowed. */
+ if (t1->klass->ref_next || t2->klass->ref_next)
+ return false;
+ return refs_equal (t1->klass, t2->klass);
+}
+
static bool
type_isvoid (type *t)
{
@@ -842,16 +811,6 @@ type_initialized (type *t)
return t->key == reference_type || t->key == null_type;
}
-#if 0
-static bool
-type_isresolved (type *t)
-{
- return (t->key == reference_type
- || t->key == null_type
- || t->key == uninitialized_reference_type);
-}
-#endif
-
static void
type_verify_dimensions (type *t, int ndims)
{
@@ -986,16 +945,6 @@ struct state
acquired from the verification list. */
#define NO_NEXT -1
-#if 0
-static void
-init_state (state *s)
-{
- s->stack = NULL;
- s->locals = NULL;
- s->next = INVALID_STATE;
-}
-#endif
-
static void
init_state_with_stack (state *s, int max_stack, int max_locals)
{
@@ -1052,7 +1001,6 @@ make_state (int max_stack, int max_locals)
return s;
}
-#if 0
static void
free_state (state *s)
{
@@ -1061,29 +1009,6 @@ free_state (state *s)
if (s->locals != NULL)
vfy_free (s->locals);
}
-#endif
-
-#if 0
- void *operator new[] (size_t bytes)
- {
- return vfy_alloc (bytes);
- }
-
- void operator delete[] (void *mem)
- {
- vfy_free (mem);
- }
-
- void *operator new (size_t bytes)
- {
- return vfy_alloc (bytes);
- }
-
- void operator delete (void *mem)
- {
- vfy_free (mem);
- }
-#endif
/* Modify this state to reflect entry to an exception handler. */
static void
@@ -1097,20 +1022,6 @@ state_set_exception (state *s, type *t, int max_stack)
init_type_from_tag (&s->stack[i], unsuitable_type);
}
-static int
-state_get_pc (state *s)
-{
- return s->pc;
-}
-
-#if 0
-static void
-set_pc (state *s, int npc)
-{
- s->pc = npc;
-}
-#endif
-
/* Merge STATE_OLD into this state. Destructively modifies this
state. Returns true if the new state was in fact changed.
Will throw an exception if the states are not mergeable. */
@@ -2117,9 +2028,10 @@ handle_field_or_method (int index, int expected,
return check_class_constant (class_index);
}
-/* Return field's type, compute class' type if requested. */
+/* Return field's type, compute class' type if requested. If
+ PUTFIELD is true, use the special 'putfield' semantics. */
static type
-check_field_constant (int index, type *class_type)
+check_field_constant (int index, type *class_type, bool putfield)
{
vfy_string name, field_type;
const char *typec;
@@ -2137,6 +2049,21 @@ check_field_constant (int index, type *class_type)
init_type_from_string (&t, field_type);
else
init_type_from_tag (&t, get_type_val_for_signature (typec[0]));
+
+ /* We have an obscure special case here: we can use `putfield' on a
+ field declared in this class, even if `this' has not yet been
+ initialized. */
+ if (putfield
+ && ! type_initialized (&vfr->current_state->this_type)
+ && vfr->current_state->this_type.pc == SELF
+ && types_equal (&vfr->current_state->this_type, &ct)
+ && vfy_class_has_field (vfr->current_class, name, field_type))
+ /* Note that we don't actually know whether we're going to match
+ against 'this' or some other object of the same type. So,
+ here we set things up so that it doesn't matter. This relies
+ on knowing what our caller is up to. */
+ type_set_uninitialized (class_type, EITHER);
+
return t;
}
@@ -2320,7 +2247,7 @@ verify_instructions_0 (void)
if (new_state == NULL)
break;
- vfr->PC = state_get_pc (new_state);
+ vfr->PC = new_state->pc;
debug_print ("== State pop from pending list\n");
/* Set up the current state. */
copy_state (vfr->current_state, new_state,
@@ -2971,15 +2898,15 @@ verify_instructions_0 (void)
invalidate_pc ();
break;
case op_getstatic:
- push_type_t (check_field_constant (get_ushort (), NULL));
+ push_type_t (check_field_constant (get_ushort (), NULL, false));
break;
case op_putstatic:
- pop_type_t (check_field_constant (get_ushort (), NULL));
+ pop_type_t (check_field_constant (get_ushort (), NULL, false));
break;
case op_getfield:
{
type klass;
- type field = check_field_constant (get_ushort (), &klass);
+ type field = check_field_constant (get_ushort (), &klass, false);
pop_type_t (klass);
push_type_t (field);
}
@@ -2987,15 +2914,8 @@ verify_instructions_0 (void)
case op_putfield:
{
type klass;
- type field = check_field_constant (get_ushort (), &klass);
+ type field = check_field_constant (get_ushort (), &klass, true);
pop_type_t (field);
-
- /* We have an obscure special case here: we can use
- `putfield' on a field declared in this class, even if
- `this' has not yet been initialized. */
- if (! type_initialized (&vfr->current_state->this_type)
- && vfr->current_state->this_type.pc == SELF)
- type_set_uninitialized (&klass, SELF);
pop_type_t (klass);
}
break;
@@ -3218,32 +3138,6 @@ verify_instructions_0 (void)
handle_jsr_insn (get_int ());
break;
-#if 0
- /* These are unused here, but we call them out explicitly
- so that -Wswitch-enum doesn't complain. */
- case op_putfield_1:
- case op_putfield_2:
- case op_putfield_4:
- case op_putfield_8:
- case op_putfield_a:
- case op_putstatic_1:
- case op_putstatic_2:
- case op_putstatic_4:
- case op_putstatic_8:
- case op_putstatic_a:
- case op_getfield_1:
- case op_getfield_2s:
- case op_getfield_2u:
- case op_getfield_4:
- case op_getfield_8:
- case op_getfield_a:
- case op_getstatic_1:
- case op_getstatic_2s:
- case op_getstatic_2u:
- case op_getstatic_4:
- case op_getstatic_8:
- case op_getstatic_a:
-#endif
default:
/* Unrecognized opcode. */
verify_fail_pc ("unrecognized instruction in verify_instructions_0",
@@ -3334,17 +3228,6 @@ verify_instructions (void)
}
}
-#if 0
-_Jv_BytecodeVerifier (_Jv_InterpMethod *m)
-{
- /* We just print the text as utf-8. This is just for debugging
- anyway. */
- debug_print ("--------------------------------\n");
- debug_print ("-- Verifying method `%s'\n", m->self->name->chars());
-
-}
-#endif
-
static void
make_verifier_context (vfy_method *m)
{
@@ -3395,6 +3278,7 @@ free_verifier_context (void)
while (iter != NULL)
{
state_list *next = iter->next;
+ free_state (iter->val);
vfy_free (iter->val);
vfy_free (iter);
iter = next;
diff --git a/gcc/java/verify.h b/gcc/java/verify.h
index 3553d357960..b23a08a9888 100644
--- a/gcc/java/verify.h
+++ b/gcc/java/verify.h
@@ -1,5 +1,5 @@
/* Declarations to interface gcj with bytecode verifier.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GCC.
@@ -126,6 +126,8 @@ void vfy_note_stack_type (vfy_method *method, int pc, int slot,
void vfy_note_local_type (vfy_method *method, int pc, int slot,
vfy_jclass type);
void vfy_note_instruction_seen (int pc);
+bool vfy_class_has_field (vfy_jclass klass, vfy_string name,
+ vfy_string signature);
#define GLOM(name, stuff) name ## stuff
#define VFY_PRIMITIVE_CLASS(name) \