[multiple changes]

2000-10-18  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * jcf-write.c (OP1): Update `last_bc'.
        (struct jcf_block): Fixed indentation and typo in comments.  New
        field `last_bc'.
        (generate_bytecode_insns): Insert `nop' if `jsr' immediately
        follows `monitorenter'.
        * parse.y (patch_synchronized_statement): New local `tmp'. Call
        `patch_string'.
        Fixes gcj/232.

2000-10-13  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * check-init.c (check_init): Fixed leading comment. Use
        LOCAL_FINAL_P.
        * decl.c (push_jvm_slot): Use MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
        (give_name_to_locals): Likewise.
        (lang_mark_tree): Handle FIELD_DECL. Register `am' and `wfl'
        fields in lang_decl_var.
        * java-tree.h (DECL_FUNCTION_SYNTHETIC_CTOR,
        DECL_FUNCTION_ALL_FINAL_INITIALIZED): New macros.
        (FIELD_INNER_ACCESS): Removed ugly cast, macro rewritten.
        (FIELD_INNER_ACCESS_P, DECL_FIELD_FINAL_IUD, DECL_FIELD_FINAL_LIIC,
        DECL_FIELD_FINAL_IERR, DECL_FIELD_FINAL_WFL): New macros.
        (LOCAL_FINAL): Rewritten.
        (LOCAL_FINAL_P, FINAL_VARIABLE_P, CLASS_FINAL_VARIABLE_P
        MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): New macros.
        (struct lang_decl): Fixed comments. Added `synthetic_ctor' and
        `init_final' fields.
        (struct lang_decl_var): Fixed leading comment. Added `am', `wfl',
        `final_uid', `final_liic', `final_ierr' and `local_final' fields.
        (TYPE_HAS_FINAL_VARIABLE): New macro.
        (struct lang_type): Added `afv' field.
        * parse.y (check_static_final_variable_assignment_flag): New function.
        (reset_static_final_variable_assignment_flag): Likewise.
        (check_final_variable_local_assignment_flag): Likewise.
        (reset_final_variable_local_assignment_flag): Likewise.
        (check_final_variable_indirect_assignment): Likewise.
        (check_final_variable_global_assignment_flag): Likewise.
        (add_inner_class_fields): Use LOCAL_FINAL_P.
        (register_fields): Handle local finals and final variables.
        (craft_constructor): Set DECL_FUNCTION_SYNTHETIC_CTOR.
        (declare_local_variables): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
        (source_start_java_method): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC
        on local finals.
        (java_complete_expand_methods): Loop to set
        TYPE_HAS_FINAL_VARIABLE. Call
        `reset_final_variable_local_assignment_flag' and
        `check_final_variable_local_assignment_flag' accordingly before
        and after constructor expansion. Call
        `reset_static_final_variable_assignment_flag'
        before expanding <clinit> and after call
        `check_static_final_variable_assignment_flag' if the
        current_class isn't an interface. After all methods have been
        expanded, call `check_final_variable_global_assignment_flag' and
        `check_static_final_variable_assignment_flag' if the current class
        is an interface.
        (maybe_yank_clinit): Fixed typo in comment.
        (build_outer_field_access_methods): Removed old sanity check. Use
        FIELD_INNER_ACCESS_P. Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
        Don't create access methods for finals.
        (resolve_field_access): Use `CLASS_FINAL_VARIABLE_P'.
        (java_complete_tree): Likewise. Reset DECL_FIELD_FINAL_IUD if
        existing DECL_INIT has been processed.
        (java_complete_lhs): Likewise.
        (check_final_assignment): Filter input on `lvalue''s TREE_CODE.
        Test for COMPONENT_REF to get to the FIELD_DECL. Implemented new
        logic.
        (patch_assignment): Use LOCAL_FINAL_P.
        (fold_constant_for_init): Reset DECL_FIELD_FINAL_IUD if
        DECL_INITIAL is nullified.
        Fixes gcj/163.

