diff options
Diffstat (limited to 'gcc/java/jcf-write.c')
-rw-r--r-- | gcc/java/jcf-write.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index fcdd42447b4..82c77b1c831 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -386,8 +386,7 @@ static struct chunk * alloc_chunk (struct chunk *last, unsigned char *data, int size, struct obstack *work) { - struct chunk *chunk = (struct chunk *) - obstack_alloc (work, sizeof(struct chunk)); + struct chunk *chunk = obstack_alloc (work, sizeof(struct chunk)); if (data == NULL && size > 0) data = obstack_alloc (work, size); @@ -434,8 +433,8 @@ append_chunk_copy (unsigned char *data, int size, struct jcf_partial *state) static struct jcf_block * gen_jcf_label (struct jcf_partial *state) { - struct jcf_block *block = (struct jcf_block *) - obstack_alloc (state->chunk_obstack, sizeof (struct jcf_block)); + struct jcf_block *block + = obstack_alloc (state->chunk_obstack, sizeof (struct jcf_block)); block->next = NULL; block->linenumber = -1; block->pc = UNDEFINED_PC; @@ -518,8 +517,8 @@ static struct jcf_handler * alloc_handler (struct jcf_block *start_label, struct jcf_block *end_label, struct jcf_partial *state) { - struct jcf_handler *handler = (struct jcf_handler *) - obstack_alloc (state->chunk_obstack, sizeof (struct jcf_handler)); + struct jcf_handler *handler + = obstack_alloc (state->chunk_obstack, sizeof (struct jcf_handler)); handler->start_label = start_label; handler->end_label = end_label; handler->handler_label = get_jcf_label_here (state); @@ -576,8 +575,7 @@ localvar_alloc (tree decl, struct jcf_partial *state) ptr = (struct localvar_info**) state->localvars.data + index; state->localvars.ptr = (unsigned char *) (ptr + 1 + wide); } - info = (struct localvar_info *) - obstack_alloc (state->chunk_obstack, sizeof (struct localvar_info)); + info = obstack_alloc (state->chunk_obstack, sizeof (struct localvar_info)); ptr[0] = info; if (wide) ptr[1] = (struct localvar_info *)(~0); @@ -1004,8 +1002,8 @@ static void emit_reloc (HOST_WIDE_INT value, int kind, struct jcf_block *target, struct jcf_partial *state) { - struct jcf_relocation *reloc = (struct jcf_relocation *) - obstack_alloc (state->chunk_obstack, sizeof (struct jcf_relocation)); + struct jcf_relocation *reloc + = obstack_alloc (state->chunk_obstack, sizeof (struct jcf_relocation)); struct jcf_block *block = state->last_block; reloc->next = block->u.relocations; block->u.relocations = reloc; @@ -1464,8 +1462,9 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) OP1 (prec == 1 ? OPCODE_fconst_0 : OPCODE_dconst_0); else if (real_onep (exp)) OP1 (prec == 1 ? OPCODE_fconst_1 : OPCODE_dconst_1); - /* FIXME Should also use fconst_2 for 2.0f. - Also, should use iconst_2/ldc followed by i2f/i2d + else if (prec == 1 && real_twop (exp)) + OP1 (OPCODE_fconst_2); + /* ??? We could also use iconst_3/ldc followed by i2f/i2d for other float/double when the value is a small integer. */ else { @@ -1582,8 +1581,8 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) case CASE_EXPR: { struct jcf_switch_state *sw_state = state->sw_state; - struct jcf_relocation *reloc = (struct jcf_relocation *) - obstack_alloc (state->chunk_obstack, sizeof (struct jcf_relocation)); + struct jcf_relocation *reloc + = obstack_alloc (state->chunk_obstack, sizeof (struct jcf_relocation)); HOST_WIDE_INT case_value = TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)); reloc->kind = 0; reloc->label = get_jcf_label_here (state); @@ -1663,8 +1662,8 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) HOST_WIDE_INT i; unsigned HOST_WIDE_INT delta; /* Copy the chain of relocs into a sorted array. */ - struct jcf_relocation **relocs = (struct jcf_relocation **) - xmalloc (sw_state.num_cases * sizeof (struct jcf_relocation *)); + struct jcf_relocation **relocs + = xmalloc (sw_state.num_cases * sizeof (struct jcf_relocation *)); /* The relocs arrays is a buffer with a gap. The assumption is that cases will normally come in "runs". */ int gap_start = 0; @@ -2415,6 +2414,23 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) case JAVA_EXC_OBJ_EXPR: NOTE_PUSH (1); /* Pushed by exception system. */ break; + case MIN_EXPR: + case MAX_EXPR: + { + /* This copes with cases where fold() has created MIN or MAX + from a conditional expression. */ + enum tree_code code = TREE_CODE (exp) == MIN_EXPR ? LT_EXPR : GT_EXPR; + tree op0 = TREE_OPERAND (exp, 0); + tree op1 = TREE_OPERAND (exp, 1); + tree x; + if (TREE_SIDE_EFFECTS (op0) || TREE_SIDE_EFFECTS (op1)) + abort (); + x = build (COND_EXPR, TREE_TYPE (exp), + build (code, boolean_type_node, op0, op1), + op0, op1); + generate_bytecode_insns (x, target, state); + break; + } case NEW_CLASS_EXPR: { tree class = TREE_TYPE (TREE_TYPE (exp)); @@ -2669,8 +2685,7 @@ perform_relocations (struct jcf_partial *state) unsigned char *old_ptr = old_buffer + old_size; if (new_size != old_size) { - chunk->data = (unsigned char *) - obstack_alloc (state->chunk_obstack, new_size); + chunk->data = obstack_alloc (state->chunk_obstack, new_size); chunk->size = new_size; } new_ptr = chunk->data + new_size; @@ -2922,6 +2937,12 @@ generate_classfile (tree clas, struct jcf_partial *state) tree type = TREE_TYPE (part); tree save_function = current_function_decl; int synthetic_p = 0; + + /* Invisible Miranda methods shouldn't end up in the .class + file. */ + if (METHOD_INVISIBLE (part)) + continue; + current_function_decl = part; ptr = append_chunk (NULL, 8, state); i = get_access_flags (part); PUT2 (i); |