diff --git a/CommonAssemblyInfo.cs.in b/CommonAssemblyInfo.cs.in index 8d08dc8d7..af47d23ac 100644 --- a/CommonAssemblyInfo.cs.in +++ b/CommonAssemblyInfo.cs.in @@ -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.3.0")] +[assembly: AssemblyVersion("8.6.4.0")] #if SIGNCODE #pragma warning disable 1699 diff --git a/openjdk/commonAttributes.class b/openjdk/commonAttributes.class index 3eae29574..71bfe54ff 100644 Binary files a/openjdk/commonAttributes.class and b/openjdk/commonAttributes.class differ diff --git a/openjdk/java/lang/PropertyConstants.class b/openjdk/java/lang/PropertyConstants.class index 648601b32..302c379e8 100644 Binary files a/openjdk/java/lang/PropertyConstants.class and b/openjdk/java/lang/PropertyConstants.class differ diff --git a/runtime/ByteCodeHelper.cs b/runtime/ByteCodeHelper.cs index ed23a7790..21b9b240b 100644 --- a/runtime/ByteCodeHelper.cs +++ b/runtime/ByteCodeHelper.cs @@ -27,6 +27,7 @@ Jeroen Frijters using System.Threading; using IKVM.Attributes; using IKVM.Internal; +using System.Collections.Generic; using System.Runtime.InteropServices; namespace IKVM.Runtime @@ -189,7 +190,7 @@ public static void DynamicAastore(object arrayref, int index, object val) { #if !FIRST_PASS Profiler.Count("DynamicAastore"); - ((Array)arrayref).SetValue(val, index); + ((IList)arrayref)[index] = val; #endif } @@ -200,7 +201,7 @@ public static object DynamicAaload(object arrayref, int index) return null; #else Profiler.Count("DynamicAaload"); - return ((Array)arrayref).GetValue(index); + return ((IList)arrayref)[index]; #endif } diff --git a/runtime/compiler.cs b/runtime/compiler.cs index ecbce28d9..0da0fe78f 100644 --- a/runtime/compiler.cs +++ b/runtime/compiler.cs @@ -2069,8 +2069,12 @@ private void Compile(Block block, int startIndex) TypeWrapper tw = ma.GetRawStackTypeWrapper(i, 1); if(tw.IsUnloadable) { + #if STATIC_COMPILER Profiler.Count("EmitDynamicAaload"); ilGenerator.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicAaload); + #else + ilGenerator.Emit(OpCodes.Callvirt, Helper.ArrayLoad); + #endif } else { @@ -2141,8 +2145,12 @@ private void Compile(Block block, int startIndex) TypeWrapper tw = ma.GetRawStackTypeWrapper(i, 2); if(tw.IsUnloadable) { + #if STATIC_COMPILER Profiler.Count("EmitDynamicAastore"); ilGenerator.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicAastore); + #else + ilGenerator.Emit(OpCodes.Callvirt, Helper.ArrayLoad); + #endif } else { diff --git a/runtime/jessielesbian.cs b/runtime/jessielesbian.cs index 77c2fe506..838795d1c 100644 --- a/runtime/jessielesbian.cs +++ b/runtime/jessielesbian.cs @@ -1,6 +1,8 @@ using System; -using System.Collections.Generic; +using IKVM.Internal; +using System.Reflection; using Instruction = IKVM.Internal.ClassFile.Method.Instruction; +using System.Collections.Generic; //Do you believe in high-quality code by Female/LGBT programmers? Leave u/jessielesbian a PM on Reddit! @@ -8,13 +10,18 @@ namespace jessielesbian.IKVM { public static class Helper { + static Helper() + { + Array array = new object[0]; + ArrayLoad = new Func(array.GetValue).Method; + ArrayStore = new Action(array.SetValue).Method; + } public static int optpasses = 0; public static bool enableJITPreOptimization = false; internal static bool experimentalOptimizations { get { - return (optpasses > 0); } } @@ -122,14 +129,6 @@ internal static Instruction[] Optimize(Instruction[] instructions) instructions = (Instruction[])instructions.Clone(); int optimizations = 1279738452; - List brtargets = new List(instructions.Length); - for (int i = 1; i < instructions.Length; i++) - { - if (IsBranchInstruction(instructions[i])) - { - brtargets.Add(i); - } - } while (optimizations != 0) { optimizations = 0; @@ -140,21 +139,9 @@ internal static Instruction[] Optimize(Instruction[] instructions) { prevIndex--; } - if (brtargets.Contains(prevIndex) || IsBranchInstruction(instructions[prevIndex])) - { - continue; - } Instruction current = instructions[i]; Instruction prev = instructions[i - 1]; - if (brtargets.Contains(i)) - { - continue; - } - if (brtargets.Contains(i - 1)) - { - continue; - } - if (brtargets.Contains(i + 1)) + if (IsBranchInstruction(current) || IsBranchInstruction(prev)) { continue; } @@ -311,7 +298,7 @@ internal static Instruction[] Optimize(Instruction[] instructions) optimizations = optimizations + 1; } } - //peephole optimization: remove unnecessary swaps + //peephole optimization: remove unnecessary swaps + branch optimizations if (prev.NormalizedOpCode == NormalizedByteCode.__swap) { switch (current.NormalizedOpCode) @@ -353,41 +340,17 @@ internal static Instruction[] Optimize(Instruction[] instructions) break; } } - //branch optimizations - if(prev.NormalizedOpCode == NormalizedByteCode.__aconst_null) - { - if(current.NormalizedOpCode == NormalizedByteCode.__ifnull) - { - prev = GetInstuction(NormalizedByteCode.__nop); - current.PatchOpCode(NormalizedByteCode.__goto); - optimizations = optimizations + 1; - } - else if (current.NormalizedOpCode == NormalizedByteCode.__ifnonnull) - { - prev = GetInstuction(NormalizedByteCode.__nop); - current = prev; - optimizations = optimizations + 1; - } - } - if(IsBranchInstruction(current)) - { - Instruction target = instructions[current.TargetIndex]; - if (target.NormalizedOpCode == NormalizedByteCode.__goto) - { - current.TargetIndex = target.TargetIndex; - optimizations = optimizations + 1; - } - else if(target.NormalizedOpCode == NormalizedByteCode.__nop) - { - current.TargetIndex++; - optimizations = optimizations + 1; - } - } instructions[i] = current; instructions[i - 1] = prev; } } return instructions; } + internal static readonly MethodInfo ArrayLoad; + internal static readonly MethodInfo ArrayStore; + public static object aaload(Array array, int index) + { + return array.GetValue(index); + } } } \ No newline at end of file diff --git a/runtime/vm.cs b/runtime/vm.cs index a98cd7cfb..bd4212fb2 100644 --- a/runtime/vm.cs +++ b/runtime/vm.cs @@ -35,6 +35,7 @@ Jeroen Frijters using System.Security; using System.Security.Permissions; using IKVM.Internal; +using System.Collections.Generic; #if !STATIC_COMPILER && !STUB_GENERATOR namespace IKVM.Internal