United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6588413 : Use -fvisibility=hidden for gcc compiles

Details
Type:
Enhancement
Submit Date:
2007-08-02
Status:
Closed
Updated Date:
2013-03-08
Project Name:
JDK
Resolved Date:
2011-04-24
Component:
hotspot
OS:
linux
Sub-Component:
build
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2_18
Fixed Versions:
hs21 (b02)

Related Reports
Backport:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
On compiling the JDK code with the new gcc compiler option "-fvisibility=hidden"quite some speed improvements on all platforms are observed, but for it to work, SAP code which is marked with "JNI_EXPORT" needs to be exported correctly by the compiler. The attached patch fixes this.

The attached "jni_md.h.new" file is a version of the file, how it could look like.
% more jni_md.h.diff
--- jni_md.h    2007-07-19 15:13:07.661299000 +0200
+++ jni_md.h.new        2007-07-19 15:12:02.826109000 +0200
@@ -8,9 +8,16 @@
 #ifndef _JAVASOFT_JNI_MD_H_
 #define _JAVASOFT_JNI_MD_H_

-#define JNIEXPORT
-#define JNIIMPORT
-#define JNICALL
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+# define JNIEXPORT     __attribute__((visibility("default")))
+# define JNIIMPORT     __attribute__((visibility("default")))
+# define JNICALL
+#else
+# define JNIEXPORT
+# define JNIIMPORT
+# define JNICALL
+#endif
+

 typedef int jint;
 #ifdef _LP64 /* 64-bit Solaris */

                                    

Comments
PUBLIC COMMENTS

See

http://gcc.gnu.org/wiki/Visibility
                                     
2010-09-01
EVALUATION

I don't see a performance increase with this version of gcc for specjvm98.  What performance improvements did the customer find get faster and what version of gcc? thanks.

crocker% g++ --version
g++ (Ubuntu 4.4.1-4ubuntu8) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
                                     
2011-01-18
EVALUATION

We get no improvements with this option so I would like to close this as WNF, unless the open source community needs the JNIEXPORT and JNIIMPORT change in the description for merging purposes.  Reducing priority at any rate and not fixing for jdk7.
                                     
2011-01-20
EVALUATION

Summary: Add option for gcc 4 and above, define JNIEXPORT and JNIIMPORT to visib
ility=default, add for jio_snprintf and others since -fvisibility=hidden overrid
es --version-script definitions.
                                     
2011-02-01



Hardware and Software, Engineered to Work Together