commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic-portable-native-sync-1.patch


From: Steven Augart
Subject: Re: dynamic-portable-native-sync-1.patch
Date: Wed, 07 Jul 2004 00:28:13 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616

Mark Wielaard wrote:
Hi,

On Sun, 2004-06-20 at 02:20, Steven Augart wrote:

OK to commit?


This looks fine to me. Thanks for making this a runtime configuration
option! Can you add a one-line blurb to the NEWS file about this (with a
see the vmintegration guide) when you commit.

I have committed it; the final version of the patch is attached.



2004-06-19  Steven Augart  <address@hidden>

* gnu/java/awtk/peer/gtk/GtkMainThread.java (run): Pass the value of the gnu.classpath.awt.gtk.portable.native.sync system property to C.


s/awtk/awt/ typo.
fixed


address@hidden: this is written in anticipation of 1.2 support and does not
address@hidden: this is written in anticipation of Java 1.2 support and does not


Note that in our documentation and manuals we try to avoid suggesting
that GNU Classpath is Java. It is not. Although we do hope that it is as
compatible with it as possible (so people can migrate to a free
implementation when they want). Since there is a trademark on certain
uses of the word Java we normally don't call anything Java. In the above
you would say "1.2 library support" and instead of Java runtime we just
use "runtime", or if it is explicitly for the particular byte code
instructions often associated with the java programming language
"interpreter for java byte codes". This is also more correct since with
e.g. gcj or ikvm.net the execution model is completely different from
the traditional byte code interpreter or just in time compiler.

Sorry for nitpicking about this. But if we can avoid any legal issues
about the java trademark then lets do that. It is also more clear and
fair to our users. We don't want them to think of GNU Classpath as the
same thing as that proprietary implementation that restricts their
rights and gives control on how they can use it to a small cabal.

I have made the alteration.

Like the Classpath project, the Jikes RVM project is also careful never to imply that Jikes RVM is officially Java. I don't believe that it would put Classpath in a legally awkward position to say that we anticipate supporting "Java 1.2", but I certainly agree that it won't put Classpath in an awkward position if I *don't* say it! (The preceding sentence is not directly translatable into Italian or other languages that don't follow technical English's baroque interpretation of double negatives :))





--
Steven Augart

Jikes RVM, a free, open source, Virtual Machine:
http://oss.software.ibm.com/jikesrvm
This patch makes the portable-native-sync no longer need build-time
configuration.  Instead, we configure it at run-time.  Build-time sets
the defaults.

Committed with the following ChangeLog entry: 

2004-07-07  Steven Augart  <address@hidden>

        * gnu/java/awt/peer/gtk/GtkMainThread.java (run): Pass the value of 
        the gnu.classpath.awt.gtk.portable.native.sync system property to C.

        * configure.ac: Correct description of PORTABLE_NATIVE_SYNC
        config.h definition.

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,
        include/gnu_java_awt_peer_gtk_GtkMainThread.h
        (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): New argument,
        portableNativeSync.  Delegate PORTABLE_NATIVE_SYNC work to
        init_glib_threads. 
        (init_glib_threads): New function.

        * doc/vmintegration.texinfo (VM Threading Model): Explain the
        gnu.classpath.awt.gtk.portable.native.sync system property. 

        * NEWS: Mention the gnu.classpath.awt.gtk.portable.native.sync
        new system property.

Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.33
diff -I*.class -u -r1.33 configure.ac
--- configure.ac        4 Jul 2004 21:51:58 -0000       1.33
+++ configure.ac        7 Jul 2004 04:24:03 -0000
@@ -274,11 +274,15 @@
 CLASSPATH_ENABLE_GJDOC
 
 dnl -----------------------------------------------------------
+dnl This sets the build-time default, which can now be overridden 
+dnl by setting the system property gnu.classpath.awt.gtk.portable.native.sync
+dnl to "true" or "false".
+dnl -----------------------------------------------------------
 AC_ARG_ENABLE([portable-native-sync],
               [AS_HELP_STRING(--enable-portable-native-sync,synchronize VM 
threads portably)],
               [case "${enableval}" in 
                 yes) 
-                     AC_DEFINE(PORTABLE_NATIVE_SYNC, 1, [Define to 1 if you 
want to synchronize VM threads portably])
+                     AC_DEFINE(PORTABLE_NATIVE_SYNC, 1, [Define if you want to 
synchronize VM threads portably by default; undef otherwise])
                      ;;
                 no)  ;;
                 *)   
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.43
diff -I*.class -u -r1.43 NEWS
--- NEWS        4 Jul 2004 18:32:29 -0000       1.43
+++ NEWS        7 Jul 2004 04:24:03 -0000
@@ -1,13 +1,19 @@
 New in release 0.10 (in preparation)
 
