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]

[gcjx] Patch: FYI: default -target


I'm checking this in on the gcjx branch.

-target now defaults to whatever was given as -source.
Also, we now handle -target 1.3 correctly, by not doing exception
chaining (when asked).

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* model/class.cc (add_class_members): Handle 1.3 target.  Mark
	method as 'used'.
	* compiler.cc (compiler): Initialize new field.
	(set_target_1_5): Updated.
	(set_target_1_4): Updated.
	(set_target_1_3): Updated.
	* compiler.hh (compiler::target_14): New field.
	* main.cc (argument_parser::source_argument): New field.
	(argument_parser::set_source): Set it.
	(argument_parser::target_argument): New field.
	(argument_parser::set_target): Set it.
	(argument_parser::parse_args): 

Index: TODO
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/TODO,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 TODO
--- TODO 22 Jan 2005 08:35:22 -0000 1.1.2.9
+++ TODO 23 Jan 2005 00:34:09 -0000
@@ -273,6 +273,9 @@
 
 Tree generation
 
+we should factor out things like object layout, etc, so that
+we can reuse the bulk of this code with LLVM
+
 build_address_of() the functions we call
 document this in tree.def:call_expr ?
 
Index: compiler.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/compiler.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 compiler.cc
--- compiler.cc 13 Jan 2005 03:18:33 -0000 1.1.2.1
+++ compiler.cc 23 Jan 2005 00:34:09 -0000
@@ -1,6 +1,6 @@
 // A single compilation.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -133,7 +133,9 @@
     feature_annotations (true),
     target_assert (true),
     target_debug (false),
-    target_15 (false),		// FIXME: inconsistent with other defaults
+    target_15 (false),
+    // For now this is the default.
+    target_14 (true),
     target_verify (false)
 {
 }
@@ -327,6 +329,7 @@
 compiler::set_target_1_5 ()
 {
   target_15 = true;
+  target_14 = false;
   target_assert = true;
 }
 
@@ -334,6 +337,7 @@
 compiler::set_target_1_4 ()
 {
   target_15 = false;
+  target_14 = true;
   target_assert = true;
 }
 
@@ -341,6 +345,7 @@
 compiler::set_target_1_3 ()
 {
   target_15 = false;
+  target_14 = false;
   target_assert = false;
 }
 
Index: compiler.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/compiler.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 compiler.hh
--- compiler.hh 13 Jan 2005 03:18:33 -0000 1.1.2.1
+++ compiler.hh 23 Jan 2005 00:34:09 -0000
@@ -1,6 +1,6 @@
 // A single compilation, perhaps of multiple files.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -276,6 +276,7 @@
 
   // Flags used only when compiling to bytecode.
   compiler_flag target_15;
+  compiler_flag target_14;
   compiler_flag target_verify;
 
   void set_class_factory (classpath_class_factory *fac);
Index: main.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/main.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 main.cc
--- main.cc 13 Jan 2005 03:18:33 -0000 1.1.2.1
+++ main.cc 23 Jan 2005 00:34:09 -0000
@@ -1,6 +1,6 @@
 // Main program, at least for testing.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -294,6 +294,7 @@
       comp->set_source_1_5 ();
     else
       die_unrecognized ("source", arg);
+    source_argument = arg;
   }
 
   void
@@ -307,6 +308,7 @@
       comp->set_target_1_5 ();
     else
       die_unrecognized ("target", arg);
+    target_argument = arg;
   }
 
   void
@@ -477,6 +479,11 @@
 	  die_unrecognized ("option", arg);
       }
 
+    // If -source was set, and -target was not, then -target defaults
+    // to -source.
+    if (! source_argument.empty () && target_argument.empty ())
+      set_target (source_argument);
+
     std::list<class_factory *> facs;
 
     if (! bootclasspath.empty ())
@@ -525,6 +532,13 @@
   }
   
 private:
+
+  // The '-source' argument.  If not specified, the empty string.
+  std::string source_argument;
+
+  // Likewise for '-target'.
+  std::string target_argument;
+
   compiler *comp;
   std::deque<std::string> args;
 };
Index: model/class.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/class.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 class.cc
--- model/class.cc 22 Jan 2005 07:56:24 -0000 1.1.2.4
+++ model/class.cc 23 Jan 2005 00:34:09 -0000
@@ -1490,6 +1490,7 @@
       class_->set_synthetic ();
       class_->set_return_type (new model_forwarding_resolved (loc,
 							      global->get_compiler ()->java_lang_Class ()));
+      class_->set_used ();
 
       // This method accepts a string and a boolean as arguments.  The
       // idea comes from jikes.  The boolean controls whether we want
@@ -1511,7 +1512,6 @@
 
       assert (! global->get_compiler ()->target_15 ());
 
-      // FIXME: pre-1.4, we can't use initCause().
       // FIXME: we could really clean up this code by adding some new
       // constructors and helper methods here and there.
       // FIXME: we have un-ref'd objects here, could be a memory
@@ -1540,17 +1540,25 @@
 								  global->get_compiler ()->java_lang_ClassNotFoundException ()),
 				   this);
 
-      ref_method_invocation initcause = new model_method_invocation (loc);
-      initcause->set_method ("initCause");
-      args.push_back (new model_simple_variable_ref (loc, exc.get ()));
-      initcause->set_arguments (args);
-      initcause->set_expression (new model_new (loc,
-						global->get_compiler ()->java_lang_NoClassDefFoundError ()));
+      ref_simple_variable_ref varref
+	= new model_simple_variable_ref (loc, exc.get ());
       ref_expression throw_expr
-	= new model_cast (loc,
-			  new model_forwarding_resolved (loc,
-							 global->get_compiler ()->java_lang_Error ()),
-			  initcause);
+	= new model_new (loc, global->get_compiler ()->java_lang_NoClassDefFoundError ());
+
+      if (global->get_compiler ()->target_14 ())
+	{
+	  // In 1.4 we can chain the exception.
+	  ref_method_invocation initcause = new model_method_invocation (loc);
+	  initcause->set_method ("initCause");
+	  args.push_back (varref);
+	  initcause->set_arguments (args);
+	  initcause->set_expression (throw_expr);
+	  throw_expr
+	    = new model_cast (loc,
+			      new model_forwarding_resolved (loc,
+							     global->get_compiler ()->java_lang_Error ()),
+			      initcause);
+	}
 
       ref_throw throw_stmt = new model_throw (loc);
       throw_stmt->set_expression (throw_expr);


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