diff options
author | jfrijters <jfrijters> | 2013-08-07 13:26:23 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2013-08-07 13:26:23 +0400 |
commit | c23b753f138cfd97bc859aef6edcb8c7f78901f8 (patch) | |
tree | eaf713a38ce7b2ba46a3a13b1648b15308c4dd3d | |
parent | f49d9c8c00ff6bc5d85538f1516c5aec160b04b2 (diff) |
Added optimization to omit ImplementAttribute in some cases.
-rw-r--r-- | openjdk/response.txt | 30 | ||||
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 46 | ||||
-rw-r--r-- | runtime/TypeWrapper.cs | 23 |
3 files changed, 61 insertions, 38 deletions
diff --git a/openjdk/response.txt b/openjdk/response.txt index a09e5342..fff0d642 100644 --- a/openjdk/response.txt +++ b/openjdk/response.txt @@ -428,7 +428,7 @@ assembly.class } { -out:IKVM.OpenJDK.XML.Bind.dll - -baseaddress:0x582E0000 + -baseaddress:0x582B0000 -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:0x58640000 + -baseaddress:0x58610000 -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:0x58BB0000 + -baseaddress:0x58B80000 -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:0x58D00000 + -baseaddress:0x58CD0000 -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:0x59ED0000 + -baseaddress:0x59EA0000 -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:0x5A560000 + -baseaddress:0x5A530000 -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:0x5AB30000 + -baseaddress:0x5AB00000 -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:0x5ADA0000 + -baseaddress:0x5AD70000 -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:0x5B5B0000 + -baseaddress:0x5B580000 com/sun/management/*.class java/lang/management/*.class sun/management/*.class @@ -892,7 +892,7 @@ assembly.class } { -out:IKVM.OpenJDK.Misc.dll - -baseaddress:0x5B910000 + -baseaddress:0x5B8E0000 -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:0x5BA30000 + -baseaddress:0x5BA00000 -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:0x5BB80000 + -baseaddress:0x5BB50000 -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:0x5BCD0000 + -baseaddress:0x5BCA0000 -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:0x5BDF0000 + -baseaddress:0x5BDC0000 @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:0x5BEB0000 + -baseaddress:0x5BE80000 -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 dadaf6b4..2037ce22 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -829,7 +829,6 @@ namespace IKVM.Internal { AddCliEnum(); } - AddImplementsAttribute(); AddInnerClassAttribute(enclosing != null, outerClass.innerClass != 0, mangledTypeName, outerClass.accessFlags); if (classFile.DeprecatedAttribute && !Annotation.HasObsoleteAttribute(classFile.Annotations)) { @@ -901,17 +900,6 @@ namespace IKVM.Internal } #if STATIC_COMPILER - private void AddImplementsAttribute() - { - TypeWrapper[] interfaces = wrapper.Interfaces; - string[] implements = new string[interfaces.Length]; - for (int i = 0; i < implements.Length; i++) - { - implements[i] = interfaces[i].Name; - } - AttributeHelper.SetImplementsAttribute(typeBuilder, interfaces); - } - private void AddInnerClassAttribute(bool isNestedType, bool isInnerClass, string mangledTypeName, Modifiers innerClassFlags) { string name = classFile.Name; @@ -4283,6 +4271,10 @@ namespace IKVM.Internal } } +#if STATIC_COMPILER + AddImplementsAttribute(); +#endif + Type type; Profiler.Enter("TypeBuilder.CreateType"); try @@ -4314,6 +4306,36 @@ namespace IKVM.Internal } #if STATIC_COMPILER + private void AddImplementsAttribute() + { + TypeWrapper[] interfaces = wrapper.Interfaces; + if (wrapper.BaseTypeWrapper == CoreClasses.java.lang.Object.Wrapper) + { + // We special case classes extending java.lang.Object to optimize the metadata encoding + // for anonymous classes that implement an interface. + Type[] actualInterfaces = typeBuilder.GetInterfaces(); + if (actualInterfaces.Length == 0) + { + return; + } + else if (actualInterfaces.Length == 1 + && interfaces.Length == 1 + && !interfaces[0].IsRemapped + && interfaces[0].TypeAsBaseType == actualInterfaces[0]) + { + // We extend java.lang.Object and implement only a single (non-remapped) interface, + // in this case we can omit the ImplementAttribute since the runtime will be able + // to reliable reproduce the "list" of implemented interfaces. + return; + } + } + else if (interfaces.Length == 0) + { + return; + } + AttributeHelper.SetImplementsAttribute(typeBuilder, interfaces); + } + private TypeBuilder DefineNestedInteropType(string name) { CompilerClassLoader ccl = wrapper.classLoader; diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index 612f88c0..1522274a 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -528,19 +528,16 @@ namespace IKVM.Internal #if STATIC_COMPILER internal static void SetImplementsAttribute(TypeBuilder typeBuilder, TypeWrapper[] ifaceWrappers) { - if(ifaceWrappers != null && ifaceWrappers.Length != 0) + string[] interfaces = new string[ifaceWrappers.Length]; + for(int i = 0; i < interfaces.Length; i++) { - string[] interfaces = new string[ifaceWrappers.Length]; - for(int i = 0; i < interfaces.Length; i++) - { - interfaces[i] = ifaceWrappers[i].Name; - } - if(implementsAttribute == null) - { - implementsAttribute = typeofImplementsAttribute.GetConstructor(new Type[] { JVM.Import(typeof(string[])) }); - } - typeBuilder.SetCustomAttribute(new CustomAttributeBuilder(implementsAttribute, new object[] { interfaces })); + interfaces[i] = ifaceWrappers[i].Name; } + if(implementsAttribute == null) + { + implementsAttribute = typeofImplementsAttribute.GetConstructor(new Type[] { JVM.Import(typeof(string[])) }); + } + typeBuilder.SetCustomAttribute(new CustomAttributeBuilder(implementsAttribute, new object[] { interfaces })); } #endif @@ -3846,6 +3843,10 @@ namespace IKVM.Internal ImplementsAttribute attr = AttributeHelper.GetImplements(type); if (attr == null) { + if (BaseTypeWrapper == CoreClasses.java.lang.Object.Wrapper) + { + return GetImplementedInterfacesAsTypeWrappers(type); + } return TypeWrapper.EmptyArray; } string[] interfaceNames = attr.Interfaces; |