Imported Upstream version 5.20.0.180

Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-04 20:11:37 +00:00
parent 0e2d47d1c8
commit 0510252385
3360 changed files with 83827 additions and 39243 deletions

View File

@@ -18,7 +18,7 @@ typedef struct BundleMonoAPI
{
void (*mono_register_bundled_assemblies) (const MonoBundledAssembly **assemblies);
void (*mono_register_config_for_assembly) (const char* assembly_name, const char* config_xml);
void (*mono_jit_set_aot_mode) (int mode);
void (*mono_jit_set_aot_mode) (MonoAotMode mode);
void (*mono_aot_register_module) (void* aot_info);
void (*mono_config_parse_memory) (const char *buffer);
void (*mono_register_machine_config) (const char *config_xml);

View File

@@ -470,7 +470,7 @@ class MakeBundle {
// Modern bundling starts here
if (!custom_mode){
if (runtime != null){
// Nothing to do here, the user has chosen to manually specify --runtime nad libraries
// Nothing to do here, the user has chosen to manually specify --runtime and libraries
} else if (sdk_path != null) {
VerifySdk (sdk_path);
} else if (cross_target == "default" || cross_target == null){
@@ -655,15 +655,28 @@ class MakeBundle {
class PackageMaker {
Dictionary<string, Tuple<long,int>> locations = new Dictionary<string, Tuple<long,int>> ();
const int align = 4096;
int align = 4096; // first non-Windows alignment, saving on average 30K
Stream package;
public PackageMaker (string output)
public PackageMaker (string runtime, string output)
{
package = File.Create (output, 128*1024);
if (IsUnix){
File.SetAttributes (output, unchecked ((FileAttributes) 0x80000000));
}
Console.WriteLine ("Using runtime: " + runtime);
// Probe for MZ signature to decide if we are targeting Windows,
// so we can optimize an average of 30K away on Unix.
using (Stream runtimeStream = File.OpenRead (runtime)) {
var runtimeBuffer = new byte [2];
if (runtimeStream.Read (runtimeBuffer, 0, 2) == 2
&& runtimeBuffer [0] == (byte)'M'
&& runtimeBuffer [1] == (byte)'Z')
align = 1 << 16; // first Windows alignment
}
AddFile (runtime);
}
public int AddFile (string fname)
@@ -675,6 +688,7 @@ class MakeBundle {
Console.WriteLine ("At {0:x} with input {1}", package.Position, fileStream.Length);
fileStream.CopyTo (package);
package.Position = package.Position + (align - (package.Position % align));
align = 4096; // rest of alignment for all systems
return (int) ret;
}
}
@@ -688,14 +702,17 @@ class MakeBundle {
public void AddString (string entry, string text)
{
// FIXME Strings are over-aligned?
var bytes = Encoding.UTF8.GetBytes (text);
locations [entry] = Tuple.Create (package.Position, bytes.Length);
package.Write (bytes, 0, bytes.Length);
package.WriteByte (0);
package.Position = package.Position + (align - (package.Position % align));
}
public void AddStringPair (string entry, string key, string value)
{
// FIXME Strings are over-aligned?
var kbytes = Encoding.UTF8.GetBytes (key);
var vbytes = Encoding.UTF8.GetBytes (value);
@@ -785,9 +802,7 @@ class MakeBundle {
return false;
}
var maker = new PackageMaker (output);
Console.WriteLine ("Using runtime: " + runtime);
maker.AddFile (runtime);
var maker = new PackageMaker (runtime, output);
foreach (var url in files){
string fname = LocateFile (new Uri (url).LocalPath);
@@ -884,6 +899,7 @@ typedef struct {
template_stream.Dispose ();
if (compress) {
tc.WriteLine ("#define USE_COMPRESSED_ASSEMBLY\n");
tc.WriteLine ("typedef struct _compressed_data {");
tc.WriteLine ("\tMonoBundledAssembly assembly;");
tc.WriteLine ("\tint compressed_size;");
@@ -973,7 +989,7 @@ typedef struct {
FileStream cf = File.OpenRead (fname + ".config");
if (!quiet)
Console.WriteLine (" config from: " + fname + ".config");
tc.WriteLine ("extern const unsigned char assembly_config_{0} [];", encoded);
tc.WriteLine ("extern const char assembly_config_{0} [];", encoded);
WriteSymbol (ts, "assembly_config_" + encoded, cf.Length);
WriteBuffer (ts, cf, buffer);
ts.WriteLine ();
@@ -1044,7 +1060,8 @@ typedef struct {
tc.WriteLine ("\textern const void *mono_aot_module_{0}_info;", asm);
}
tc.WriteLine ("\nstatic void install_aot_modules (void) {\n");
tc.WriteLine ("\n#ifndef USE_COMPRESSED_ASSEMBLY\n");
tc.WriteLine ("static void install_aot_modules (void) {\n");
foreach (string asm in aot_names){
tc.WriteLine ("\tmono_api.mono_aot_register_module (mono_aot_module_{0}_info);\n", asm);
}
@@ -1066,6 +1083,7 @@ typedef struct {
tc.WriteLine ("\tmono_api.mono_jit_set_aot_mode ({0});", enum_aot_mode);
tc.WriteLine ("\n}\n");
tc.WriteLine ("#endif\n");
tc.WriteLine ("static char *image_name = \"{0}\";", prog);

View File

@@ -18,6 +18,8 @@ void initialize_mono_api (const BundleMonoAPI *info)
mono_api.mono_register_machine_config = info->mono_register_machine_config;
}
#ifdef USE_COMPRESSED_ASSEMBLY
static int
validate_api_pointer (const char *name, void *ptr)
{
@@ -47,6 +49,12 @@ validate_api_struct ()
exit (1);
}
#ifdef USE_DEFAULT_MONO_API_STRUCT
// We don't export in jit.h
// So declare here, and get it from mono
void mono_aot_register_module (void *aot_info);
#endif // USE_DEFAULT_MONO_API_STRUCT
static void
init_default_mono_api_struct ()
{
@@ -59,3 +67,5 @@ init_default_mono_api_struct ()
mono_api.mono_register_machine_config = mono_register_machine_config;
#endif // USE_DEFAULT_MONO_API_STRUCT
}
#endif