* [gcjx] Patch: FYI: interface call bug fix
@ 2005-10-12 13:27 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-10-12 13:27 UTC (permalink / raw)
To: Java Patch List
I'm checking this in on the gcjx branch.
This fixes interface method calls. Like so many things, these still
aren't fully complete; in particular we aren't using the constant
time dispatch approach yet.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* abi.cc (build_method_call): Use new get_descriptor. Correctly
look up class object. Put 'obj' onto argument list.
* classobj.cc (get_descriptor): Removed.
(get_descriptor): Likewise.
(create_one_field_record): Updated.
(create_method_throws): Likewise.
(create_one_method_record): Likewise.
(create_index_table): Likewise.
* builtins.hh (tree_builtins::get_descriptor): New methods.
Index: abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.24
diff -u -r1.1.2.24 abi.cc
--- abi.cc 11 Jul 2005 16:31:25 -0000 1.1.2.24
+++ abi.cc 12 Oct 2005 13:25:57 -0000
@@ -67,14 +67,27 @@
// FIXME: use _Jv_LookupInterfaceMethodIdx.
- tree klass_tree
- = builtins->map_class_object (meth->get_declaring_class ());
+ obj = save_expr (obj);
+ args = tree_cons (NULL_TREE, obj, args);
+
+ 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 name_tree = builtins->map_utf8const (meth->get_name ());
- // FIXME: use our own get_descriptor().
- tree desc_tree = builtins->map_utf8const (meth->get_descriptor ());
+ tree desc_tree = builtins->map_utf8const (tree_builtins::get_descriptor (meth));
tree lookup_args
- = tree_cons (NULL_TREE, klass_tree,
+ = tree_cons (NULL_TREE, obj_class,
tree_cons (NULL_TREE, name_tree,
build_tree_list (NULL_TREE, desc_tree)));
@@ -99,6 +112,7 @@
// leave it to the optimizers to deduce that 'this != null' and
// remove checks in this case. We force a real check because in
// the case of a final method, a SEGV will not be generated.
+ // FIXME: we may need a check anyway, depending on platform.
if (! meth->constructor_p ()
&& (meth->get_modifiers () & ACC_PRIVATE) == 0)
obj = builtins->check_reference (obj, true);
@@ -321,6 +335,9 @@
{
assert (obj != NULL_TREE);
+ obj = save_expr (obj);
+ args = tree_cons (NULL_TREE, obj, args);
+
int slot = 2 * current->register_interface_call (meth);
tree itable = builtins->get_itable_decl (current->get ());
@@ -370,10 +387,13 @@
tree atable = builtins->get_atable_decl (current->get ());
// For final methods we have to do an explicit check.
+ // FIXME: we may need a check anyway, depending on platform.
if (! meth->constructor_p ()
&& (meth->get_modifiers () & ACC_PRIVATE) == 0)
obj = builtins->check_reference (obj, true);
+ args = tree_cons (NULL_TREE, obj, args);
+
tree atable_ref = build4 (ARRAY_REF, ptr_type_node, atable,
build_int_cst (type_jint, slot),
NULL_TREE, NULL_TREE);
@@ -388,6 +408,9 @@
// Virtual dispatch.
assert (obj != NULL_TREE);
+ obj = save_expr (obj);
+ args = tree_cons (NULL_TREE, obj, args);
+
int slot = current->register_indirect_call (meth);
tree otable = builtins->get_otable_decl (current->get ());
Index: builtins.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.hh,v
retrieving revision 1.1.2.17
diff -u -r1.1.2.17 builtins.hh
--- builtins.hh 17 Apr 2005 21:29:28 -0000 1.1.2.17
+++ builtins.hh 12 Oct 2005 13:25:57 -0000
@@ -154,6 +154,20 @@
tree map_catch_class (model_class *, model_class *);
std::map<model_class *, tree> *get_catch_map (model_class *);
+
+ // Like the get_descriptor() methods, but returns the format wanted
+ // by libgcj. FIXME: why do we have these?
+ static std::string get_descriptor (model_type *t)
+ {
+ // Why do we do this?
+ return join (split (t->get_descriptor (), '/'), '.');
+ }
+
+ static std::string get_descriptor (model_method *m)
+ {
+ // Why do we do this?
+ return join (split (m->get_descriptor (), '/'), '.');
+ }
};
#endif // GCC_JAVA_BUILTINS_HH
Index: classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.26
diff -u -r1.1.2.26 classobj.cc
--- classobj.cc 11 Jul 2005 16:28:33 -0000 1.1.2.26
+++ classobj.cc 12 Oct 2005 13:25:57 -0000
@@ -81,20 +81,6 @@
\f
-static std::string
-get_descriptor (model_type *t)
-{
- // Why do we do this?
- return join (split (t->get_descriptor (), '/'), '.');
-}
-
-static std::string
-get_descriptor (model_method *m)
-{
- // Why do we do this?
- return join (split (m->get_descriptor (), '/'), '.');
-}
-
tree
class_object_creator::make_decl (tree type, tree value)
{
@@ -118,7 +104,7 @@
inst.set_field ("name", builtins->map_utf8const (field->get_name ()));
// FIXME: ABI difference here.
inst.set_field ("type",
- builtins->map_utf8const (get_descriptor (field->type ())));
+ builtins->map_utf8const (tree_builtins::get_descriptor (field->type ())));
inst.set_field ("accflags", build_int_cst (type_jint,
field->get_modifiers ()));
inst.set_field ("bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl)));
@@ -189,7 +175,7 @@
i != throw_list.end ();
++i)
{
- tree utf = builtins->map_utf8const (get_descriptor ((*i)->type ()));
+ tree utf = builtins->map_utf8const (tree_builtins::get_descriptor ((*i)->type ()));
cons_list = tree_cons (NULL_TREE, utf, cons_list);
}
@@ -213,7 +199,7 @@
mdecl = build_address_of (builtins->map_method (method));
inst.set_field ("name", builtins->map_utf8const (method->get_name()));
inst.set_field ("signature",
- builtins->map_utf8const (get_descriptor (method)));
+ builtins->map_utf8const (tree_builtins::get_descriptor (method)));
inst.set_field ("accflags",
build_int_cst (type_jushort, method->get_modifiers ()));
gcj_abi *abi = builtins->find_abi ();
@@ -279,16 +265,16 @@
if (dynamic_cast<model_field *> (*i))
{
model_field *field = assert_cast<model_field *> (*i);
- class_desc = get_descriptor (field->get_declaring_class ());
+ class_desc = tree_builtins::get_descriptor (field->get_declaring_class ());
name = field->get_name ();
- descriptor = get_descriptor (field->type ());
+ descriptor = tree_builtins::get_descriptor (field->type ());
}
else
{
model_method *method = assert_cast<model_method *> (*i);
- class_desc = get_descriptor (method->get_declaring_class ());
+ class_desc = tree_builtins::get_descriptor (method->get_declaring_class ());
name = method->get_name ();
- descriptor = get_descriptor (method);
+ descriptor = tree_builtins::get_descriptor (method);
}
tree class_tree = builtins->map_utf8const (class_desc);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-12 13:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12 13:27 [gcjx] Patch: FYI: interface call bug fix Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).