diff options
Diffstat (limited to 'gcc/java/jcf-write.c')
-rw-r--r-- | gcc/java/jcf-write.c | 234 |
1 files changed, 66 insertions, 168 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 15035c0..fe00812 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -352,10 +352,7 @@ static void append_gcj_attribute (struct jcf_partial *, tree); static int CHECK_PUT (void *, struct jcf_partial *, int); static int -CHECK_PUT (ptr, state, i) - void *ptr; - struct jcf_partial *state; - int i; +CHECK_PUT (void *ptr, struct jcf_partial *state, int i) { if ((unsigned char *) ptr < state->chunk->data || (unsigned char *) ptr + i > state->chunk->data + state->chunk->size) @@ -385,11 +382,8 @@ CHECK_PUT (ptr, state, i) However, if DATA is NULL and SIZE>0, allocate a buffer as well. */ static struct chunk * -alloc_chunk (last, data, size, work) - struct chunk *last; - unsigned char *data; - int size; - struct obstack *work; +alloc_chunk (struct chunk *last, unsigned char *data, + int size, struct obstack *work) { struct chunk *chunk = (struct chunk *) obstack_alloc (work, sizeof(struct chunk)); @@ -409,8 +403,7 @@ alloc_chunk (last, data, size, work) static int CHECK_OP (struct jcf_partial *); static int -CHECK_OP (state) - struct jcf_partial *state; +CHECK_OP (struct jcf_partial *state) { if (state->bytecode.ptr > state->bytecode.limit) abort (); @@ -422,10 +415,7 @@ CHECK_OP (state) #endif static unsigned char * -append_chunk (data, size, state) - unsigned char *data; - int size; - struct jcf_partial *state; +append_chunk (unsigned char *data, int size, struct jcf_partial *state) { state->chunk = alloc_chunk (state->chunk, data, size, state->chunk_obstack); if (state->first == NULL) @@ -434,18 +424,14 @@ append_chunk (data, size, state) } static void -append_chunk_copy (data, size, state) - unsigned char *data; - int size; - struct jcf_partial *state; +append_chunk_copy (unsigned char *data, int size, struct jcf_partial *state) { unsigned char *ptr = append_chunk (NULL, size, state); memcpy (ptr, data, size); } static struct jcf_block * -gen_jcf_label (state) - struct jcf_partial *state; +gen_jcf_label (struct jcf_partial *state) { struct jcf_block *block = (struct jcf_block *) obstack_alloc (state->chunk_obstack, sizeof (struct jcf_block)); @@ -456,8 +442,7 @@ gen_jcf_label (state) } static void -finish_jcf_block (state) - struct jcf_partial *state; +finish_jcf_block (struct jcf_partial *state) { struct jcf_block *block = state->last_block; struct jcf_relocation *reloc; @@ -483,9 +468,7 @@ finish_jcf_block (state) } static void -define_jcf_label (label, state) - struct jcf_block *label; - struct jcf_partial *state; +define_jcf_label (struct jcf_block *label, struct jcf_partial *state) { if (state->last_block != NULL) finish_jcf_block (state); @@ -500,8 +483,7 @@ define_jcf_label (label, state) } static struct jcf_block * -get_jcf_label_here (state) - struct jcf_partial *state; +get_jcf_label_here (struct jcf_partial *state) { if (state->last_block != NULL && BUFFER_LENGTH (&state->bytecode) == 0) return state->last_block; @@ -516,9 +498,7 @@ get_jcf_label_here (state) /* Note a line number entry for the current PC and given LINE. */ static void -put_linenumber (line, state) - int line; - struct jcf_partial *state; +put_linenumber (int line, struct jcf_partial *state) { struct jcf_block *label = get_jcf_label_here (state); if (label->linenumber > 0) @@ -534,10 +514,8 @@ put_linenumber (line, state) in the range (START_LABEL, END_LABEL). */ static struct jcf_handler * -alloc_handler (start_label, end_label, state) - struct jcf_block *start_label; - struct jcf_block *end_label; - struct jcf_partial *state; +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)); @@ -576,9 +554,7 @@ struct localvar_info ((struct localvar_info**) state->localvars.ptr - localvar_buffer) static void -localvar_alloc (decl, state) - tree decl; - struct jcf_partial *state; +localvar_alloc (tree decl, struct jcf_partial *state) { struct jcf_block *start_label = get_jcf_label_here (state); int wide = TYPE_IS_WIDE (TREE_TYPE (decl)); @@ -623,9 +599,7 @@ localvar_alloc (decl, state) } static void -localvar_free (decl, state) - tree decl; - struct jcf_partial *state; +localvar_free (tree decl, struct jcf_partial *state) { struct jcf_block *end_label = get_jcf_label_here (state); int index = DECL_LOCAL_INDEX (decl); @@ -654,8 +628,7 @@ localvar_free (decl, state) a field (FIELD_DECL or VAR_DECL, if static), as encoded in a .class file. */ static int -get_access_flags (decl) - tree decl; +get_access_flags (tree decl) { int flags = 0; int isfield = TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == VAR_DECL; @@ -721,9 +694,7 @@ get_access_flags (decl) /* Write the list of segments starting at CHUNKS to STREAM. */ static void -write_chunks (stream, chunks) - FILE* stream; - struct chunk *chunks; +write_chunks (FILE* stream, struct chunk *chunks) { for (; chunks != NULL; chunks = chunks->next) fwrite (chunks->data, chunks->size, 1, stream); @@ -733,9 +704,7 @@ write_chunks (stream, chunks) (Caller is responsible for doing NOTE_PUSH.) */ static void -push_constant1 (index, state) - HOST_WIDE_INT index; - struct jcf_partial *state; +push_constant1 (HOST_WIDE_INT index, struct jcf_partial *state) { RESERVE (3); if (index < 256) @@ -754,9 +723,7 @@ push_constant1 (index, state) (Caller is responsible for doing NOTE_PUSH.) */ static void -push_constant2 (index, state) - HOST_WIDE_INT index; - struct jcf_partial *state; +push_constant2 (HOST_WIDE_INT index, struct jcf_partial *state) { RESERVE (3); OP1 (OPCODE_ldc2_w); @@ -767,9 +734,7 @@ push_constant2 (index, state) Caller is responsible for doing NOTE_PUSH. */ static void -push_int_const (i, state) - HOST_WIDE_INT i; - struct jcf_partial *state; +push_int_const (HOST_WIDE_INT i, struct jcf_partial *state) { RESERVE(3); if (i >= -1 && i <= 5) @@ -793,9 +758,8 @@ push_int_const (i, state) } static int -find_constant_wide (lo, hi, state) - HOST_WIDE_INT lo, hi; - struct jcf_partial *state; +find_constant_wide (HOST_WIDE_INT lo, HOST_WIDE_INT hi, + struct jcf_partial *state) { HOST_WIDE_INT w1, w2; lshift_double (lo, hi, -32, 64, &w1, &w2, 1); @@ -807,9 +771,7 @@ find_constant_wide (lo, hi, state) Return the index in the constant pool. */ static int -find_constant_index (value, state) - tree value; - struct jcf_partial *state; +find_constant_index (tree value, struct jcf_partial *state) { if (TREE_CODE (value) == INTEGER_CST) { @@ -847,9 +809,7 @@ find_constant_index (value, state) Caller is responsible for doing NOTE_PUSH. */ static void -push_long_const (lo, hi, state) - HOST_WIDE_INT lo, hi; - struct jcf_partial *state; +push_long_const (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state) { HOST_WIDE_INT highpart, dummy; jint lowpart = WORD_TO_INT (lo); @@ -873,10 +833,7 @@ push_long_const (lo, hi, state) } static void -field_op (field, opcode, state) - tree field; - int opcode; - struct jcf_partial *state; +field_op (tree field, int opcode, struct jcf_partial *state) { int index = find_fieldref_index (&state->cpool, field); RESERVE (3); @@ -889,9 +846,7 @@ field_op (field, opcode, state) opcodes typically depend on the operand type. */ static int -adjust_typed_op (type, max) - tree type; - int max; +adjust_typed_op (tree type, int max) { switch (TREE_CODE (type)) { @@ -924,9 +879,7 @@ adjust_typed_op (type, max) } static void -maybe_wide (opcode, index, state) - int opcode, index; - struct jcf_partial *state; +maybe_wide (int opcode, int index, struct jcf_partial *state) { if (index >= 256) { @@ -949,9 +902,7 @@ maybe_wide (opcode, index, state) (The new words get inserted at stack[SP-size-offset].) */ static void -emit_dup (size, offset, state) - int size, offset; - struct jcf_partial *state; +emit_dup (int size, int offset, struct jcf_partial *state) { int kind; if (size == 0) @@ -970,19 +921,14 @@ emit_dup (size, offset, state) } static void -emit_pop (size, state) - int size; - struct jcf_partial *state; +emit_pop (int size, struct jcf_partial *state) { RESERVE (1); OP1 (OPCODE_pop - 1 + size); } static void -emit_iinc (var, value, state) - tree var; - HOST_WIDE_INT value; - struct jcf_partial *state; +emit_iinc (tree var, HOST_WIDE_INT value, struct jcf_partial *state) { int slot = DECL_LOCAL_INDEX (var); @@ -1004,10 +950,9 @@ emit_iinc (var, value, state) } static void -emit_load_or_store (var, opcode, state) - tree var; /* Variable to load from or store into. */ - int opcode; /* Either OPCODE_iload or OPCODE_istore. */ - struct jcf_partial *state; +emit_load_or_store (tree var, /* Variable to load from or store into. */ + int opcode, /* Either OPCODE_iload or OPCODE_istore. */ + struct jcf_partial *state) { tree type = TREE_TYPE (var); int kind = adjust_typed_op (type, 4); @@ -1022,38 +967,29 @@ emit_load_or_store (var, opcode, state) } static void -emit_load (var, state) - tree var; - struct jcf_partial *state; +emit_load (tree var, struct jcf_partial *state) { emit_load_or_store (var, OPCODE_iload, state); NOTE_PUSH (TYPE_IS_WIDE (TREE_TYPE (var)) ? 2 : 1); } static void -emit_store (var, state) - tree var; - struct jcf_partial *state; +emit_store (tree var, struct jcf_partial *state) { emit_load_or_store (var, OPCODE_istore, state); NOTE_POP (TYPE_IS_WIDE (TREE_TYPE (var)) ? 2 : 1); } static void -emit_unop (opcode, type, state) - enum java_opcode opcode; - tree type ATTRIBUTE_UNUSED; - struct jcf_partial *state; +emit_unop (enum java_opcode opcode, tree type ATTRIBUTE_UNUSED, + struct jcf_partial *state) { RESERVE(1); OP1 (opcode); } static void -emit_binop (opcode, type, state) - enum java_opcode opcode; - tree type; - struct jcf_partial *state; +emit_binop (enum java_opcode opcode, tree type, struct jcf_partial *state) { int size = TYPE_IS_WIDE (type) ? 2 : 1; RESERVE(1); @@ -1062,11 +998,8 @@ emit_binop (opcode, type, state) } static void -emit_reloc (value, kind, target, state) - HOST_WIDE_INT value; - int kind; - struct jcf_block *target; - struct jcf_partial *state; +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)); @@ -1083,9 +1016,7 @@ emit_reloc (value, kind, target, state) } static void -emit_switch_reloc (label, state) - struct jcf_block *label; - struct jcf_partial *state; +emit_switch_reloc (struct jcf_block *label, struct jcf_partial *state) { emit_reloc (RELOCATION_VALUE_0, BLOCK_START_RELOC, label, state); } @@ -1094,9 +1025,7 @@ emit_switch_reloc (label, state) but re-uses an existing case reloc. */ static void -emit_case_reloc (reloc, state) - struct jcf_relocation *reloc; - struct jcf_partial *state; +emit_case_reloc (struct jcf_relocation *reloc, struct jcf_partial *state) { struct jcf_block *block = state->last_block; reloc->next = block->u.relocations; @@ -1110,10 +1039,8 @@ emit_case_reloc (reloc, state) The opcode is OPCODE, the inverted opcode is INV_OPCODE. */ static void -emit_if (target, opcode, inv_opcode, state) - struct jcf_block *target; - int opcode, inv_opcode; - struct jcf_partial *state; +emit_if (struct jcf_block *target, int opcode, int inv_opcode, + struct jcf_partial *state) { RESERVE(3); OP1 (opcode); @@ -1122,9 +1049,7 @@ emit_if (target, opcode, inv_opcode, state) } static void -emit_goto (target, state) - struct jcf_block *target; - struct jcf_partial *state; +emit_goto (struct jcf_block *target, struct jcf_partial *state) { RESERVE(3); OP1 (OPCODE_goto); @@ -1133,9 +1058,7 @@ emit_goto (target, state) } static void -emit_jsr (target, state) - struct jcf_block *target; - struct jcf_partial *state; +emit_jsr (struct jcf_block *target, struct jcf_partial *state) { RESERVE(3); OP1 (OPCODE_jsr); @@ -1150,13 +1073,11 @@ emit_jsr (target, state) may be able to optimize away GOTO TRUE_LABEL; TRUE_LABEL:) */ static void -generate_bytecode_conditional (exp, true_label, false_label, - true_branch_first, state) - tree exp; - struct jcf_block *true_label; - struct jcf_block *false_label; - int true_branch_first; - struct jcf_partial *state; +generate_bytecode_conditional (tree exp, + struct jcf_block *true_label, + struct jcf_block *false_label, + int true_branch_first, + struct jcf_partial *state) { tree exp0, exp1, type; int save_SP = state->code_SP; @@ -1361,9 +1282,7 @@ generate_bytecode_conditional (exp, true_label, false_label, emit label that is LIMIT). */ static void -call_cleanups (limit, state) - struct jcf_block *limit; - struct jcf_partial *state; +call_cleanups (struct jcf_block *limit, struct jcf_partial *state) { struct jcf_block *block = state->labeled_blocks; for (; block != limit; block = block->next) @@ -1374,9 +1293,7 @@ call_cleanups (limit, state) } static void -generate_bytecode_return (exp, state) - tree exp; - struct jcf_partial *state; +generate_bytecode_return (tree exp, struct jcf_partial *state) { tree return_type = TREE_TYPE (TREE_TYPE (state->current_method)); int returns_void = TREE_CODE (return_type) == VOID_TYPE; @@ -1443,10 +1360,7 @@ generate_bytecode_return (exp, state) TARGET is one of STACK_TARGET or IGNORE_TARGET. */ static void -generate_bytecode_insns (exp, target, state) - tree exp; - int target; - struct jcf_partial *state; +generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) { tree type, arg; enum java_opcode jopcode; @@ -2641,8 +2555,7 @@ generate_bytecode_insns (exp, target, state) } static void -perform_relocations (state) - struct jcf_partial *state; +perform_relocations (struct jcf_partial *state) { struct jcf_block *block; struct jcf_relocation *reloc; @@ -2840,9 +2753,7 @@ perform_relocations (state) } static void -init_jcf_state (state, work) - struct jcf_partial *state; - struct obstack *work; +init_jcf_state (struct jcf_partial *state, struct obstack *work) { state->chunk_obstack = work; state->first = state->chunk = NULL; @@ -2852,9 +2763,7 @@ init_jcf_state (state, work) } static void -init_jcf_method (state, method) - struct jcf_partial *state; - tree method; +init_jcf_method (struct jcf_partial *state, tree method) { state->current_method = method; state->blocks = state->last_block = NULL; @@ -2875,8 +2784,7 @@ init_jcf_method (state, method) } static void -release_jcf_state (state) - struct jcf_partial *state; +release_jcf_state (struct jcf_partial *state) { CPOOL_FINISH (&state->cpool); obstack_free (state->chunk_obstack, state->first); @@ -2888,9 +2796,7 @@ release_jcf_state (state) static GTY(()) tree SourceFile_node; static struct chunk * -generate_classfile (clas, state) - tree clas; - struct jcf_partial *state; +generate_classfile (tree clas, struct jcf_partial *state) { struct chunk *cpool_chunk; const char *source_file, *s; @@ -3210,8 +3116,7 @@ generate_classfile (clas, state) static GTY(()) tree Synthetic_node; static unsigned char * -append_synthetic_attribute (state) - struct jcf_partial *state; +append_synthetic_attribute (struct jcf_partial *state) { unsigned char *ptr = append_chunk (NULL, 6, state); int i; @@ -3228,9 +3133,7 @@ append_synthetic_attribute (state) } static void -append_gcj_attribute (state, class) - struct jcf_partial *state; - tree class; +append_gcj_attribute (struct jcf_partial *state, tree class) { unsigned char *ptr; int i; @@ -3247,9 +3150,7 @@ append_gcj_attribute (state, class) static tree InnerClasses_node; static void -append_innerclasses_attribute (state, class) - struct jcf_partial *state; - tree class; +append_innerclasses_attribute (struct jcf_partial *state, tree class) { tree orig_decl = TYPE_NAME (class); tree current, decl; @@ -3302,9 +3203,8 @@ append_innerclasses_attribute (state, class) } static void -append_innerclasses_attribute_entry (state, decl, name) - struct jcf_partial *state; - tree decl, name; +append_innerclasses_attribute_entry (struct jcf_partial *state, + tree decl, tree name) { int icii, icaf; int ocii = 0, ini = 0; @@ -3328,8 +3228,7 @@ append_innerclasses_attribute_entry (state, decl, name) } static char * -make_class_file_name (clas) - tree clas; +make_class_file_name (tree clas) { const char *dname, *cname, *slash; char *r; @@ -3396,8 +3295,7 @@ make_class_file_name (clas) The output .class file name is make_class_file_name(CLAS). */ void -write_classfile (clas) - tree clas; +write_classfile (tree clas) { struct obstack *work = &temporary_obstack; struct jcf_partial state[1]; |