-* Fixed the code enabled by the --portable-native-sync configure option; it 
-  had been broken since Classpath release 0.06, when we upgraded to GTK+2.  
+* Fixed the "portable native sync" code; it had been broken since
+  Classpath release 0.06, when we upgraded to GTK+2.    
   
   Explanation: Classpath's AWT peers use GTK+.  GTK+ uses GLIB.  GLIB by
   default uses the platform's native threading model -- pthreads in most cases.
   If the Java runtime doesn't use the native threading model, then you should
   specify --portable-native-sync when configuring Classpath, so that GLIB will
-  use the Java threading primitives instead.
+  use the Java threading primitives instead.  (For a superior alternative,
+  see below.)
+
+* The VM can set the system property
+  gnu.classpath.awt.gtk.portable.native.sync instead of using the
+  --portable-native-sync configure-type option.  See
+  doc/vmintegration.texinfo for details.
 
 * We intend that the next release of GNU Classpath will require the VM 
   to provide JNI 1.2.  Classpath currently uses only JNI 1.1, except for 
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,v
retrieving revision 1.20
diff -I*.class -u -r1.20 gnu_java_awt_peer_gtk_GtkMainThread.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c   27 Jun 2004 
11:36:32 -0000      1.20
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c   7 Jul 2004 
04:24:03 -0000
@@ -65,6 +65,8 @@
 
 GtkWindowGroup *global_gtk_window_group;
 
+static void init_glib_threads(JNIEnv *, jint);
+
 double dpi_conversion_factor;
 
 static void init_dpi_conversion_factor ();
@@ -74,10 +76,17 @@
 /*
  * Call gtk_init.  It is very important that this happen before any other
  * gtk calls.
+ *
+ * The portableNativeSync argument may have the values:
+ *   1 if the Java property gnu.classpath.awt.gtk.portable.native.sync
+ *     is set to "true".  
+ *   0 if it is set to "false"
+ *  -1 if unset.
  */
 
 JNIEXPORT void JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz)
+Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz,
+                                                  jint portableNativeSync)
 {
   int argc = 1;
   char **argv;
@@ -101,16 +110,7 @@
 #endif
   argv[1] = NULL;
 
-  /* until we have JDK 1.2 JNI, assume we have a VM with threads that 
-     match what GLIB was compiled for */
-#ifdef PORTABLE_NATIVE_SYNC
-  (*env)->GetJavaVM( env, &the_vm );
-  g_thread_init ( &portable_native_sync_jni_functions );
-  /* Debugging progress message; uncomment if needed: */
-  /*   printf("called gthread init\n"); */
-#else
-  g_thread_init ( NULL );
-#endif
+  init_glib_threads(env, portableNativeSync);
 
   /* From GDK 2.0 onwards we have to explicitly call gdk_threads_init */
   gdk_threads_init();
@@ -206,6 +206,37 @@
   init_dpi_conversion_factor ();
 }
 
+
+/** Initialize GLIB's threads properly, based on the value of the
+    gnu.classpath.awt.gtk.portable.native.sync Java system property.  If
+    that's unset, use the PORTABLE_NATIVE_SYNC config.h macro.  (TODO: 
+    In some release following 0.10, that config.h macro will go away.)
+    */ 
+static void 
+init_glib_threads(JNIEnv *env, jint portableNativeSync)
+{
+  if (portableNativeSync < 0)
+    {
+#ifdef PORTABLE_NATIVE_SYNC /* Default value, if not set by the Java system
+                               property */ 
+      portableNativeSync = 1;
+#else
+      portableNativeSync = 0;
+#endif
+    }
+  
+  (*env)->GetJavaVM( env, &the_vm );
+  if (portableNativeSync)
+    g_thread_init ( &portable_native_sync_jni_functions );
+  else
+    g_thread_init ( NULL );
+
+  /* Debugging progress message; uncomment if needed: */
+  /*   printf("called gthread init\n"); */
+}
+
+
+
 /*
  * Run gtk_main and block.
  */ 
