This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Adding fields to object_type_node
- To: java at gcc dot gnu dot org
- Subject: Adding fields to object_type_node
- From: Dachuan Yu <dachuan dot yu at yale dot edu>
- Date: Thu, 04 Oct 2001 14:51:18 -0400
- Organization: Yale University
I was trying to add one more field into
"object_type_node" and "class_type_node". It was
only 5 lines of code. But after the change,
HelloWorld.java would be compiled wrong such that it
gives segment fault when the output HelloWorld
executable is run. I was hoping that I could cheat
by asking people who are familiar with gcj and the
tree representation...
Basicly I want to add a new structure "otable" along
with the "vtable". Starting simple, I was just
trying to add this "otable" into "object_type_node"
and "class_type_node". It's not used anywhere yet. I
added this "otable" by mimicing the way "vtable" is
added (even the type is the same), as follows,
In "java/decl.c" "init_decl_processing" right after
pushing the field "vtable", I push the field
"otable".
---------------------
......
PUSH_FIELD (object_type_node, field, "vtable",
dtable_ptr_type);
/* Start of My Change */
PUSH_FIELD (object_type_node, field, "otable",
dtable_ptr_type);
/* End of My Change */
......
PUSH_FIELD (class_type_node, field, "vtable",
dtable_ptr_type);
/* Start of My Change */
PUSH_FIELD (class_type_node, field, "otable",
dtable_ptr_type);
/* End of My Change */
......
---------------------
In "java/class.c" "make_class_data" right after
pushing the value for field "vtable", I push for
"otable" (using NULL_TREE as the value).
---------------------
......
START_RECORD_CONSTRUCTOR (temp, object_type_node);
PUSH_FIELD_VALUE (temp, "vtable",
build1 (ADDR_EXPR, dtable_ptr_type,
class_dtable_decl));
/* Start of My Change */
PUSH_FIELD_VALUE (temp, "otable", NULL_TREE);
/* End of My Change */
......
START_RECORD_CONSTRUCTOR (cons, class_type_node);
......
PUSH_FIELD_VALUE (cons, "vtable",
dtable_decl == NULL_TREE ? null_pointer_node
: build1 (ADDR_EXPR, dtable_ptr_type,
dtable_decl));
/* Start of My Change */
PUSH_FIELD_VALUE (cons, "otable", NULL_TREE);
/* End of My Change */
......
---------------------
In "java/expr.c" "java_lang_expand_expr" right after
pushing value for field "vtable", I push for
"otable" (using NULL_TREE as the value).
---------------------
......
START_RECORD_CONSTRUCTOR (temp, object_type_node);
PUSH_FIELD_VALUE (temp, "vtable",
get_primitive_array_vtable (element_type));
/* Start of My Change */
PUSH_FIELD_VALUE (temp, "otable", NULL_TREE);
/* End of My Change */
......
---------------------
I was wondering maybe people familiar with the class
representation as tree nodes would immediately know
where the problem is. Otherwise I would have to look
at the output .s file to see the problem, which
doesn't seem very appealing... Again, the (broken)
compiler generates executable without complaining
anything. But when the executable is run, it dumps
core. (Actually if I only add "otable" for
"class_type_node", then it seems working fine on my
testcases.)
Thanks!
Dachuan