diff options
author | jfrijters <jfrijters> | 2013-08-07 16:15:18 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2013-08-07 16:15:18 +0400 |
commit | 9201af77c0d506d003a7529fa956b1b59ed5b25e (patch) | |
tree | 6c53afa799f04515b1699797fbd94657762faa98 | |
parent | c23b753f138cfd97bc859aef6edcb8c7f78901f8 (diff) |
Added optimization to omit InnerClassesAttribute to record reflective modifiers when we can predict them.
-rw-r--r-- | openjdk/response.txt | 40 | ||||
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 2 | ||||
-rw-r--r-- | runtime/TypeWrapper.cs | 53 |
3 files changed, 70 insertions, 25 deletions
diff --git a/openjdk/response.txt b/openjdk/response.txt index fff0d642..59ddd33c 100644 --- a/openjdk/response.txt +++ b/openjdk/response.txt @@ -167,7 +167,7 @@ assembly.class } { -out:IKVM.OpenJDK.Corba.dll - -baseaddress:0x56C60000 + -baseaddress:0x56C30000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/corba/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/jndi/cosnaming/jndiprovider.properties @OPENJDK7@/build/linux-amd64/impsrc/com/sun/corba/se/impl/activation/*.class @@ -285,7 +285,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.API.dll - -baseaddress:0x572C0000 + -baseaddress:0x57290000 @OPENJDK7@/build/linux-amd64/impsrc/javax/xml/*.class @OPENJDK7@/build/linux-amd64/impsrc/javax/xml/datatype/*.class @OPENJDK7@/build/linux-amd64/impsrc/javax/xml/namespace/*.class @@ -318,7 +318,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.XPath.dll - -baseaddress:0x57380000 + -baseaddress:0x57350000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xalan/internal/res/* @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/extensions/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/res/*.class @@ -343,7 +343,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.Parse.dll - -baseaddress:0x576E0000 + -baseaddress:0x576B0000 -resource:com/sun/org/apache/xml/internal/serialize/HTMLEntities.res=@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xml/internal/serialize/HTMLEntities.res -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xerces/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xml/internal/serializer/* @@ -404,7 +404,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.Transform.dll - -baseaddress:0x57E90000 + -baseaddress:0x57E60000 @OPENJDK7@/build/linux-amd64/impsrc/com/sun/java_cup/internal/runtime/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/bcel/internal/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/bcel/internal/classfile/*.class @@ -428,7 +428,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.Bind.dll - -baseaddress:0x582B0000 + -baseaddress:0x58280000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/javax/xml/bind/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/xml/internal/bind/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/xml/internal/fastinfoset/* @@ -487,7 +487,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.WebServices.dll - -baseaddress:0x58610000 + -baseaddress:0x585E0000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/xml/internal/messaging/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/xml/internal/ws/* @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/glassfish/external/amx/*.class @@ -607,7 +607,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.Crypto.dll - -baseaddress:0x58B80000 + -baseaddress:0x58B50000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xml/internal/security/* @OPENJDK7@/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/*.class @OPENJDK7@/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/*.class @@ -643,7 +643,7 @@ assembly.class } { -out:IKVM.OpenJDK.SwingAWT.dll - -baseaddress:0x58CD0000 + -baseaddress:0x58CA0000 -remap:swingawt.xml -resource:META-INF/services/sun.java2d.pipe.RenderingEngine=resources/META-INF/services/sun.java2d.pipe.RenderingEngine -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/META-INF/services/sun.java2d.cmm.PCMM @@ -743,7 +743,7 @@ assembly.class } { -out:IKVM.OpenJDK.Charsets.dll - -baseaddress:0x59EA0000 + -baseaddress:0x59E40000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/charsets.jar/sun/nio/cs/ext/sjis0213.dat -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/charsets.jar/META-INF/services/java.nio.charset.spi.CharsetProvider @OPENJDK7@/build/linux-amd64/gensrc/sun/nio/cs/ext/*.class @@ -752,7 +752,7 @@ assembly.class } { -out:IKVM.OpenJDK.Util.dll - -baseaddress:0x5A530000 + -baseaddress:0x5A4D0000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/java/util/jar/pack/intrinsic.properties -recurse:resources.zip/sun/launcher/resources/* -resource:META-INF/services/java.nio.file.spi.FileSystemProvider=@OPENJDK7@/jdk/src/share/demo/nio/zipfs/src/META-INF/services/java.nio.file.spi.FileSystemProvider @@ -775,7 +775,7 @@ assembly.class } { -out:IKVM.OpenJDK.Text.dll - -baseaddress:0x5AB00000 + -baseaddress:0x5AAA0000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/sun/text/* @OPENJDK7@/build/linux-amd64/j2re-image/lib/ext/localedata.jar @OPENJDK7@/jdk/src/share/classes/java/text/*.class @@ -787,7 +787,7 @@ assembly.class } { -out:IKVM.OpenJDK.Security.dll - -baseaddress:0x5AD70000 + -baseaddress:0x5AD10000 -remap:security.xml sun/security/jgss/wrapper/*.class @OPENJDK7@/jdk/src/share/classes/com/sun/crypto/provider/*.class @@ -858,7 +858,7 @@ assembly.class } { -out:IKVM.OpenJDK.Management.dll - -baseaddress:0x5B580000 + -baseaddress:0x5B520000 com/sun/management/*.class java/lang/management/*.class sun/management/*.class @@ -892,7 +892,7 @@ assembly.class } { -out:IKVM.OpenJDK.Misc.dll - -baseaddress:0x5B8E0000 + -baseaddress:0x5B880000 -resource:com/sun/servicetag/resources/javase_5_swordfish.properties=@OPENJDK7@/jdk/src/share/classes/com/sun/servicetag/resources/javase_5_swordfish.properties -resource:com/sun/servicetag/resources/javase_6_swordfish.properties=@OPENJDK7@/jdk/src/share/classes/com/sun/servicetag/resources/javase_6_swordfish.properties -resource:com/sun/servicetag/resources/javase_7_swordfish.properties=@OPENJDK7@/jdk/src/share/classes/com/sun/servicetag/resources/javase_7_swordfish.properties @@ -993,7 +993,7 @@ assembly.class } { -out:IKVM.OpenJDK.Naming.dll - -baseaddress:0x5BA00000 + -baseaddress:0x5B9A0000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/jndi/ldap/jndiprovider.properties -resource:META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor=@OPENJDK7@/jdk/src/share/classes/sun/net/spi/nameservice/dns/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor sun/net/dns/*.class @@ -1019,7 +1019,7 @@ assembly.class } { -out:IKVM.OpenJDK.Jdbc.dll - -baseaddress:0x5BB50000 + -baseaddress:0x5BAF0000 -resource:META-INF/services/java.sql.Driver=resources/META-INF/services/java.sql.Driver -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/rowset/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/javax/sql/* @@ -1037,7 +1037,7 @@ assembly.class } { -out:IKVM.OpenJDK.Remoting.dll - -baseaddress:0x5BCA0000 + -baseaddress:0x5BC40000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/sun/rmi/* @OPENJDK7@/build/linux-amd64/classes/sun/rmi/registry/*.class @OPENJDK7@/build/linux-amd64/classes/sun/rmi/server/*.class @@ -1063,7 +1063,7 @@ assembly.class } { -out:IKVM.OpenJDK.Beans.dll - -baseaddress:0x5BDC0000 + -baseaddress:0x5BD60000 @OPENJDK7@/build/linux-amd64/impsrc/com/sun/activation/registries/*.class @OPENJDK7@/build/linux-amd64/impsrc/javax/activation/*.class @OPENJDK7@/jdk/src/share/classes/com/sun/beans/*.class @@ -1076,7 +1076,7 @@ assembly.class } { -out:IKVM.OpenJDK.Media.dll - -baseaddress:0x5BE80000 + -baseaddress:0x5BE20000 -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/META-INF/services/javax.print.* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/META-INF/services/javax.sound.* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/imageio/plugins/common/iio-plugin.properties diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 2037ce22..86b091a5 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -916,7 +916,7 @@ namespace IKVM.Internal name = null; } - if (isInnerClass || name != null) + if ((isInnerClass && CompiledTypeWrapper.PredictReflectiveModifiers(wrapper) != innerClassFlags) || name != null) { // HACK we abuse the InnerClassAttribute to record to real name for non-inner classes as well AttributeHelper.SetInnerClass(typeBuilder, name, isInnerClass ? innerClassFlags : wrapper.Modifiers); diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index 1522274a..8bcf3824 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -3697,10 +3697,10 @@ namespace IKVM.Internal { return name; } - if(type.DeclaringType != null) - { - return GetName(type.DeclaringType) + "$" + TypeNameUtil.Unescape(type.Name); - } + } + if(type.DeclaringType != null) + { + return GetName(type.DeclaringType) + "$" + TypeNameUtil.Unescape(type.Name); } return TypeNameUtil.Unescape(type.FullName); } @@ -3958,6 +3958,47 @@ namespace IKVM.Internal } } + // returns true iff name is of the form "...$<n>" + private static bool IsAnonymousClassName(string name) + { + int index = name.LastIndexOf('$') + 1; + if (index > 1 && index < name.Length) + { + while (index < name.Length) + { + if ("0123456789".IndexOf(name[index++]) == -1) + { + return false; + } + } + return true; + } + return false; + } + + // This method uses some heuristics to predict the reflective modifiers and if the prediction matches + // we can avoid storing the InnerClassesAttribute to record the modifiers. + // The heuristics are based on javac from Java 7. + internal static Modifiers PredictReflectiveModifiers(TypeWrapper tw) + { + Modifiers modifiers = Modifiers.Static | (tw.Modifiers & (Modifiers.Public | Modifiers.Abstract | Modifiers.Interface)); + // javac marks anonymous classes as final, but the InnerClasses attribute access_flags does not have the ACC_FINAL flag set + if (tw.IsFinal && !IsAnonymousClassName(tw.Name)) + { + modifiers |= Modifiers.Final; + } + // javac uses the this$0 field to store the outer instance reference for non-static inner classes + foreach (FieldWrapper fw in tw.GetFields()) + { + if (fw.Name == "this$0") + { + modifiers &= ~Modifiers.Static; + break; + } + } + return modifiers; + } + internal override Modifiers ReflectiveModifiers { get @@ -3972,6 +4013,10 @@ namespace IKVM.Internal // (minus ACC_SUPER) mods = attr.Modifiers & (Modifiers)0x761F; } + else if (type.DeclaringType != null) + { + mods = PredictReflectiveModifiers(this); + } else { // the mask comes from JVM_RECOGNIZED_CLASS_MODIFIERS in src/hotspot/share/vm/prims/jvm.h |