diff options
author | Bryce McKinlay <bryce@waitaki.otago.ac.nz> | 2001-12-15 08:31:49 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2001-12-15 08:31:49 +0000 |
commit | 861ef92859ce3681ae24ecac1384e0be2a035c9d (patch) | |
tree | a15d17366ad109cb78a0bc4f4aaf8e142550387d /gcc/java/decl.c | |
parent | ed86a83d510ad44be77328cf80b1e6198f992c7c (diff) | |
download | gcc-861ef92859ce3681ae24ecac1384e0be2a035c9d.zip gcc-861ef92859ce3681ae24ecac1384e0be2a035c9d.tar.gz gcc-861ef92859ce3681ae24ecac1384e0be2a035c9d.tar.bz2 |
java-tree.h (otable_methods, [...]): New field/global tree definitions.
gcc/java:
* java-tree.h (otable_methods, otable_decl, otable_syms_decl,
otable_type, otable_ptr_type, method_symbol_type,
method_symbols_array_type, method_symbols_array_ptr_type): New
field/global tree definitions.
(flag_indirect_dispatch): New flag.
* decl.c (java_init_decl_processing): Initialize new otable and
otable_syms type nodes and decls. Add new field "index" to
method_type_node.
* class.c (build_method_symbols_entry): New function.
(make_method_value): Set "index" to to method's vtable index for
virtual methods when indirect-dispatch is not used.
(make_class_data): For indirect-dispatch, dont emit the dtable_decl,
and set vtable_method_count to -1. Set otable and otable_syms field
if indirect-dispatch is used and there was something to put in them.
(build_method_symbols_entry): New function.
(emit_offset_symbol_table): New function.
* expr.c (get_offset_table_index): New function.
(build_invokevirtual): Build array reference to otable at the index
returned by get_offset_table_index, and use the result as the vtable
offset.
(build_invokeinterface): Similar.
* jcf-parse.c (yyparse): If indirect-dispatch, call
emit_offset_symbol_table at the end of compilation, after all classes
have been generated.
* jvspec.c: Don't pass findirect-dispatch to jvgenmain.
* lang.c (flag_indirect_dispatch): Define.
(lang_f_options): Add indirect-dispatch flag.
libjava:
* include/jvm.h (_Jv_VTable::idx_to_offset): New method.
* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call
_Jv_MakeVTable and _Jv_LinkOffsetTable if needed.
* java/lang/Class.h (_Jv_Method): Add "index" field.
(_Jv_MethodSymbol): New struct type.
(_Jv_LinkOffsetTable, _Jv_LayoutVTableMethods, _Jv_SetVTableEntries,
_Jv_MakeVTable): Friends.
(otable, otable_syms): New Class fields.
* java/lang/natClass.cc (_Jv_LinkOffsetTable): New function.
(isVirtualMethod): New static function.
(_Jv_LayoutVTableMethods): New function.
(_Jv_SetVTableEntries): New function.
(_Jv_MakeVTable): New function.
From-SVN: r48038
Diffstat (limited to 'gcc/java/decl.c')
-rw-r--r-- | gcc/java/decl.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 17b3607..4cfa9ba 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -614,6 +614,35 @@ java_init_decl_processing () dtable_type = make_node (RECORD_TYPE); dtable_ptr_type = build_pointer_type (dtable_type); + otable_type = make_node (RECORD_TYPE); + otable_ptr_type = build_pointer_type (otable_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); + + one_elt_array_domain_type = build_index_type (integer_one_node); + 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); + + otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), + build_array_type (integer_type_node, + one_elt_array_domain_type)); + DECL_EXTERNAL (otable_decl) = 1; + TREE_STATIC (otable_decl) = 1; + TREE_READONLY (otable_decl) = 1; + pushdecl (otable_decl); + + otable_syms_decl = build_decl (VAR_DECL, get_identifier ("otable_syms"), + method_symbols_array_type); + TREE_STATIC (otable_syms_decl) = 1; + TREE_CONSTANT (otable_syms_decl) = 1; + pushdecl (otable_syms_decl); + PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type); /* This isn't exactly true, but it is what we have in the source. There is an unresolved issue here, which is whether the vtable @@ -647,6 +676,9 @@ java_init_decl_processing () PUSH_FIELD (class_type_node, field, "field_count", short_type_node); PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node); 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); PUSH_FIELD (class_type_node, field, "interfaces", build_pointer_type (class_ptr_type)); PUSH_FIELD (class_type_node, field, "loader", ptr_type_node); @@ -661,6 +693,7 @@ java_init_decl_processing () for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t)) FIELD_PRIVATE (t) = 1; push_super_field (class_type_node, object_type_node); + FINISH_RECORD (class_type_node); build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node); @@ -680,7 +713,6 @@ java_init_decl_processing () FINISH_RECORD (field_type_node); build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node); - one_elt_array_domain_type = build_index_type (integer_one_node); nativecode_ptr_array_type_node = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type); @@ -717,6 +749,7 @@ java_init_decl_processing () PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type); PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type); PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node); + PUSH_FIELD (method_type_node, field, "index", unsigned_short_type_node); PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node); PUSH_FIELD (method_type_node, field, "throws", ptr_type_node); FINISH_RECORD (method_type_node); |