2000-10-09  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * parse.y (pop_current_osb): New function.
        (array_type:): Use `dims:', changed actions
        accordingly. Suggested by Anthony Green.
        (array_creation_expression:): Used pop_current_osb.
        (cast_expression:): Likewise.
        (search_applicable_method_list): Fixed indentation.

2000-10-08  Anthony Green  <green@redhat.com>

        * parse.y (array_type_literal): Remove production.
        (type_literals): Refer to array_type, not array_type_literal.

(http://gcc.gnu.org/ml/gcc-patches/2000-12/msg00317.html)

From-SVN: r38070
parent ee457005
......@@ -235,6 +235,17 @@ Thu Nov 23 02:19:14 2000 J"orn Rennecke <amylaar@redhat.com>
* verify.c (CHECK_PC_IN_RANGE): Cast result of stmt-expr to void.
2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* jcf-write.c (OP1): Update `last_bc'.
(struct jcf_block): Fixed indentation and typo in comments. New
field `last_bc'.
(generate_bytecode_insns): Insert `nop' if `jsr' immediately
follows `monitorenter'.
* parse.y (patch_synchronized_statement): New local `tmp'. Call
`patch_string'.
Fixes gcj/232.
2000-10-16 Tom Tromey <tromey@cygnus.com>
* jvspec.c (lang_specific_driver): Recognize -MF and -MT.
......@@ -298,6 +309,68 @@ Thu Nov 23 02:19:14 2000 J"orn Rennecke <amylaar@redhat.com>
* decl.c (init_decl_processing): Call init_class_processing before
anything else.
2000-10-13 Alexandre Petit-Bianco <apbianco@cygnus.com>
* check-init.c (check_init): Fixed leading comment. Use
LOCAL_FINAL_P.
* decl.c (push_jvm_slot): Use MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
(give_name_to_locals): Likewise.
(lang_mark_tree): Handle FIELD_DECL. Register `am' and `wfl'
fields in lang_decl_var.
* java-tree.h (DECL_FUNCTION_SYNTHETIC_CTOR,
DECL_FUNCTION_ALL_FINAL_INITIALIZED): New macros.
(FIELD_INNER_ACCESS): Removed ugly cast, macro rewritten.
(FIELD_INNER_ACCESS_P, DECL_FIELD_FINAL_IUD, DECL_FIELD_FINAL_LIIC,
DECL_FIELD_FINAL_IERR, DECL_FIELD_FINAL_WFL): New macros.
(LOCAL_FINAL): Rewritten.
(LOCAL_FINAL_P, FINAL_VARIABLE_P, CLASS_FINAL_VARIABLE_P
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): New macros.
(struct lang_decl): Fixed comments. Added `synthetic_ctor' and
`init_final' fields.
(struct lang_decl_var): Fixed leading comment. Added `am', `wfl',
`final_uid', `final_liic', `final_ierr' and `local_final' fields.
(TYPE_HAS_FINAL_VARIABLE): New macro.
(struct lang_type): Added `afv' field.
* parse.y (check_static_final_variable_assignment_flag): New function.
(reset_static_final_variable_assignment_flag): Likewise.
(check_final_variable_local_assignment_flag): Likewise.
(reset_final_variable_local_assignment_flag): Likewise.
(check_final_variable_indirect_assignment): Likewise.
(check_final_variable_global_assignment_flag): Likewise.
(add_inner_class_fields): Use LOCAL_FINAL_P.
(register_fields): Handle local finals and final variables.
(craft_constructor): Set DECL_FUNCTION_SYNTHETIC_CTOR.
(declare_local_variables): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
(source_start_java_method): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC
on local finals.
(java_complete_expand_methods): Loop to set
TYPE_HAS_FINAL_VARIABLE. Call
`reset_final_variable_local_assignment_flag' and
`check_final_variable_local_assignment_flag' accordingly before
and after constructor expansion. Call
`reset_static_final_variable_assignment_flag'
before expanding <clinit> and after call
`check_static_final_variable_assignment_flag' if the
current_class isn't an interface. After all methods have been
expanded, call `check_final_variable_global_assignment_flag' and
`check_static_final_variable_assignment_flag' if the current class
is an interface.
(maybe_yank_clinit): Fixed typo in comment.
(build_outer_field_access_methods): Removed old sanity check. Use
FIELD_INNER_ACCESS_P. Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC.
Don't create access methods for finals.
(resolve_field_access): Use `CLASS_FINAL_VARIABLE_P'.
(java_complete_tree): Likewise. Reset DECL_FIELD_FINAL_IUD if
existing DECL_INIT has been processed.
(java_complete_lhs): Likewise.
(check_final_assignment): Filter input on `lvalue''s TREE_CODE.
Test for COMPONENT_REF to get to the FIELD_DECL. Implemented new
logic.
(patch_assignment): Use LOCAL_FINAL_P.
(fold_constant_for_init): Reset DECL_FIELD_FINAL_IUD if
DECL_INITIAL is nullified.
Fixes gcj/163.
2000-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Make-lang.in (parse.c, parse-scan.c): Create atomically.
......@@ -403,6 +476,20 @@ Thu Nov 23 02:19:14 2000 J"orn Rennecke <amylaar@redhat.com>
fields.
* lex.h (java_lexer): Added out_buffer, out_first, out_last.
2000-10-09 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (pop_current_osb): New function.
(array_type:): Use `dims:', changed actions
accordingly. Suggested by Anthony Green.
(array_creation_expression:): Used pop_current_osb.
(cast_expression:): Likewise.
(search_applicable_method_list): Fixed indentation.
2000-10-08 Anthony Green <green@redhat.com>
* parse.y (array_type_literal): Remove production.
(type_literals): Refer to array_type, not array_type_literal.
2000-10-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
Patch contributed by Corey Minyard.
......
......@@ -356,8 +356,7 @@ done_alternative (after, current)
start_current_locals = current.save_start_current_locals; \
}
/* Check for (un)initialized local variables in EXP.
*/
/* Check for (un)initialized local variables in EXP. */
static void
check_init (exp, before)
......@@ -387,14 +386,14 @@ check_init (exp, before)
/* We're interested in variable declaration and parameter
declaration when they're declared with the `final' modifier. */
if ((TREE_CODE (tmp) == VAR_DECL && ! FIELD_STATIC (tmp))
|| (TREE_CODE (tmp) == PARM_DECL && LOCAL_FINAL (tmp)))
|| (TREE_CODE (tmp) == PARM_DECL && LOCAL_FINAL_P (tmp)))
{
int index;
check_init (TREE_OPERAND (exp, 1), before);
index = DECL_BIT_INDEX (tmp);
/* A final local already assigned or a final parameter
assigned must be reported as errors */
if (LOCAL_FINAL (tmp)
if (LOCAL_FINAL_P (tmp)
&& (index == -1 || TREE_CODE (tmp) == PARM_DECL))
parse_error_context (wfl, "Can't assign here a value to the `final' variable `%s'", IDENTIFIER_POINTER (DECL_NAME (tmp)));
......
......@@ -127,8 +127,7 @@ push_jvm_slot (index, decl)
/* Now link the decl into the decl_map. */
if (DECL_LANG_SPECIFIC (decl) == NULL)
{
DECL_LANG_SPECIFIC (decl)
= (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var));
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_LOCAL_START_PC (decl) = 0;
DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl);
DECL_LOCAL_SLOT_NUMBER (decl) = index;
......@@ -1620,8 +1619,7 @@ give_name_to_locals (jcf)
comments for expr.c:maybe_adjust_start_pc. */
start_pc = maybe_adjust_start_pc (jcf, code_offset, start_pc, slot);
DECL_LANG_SPECIFIC (decl)
= (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var));
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_LOCAL_SLOT_NUMBER (decl) = slot;
DECL_LOCAL_START_PC (decl) = start_pc;
#if 0
......@@ -1901,7 +1899,8 @@ lang_mark_tree (t)
ggc_mark_tree (li->utf8_ref);
}
else if (TREE_CODE (t) == VAR_DECL
|| TREE_CODE (t) == PARM_DECL)
|| TREE_CODE (t) == PARM_DECL
|| TREE_CODE (t) == FIELD_DECL)
{
struct lang_decl_var *ldv =
((struct lang_decl_var *) DECL_LANG_SPECIFIC (t));
......@@ -1909,6 +1908,8 @@ lang_mark_tree (t)
{
ggc_mark (ldv);
ggc_mark_tree (ldv->slot_chain);
ggc_mark_tree (ldv->am);
ggc_mark_tree (ldv->wfl);
}
}
else if (TREE_CODE (t) == FUNCTION_DECL)
......
......@@ -88,7 +88,6 @@ struct JCF;
3: METHOD_FINAL (in FUNCTION_DECL)
FIELD_FINAL (in FIELD_DECL)
CLASS_FINAL (in TYPE_DECL)
LOCAL_FINAL (in VAR_DECL)
4: METHOD_SYNCHRONIZED (in FUNCTION_DECL).
LABEL_IN_SUBR (in LABEL_DECL)
CLASS_INTERFACE (in TYPE_DECL)
......@@ -701,11 +700,12 @@ struct lang_identifier
is excluded, because sometimes created as a parameter before the
function decl exists. */
#define DECL_FUNCTION_NAP(DECL) (DECL_LANG_SPECIFIC(DECL)->nap)
/* For a FIELD_DECL, holds the name of the access method used to
read/write the content of the field from an inner class.
The cast is ugly. FIXME */
#define FIELD_INNER_ACCESS(DECL) ((tree)DECL_LANG_SPECIFIC (DECL))
/* True if DECL is a synthetic ctor. */
#define DECL_FUNCTION_SYNTHETIC_CTOR(DECL) \
(DECL_LANG_SPECIFIC(DECL)->synthetic_ctor)
/* True if DECL initializes all its finals */
#define DECL_FUNCTION_ALL_FINAL_INITIALIZED(DECL) \
(DECL_LANG_SPECIFIC(DECL)->init_final)
/* True when DECL aliases an outer context local variable. */
#define FIELD_LOCAL_ALIAS(DECL) DECL_LANG_FLAG_6 (DECL)
......@@ -779,6 +779,46 @@ struct lang_identifier
slot_number in decl_map. */
#define DECL_LOCAL_SLOT_CHAIN(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_chain)
/* For a FIELD_DECL, holds the name of the access method. Used to
read/write the content of the field from an inner class. */
#define FIELD_INNER_ACCESS(DECL) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(DECL))->am)
/* Safely tests whether FIELD_INNER_ACCESS exists or not. */
#define FIELD_INNER_ACCESS_P(DECL) \
DECL_LANG_SPECIFIC (DECL) && FIELD_INNER_ACCESS (DECL)
/* True if a final variable was initialized upon its declaration. */
#define DECL_FIELD_FINAL_IUD(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->final_iud)
/* Set to true if a final variable is seen locally initialized on a
ctor. */
#define DECL_FIELD_FINAL_LIIC(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->final_liic)
/* Set to true if an initialization error was already found with this
final variable. */
#define DECL_FIELD_FINAL_IERR(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->final_ierr)
/* The original WFL of a final variable. */
#define DECL_FIELD_FINAL_WFL(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->wfl)
/* True if NODE is a local final (as opposed to a final variable.)
This macro accesses the flag to read or set it. */
#define LOCAL_FINAL(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->local_final)
/* True if NODE is a local final. */
#define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && LOCAL_FINAL (NODE))
/* True if NODE is a final variable */
#define FINAL_VARIABLE_P(NODE) (FIELD_FINAL (NODE) && !FIELD_STATIC (NODE))
/* True if NODE is a class final variable */
#define CLASS_FINAL_VARIABLE_P(NODE) \
(FIELD_FINAL (NODE) && FIELD_STATIC (NODE))
/* Create a DECL_LANG_SPECIFIC if necessary. */
#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \
if (DECL_LANG_SPECIFIC (T) == NULL) \
{ \
DECL_LANG_SPECIFIC ((T)) \
= ((struct lang_decl *) \
ggc_alloc_cleared (sizeof (struct lang_decl_var))); \
}
/* For a local VAR_DECL, holds the index into a words bitstring that
specifies if this decl is definitively assigned.
......@@ -798,15 +838,15 @@ struct lang_decl
tree throws_list; /* Exception specified by `throws' */
tree function_decl_body; /* Hold all function's statements */
tree called_constructor; /* When decl is a constructor, the
list of other constructor it calls. */
list of other constructor it calls */
struct hash_table init_test_table;
/* Class initialization test variables. */
/* Class initialization test variables */
tree inner_access; /* The identifier of the access method
used for invocation from inner classes */
int nap; /* Number of artificial parameters */
int native : 1; /* Nonzero if this is a native
method. */
int native : 1; /* Nonzero if this is a native method */
int synthetic_ctor : 1; /* Nonzero if this is a synthetic ctor */
int init_final : 1; /* Nonzero all finals are initialized */
};
/* init_test_table hash table entry structure. */
......@@ -816,13 +856,20 @@ struct init_test_hash_entry
tree init_test_decl;
};
/* DECL_LANG_SPECIFIC for VAR_DECL and PARM_DECL. */
/* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL
(access methods on outer class fields) and final fields. */
struct lang_decl_var
{
int slot_number;
int start_pc;
int end_pc;
tree slot_chain;
tree am; /* Access method for this field (1.1) */
tree wfl; /* Original wfl */
int final_iud : 1; /* Final initialized upon declaration */
int final_liic : 1; /* Final locally initialized in ctors */
int final_ierr : 1; /* Initialization error already detected */
int local_final : 1; /* True if the decl is a local final */
};
/* Macro to access fields in `struct lang_type'. */
......@@ -847,6 +894,7 @@ struct lang_decl_var
#define TYPE_DOT_CLASS(T) (TYPE_LANG_SPECIFIC(T)->dot_class)
#define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->pic)
#define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->poic)
#define TYPE_HAS_FINAL_VARIABLE(T) (TYPE_LANG_SPECIFIC(T)->afv)
struct lang_type
{
......@@ -863,6 +911,7 @@ struct lang_type
<non_primitive_type>.class */
unsigned pic:1; /* Private Inner Class. */
unsigned poic:1; /* Protected Inner Class. */
unsigned afv:1; /* Has final variables */
};
#ifdef JAVA_USE_HANDLES
......@@ -1110,7 +1159,6 @@ struct rtx_def * java_lang_expand_expr PARAMS ((tree, rtx, enum machine_mode,
#define FIELD_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
#define FIELD_VOLATILE(DECL) DECL_LANG_FLAG_4 (DECL)
#define FIELD_TRANSIENT(DECL) DECL_LANG_FLAG_5 (DECL)
#define LOCAL_FINAL(DECL) FIELD_FINAL(DECL)
/* Access flags etc for a class (a TYPE_DECL): */
......
......@@ -57,7 +57,7 @@ char *jcf_write_base_directory = NULL;
/* Add a 1-byte instruction/operand I to bytecode.data,
assuming space has already been RESERVE'd. */
#define OP1(I) (*state->bytecode.ptr++ = (I), CHECK_OP(state))
#define OP1(I) (state->last_bc = *state->bytecode.ptr++ = (I), CHECK_OP(state))
/* Like OP1, but I is a 2-byte big endian integer. */
......@@ -131,13 +131,14 @@ struct jcf_block
int linenumber;
/* After finish_jcf_block is called, The actual instructions contained in this block.
Before than NULL, and the instructions are in state->bytecode. */
/* After finish_jcf_block is called, The actual instructions
contained in this block. Before than NULL, and the instructions
are in state->bytecode. */
union {
struct chunk *chunk;
/* If pc==PENDING_CLEANUP_PC, start_label is the start of the region
coveed by the cleanup. */
covered by the cleanup. */
struct jcf_block *start_label;
} v;
......@@ -272,8 +273,10 @@ struct jcf_partial
/* If non-NULL, use this for the return value. */
tree return_value_decl;
/* Information about the current switch statemenet. */
/* Information about the current switch statement. */
struct jcf_switch_state *sw_state;
enum java_opcode last_bc; /* The last emitted bytecode */
};
static void generate_bytecode_insns PARAMS ((tree, int, struct jcf_partial *));
......@@ -2158,6 +2161,15 @@ generate_bytecode_insns (exp, target, state)
tree src = TREE_OPERAND (exp, 0);
tree src_type = TREE_TYPE (src);
tree dst_type = TREE_TYPE (exp);
/* Detect the situation of compiling an empty synchronized
block. A nop should be emitted in order to produce
verifiable bytecode. */
if (exp == empty_stmt_node
&& state->last_bc == OPCODE_monitorenter
&& state->labeled_blocks
&& state->labeled_blocks->pc == PENDING_CLEANUP_PC)
OP1 (OPCODE_nop);
else
generate_bytecode_insns (TREE_OPERAND (exp, 0), target, state);
if (target == IGNORE_TARGET || src_type == dst_type)
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment