Skip to content

Commit

Permalink
IKVM 8.6.5.0 - fixed preoptimizer + added extreme optimizations
Browse files Browse the repository at this point in the history
added IKVMC argument: -extremeoptimize

added IKVM argument: -Xextremeoptimize
  • Loading branch information
jessiepathfinder committed Jan 2, 2020
1 parent 1d22b7d commit abb5a14
Show file tree
Hide file tree
Showing 12 changed files with 400 additions and 389 deletions.
2 changes: 1 addition & 1 deletion CommonAssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using System.Reflection;
[assembly: AssemblyCopyright("Copyright (C) 2019 Jessie Lesbian (based on work by Jeroen Frijters and Windward Studios)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("8.6.4.0")]
[assembly: AssemblyVersion("8.6.5.0")]

#if SIGNCODE
#pragma warning disable 1699
Expand Down
Binary file removed bin/ICSharpCode.SharpZipLib.dll
Binary file not shown.
15 changes: 0 additions & 15 deletions bin/ikvm.exe.manifest

This file was deleted.

5 changes: 5 additions & 0 deletions ikvm/starter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ static int Main(string[] args)
Console.Error.WriteLine("SORRY, IKVM.NET experimental optimizations disabled, reason: negative or invalid number of optimization passes.");
}
}
else if(arg == "-Xextremeoptimize")
{
Helper.extremeOptimizations = true;
}
else if(arg == "-Xpreoptimize")
{
Helper.enableJITPreOptimization = true;
Expand Down Expand Up @@ -445,6 +449,7 @@ private static void PrintXHelp()
Console.Error.WriteLine(" -Xnoglobbing Disable argument globbing");
Console.Error.WriteLine(" -Xverify Enable strict class file verification");
Console.Error.WriteLine(" -Xoptimize:n Enable IKVM.NET experimental optimizations and use N passes of optimization");
Console.Error.WriteLine(" -Xextremeoptimize Enable extreme usage of IKVM.NET experimental optimizations optimizations");
Console.Error.WriteLine(" -Xpreoptimize Enable precompilation optimizations");
Console.Error.WriteLine();
Console.Error.WriteLine("The -X options are non-standard and subject to change without notice.");
Expand Down
5 changes: 5 additions & 0 deletions ikvmc/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ private static void PrintHelp()
Console.Error.WriteLine("-strictfinalfieldsemantics Don't allow final fields to be modified outside");
Console.Error.WriteLine(" of initializer methods");
Console.Error.WriteLine("-optimize:n Enable IKVM.NET experimental optimizations and use N passes of optimization");
Console.Error.WriteLine("-extremeoptimize Enable extreme usage of IKVM.NET experimental optimizations optimizations");
Console.Error.WriteLine("-preoptimize Enable precompilation optimizations");
Console.Error.WriteLine();
Console.Error.WriteLine(" - ERRORS AND WARNINGS -");
Expand Down Expand Up @@ -1026,6 +1027,10 @@ void ContinueParseCommandLine(IEnumerator<string> arglist, List<CompilerOptions>
Console.Error.WriteLine("SORRY, IKVM.NET experimental optimizations disabled, reason: negative or invalid number of optimization passes.");
}
}
else if(s == "-extremeoptimize")
{
Helper.extremeOptimizations = true;
}
else if(s == "-preoptimize")
{
Helper.enableJITPreOptimization = true;
Expand Down
Binary file modified openjdk/commonAttributes.class
Binary file not shown.
Binary file modified openjdk/java/lang/PropertyConstants.class
Binary file not shown.
1 change: 1 addition & 0 deletions openjdk/openjdk.build
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<arg value="-warnaserror" />
<!-- we need optimizations since Jessie Lesbian had waiting difficulties. -->
<arg value="-optimize:5" />
<arg value="-extremeoptimize" />
<arg value="-preoptimize" />
<arg value="-removeassertions" />
<arg value="-compressresources" />
Expand Down
4 changes: 2 additions & 2 deletions runtime/ByteCodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static void DynamicAastore(object arrayref, int index, object val)
{
#if !FIRST_PASS
Profiler.Count("DynamicAastore");
((IList<object>)arrayref)[index] = val;
((Array)arrayref).SetValue(val, index);
#endif
}

Expand All @@ -201,7 +201,7 @@ public static object DynamicAaload(object arrayref, int index)
return null;
#else
Profiler.Count("DynamicAaload");
return ((IList<object>)arrayref)[index];
return ((Array)arrayref).GetValue(index);
#endif
}

Expand Down
53 changes: 28 additions & 25 deletions runtime/CodeEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ arising from the use of this software.
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
Expand All @@ -36,6 +36,7 @@ Jeroen Frijters
using System.Runtime.InteropServices;
using System.Diagnostics.SymbolStore;
using System.Diagnostics;
using jessielesbian.IKVM;

namespace IKVM.Internal
{
Expand Down Expand Up @@ -98,13 +99,14 @@ internal void Declare(ILGenerator ilgen)

sealed class CodeEmitter
{
private bool optimized = false;
private static readonly MethodInfo objectToString = Types.Object.GetMethod("ToString", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null);
private static readonly MethodInfo verboseCastFailure = JVM.SafeGetEnvironmentVariable("IKVM_VERBOSE_CAST") == null ? null : ByteCodeHelperMethods.VerboseCastFailure;
private static readonly MethodInfo monitorEnter = JVM.Import(typeof(System.Threading.Monitor)).GetMethod("Enter", BindingFlags.Public | BindingFlags.Static, null, new Type[] { Types.Object }, null);
private static readonly MethodInfo monitorExit = JVM.Import(typeof(System.Threading.Monitor)).GetMethod("Exit", BindingFlags.Public | BindingFlags.Static, null, new Type[] { Types.Object }, null);
private static bool experimentalOptimizations {
get {
return jessielesbian.IKVM.Helper.experimentalOptimizations;
return Helper.experimentalOptimizations;
}
}
private static MethodInfo memoryBarrier;
Expand All @@ -121,7 +123,6 @@ private static bool experimentalOptimizations {
#if LABELCHECK
private Dictionary<CodeEmitterLabel, System.Diagnostics.StackFrame> labels = new Dictionary<CodeEmitterLabel, System.Diagnostics.StackFrame>();
#endif
private bool optimized = false;
enum CodeType : short
{
Unreachable,
Expand Down Expand Up @@ -1261,7 +1262,7 @@ private void ChaseBranches()
/*
* Here we do a couple of different optimizations to unconditional branches:
* - a branch to a ret or endfinally will be replaced
* by the ret or endfinally instruction (because that is always at least as efficient)
* by the ret or endfinally instruction (because that is always at least as efficient)
* - a branch to a branch will remove the indirection
* - a leave to a branch or leave will remove the indirection
*/
Expand Down Expand Up @@ -2121,9 +2122,9 @@ private void CLRv4_x64_JIT_Workaround()
//
// This means we only have to detect these specific patterns:
//
// ldc.i8 0x0 ldarg
// ldarg ldc.i8 0x0
// beq/bne beq/bne
// ldc.i8 0x0 ldarg
// ldarg ldc.i8 0x0
// beq/bne beq/bne
//
// The workaround is to replace ldarg with ldarga/ldind.i8. Looking at the generated code by the x86 and x64 JITs
// this appears to be as efficient as the ldarg and it avoids the x64 bug.
Expand Down Expand Up @@ -2165,22 +2166,22 @@ private void CheckInvariantBranchInOrOutOfBlocks()
* This is a stronger invariant than requirement by MSIL, because
* we also disallow the following sequence:
*
* Br Label0
* ...
* BeginExceptionBlock
* Label0:
* ...
* Br Label0
*
* Br Label0
* ...
* BeginExceptionBlock
* Label0:
* ...
* Br Label0
*
* This should be rewritten as:
*
* Br Label0
* ...
* Label0:
* BeginExceptionBlock
* Label1:
* ...
* Br Label1
* Br Label0
* ...
* Label0:
* BeginExceptionBlock
* Label1:
* ...
* Br Label1
*/
int blockId = 0;
int nextBlockId = 1;
Expand Down Expand Up @@ -2305,7 +2306,8 @@ private void Optimize(){
{
CheckInvariants();
MoveLocalDeclarationToBeginScope();
for (int i = 0; i < jessielesbian.IKVM.Helper.optpasses; i++)
List<int> prevcodes = new List<int>(code.Capacity);
for (int i = 0; (i < Helper.optpasses) || (!prevcodes.Contains(code.GetHashCode()) && Helper.extremeOptimizations); i++)
{
RemoveJumpNext();
CheckInvariants();
Expand All @@ -2331,6 +2333,7 @@ private void Optimize(){
CheckInvariants();
RemoveDeadCode();
CheckInvariants();
prevcodes.Add(code.GetHashCode());
}
}
OptimizeEncodings();
Expand Down
Loading

0 comments on commit abb5a14

Please sign in to comment.