Generate calls through new minifacades

This commit is contained in:
Michael Bogdanov
2015-08-31 14:48:35 +03:00
parent 0289b8e290
commit 47635c19a2
11 changed files with 31 additions and 28 deletions
@@ -151,7 +151,8 @@ public class FunctionCodegen {
int flags = getMethodAsmFlags(functionDescriptor, contextKind); int flags = getMethodAsmFlags(functionDescriptor, contextKind);
boolean isNative = NativeDeclarationsPackage.hasNativeAnnotation(functionDescriptor); boolean isNative = NativeDeclarationsPackage.hasNativeAnnotation(functionDescriptor);
if (isNative && owner instanceof PackageContext && !(owner instanceof PackageFacadeContext)) { //TODO: generate native method only in new mini facades (now it equals to package part)
if (isNative && owner instanceof PackageFacadeContext) {
// Native methods are only defined in package facades and do not need package part implementations // Native methods are only defined in package facades and do not need package part implementations
return; return;
} }
@@ -674,21 +674,21 @@ public class MethodInliner {
//TODO: check it's external module //TODO: check it's external module
//TODO?: assert method exists in facade? //TODO?: assert method exists in facade?
public String changeOwnerForExternalPackage(String type, int opcode) { public String changeOwnerForExternalPackage(String type, int opcode) {
if (isSameModule || (opcode & Opcodes.INVOKESTATIC) == 0) { //if (isSameModule || (opcode & Opcodes.INVOKESTATIC) == 0) {
return type; // return type;
} //}
JvmClassName name = JvmClassName.byInternalName(type); //JvmClassName name = JvmClassName.byInternalName(type);
String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(name.getPackageFqName()); //String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(name.getPackageFqName());
if (type.startsWith(packageClassInternalName + '$')) { //if (type.startsWith(packageClassInternalName + '$')) {
VirtualFile virtualFile = InlineCodegenUtil.findVirtualFile(inliningContext.state.getProject(), type); // VirtualFile virtualFile = InlineCodegenUtil.findVirtualFile(inliningContext.state.getProject(), type);
if (virtualFile != null) { // if (virtualFile != null) {
KotlinJvmBinaryClass klass = KotlinBinaryClassCache.getKotlinBinaryClass(virtualFile); // KotlinJvmBinaryClass klass = KotlinBinaryClassCache.getKotlinBinaryClass(virtualFile);
if (klass != null && klass.getClassHeader().getSyntheticClassKind() == KotlinSyntheticClass.Kind.PACKAGE_PART) { // if (klass != null && klass.getClassHeader().getSyntheticClassKind() == KotlinSyntheticClass.Kind.PACKAGE_PART) {
return packageClassInternalName; // return packageClassInternalName;
} // }
} // }
} //}
return type; return type;
} }
@@ -80,4 +80,4 @@ public class Concat : IntrinsicMethod() {
} }
} }
} }
} }
@@ -159,7 +159,7 @@ public class JetTypeMapper {
@NotNull CallableMemberDescriptor descriptor, @NotNull CallableMemberDescriptor descriptor,
boolean insideModule boolean insideModule
) { ) {
if (insideModule) { ///if (insideModule) {
JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor); JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
if (file != null) { if (file != null) {
return PackagePartClassUtils.getPackagePartInternalName(file); return PackagePartClassUtils.getPackagePartInternalName(file);
@@ -171,9 +171,11 @@ public class JetTypeMapper {
FqName packagePartFqName = PackagePartClassUtils.getPackagePartFqName((DeserializedCallableMemberDescriptor) directMember); FqName packagePartFqName = PackagePartClassUtils.getPackagePartFqName((DeserializedCallableMemberDescriptor) directMember);
return internalNameByFqNameWithoutInnerClasses(packagePartFqName); return internalNameByFqNameWithoutInnerClasses(packagePartFqName);
} }
}
return PackageClassUtils.getPackageClassInternalName(packageFragment.getFqName()); //}
throw new RuntimeException("Unreachable state");
//return PackageClassUtils.getPackageClassInternalName(packageFragment.getFqName());
} }
@NotNull @NotNull
@@ -35,7 +35,7 @@ fun box(): String {
return "Link error expected on object" return "Link error expected on object"
} }
catch (e: java.lang.UnsatisfiedLinkError) { catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.FooPackage.topLevel(I)D") return "Fail 3: " + e.getMessage() if (e.getMessage() != "foo.DefaultKt.topLevel(I)D") return "Fail 3: " + e.getMessage()
} }
return "OK" return "OK"
} }
@@ -36,8 +36,8 @@ fun check(body: () -> Unit, signature: String): String? {
} }
fun box(): String { fun box(): String {
return check({defaultGetter}, "_DefaultPackage.getDefaultGetter()I") return check({defaultGetter}, "NativePropertyAccessorsKt.getDefaultGetter()I")
?: check({defaultSetter = 1}, "_DefaultPackage.setDefaultSetter(I)V") ?: check({defaultSetter = 1}, "NativePropertyAccessorsKt.setDefaultSetter(I)V")
?: check({C.defaultGetter}, "C\$Companion.getDefaultGetter()I") ?: check({C.defaultGetter}, "C\$Companion.getDefaultGetter()I")
?: check({C.defaultSetter = 1}, "C\$Companion.setDefaultSetter(I)V") ?: check({C.defaultSetter = 1}, "C\$Companion.setDefaultSetter(I)V")
@@ -13,7 +13,7 @@ fun box(): String {
return "Link error expected on object" return "Link error expected on object"
} }
catch (e: java.lang.UnsatisfiedLinkError) { catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.FooPackage.bar(JLjava/lang/String;)D") return "Fail 1: " + e.getMessage() if (e.getMessage() != "foo.TopLevelKt.bar(JLjava/lang/String;)D") return "Fail 1: " + e.getMessage()
} }
return "OK" return "OK"
@@ -8,5 +8,5 @@ fun test2() {
prop prop
} }
// 1 a/APackage.test1 \(\)V // 1 a/SourceKt.test1 \(\)V
// 1 a/APackage.getProp \(\)I // 1 a/SourceKt.getProp \(\)I
@@ -2,8 +2,8 @@ LineBreakpoint created at stepIntoStdlibFacadeClass.kt:6
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlibFacadeClass.StepIntoStdlibFacadeClassPackage !JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlibFacadeClass.StepIntoStdlibFacadeClassPackage
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
stepIntoStdlibFacadeClass.kt:6 stepIntoStdlibFacadeClass.kt:6
SequenceKt.!EXT!
_Mapping.!EXT! _Mapping.!EXT!
Iterators.!EXT!
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0 Process finished with exit code 0
@@ -1,5 +1,5 @@
Cleaning output files: Cleaning output files:
out/production/module/Foo.class out/production/module/FooKt.class
out/production/module/_DefaultPackage.class out/production/module/_DefaultPackage.class
End of files End of files
Compiling files: Compiling files:
@@ -1,5 +1,5 @@
Cleaning output files: Cleaning output files:
out/production/module/Foo.class out/production/module/FooKt.class
out/production/module/_DefaultPackage.class out/production/module/_DefaultPackage.class
End of files End of files
Compiling files: Compiling files: