This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: handle array access
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 03 Apr 2005 18:47:40 -0600
- Subject: [gcjx] Patch: FYI: handle array access
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes array accesses when lowering from bytecode.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tree.hh (tree_generator::array_access): Updated.
(tree_generator::array_store): Likewise.
* lower.cc (array_access): Added 'mtype' argument.
(array_store): Likewise.
(visit_bytecode_block): Updated.
Index: lower.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/lower.cc,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 lower.cc
--- lower.cc 4 Apr 2005 00:30:05 -0000 1.1.2.15
+++ lower.cc 4 Apr 2005 00:48:11 -0000
@@ -251,35 +251,37 @@
break;
case op_iaload:
- insn = array_access (type_jint);
+ insn = array_access (primitive_int_type, type_jint);
break;
case op_laload:
- insn = array_access (type_jlong);
+ insn = array_access (primitive_long_type, type_jlong);
break;
case op_faload:
- insn = array_access (type_jfloat);
+ insn = array_access (primitive_float_type, type_jfloat);
break;
case op_daload:
- insn = array_access (type_jdouble);
+ insn = array_access (primitive_double_type, type_jdouble);
break;
case op_aaload:
- insn = array_access (type_object_ptr);
+ // FIXME: we shouldn't even require Object with the BC ABI.
+ insn = array_access (global->get_compiler ()->java_lang_Object (),
+ type_object_ptr);
break;
case op_baload:
- insn = array_access (type_jbyte);
+ insn = array_access (primitive_byte_type, type_jbyte);
break;
case op_caload:
- insn = array_access (type_jchar);
+ insn = array_access (primitive_char_type, type_jchar);
break;
case op_saload:
- insn = array_access (type_jshort);
+ insn = array_access (primitive_short_type, type_jshort);
break;
case op_istore:
@@ -338,35 +340,37 @@
break;
case op_iastore:
- insn = array_store (type_jint);
+ insn = array_store (primitive_int_type, type_jint);
break;
case op_lastore:
- insn = array_store (type_jlong);
+ insn = array_store (primitive_long_type, type_jlong);
break;
case op_fastore:
- insn = array_store (type_jfloat);
+ insn = array_store (primitive_float_type, type_jfloat);
break;
case op_dastore:
- insn = array_store (type_jdouble);
+ insn = array_store (primitive_double_type, type_jdouble);
break;
case op_aastore:
- insn = array_store (type_object_ptr);
+ // FIXME: we shouldn't even require Object with the BC ABI.
+ insn = array_store (global->get_compiler ()->java_lang_Object (),
+ type_object_ptr);
break;
case op_bastore:
- insn = array_store (type_jbyte);
+ insn = array_store (primitive_byte_type, type_jbyte);
break;
case op_castore:
- insn = array_store (type_jchar);
+ insn = array_store (primitive_char_type, type_jchar);
break;
case op_sastore:
- insn = array_store (type_jshort);
+ insn = array_store (primitive_short_type, type_jshort);
break;
case op_pop:
@@ -1764,10 +1768,10 @@
// An array store operation.
tree
-tree_generator::array_store (tree type)
+tree_generator::array_store (model_type *mtype, tree type)
{
tree val = pop (type);
- tree ary = array_access (type);
+ tree ary = array_access (mtype, type);
tree result = build2 (MODIFY_EXPR, type, ary, val);
TREE_SIDE_EFFECTS (result) = 1;
return result;
@@ -1775,9 +1779,9 @@
// An array fetch operation.
tree
-tree_generator::array_access (tree type)
+tree_generator::array_access (model_type *mtype, tree type)
{
- tree array_type = NULL_TREE; // fixme (type);
+ tree array_type = gcc_builtins->map_type (mtype->array ());
tree index = pop (type_jint);
tree array = pop (array_type);
Index: tree.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.hh,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 tree.hh
--- tree.hh 27 Mar 2005 03:07:26 -0000 1.1.2.10
+++ tree.hh 4 Apr 2005 00:48:11 -0000
@@ -162,8 +162,8 @@
tree load (int, tree);
tree store (int, tree);
tree find_generic_slot (int, tree, tree *);
- tree array_store (tree);
- tree array_access (tree);
+ tree array_store (model_type *, tree);
+ tree array_access (model_type *, tree);
tree find_class (const std::string &);
tree handle_ldc (constant_pool *, uint16);
bool type_wide_p (tree) const;