Index: include/gnu_java_awt_peer_gtk_GtkMainThread.h
===================================================================
RCS file: 
/cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_GtkMainThread.h,v
retrieving revision 1.3
diff -I*.class -u -r1.3 gnu_java_awt_peer_gtk_GtkMainThread.h
--- include/gnu_java_awt_peer_gtk_GtkMainThread.h       28 May 2004 17:27:53 
-0000      1.3
+++ include/gnu_java_awt_peer_gtk_GtkMainThread.h       7 Jul 2004 04:24:03 
-0000
@@ -10,7 +10,7 @@
 {
 #endif
 
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit 
(JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit 
(JNIEnv *env, jclass, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkMain 
(JNIEnv *env, jobject);
 
 #ifdef __cplusplus
Index: gnu/java/awt/peer/gtk/GtkMainThread.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkMainThread.java,v
retrieving revision 1.11
diff -I*.class -u -r1.11 GtkMainThread.java
--- gnu/java/awt/peer/gtk/GtkMainThread.java    22 Jan 2002 22:26:56 -0000      
1.11
+++ gnu/java/awt/peer/gtk/GtkMainThread.java    7 Jul 2004 04:24:03 -0000
@@ -43,7 +43,15 @@
   private static Thread mainThread = null;
   private static Object mainThreadLock = new Object();
 
-  static native void gtkInit();
+  /**
+   * Call gtk_init.  It is very important that this happen before any other
+   * gtk calls.
+   *
+   * @param portableNativeSync 1 if the Java property
+   * gnu.classpath.awt.gtk.portable.native.sync is set to "true".  0 if it is
+   * set to "false".  -1 if unset.
+   */
+  static native void gtkInit(int portableNativeSync);
   native void gtkMain();
   
   public GtkMainThread() 
@@ -67,9 +75,22 @@
   
   public void run() 
   {
+    /* Pass the value of the gnu.classpath.awt.gtk.portable.native.sync system
+     * property to C. */ 
+    int portableNativeSync;     
+    String portNatSyncProp = 
+      System.getProperty("gnu.classpath.awt.gtk.portable.native.sync");
+
+    if (portNatSyncProp == null)
+      portableNativeSync = -1;  // unset
+    else if (Boolean.valueOf(portNatSyncProp).booleanValue())
+      portableNativeSync = 1;   // true
+    else
+      portableNativeSync = 0;   // false
+    
     synchronized (this) 
       {
-       gtkInit();
+       gtkInit(portableNativeSync);
        notify();
       }
     gtkMain();
Index: doc/vmintegration.texinfo
===================================================================
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.11
diff -I*.class -u -r1.11 vmintegration.texinfo
--- doc/vmintegration.texinfo   6 Jun 2004 04:36:54 -0000       1.11
+++ doc/vmintegration.texinfo   7 Jul 2004 04:24:03 -0000
@@ -310,7 +310,7 @@
 
 Classpath currently uses only JNI 1.1, except for one JNI 1.2 function
 in the JNI Invocation API: GetEnv().  And GetEnv() is only used in the
---portable-native-sync code, so it's only actually used by Jikes RVM
+``portable native sync'' code, so it's only actually used by Jikes RVM
 and Kaffe.  
 
 A future direction will probably be to require that all VMs provide
@@ -321,12 +321,42 @@
 @comment  node-name,  next,  previous,  up
 @section VM Threading Model
 
-Classpath's AWT peers use GTK+.  GTK+ uses GLIB.  GLIB by default uses
-the platform's native threading model -- pthreads in most cases.
+Classpath's AWT peers use GTK+.  GTK+ uses GLIB.  Normally, Classpath
+will initialize GLIB's @dfn{gthreads} to use
+the platform's native threading address@hidden native threading
+model is pthreads on Linux and AIX, the two platforms Classpath
+currently runs on.}
 
 If the Java runtime doesn't use the native threading model, then you
-should specify --portable-native-sync when configuring Classpath, so
-that GLIB will use the Java threading primitives instead.
+will want Classpath to tell GLIB to use the Java threading primitives
+instead.  Otherwise, GLIB would use the native threading model to
+perform operations such as creating thread-local data, and that just
+doesn't work on systems (such as Kaffe in some configurations, and
+such as Jikes RVM) that use @i{m}:@i{n} threading.
+
+Historically, enabling the Java threading primitives had been done at
+build time, by configuring classpath with the
address@hidden option.  This had bad consequences,
+though -- it meant that the prebuild GNU Classpath package distributed
+with Debian GNU/Linux would not be usable with VMs that could
+otherwise have used it.  Instead, we encourage
+the use of the Java system property
address@hidden  A VM that wants
+GLIB to use the Java threading primitives should modify
address@hidden()} to include code like the
+following:
+
address@hidden
+static void insertSystemProperties(Properties @var{p}) 
address@hidden example
+...
address@hidden
address@hidden("gnu.classpath.awt.gtk.portable.native.sync", "true");
address@hidden example
+
+So, the configure option
address@hidden is deprecated, and should go away in a
+subsequent release of GNU Classpath.
 
 @bye
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]