diff options
author | Andrew Haley <aph@redhat.com> | 2003-10-01 16:22:13 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2003-10-01 16:22:13 +0000 |
commit | 9dfc2ec225a5a8f0a5d2a9b5853d0a19d728e129 (patch) | |
tree | 2dba069aa1abbb8cef2f212c67ca484cf5f8a674 /gcc | |
parent | 530ce5517ce00a43761d303a614b25d3371dd030 (diff) | |
download | gcc-9dfc2ec225a5a8f0a5d2a9b5853d0a19d728e129.zip gcc-9dfc2ec225a5a8f0a5d2a9b5853d0a19d728e129.tar.gz gcc-9dfc2ec225a5a8f0a5d2a9b5853d0a19d728e129.tar.bz2 |
jcf-parse.c (java_parse_file): Write otable and atable.
2003-10-01 Andrew Haley <aph@redhat.com>
* jcf-parse.c (java_parse_file): Write otable and atable.
* java-tree.h (atable_methods): New.
(atable_decl): New.
(atable_syms_decl): New.
(enum java_tree_index): Add JTI_ATABLE_METHODS, JTI_ATABLE_DECL,
JTI_ATABLE_SYMS_DECL. Rename JTI_METHOD_SYMBOL* to JTI_SYMBOL*.
(symbol_*type): Rename method_symbol* to symbol*type.
(emit_offset_symbol_table): Delete.
(emit_symbol_table): New.
(get_symbol_table_index): New.
(atable_type): New.
* expr.c (build_field_ref): Handle flag_indirect_dispatch.
(build_known_method_ref): Likewise.
(get_symbol_table_index): Rename from get_offset_table_index.
Parameterize to allow re-use by differing types of symbol table.
(build_invokevirtual): Pass table to get_offset_table_index.
* decl.c (java_init_decl_processing): Push types and decls for
atable and atable_syyms.
* class.c (build_static_field_ref): Handle flag_indirect_dispatch.
(make_class_data): Add new fields atable and atable_syms.
(emit_symbol_table): Rename from emit_offset_symbol_table.
Parameterize to allow re-use by different types of symbol table.
(build_symbol_entry): Renamed from build_method_symbols_entry.
2003-10-01 Andrew Haley <aph@redhat.com>
* java/lang/natClass.cc (initializeClass): Check for otable and
atable.
(_Jv_LinkOffsetTable): Check for existence of atable. Rewrite
loops using for(). Search superinterfaces. Check for fields as
well as methods. Initialize atable as well as otable: check for
static methods as well as virtual methods.
* java/lang/Class.h (struct _Jv_AddressTable): New.
(atable): New.
(atable_syms): New.
* include/jvm.h (_Jv_equalUtf8Consts): constify.
* prims.cc (_Jv_equalUtf8Consts): constify.
From-SVN: r71979
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 26 | ||||
-rw-r--r-- | gcc/java/class.c | 118 | ||||
-rw-r--r-- | gcc/java/decl.c | 47 | ||||
-rw-r--r-- | gcc/java/expr.c | 65 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 62 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 11 |
6 files changed, 232 insertions, 97 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index bf5da8c..ee3a016 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,29 @@ +2003-10-01 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (java_parse_file): Write otable and atable. + * java-tree.h (atable_methods): New. + (atable_decl): New. + (atable_syms_decl): New. + (enum java_tree_index): Add JTI_ATABLE_METHODS, JTI_ATABLE_DECL, + JTI_ATABLE_SYMS_DECL. Rename JTI_METHOD_SYMBOL* to JTI_SYMBOL*. + (symbol_*type): Rename method_symbol* to symbol*type. + (emit_offset_symbol_table): Delete. + (emit_symbol_table): New. + (get_symbol_table_index): New. + (atable_type): New. + * expr.c (build_field_ref): Handle flag_indirect_dispatch. + (build_known_method_ref): Likewise. + (get_symbol_table_index): Rename from get_offset_table_index. + Parameterize to allow re-use by differing types of symbol table. + (build_invokevirtual): Pass table to get_offset_table_index. + * decl.c (java_init_decl_processing): Push types and decls for + atable and atable_syyms. + * class.c (build_static_field_ref): Handle flag_indirect_dispatch. + (make_class_data): Add new fields atable and atable_syms. + (emit_symbol_table): Rename from emit_offset_symbol_table. + Parameterize to allow re-use by different types of symbol table. + (build_symbol_entry): Renamed from build_method_symbols_entry. + 2003-09-30 Roger Sayle <roger@eyesopen.com> * jcf-write.c (generate_bytecode_insns): Implement evaluate-once diff --git a/gcc/java/class.c b/gcc/java/class.c index 552a4f4..d64db51 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -59,7 +59,7 @@ static void add_interface_do (tree, tree, int); static tree maybe_layout_super_class (tree, tree); static void add_miranda_methods (tree, tree); static int assume_compiled (const char *); -static tree build_method_symbols_entry (tree); +static tree build_symbol_entry (tree); static GTY(()) rtx registerClass_libfunc; @@ -925,7 +925,8 @@ build_static_field_ref (tree fdecl) However, currently sometimes gcj is too eager and will end up returning the field itself, leading to an incorrect external reference being generated. */ - if (is_compiled + if ((is_compiled + && (! flag_indirect_dispatch || current_class == fclass)) || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE && (JSTRING_TYPE_P (TREE_TYPE (fdecl)) || JNUMERIC_TYPE_P (TREE_TYPE (fdecl))) @@ -939,7 +940,18 @@ build_static_field_ref (tree fdecl) } return fdecl; } - else + + if (flag_indirect_dispatch) + { + tree table_index + = build_int_2 (get_symbol_table_index (fdecl, &atable_methods), 0); + tree field_address + = build (ARRAY_REF, build_pointer_type (TREE_TYPE (fdecl)), + atable_decl, table_index); + return fold (build1 (INDIRECT_REF, TREE_TYPE (fdecl), + field_address)); + } + else { /* Compile as: * *(FTYPE*)build_class_ref(FCLASS)->fields[INDEX].info.addr */ @@ -1500,7 +1512,6 @@ make_class_data (tree type) : build (PLUS_EXPR, dtable_ptr_type, build1 (ADDR_EXPR, dtable_ptr_type, dtable_decl), dtable_start_offset)); - if (otable_methods == NULL_TREE) { PUSH_FIELD_VALUE (cons, "otable", null_pointer_node); @@ -1511,9 +1522,25 @@ make_class_data (tree type) PUSH_FIELD_VALUE (cons, "otable", build1 (ADDR_EXPR, otable_ptr_type, otable_decl)); PUSH_FIELD_VALUE (cons, "otable_syms", - build1 (ADDR_EXPR, method_symbols_array_ptr_type, + build1 (ADDR_EXPR, symbols_array_ptr_type, otable_syms_decl)); + TREE_CONSTANT (otable_decl) = 1; + } + if (atable_methods == NULL_TREE) + { + PUSH_FIELD_VALUE (cons, "atable", null_pointer_node); + PUSH_FIELD_VALUE (cons, "atable_syms", null_pointer_node); } + else + { + PUSH_FIELD_VALUE (cons, "atable", + build1 (ADDR_EXPR, atable_ptr_type, atable_decl)); + PUSH_FIELD_VALUE (cons, "atable_syms", + build1 (ADDR_EXPR, symbols_array_ptr_type, + atable_syms_decl)); + TREE_CONSTANT (atable_decl) = 1; + } + PUSH_FIELD_VALUE (cons, "interfaces", interfaces); PUSH_FIELD_VALUE (cons, "loader", null_pointer_node); PUSH_FIELD_VALUE (cons, "interface_count", build_int_2 (interface_len, 0)); @@ -2098,58 +2125,59 @@ emit_register_classes (void) } } -/* Make a method_symbol_type (_Jv_MethodSymbol) node for METHOD. */ +/* Make a symbol_type (_Jv_MethodSymbol) node for DECL. */ static tree -build_method_symbols_entry (tree method) +build_symbol_entry (tree decl) { - tree clname, name, signature, method_symbol; + tree clname, name, signature, sym; - clname = build_utf8_ref (DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)))); - name = build_utf8_ref (DECL_NAME (method)); - signature = build_java_signature (TREE_TYPE (method)); + clname = build_utf8_ref (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))); + name = build_utf8_ref (DECL_NAME (decl)); + signature = build_java_signature (TREE_TYPE (decl)); signature = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (signature), IDENTIFIER_LENGTH (signature))); - START_RECORD_CONSTRUCTOR (method_symbol, method_symbol_type); - PUSH_FIELD_VALUE (method_symbol, "clname", clname); - PUSH_FIELD_VALUE (method_symbol, "name", name); - PUSH_FIELD_VALUE (method_symbol, "signature", signature); - FINISH_RECORD_CONSTRUCTOR (method_symbol); - TREE_CONSTANT (method_symbol) = 1; + START_RECORD_CONSTRUCTOR (sym, symbol_type); + PUSH_FIELD_VALUE (sym, "clname", clname); + PUSH_FIELD_VALUE (sym, "name", name); + PUSH_FIELD_VALUE (sym, "signature", signature); + FINISH_RECORD_CONSTRUCTOR (sym); + TREE_CONSTANT (sym) = 1; - return method_symbol; + return sym; } -/* Emit the offset symbols table for indirect virtual dispatch. */ +/* Emit a symbol table: used by -findirect-dispatch. */ -void -emit_offset_symbol_table (void) +tree +emit_symbol_table (tree name, tree the_table, tree decl_list, tree the_syms_decl, + tree the_array_element_type) { tree method_list, method, table, list, null_symbol; - tree otable_bound, otable_array_type; + tree table_size, the_array_type; int index; - /* Only emit an offset table if this translation unit actually made virtual - calls. */ - if (otable_methods == NULL_TREE) - return; + /* Only emit a table if this translation unit actually made any + references via it. */ + if (decl_list == NULL_TREE) + return the_table; /* Build a list of _Jv_MethodSymbols for each entry in otable_methods. */ index = 0; - method_list = otable_methods; + method_list = decl_list; list = NULL_TREE; while (method_list != NULL_TREE) { method = TREE_VALUE (method_list); - list = tree_cons (NULL_TREE, build_method_symbols_entry (method), list); + list = tree_cons (NULL_TREE, build_symbol_entry (method), list); method_list = TREE_CHAIN (method_list); index++; } /* Terminate the list with a "null" entry. */ - START_RECORD_CONSTRUCTOR (null_symbol, method_symbol_type); + START_RECORD_CONSTRUCTOR (null_symbol, symbol_type); PUSH_FIELD_VALUE (null_symbol, "clname", null_pointer_node); PUSH_FIELD_VALUE (null_symbol, "name", null_pointer_node); PUSH_FIELD_VALUE (null_symbol, "signature", null_pointer_node); @@ -2159,24 +2187,26 @@ emit_offset_symbol_table (void) /* Put the list in the right order and make it a constructor. */ list = nreverse (list); - table = build_constructor (method_symbols_array_type, list); + table = build_constructor (symbols_array_type, list); /* Make it the initial value for otable_syms and emit the decl. */ - DECL_INITIAL (otable_syms_decl) = table; - DECL_ARTIFICIAL (otable_syms_decl) = 1; - DECL_IGNORED_P (otable_syms_decl) = 1; - rest_of_decl_compilation (otable_syms_decl, NULL, 1, 0); + DECL_INITIAL (the_syms_decl) = table; + DECL_ARTIFICIAL (the_syms_decl) = 1; + DECL_IGNORED_P (the_syms_decl) = 1; + rest_of_decl_compilation (the_syms_decl, NULL, 1, 0); - /* Now that its size is known, redefine otable as an uninitialized static - array of INDEX + 1 integers. The extra entry is used by the runtime - to track whether the otable has been initialized. */ - otable_bound = build_index_type (build_int_2 (index, 0)); - otable_array_type = build_array_type (integer_type_node, otable_bound); - otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), - otable_array_type); - TREE_STATIC (otable_decl) = 1; - TREE_READONLY (otable_decl) = 1; - rest_of_decl_compilation (otable_decl, NULL, 1, 0); + /* Now that its size is known, redefine the table as an + uninitialized static array of INDEX + 1 elements. The extra entry + is used by the runtime to track whether the table has been + initialized. */ + table_size = build_index_type (build_int_2 (index, 0)); + the_array_type = build_array_type (the_array_element_type, table_size); + the_table = build_decl (VAR_DECL, name, the_array_type); + TREE_STATIC (the_table) = 1; + TREE_READONLY (the_table) = 1; + rest_of_decl_compilation (the_table, NULL, 1, 0); + + return the_table; } void diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 4e413de..8355431 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -621,32 +621,46 @@ java_init_decl_processing (void) one_elt_array_domain_type); TYPE_NONALIASED_COMPONENT (otable_type) = 1; otable_ptr_type = build_pointer_type (otable_type); + atable_type = build_array_type (ptr_type_node, + one_elt_array_domain_type); + TYPE_NONALIASED_COMPONENT (atable_type) = 1; + atable_ptr_type = build_pointer_type (atable_type); - method_symbol_type = make_node (RECORD_TYPE); - PUSH_FIELD (method_symbol_type, field, "clname", utf8const_ptr_type); - PUSH_FIELD (method_symbol_type, field, "name", utf8const_ptr_type); - PUSH_FIELD (method_symbol_type, field, "signature", utf8const_ptr_type); - FINISH_RECORD (method_symbol_type); + symbol_type = make_node (RECORD_TYPE); + PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type); + PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type); + PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type); + FINISH_RECORD (symbol_type); - method_symbols_array_type = build_array_type (method_symbol_type, - one_elt_array_domain_type); - method_symbols_array_ptr_type = build_pointer_type - (method_symbols_array_type); + symbols_array_type = build_array_type (symbol_type, + one_elt_array_domain_type); + symbols_array_ptr_type = build_pointer_type (symbols_array_type); if (flag_indirect_dispatch) { - otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), - otable_type); + otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), otable_type); DECL_EXTERNAL (otable_decl) = 1; TREE_STATIC (otable_decl) = 1; TREE_READONLY (otable_decl) = 1; - pushdecl (otable_decl); - + TREE_CONSTANT (otable_decl) = 1; + pushdecl (otable_decl); otable_syms_decl = build_decl (VAR_DECL, get_identifier ("otable_syms"), - method_symbols_array_type); + symbols_array_type); TREE_STATIC (otable_syms_decl) = 1; TREE_CONSTANT (otable_syms_decl) = 1; pushdecl (otable_syms_decl); + + atable_decl = build_decl (VAR_DECL, get_identifier ("atable"), atable_type); + DECL_EXTERNAL (atable_decl) = 1; + TREE_STATIC (atable_decl) = 1; + TREE_READONLY (atable_decl) = 1; + TREE_CONSTANT (atable_decl) = 1; + pushdecl (atable_decl); + atable_syms_decl = build_decl (VAR_DECL, get_identifier ("atable_syms"), + symbols_array_type); + TREE_STATIC (atable_syms_decl) = 1; + TREE_CONSTANT (atable_syms_decl) = 1; + pushdecl (atable_syms_decl); } PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type); @@ -684,7 +698,10 @@ java_init_decl_processing (void) PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type); PUSH_FIELD (class_type_node, field, "otable", otable_ptr_type); PUSH_FIELD (class_type_node, field, "otable_syms", - method_symbols_array_ptr_type); + symbols_array_ptr_type); + PUSH_FIELD (class_type_node, field, "atable", atable_ptr_type); + PUSH_FIELD (class_type_node, field, "atable_syms", + symbols_array_ptr_type); PUSH_FIELD (class_type_node, field, "interfaces", build_pointer_type (class_ptr_type)); PUSH_FIELD (class_type_node, field, "loader", ptr_type_node); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 994a8c5..2c9ac09 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -84,7 +84,6 @@ static tree build_java_check_indexed_type (tree, tree); static tree case_identity (tree, tree); static unsigned char peek_opcode_at_pc (struct JCF *, int, int); static int emit_init_test_initialization (void **entry, void * ptr); -static int get_offset_table_index (tree); static GTY(()) tree operand_type[59]; @@ -1510,6 +1509,25 @@ build_field_ref (tree self_value, tree self_class, tree name) tree base_type = promote_type (base_class); if (base_type != TREE_TYPE (self_value)) self_value = fold (build1 (NOP_EXPR, base_type, self_value)); + if (flag_indirect_dispatch + && current_class != self_class) + /* FIXME: current_class != self_class is not exactly the right + test. What we really want to know is whether self_class is + in the same translation unit as current_class. If it is, + we can make a direct reference. */ + { + tree otable_index + = build_int_2 + (get_symbol_table_index (field_decl, &otable_methods), 0); + tree field_offset = build (ARRAY_REF, integer_type_node, otable_decl, + otable_index); + tree address + = fold (build (PLUS_EXPR, + build_pointer_type (TREE_TYPE (field_decl)), + self_value, field_offset)); + return fold (build1 (INDIRECT_REF, TREE_TYPE (field_decl), address)); + } + self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)), self_value, check); return fold (build (COMPONENT_REF, TREE_TYPE (field_decl), @@ -1744,8 +1762,19 @@ build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED, tree func; if (is_compiled_class (self_type)) { - make_decl_rtl (method, NULL); - func = build1 (ADDR_EXPR, method_ptr_type_node, method); + if (!flag_indirect_dispatch + || (!TREE_PUBLIC (method) && DECL_CONTEXT (method))) + { + make_decl_rtl (method, NULL); + func = build1 (ADDR_EXPR, method_ptr_type_node, method); + } + else + { + tree table_index = build_int_2 (get_symbol_table_index + (method, &atable_methods), 0); + func = build (ARRAY_REF, method_ptr_type_node, atable_decl, + table_index); + } } else { @@ -1816,27 +1845,29 @@ invoke_build_dtable (int is_invoke_interface, tree arg_list) return dtable; } -/* Determine the index in the virtual offset table (otable) for a call to - METHOD. If this method has not been seen before, it will be added to the - otable_methods. If it has, the existing otable slot will be reused. */ +/* Determine the index in SYMBOL_TABLE for a reference to the decl + T. If this decl has not been seen before, it will be added to the + otable_methods. If it has, the existing table slot will be + reused. */ -static int -get_offset_table_index (tree method) +int +get_symbol_table_index (tree t, tree *symbol_table) { int i = 1; tree method_list; - - if (otable_methods == NULL_TREE) + + if (*symbol_table == NULL_TREE) { - otable_methods = build_tree_list (method, method); + *symbol_table = build_tree_list (t, t); return 1; } - method_list = otable_methods; + method_list = *symbol_table; while (1) { - if (TREE_VALUE (method_list) == method) + tree value = TREE_VALUE (method_list); + if (value == t) return i; i++; if (TREE_CHAIN (method_list) == NULL_TREE) @@ -1845,7 +1876,7 @@ get_offset_table_index (tree method) method_list = TREE_CHAIN (method_list); } - TREE_CHAIN (method_list) = build_tree_list (method, method); + TREE_CHAIN (method_list) = build_tree_list (t, t); return i; } @@ -1860,7 +1891,8 @@ build_invokevirtual (tree dtable, tree method) if (flag_indirect_dispatch) { - otable_index = build_int_2 (get_offset_table_index (method), 0); + otable_index + = build_int_2 (get_symbol_table_index (method, &otable_methods), 0); method_index = build (ARRAY_REF, integer_type_node, otable_decl, otable_index); } @@ -1924,7 +1956,8 @@ build_invokeinterface (tree dtable, tree method) if (flag_indirect_dispatch) { - otable_index = build_int_2 (get_offset_table_index (method), 0); + otable_index + = build_int_2 (get_symbol_table_index (method, &otable_methods), 0); idx = build (ARRAY_REF, integer_type_node, otable_decl, otable_index); } else diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 8f52428..42f99b5 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -146,17 +146,26 @@ extern int compiling_from_source; /* List of all class filenames seen so far. */ #define all_class_filename java_global_trees [JTI_ALL_CLASS_FILENAME] -/* List of virtual method decls called in this translation unit, used to - generate virtual method offset symbol table. */ +/* List of virtual decls referred to by this translation unit, used to + generate virtual method offset symbol table. */ #define otable_methods java_global_trees [JTI_OTABLE_METHODS] +/* List of static decls referred to by this translation unit, used to + generate virtual method offset symbol table. */ +#define atable_methods java_global_trees [JTI_ATABLE_METHODS] -/* The virtual method offset table. This is emitted as uninitialized data of - the required length, and filled out at run time during class linking. */ +/* The virtual offset table. This is emitted as uninitialized data of + the required length, and filled out at run time during class + linking. */ #define otable_decl java_global_trees [JTI_OTABLE_DECL] +/* The static address table. */ +#define atable_decl java_global_trees [JTI_ATABLE_DECL] -/* The virtual method offset symbol table. Used by the runtime to fill out the - otable. */ +/* The virtual offset symbol table. Used by the runtime to fill out + the otable. */ #define otable_syms_decl java_global_trees [JTI_OTABLE_SYMS_DECL] +/* The static symbol table. Used by the runtime to fill out the + otable. */ +#define atable_syms_decl java_global_trees [JTI_ATABLE_SYMS_DECL] extern int flag_emit_class_files; @@ -364,9 +373,11 @@ enum java_tree_index JTI_METHOD_PTR_TYPE_NODE, JTI_OTABLE_TYPE, JTI_OTABLE_PTR_TYPE, - JTI_METHOD_SYMBOL_TYPE, - JTI_METHOD_SYMBOLS_ARRAY_TYPE, - JTI_METHOD_SYMBOLS_ARRAY_PTR_TYPE, + JTI_ATABLE_TYPE, + JTI_ATABLE_PTR_TYPE, + JTI_SYMBOL_TYPE, + JTI_SYMBOLS_ARRAY_TYPE, + JTI_SYMBOLS_ARRAY_PTR_TYPE, JTI_END_PARAMS_NODE, @@ -409,6 +420,10 @@ enum java_tree_index JTI_OTABLE_DECL, JTI_OTABLE_SYMS_DECL, + JTI_ATABLE_METHODS, + JTI_ATABLE_DECL, + JTI_ATABLE_SYMS_DECL, + JTI_PREDEF_FILENAMES, JTI_MAX @@ -602,14 +617,18 @@ extern GTY(()) tree java_global_trees[JTI_MAX]; java_global_trees[JTI_METHOD_PTR_TYPE_NODE] #define otable_type \ java_global_trees[JTI_OTABLE_TYPE] +#define atable_type \ + java_global_trees[JTI_ATABLE_TYPE] #define otable_ptr_type \ java_global_trees[JTI_OTABLE_PTR_TYPE] -#define method_symbol_type \ - java_global_trees[JTI_METHOD_SYMBOL_TYPE] -#define method_symbols_array_type \ - java_global_trees[JTI_METHOD_SYMBOLS_ARRAY_TYPE] -#define method_symbols_array_ptr_type \ - java_global_trees[JTI_METHOD_SYMBOLS_ARRAY_PTR_TYPE] +#define atable_ptr_type \ + java_global_trees[JTI_ATABLE_PTR_TYPE] +#define symbol_type \ + java_global_trees[JTI_SYMBOL_TYPE] +#define symbols_array_type \ + java_global_trees[JTI_SYMBOLS_ARRAY_TYPE] +#define symbols_array_ptr_type \ + java_global_trees[JTI_SYMBOLS_ARRAY_PTR_TYPE] #define end_params_node \ java_global_trees[JTI_END_PARAMS_NODE] @@ -1199,7 +1218,7 @@ extern void make_class_data (tree); extern void register_class (void); extern int alloc_name_constant (int, tree); extern void emit_register_classes (void); -extern void emit_offset_symbol_table (void); +extern tree emit_symbol_table (tree, tree, tree, tree, tree); extern void lang_init_source (int); extern void write_classfile (tree); extern char *print_int_node (tree); @@ -1299,6 +1318,7 @@ extern void init_resource_processing (void); extern void start_complete_expand_method (tree); extern void java_expand_body (tree); +extern int get_symbol_table_index (tree, tree *); #define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL) @@ -1658,11 +1678,11 @@ extern tree *type_map; /* Append a field initializer to CONS for a field with the given VALUE. NAME is a char* string used for error checking; the initializer must be specified in order. */ -#define PUSH_FIELD_VALUE(CONS, NAME, VALUE) {\ - tree field = TREE_CHAIN(CONS);\ - if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), NAME) != 0) abort();\ - CONSTRUCTOR_ELTS(CONS) = tree_cons (field, VALUE, CONSTRUCTOR_ELTS(CONS));\ - TREE_CHAIN(CONS) = TREE_CHAIN (field); } + #define PUSH_FIELD_VALUE(CONS, NAME, VALUE) {\ + tree field = TREE_CHAIN(CONS);\ + if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), NAME) != 0) abort();\ + CONSTRUCTOR_ELTS(CONS) = tree_cons (field, VALUE, CONSTRUCTOR_ELTS(CONS));\ + TREE_CHAIN(CONS) = TREE_CHAIN (field); } /* Finish creating a record CONSTRUCTOR CONS. */ #define FINISH_RECORD_CONSTRUCTOR(CONS) \ diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 4abd6ce..de4b213 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -1127,7 +1127,16 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) /* Emit the .jcf section. */ emit_register_classes (); if (flag_indirect_dispatch) - emit_offset_symbol_table (); + { + otable_decl + = emit_symbol_table + (get_identifier ("otable"), + otable_decl, otable_methods, otable_syms_decl, integer_type_node); + atable_decl + = emit_symbol_table + (get_identifier ("atable"), + atable_decl, atable_methods, atable_syms_decl, ptr_type_node); + } } write_resource_constructor (); |