Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2005-01-06 12:36:49 +0300
committerjfrijters <jfrijters>2005-01-06 12:36:49 +0300
commitad2b7aeb2bce47acad12cbdfde32a9d87bee5641 (patch)
tree365f6537338bd11eaa5928dd43b05839411b439c
parentc5c9076b77e22907277186dc7b125db7f28df0a7 (diff)
*** empty log message ***
-rw-r--r--classpath/classpath.build2
-rw-r--r--ikvmc/Compiler.cs5
-rw-r--r--runtime/ClassFile.cs4
-rw-r--r--runtime/vm.cs49
4 files changed, 56 insertions, 4 deletions
diff --git a/classpath/classpath.build b/classpath/classpath.build
index 35fcdaf8..915a8368 100644
--- a/classpath/classpath.build
+++ b/classpath/classpath.build
@@ -28,7 +28,7 @@
</target>
<target name="IKVM.GNU.Classpath.dll" depends="classes">
- <exec program="${nant.project.basedir}/../bin/ikvmc.exe" useruntimeengine="true" commandline="-version:0.9.* -opt:fields -nojni -out:IKVM.GNU.Classpath.dll -remap:map.xml -exclude:exclude.lst -target:library -recurse:./*.class -recurse:${Classpath.dir}/*.class -recurse:${Classpath.dir}/*.properties -recurse:${Classpath.dir}/resource/*.properties mscorlib.jar System.jar System.Xml.jar -resource:lib/security/classpath.security=classpath.security" />
+ <exec program="${nant.project.basedir}/../bin/ikvmc.exe" useruntimeengine="true" commandline="-version:0.9.* -monoBugWorkaround -opt:fields -nojni -out:IKVM.GNU.Classpath.dll -remap:map.xml -exclude:exclude.lst -target:library -recurse:./*.class -recurse:${Classpath.dir}/*.class -recurse:${Classpath.dir}/*.properties -recurse:${Classpath.dir}/resource/*.properties mscorlib.jar System.jar System.Xml.jar -resource:lib/security/classpath.security=classpath.security" />
<copy file="IKVM.GNU.Classpath.dll" tofile="../bin/IKVM.GNU.Classpath.dll.new" />
<if propertytrue="nant.platform.win32">
<call target="peverify-classpath"/>
diff --git a/ikvmc/Compiler.cs b/ikvmc/Compiler.cs
index a42680f3..4cb31327 100644
--- a/ikvmc/Compiler.cs
+++ b/ikvmc/Compiler.cs
@@ -118,6 +118,7 @@ class Compiler
Console.Error.WriteLine(" -opt:fields Remove unused private fields");
Console.Error.WriteLine(" -Xtrace:<string> Displays all tracepoints with the given name");
Console.Error.WriteLine(" -Xmethodtrace:<string> Build tracing into the specified output methods");
+ Console.Error.WriteLine(" -monoBugWorkaround Workaround metadata bug in Mono 1.0.5 and 1.1.3");
return 1;
}
foreach(string s in arglist)
@@ -349,6 +350,10 @@ class Compiler
{
options.nostacktraceinfo = true;
}
+ else if(s == "-monoBugWorkaround")
+ {
+ options.monoBugWorkaround = true;
+ }
else if(s == "-opt:fields")
{
options.removeUnusedFields = true;
diff --git a/runtime/ClassFile.cs b/runtime/ClassFile.cs
index 63f683c9..d210a0c8 100644
--- a/runtime/ClassFile.cs
+++ b/runtime/ClassFile.cs
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002, 2003, 2004 Jeroen Frijters
+ Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -550,7 +550,7 @@ sealed class ClassFile
ArrayList list = new ArrayList();
foreach(Field f in fields)
{
- if(f.IsPrivate && f.Name != "serialVersionUID" && !IsReferenced(f))
+ if(f.IsPrivate && f.IsStatic && f.Name != "serialVersionUID" && !IsReferenced(f))
{
// unused, so we skip it
Tracer.Info(Tracer.Compiler, "Unused field {0}::{1}", this.Name, f.Name);
diff --git a/runtime/vm.cs b/runtime/vm.cs
index 44b34bde..5579bad0 100644
--- a/runtime/vm.cs
+++ b/runtime/vm.cs
@@ -173,7 +173,15 @@ namespace IKVM.Runtime
// use the TLS as a hack to track when the thread dies (if the object stored in the TLS is finalized,
// we know the thread is dead). So to make that work for the main thread, we explicitly clear the TLS
// slot that contains our hack object.
- Thread.SetData(Thread.GetNamedDataSlot("ikvm-thread-hack"), null);
+ try
+ {
+ Thread.SetData(Thread.GetNamedDataSlot("ikvm-thread-hack"), null);
+ }
+ catch(NullReferenceException)
+ {
+ // MONOBUG Thread.SetData throws a NullReferenceException on Mono
+ // if the slot hadn't already been allocated
+ }
}
}
@@ -289,6 +297,7 @@ namespace IKVM.Internal
private static bool noStackTraceInfo;
private static bool compilationPhase1;
private static string sourcePath;
+ private static bool monoBugWorkaround;
private static ikvm.@internal.LibraryVMInterface lib;
internal static ikvm.@internal.LibraryVMInterface Library
@@ -564,11 +573,47 @@ namespace IKVM.Internal
assemblyBuilder.SetEntryPoint(mainStub, target);
}
+ private void MonoBugWorkaround()
+ {
+ // Mono 1.0.5 (and earlier) and 1.1.3 (and earlier) have bug in the metadata routines.
+ // Zoltan says:
+ // The size calculation for the MethodSematics:Association metadata column was wrong,
+ // it was based on the size of the Method table, so when the number of methods in the
+ // dll exceeded some number, all the tables after the MethodSematics table had the
+ // wrong address. This means the only workaround for this bug is to emit
+ // like 32768 dummy Events or Properties, or decrease the size of the Method table to
+ // below 32768 by dropping some classes.
+ // ---
+ // We distribute the properties in 128 nested classes, because peverify has some very
+ // non-linear algorithms and is extremely slow with 32768 properties in a single class.
+ // (it also helps make the overhead a little smaller.)
+ TypeBuilder tb = ModuleBuilder.DefineType("MonoBugWorkaround", TypeAttributes.NotPublic);
+ TypeBuilder[] nested = new TypeBuilder[128];
+ for(int i = 0; i < nested.Length; i++)
+ {
+ nested[i] = tb.DefineNestedType(i.ToString(), TypeAttributes.NestedPrivate);
+ for(int j = 0; j < 32768 / nested.Length; j++)
+ {
+ nested[i].DefineProperty(j.ToString(), PropertyAttributes.None, typeof(int), Type.EmptyTypes);
+ }
+ }
+ tb.CreateType();
+ for(int i = 0; i < nested.Length; i++)
+ {
+ nested[i].CreateType();
+ }
+ }
+
internal void Save()
{
Tracer.Info(Tracer.Compiler, "CompilerClassLoader.Save...");
FinishAll();
+ if(monoBugWorkaround)
+ {
+ MonoBugWorkaround();
+ }
+
ModuleBuilder.CreateGlobalFunctions();
if(targetIsModule)
@@ -1869,6 +1914,7 @@ namespace IKVM.Internal
public bool noglobbing;
public bool nostacktraceinfo;
public bool removeUnusedFields;
+ public bool monoBugWorkaround;
}
public static int Compile(CompilerOptions options)
@@ -1877,6 +1923,7 @@ namespace IKVM.Internal
isStaticCompiler = true;
noJniStubs = options.nojni;
noStackTraceInfo = options.nostacktraceinfo;
+ monoBugWorkaround = options.monoBugWorkaround;
foreach(string r in options.references)
{
try