classpath
[Top][All Lists]
Advanced

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

Re: performance problems with classpath 0.09 on Jikes RVM


From: David P Grove
Subject: Re: performance problems with classpath 0.09 on Jikes RVM
Date: Fri, 7 May 2004 22:13:03 -0400


Here's a patch.  Works with Jikes RVM and reduces our classpath 0.09 performance degradation on _228_jack to a slightly more tolerable 5%.  Eliot's point is probably a good one though, this is an unfortunate place to be having to cross JNI boundaries.  Probably the right long term solution for Jikes RVM is to provide our own all Java  version of FileChannelImpl that avoids exposing us to the remaining performance problems.  This would also let us hook into the nonblocking I/O layer in Jikes RVM if we wanted to.

--dave

Index: gnu_java_nio_channels_FileChannelImpl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v
retrieving revision 1.10
diff -u -r1.10 gnu_java_nio_channels_FileChannelImpl.c
--- gnu_java_nio_channels_FileChannelImpl.c        1 May 2004 10:40:56 -0000        1.10
+++ gnu_java_nio_channels_FileChannelImpl.c        8 May 2004 02:01:20 -0000
@@ -87,11 +87,27 @@
#define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF))
#define CONVERT_JINT_TO_SSIZE_T(x) (x)

+/* cache fieldID of gnu.java.nio.channels.FileChannelImpl.fd */
+static jfieldID native_fd_fieldID;
+
static jint get_native_fd(JNIEnv *env, jobject obj)
{
+  return (*env)->GetIntField (env, obj, native_fd_fieldID);
+}
+
+/*
+ * Library initialization routine.  Called as part of java.io.FileDescriptor
+ * static initialization.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_channels_FileChannelImpl_init (JNIEnv *env, jclass clazz)
+{
  jclass clazz_fc;

-  jfieldID field_fd;
+  jfieldID field;
+  jmethodID constructor;
+  jobject obj;

+  /* Initialize native_fd_fieldID so we only compute it once! */
  clazz_fc = (*env)->FindClass (env, "gnu/java/nio/channels/FileChannelImpl");
  if (!clazz_fc)
    {
@@ -99,26 +115,14 @@
      return -1;
    }

-  field_fd = (*env)->GetFieldID (env, clazz_fc, "fd", "I");
-  if (!field_fd)                                                        
+  field = (*env)->GetFieldID (env, clazz_fc, "fd", "I");
+  if (!field)                                                        
    {                                                                        
      JCL_ThrowException(env, IO_EXCEPTION, "Internal error");                
      return -1;                                                        
-    }                                                                        
-
-  return (*env)->GetIntField (env, obj, field_fd);
-}
+    }

-/*
- * Library initialization routine.  Called as part of java.io.FileDescriptor
- * static initialization.
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_nio_channels_FileChannelImpl_init (JNIEnv *env, jclass clazz)
-{
-  jfieldID field;
-  jmethodID constructor;
-  jobject obj;
+  native_fd_fieldID = field;

  constructor = (*env)->GetMethodID (env, clazz, "<init>", "(II)V");

   if (! constructor)

reply via email to

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