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]
Other format: [Raw text]

Patch: FYI: support 'ldc class' in gcj


I'm checking this in on the trunk.

This adds support for the new 1.5 'ldc class' opcode to gcj.  We
already have support for this in the runtime.

This patch is not 100% perfect -- we allow 'ldc class' even in class
files which are ostensibly 1.4.  However, we have never checked class
version numbers in the compiler (an oversight, but not one I want to
correct today), and letting this through does not have any important
ramifications -- it is only a pedantic check.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* expr.c (java_push_constant_from_pool): Handle 'ldc class'.
	* verify-glue.c (vfy_class_type): New function.
	* verify-impl.c (check_constant): Allow 'ldc class'.
	* verify.h (vfy_class_type): Declare.

Index: verify-impl.c
===================================================================
--- verify-impl.c	(revision 114043)
+++ verify-impl.c	(working copy)
@@ -1975,6 +1975,10 @@
     init_type_from_tag (&t, int_type);
   else if (vfy_tag (pool, index) == JV_CONSTANT_Float)
     init_type_from_tag (&t, float_type);
+  else if (vfy_tag (pool, index) == JV_CONSTANT_Class
+	   || vfy_tag (pool, index) == JV_CONSTANT_ResolvedClass)
+    /* FIXME: should only allow this for 1.5 bytecode.  */
+    init_type_from_class (&t, vfy_class_type ());
   else
     verify_fail_pc ("String, int, or float constant expected", vfr->start_PC);
   return t;
Index: verify-glue.c
===================================================================
--- verify-glue.c	(revision 114043)
+++ verify-glue.c	(working copy)
@@ -1,5 +1,5 @@
 /* Glue to interface gcj with bytecode verifier.
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -329,6 +329,12 @@
 }
 
 vfy_jclass
+vfy_class_type (void)
+{
+  return class_type_node;
+}
+
+vfy_jclass
 vfy_string_type (void)
 {
   vfy_jclass k;
Index: verify.h
===================================================================
--- verify.h	(revision 114043)
+++ verify.h	(working copy)
@@ -1,5 +1,5 @@
 /* Declarations to interface gcj with bytecode verifier.
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -112,6 +112,7 @@
 bool vfy_is_abstract (vfy_jclass klass);
 vfy_jclass vfy_find_class (vfy_jclass klass, vfy_string name);
 vfy_jclass vfy_object_type (void);
+vfy_jclass vfy_class_type (void);
 vfy_jclass vfy_string_type (void);
 vfy_jclass vfy_throwable_type (void);
 vfy_jclass vfy_unsuitable_type (void);
Index: expr.c
===================================================================
--- expr.c	(revision 114043)
+++ expr.c	(working copy)
@@ -3117,6 +3117,12 @@
       c = build_ref_from_constant_pool (index);
       c = convert (promote_type (string_type_node), c);
     }
+  else if (JPOOL_TAG (jcf, index) == CONSTANT_Class
+	   || JPOOL_TAG (jcf, index) == CONSTANT_ResolvedClass)
+    {
+      tree record = get_class_constant (jcf, index);
+      c = build_class_ref (record);
+    }
   else
     c = get_constant (jcf, index);
   push_value (c);


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