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);
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
return;
}
@@ -674,21 +674,21 @@ public class MethodInliner {
//TODO: check it's external module
//TODO?: assert method exists in facade?
public String changeOwnerForExternalPackage(String type, int opcode) {
if (isSameModule || (opcode & Opcodes.INVOKESTATIC) == 0) {
return type;
}
//if (isSameModule || (opcode & Opcodes.INVOKESTATIC) == 0) {
// return type;
//}
JvmClassName name = JvmClassName.byInternalName(type);
String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(name.getPackageFqName());
if (type.startsWith(packageClassInternalName + '$')) {
VirtualFile virtualFile = InlineCodegenUtil.findVirtualFile(inliningContext.state.getProject(), type);
if (virtualFile != null) {
KotlinJvmBinaryClass klass = KotlinBinaryClassCache.getKotlinBinaryClass(virtualFile);
if (klass != null && klass.getClassHeader().getSyntheticClassKind() == KotlinSyntheticClass.Kind.PACKAGE_PART) {
return packageClassInternalName;
}
}
}
//JvmClassName name = JvmClassName.byInternalName(type);
//String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(name.getPackageFqName());
//if (type.startsWith(packageClassInternalName + '$')) {
// VirtualFile virtualFile = InlineCodegenUtil.findVirtualFile(inliningContext.state.getProject(), type);
// if (virtualFile != null) {
// KotlinJvmBinaryClass klass = KotlinBinaryClassCache.getKotlinBinaryClass(virtualFile);
// if (klass != null && klass.getClassHeader().getSyntheticClassKind() == KotlinSyntheticClass.Kind.PACKAGE_PART) {
// return packageClassInternalName;
// }
// }
//}
return type;
}
@@ -80,4 +80,4 @@ public class Concat : IntrinsicMethod() {
}
}
}
}
}
@@ -159,7 +159,7 @@ public class JetTypeMapper {
@NotNull CallableMemberDescriptor descriptor,
boolean insideModule
) {
if (insideModule) {
///if (insideModule) {
JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
if (file != null) {
return PackagePartClassUtils.getPackagePartInternalName(file);
@@ -171,9 +171,11 @@ public class JetTypeMapper {
FqName packagePartFqName = PackagePartClassUtils.getPackagePartFqName((DeserializedCallableMemberDescriptor) directMember);
return internalNameByFqNameWithoutInnerClasses(packagePartFqName);
}
}
return PackageClassUtils.getPackageClassInternalName(packageFragment.getFqName());
//}
throw new RuntimeException("Unreachable state");
//return PackageClassUtils.getPackageClassInternalName(packageFragment.getFqName());
}
@NotNull
@@ -35,7 +35,7 @@ fun box(): String {
return "Link error expected on object"
}
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"
}
@@ -36,8 +36,8 @@ fun check(body: () -> Unit, signature: String): String? {
}
fun box(): String {
return check({defaultGetter}, "_DefaultPackage.getDefaultGetter()I")
?: check({defaultSetter = 1}, "_DefaultPackage.setDefaultSetter(I)V")
return check({defaultGetter}, "NativePropertyAccessorsKt.getDefaultGetter()I")
?: check({defaultSetter = 1}, "NativePropertyAccessorsKt.setDefaultSetter(I)V")
?: check({C.defaultGetter}, "C\$Companion.getDefaultGetter()I")
?: check({C.defaultSetter = 1}, "C\$Companion.setDefaultSetter(I)V")
@@ -13,7 +13,7 @@ fun box(): String {
return "Link error expected on object"
}
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"
@@ -8,5 +8,5 @@ fun test2() {
prop
}
// 1 a/APackage.test1 \(\)V
// 1 a/APackage.getProp \(\)I
// 1 a/SourceKt.test1 \(\)V
// 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
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
stepIntoStdlibFacadeClass.kt:6
SequenceKt.!EXT!
_Mapping.!EXT!
Iterators.!EXT!
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0
@@ -1,5 +1,5 @@
Cleaning output files:
out/production/module/Foo.class
out/production/module/FooKt.class
out/production/module/_DefaultPackage.class
End of files
Compiling files:
@@ -1,5 +1,5 @@
Cleaning output files:
out/production/module/Foo.class
out/production/module/FooKt.class
out/production/module/_DefaultPackage.class
End of files
Compiling files: