This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: jcf-write and last_bc


While looking at some other problems with bytecode generation, I
noticed that `state->last_bc' isn't always updated correctly.  OP1
sets this, and OP1 is also used to emit data.  When this happens,
last_bc will be set to some arbitrary byte value.

In this patch I've introduced OP1DATA, which doesn't set last_bc and
which is used whenever we're output data (as opposed to an opcode).

Ok to commit?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* jcf-write.c (OP1DATA): New macro.
	(OP2): Use it.
	(OP4): Likewise.
	(push_constant1): Likewise.
	(push_int_const): Likewise.
	(maybe_wide): Likewise.
	(emit_iinc): Likewise.
	(generate_bytecode_insns): Likewise.

Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.90
diff -u -r1.90 jcf-write.c
--- jcf-write.c 2001/10/08 20:35:03 1.90
+++ jcf-write.c 2001/10/08 23:11:03
@@ -59,16 +59,21 @@
 
 #define OP1(I) (state->last_bc = *state->bytecode.ptr++ = (I), CHECK_OP(state))
 
+/* Like OP1, but used for data.  Doesn't set last_bc.  */
+
+#define OP1DATA(D) (*state->bytecode.ptr++ = (D), CHECK_OP(state))
+
 /* Like OP1, but I is a 2-byte big endian integer. */
 
 #define OP2(I) \
-  do { int _i = (I); OP1 (_i >> 8);  OP1 (_i); CHECK_OP(state); } while (0)
+  do { int _i = (I); OP1DATA (_i >> 8); \
+       OP1DATA (_i); CHECK_OP(state); } while (0)
 
 /* Like OP1, but I is a 4-byte big endian integer. */
 
 #define OP4(I) \
-  do { int _i = (I);  OP1 (_i >> 24);  OP1 (_i >> 16); \
-       OP1 (_i >> 8); OP1 (_i); CHECK_OP(state); } while (0)
+  do { int _i = (I);  OP1DATA (_i >> 24);  OP1DATA (_i >> 16); \
+       OP1DATA (_i >> 8); OP1DATA (_i); CHECK_OP(state); } while (0)
 
 /* Macro to call each time we push I words on the JVM stack. */
 
@@ -737,7 +742,7 @@
   if (index < 256)
     {
       OP1 (OPCODE_ldc);
-      OP1 (index);
+      OP1DATA (index);
     }
   else
     {
@@ -773,7 +778,7 @@
   else if (i >= -128 && i < 128)
     {
       OP1(OPCODE_bipush);
-      OP1(i);
+      OP1DATA(i);
     }
   else if (i >= -32768 && i < 32768)
     {
@@ -933,7 +938,7 @@
     {
       RESERVE (2);
       OP1 (opcode);
-      OP1 (index);
+      OP1DATA (index);
     }
 }
 
@@ -992,8 +997,8 @@
     {
       RESERVE (3);
       OP1 (OPCODE_iinc);
-      OP1 (slot);
-      OP1 (value);
+      OP1DATA (slot);
+      OP1DATA (value);
     }
 }
 
@@ -2429,7 +2434,7 @@
 	  {
 	    int atype = encode_newarray_type (element_type);
 	    OP1 (OPCODE_newarray);
-	    OP1 (atype);
+	    OP1DATA (atype);
 	  }
 	else
 	  {
@@ -2484,7 +2489,7 @@
 				     STACK_TARGET, state);
 	    RESERVE (2);
 	    OP1 (OPCODE_newarray);
-	    OP1 (type_code);
+	    OP1DATA (type_code);
 	    break;
 	  }
 	else if (f == soft_multianewarray_node)
@@ -2503,7 +2508,7 @@
 	    RESERVE (4);
 	    OP1 (OPCODE_multianewarray);
 	    OP2 (index);
-	    OP1 (ndims);
+	    OP1DATA (ndims);
 	    break;
 	  }
 	else if (f == soft_anewarray_node)
@@ -2578,8 +2583,8 @@
 		if (nargs <= 0)
 		  abort ();
 
-		OP1 (nargs);
-		OP1 (0);
+		OP1DATA (nargs);
+		OP1DATA (0);
 	      }
 	    f = TREE_TYPE (TREE_TYPE (f));
 	    if (TREE_CODE (f) != VOID_TYPE)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]