diff options
author | Bryce McKinlay <bryce@gcc.gnu.org> | 2002-02-28 11:40:29 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2002-02-28 11:40:29 +0000 |
commit | 022dcc46051ffd0114ac3382cc7e50928f17d995 (patch) | |
tree | 6daf1252f43021f81274da35d2f5f16541eaedb2 /gcc/java/parse.y | |
parent | 70da1d030dfa76bd605100e3969df62b6aaa2512 (diff) | |
download | gcc-022dcc46051ffd0114ac3382cc7e50928f17d995.zip gcc-022dcc46051ffd0114ac3382cc7e50928f17d995.tar.gz gcc-022dcc46051ffd0114ac3382cc7e50928f17d995.tar.bz2 |
expr.c (java_array_data_offset): Removed function.
* expr.c (java_array_data_offset): Removed function.
(JAVA_ARRAY_LENGTH_OFFSET): Removed macro.
(build_java_array_length_access): Obtain "length" value using a
COMPONENT_REF, instead of INDIRECT_REF and arithmetic.
(build_java_arrayaccess): Correct comment. Access "data" using a
COMPONENT_REF, and return an ARRAY_REF instead of an INDIRECT_REF.
(build_java_arraystore_check): New function.
(expand_java_arraystore): Use build_java_arraystore_check.
* parse.y (patch_assignment): Simplify code to insert a store check
when lvalue is an ARRAY_REF. Use build_java_arraystore_check.
* check-init.c (check_init): Update to reflect that an array length
access is now a COMPONENT_REF.
* gcj.texi (Code Generation): Improve documentation of
-fno-bounds-check. Add documentation for -fno-store-check.
* java-tree.h (flag_store_check): Declare.
(build_java_arraystore_check): Declare.
* lang.c (flag_store_check): Initialize to 1.
(lang_f_options): Add store-check option.
* jvspec.c: Don't pass store-check option to jvgenmain.
* lang-options.h: Add help string for -fno-store-check.
From-SVN: r50129
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r-- | gcc/java/parse.y | 94 |
1 files changed, 21 insertions, 73 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 9f14076..d005b4e 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -12585,9 +12585,8 @@ patch_assignment (node, wfl_op1) { lhs_type = TREE_TYPE (lvalue); } - /* Or Lhs can be a array access. Should that be lvalue ? FIXME + - comment on reason why */ - else if (TREE_CODE (wfl_op1) == ARRAY_REF) + /* Or Lhs can be an array access. */ + else if (TREE_CODE (lvalue) == ARRAY_REF) { lhs_type = TREE_TYPE (lvalue); lvalue_from_array = 1; @@ -12689,80 +12688,29 @@ patch_assignment (node, wfl_op1) && lvalue_from_array && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))) { - tree check; - tree base = lvalue; + tree array, store_check, base, index_expr; - /* We need to retrieve the right argument for - _Jv_CheckArrayStore. This is somewhat complicated by bounds - and null pointer checks, both of which wrap the operand in - one layer of COMPOUND_EXPR. */ - if (TREE_CODE (lvalue) == COMPOUND_EXPR) - base = TREE_OPERAND (lvalue, 0); - else + /* Get the INDIRECT_REF. */ + array = TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0); + /* Get the array pointer expr. */ + array = TREE_OPERAND (array, 0); + store_check = build_java_arraystore_check (array, new_rhs); + + index_expr = TREE_OPERAND (lvalue, 1); + + if (TREE_CODE (index_expr) == COMPOUND_EXPR) { - tree op = TREE_OPERAND (base, 0); - - /* We can have a SAVE_EXPR here when doing String +=. */ - if (TREE_CODE (op) == SAVE_EXPR) - op = TREE_OPERAND (op, 0); - /* We can have a COMPOUND_EXPR here when doing bounds check. */ - if (TREE_CODE (op) == COMPOUND_EXPR) - op = TREE_OPERAND (op, 1); - base = TREE_OPERAND (op, 0); - /* Strip the last PLUS_EXPR to obtain the base. */ - if (TREE_CODE (base) == PLUS_EXPR) - base = TREE_OPERAND (base, 0); - } - - /* Build the invocation of _Jv_CheckArrayStore */ - new_rhs = save_expr (new_rhs); - check = build (CALL_EXPR, void_type_node, - build_address_of (soft_checkarraystore_node), - tree_cons (NULL_TREE, base, - build_tree_list (NULL_TREE, new_rhs)), - NULL_TREE); - TREE_SIDE_EFFECTS (check) = 1; - - /* We have to decide on an insertion point */ - if (TREE_CODE (lvalue) == COMPOUND_EXPR) - { - tree t; - if (flag_bounds_check) - { - t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0); - TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) = - build (COMPOUND_EXPR, void_type_node, t, check); - } - else - TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type, - check, TREE_OPERAND (lvalue, 1)); + /* A COMPOUND_EXPR here is a bounds check. The bounds check must + happen before the store check, so prepare to insert the store + check within the second operand of the existing COMPOUND_EXPR. */ + base = index_expr; } - else if (flag_bounds_check) - { - tree hook = lvalue; - tree compound = TREE_OPERAND (lvalue, 0); - tree bound_check, new_compound; - - if (TREE_CODE (compound) == SAVE_EXPR) - { - compound = TREE_OPERAND (compound, 0); - hook = TREE_OPERAND (hook, 0); - } - - /* Find the array bound check, hook the original array access. */ - bound_check = TREE_OPERAND (compound, 0); - TREE_OPERAND (hook, 0) = TREE_OPERAND (compound, 1); - - /* Make sure the bound check will happen before the store check */ - new_compound = - build (COMPOUND_EXPR, void_type_node, bound_check, check); - - /* Re-assemble the augmented array access. */ - lvalue = build (COMPOUND_EXPR, TREE_TYPE (lvalue), - new_compound, lvalue); - } else - lvalue = build (COMPOUND_EXPR, TREE_TYPE (lvalue), check, lvalue); + base = lvalue; + + index_expr = TREE_OPERAND (base, 1); + TREE_OPERAND (base, 1) = build (COMPOUND_EXPR, TREE_TYPE (index_expr), + store_check, index_expr); } /* Final locals can be used as case values in switch |