[gcjx] Patch: FYI: more BC-related fixes
Tom Tromey
tromey@redhat.com
Sun Apr 3 23:52:00 GMT 2005
I'm checking this in on the gcjx branch.
This fixes some more BC errors and adds support for interface calls.
Tom
Index: gcjx/ChangeLog
from Tom Tromey <tromey@redhat.com>
* aot/aotclass.cc (register_something): Start at 1.
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* abi.cc (build_method_call): Lay out declaring class. Handle
interface calls.
(build_field_reference): Likewise.
Index: gcjx/aot/aotclass.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/aot/Attic/aotclass.cc,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 aotclass.cc
--- gcjx/aot/aotclass.cc 3 Apr 2005 23:47:44 -0000 1.1.2.9
+++ gcjx/aot/aotclass.cc 3 Apr 2005 23:50:47 -0000
@@ -250,7 +250,9 @@
aot_class::register_something (std::vector<model_element *> &the_map,
model_element *item)
{
- int index = 0;
+ // Note that "entry 0" is a flag indicating whether the state is
+ // initialized.
+ int index = 1;
for (std::vector<model_element *>::const_iterator i = the_map.begin ();
i != the_map.end ();
++i, ++index)
@@ -258,7 +260,6 @@
if (*i == item)
return index;
}
- index = the_map.size ();
the_map.push_back (item);
return index;
}
Index: gcc/java/abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.20
diff -u -r1.1.2.20 abi.cc
--- gcc/java/abi.cc 3 Apr 2005 23:50:05 -0000 1.1.2.20
+++ gcc/java/abi.cc 3 Apr 2005 23:50:53 -0000
@@ -270,6 +270,7 @@
tree obj, tree args,
model_method *meth, bool /*is_super*/)
{
+ builtins->lay_out_class (meth->get_declaring_class ());
tree meth_tree = builtins->map_method (meth);
tree meth_ptr_type = build_pointer_type (TREE_TYPE (meth_tree));
@@ -295,9 +296,38 @@
{
assert (obj != NULL_TREE);
- int slot = current->register_interface_call (meth);
+ int slot = 2 * current->register_interface_call (meth);
tree itable = builtins->get_itable_decl (current->get ());
- abort ();
+
+ tree interface = convert (type_class_ptr,
+ build4 (ARRAY_REF, ptr_type_node, itable,
+ build_int_cst (type_jint, slot - 1),
+ NULL_TREE, NULL_TREE));
+ tree idx = convert (type_jint,
+ build4 (ARRAY_REF, ptr_type_node, itable,
+ build_int_cst (type_jint, slot),
+ NULL_TREE, NULL_TREE));
+
+ obj = builtins->check_reference (obj);
+ tree dtable = build1 (INDIRECT_REF, type_object,
+ build1 (NOP_EXPR, type_object_ptr, obj));
+ dtable = build3 (COMPONENT_REF, type_dtable_ptr,
+ dtable,
+ builtins->find_decl (type_object, "vtable"),
+ NULL_TREE);
+
+ tree obj_class = build3 (COMPONENT_REF, type_class_ptr,
+ build1 (INDIRECT_REF, type_dtable, dtable),
+ builtins->find_decl (type_dtable, "class"),
+ NULL_TREE);
+
+ tree lookup = tree_cons (NULL_TREE, obj_class,
+ tree_cons (NULL_TREE, interface,
+ build_tree_list (NULL_TREE, idx)));
+ func = build3 (CALL_EXPR, ptr_type_node,
+ builtin_Jv_LookupInterfaceMethodIdx,
+ lookup, NULL_TREE);
+ func = convert (meth_ptr_type, func);
}
// Note that, unlike the C++ ABI, we call final methods via the
// vtable. This is because a final method can be made non-final and
@@ -385,6 +415,7 @@
tree obj, model_field *field)
{
tree result;
+ builtins->lay_out_class (field->get_declaring_class ());
int slot = current->register_field_reference (field);
tree field_type = builtins->map_type (field->type ());
if (field->static_p ())
Index: gcc/java/classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.20
diff -u -r1.1.2.20 classobj.cc
--- gcc/java/classobj.cc 3 Apr 2005 23:50:05 -0000 1.1.2.20
+++ gcc/java/classobj.cc 3 Apr 2005 23:50:53 -0000
@@ -309,10 +309,14 @@
table.size ())));
result_syms = make_decl (type, build_constructor (type, result_list));
+ // Note that the table itself has an extra element for the status.
+ // FIXME: itable is double the size.
tree symtype
= build_array_type (ptr_type_node,
build_index_type (build_int_cst (type_jint,
- table.size ())));
+ 1 + table.size ())));
+ // FIXME: set DECL_INITIAL here?
+ // ... and note that itable has a different format.
TREE_TYPE (table_decl) = symtype;
rest_of_decl_compilation (table_decl, 1, 0);
More information about the Java-patches
mailing list