Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[marshal methods] Part 3 of ? #7163

Merged
merged 14 commits into from
Aug 19, 2022
Merged
6 changes: 6 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ void Run (DirectoryAssemblyResolver res)
string managedKey = type.FullName.Replace ('/', '.');
string javaKey = JavaNativeTypeManager.ToJniName (type, cache).Replace ('/', '.');

#if ENABLE_MARSHAL_METHODS
Console.WriteLine ($"##G2: {type.FullName} -> {javaKey}");
#endif
acw_map.Write (type.GetPartialAssemblyQualifiedName (cache));
acw_map.Write (';');
acw_map.Write (javaKey);
Expand Down Expand Up @@ -384,6 +387,9 @@ bool CreateJavaSources (IEnumerable<TypeDefinition> javaTypes, TypeDefinitionCac

bool ok = true;
foreach (var t in javaTypes) {
#if ENABLE_MARSHAL_METHODS
Console.WriteLine ($"##G0: JCW for {t.FullName}");
#endif
if (t.IsInterface) {
// Interfaces are in typemap but they shouldn't have JCW generated for them
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class Arm32LlvmIrGenerator : LlvmIrGenerator
public override int PointerSize => 4;
protected override string Triple => "armv7-unknown-linux-android"; // NDK appends API level, we don't need that

static readonly LlvmFunctionAttributeSet commonAttributes = new LlvmFunctionAttributeSet {
new FramePointerFunctionAttribute ("all"),
new TargetCpuFunctionAttribute ("generic"),
new TargetFeaturesFunctionAttribute ("+armv7-a,+d32,+dsp,+fp64,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,-aes,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-sha2,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp"),
};

public Arm32LlvmIrGenerator (AndroidTargetArch arch, StreamWriter output, string fileName)
: base (arch, output, fileName)
{}
Expand All @@ -25,5 +31,13 @@ protected override void AddModuleFlagsMetadata (List<LlvmIrMetadataItem> flagsFi
base.AddModuleFlagsMetadata (flagsFields);
flagsFields.Add (MetadataManager.AddNumbered (LlvmIrModuleMergeBehavior.Error, "min_enum_size", 4));
}

protected override void InitFunctionAttributes ()
{
base.InitFunctionAttributes ();

FunctionAttributes[FunctionAttributesXamarinAppInit].Add (commonAttributes);
FunctionAttributes[FunctionAttributesJniMethods].Add (commonAttributes);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class Arm64LlvmIrGenerator : LlvmIrGenerator
public override int PointerSize => 8;
protected override string Triple => "aarch64-unknown-linux-android"; // NDK appends API level, we don't need that

static readonly LlvmFunctionAttributeSet commonAttributes = new LlvmFunctionAttributeSet {
new FramePointerFunctionAttribute ("non-leaf"),
new TargetCpuFunctionAttribute ("generic"),
new TargetFeaturesFunctionAttribute ("+neon,+outline-atomics"),
};

public Arm64LlvmIrGenerator (AndroidTargetArch arch, StreamWriter output, string fileName)
: base (arch, output, fileName)
{}
Expand All @@ -29,5 +35,13 @@ protected override void AddModuleFlagsMetadata (List<LlvmIrMetadataItem> flagsFi
flagsFields.Add (MetadataManager.AddNumbered (LlvmIrModuleMergeBehavior.Error, "sign-return-address-all", 0));
flagsFields.Add (MetadataManager.AddNumbered (LlvmIrModuleMergeBehavior.Error, "sign-return-address-with-bkey", 0));
}

protected override void InitFunctionAttributes ()
{
base.InitFunctionAttributes ();

FunctionAttributes[FunctionAttributesXamarinAppInit].Add (commonAttributes);
FunctionAttributes[FunctionAttributesJniMethods].Add (commonAttributes);
}
}
}
Loading