Skip to content

Commit

Permalink
Merge pull request #465 from JasonXuDeveloper/development
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
JasonXuDeveloper authored Apr 19, 2023
2 parents 941988e + 7b41157 commit 03fd117
Show file tree
Hide file tree
Showing 19 changed files with 694 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ UnityProject/Assets/Dependencies/ILRuntime/Generated.meta
UnityProject/Logs/Packages-Update.log
UnityProject/Sandbox/*
UnityProject/Logs/*
UnityProject/Build/*
UnityProject/Build/*
UnityProject/HotUpdateScripts/.idea/*
3 changes: 2 additions & 1 deletion UnityProject/Assembly-CSharp-Editor.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cdependencies_005Cjengine_005Ccore_005Cilruntimehelper/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cdependencies_005Cjengine_005Ccore_005Cilruntimehelper/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cdependencies_005Cjengine_005Ceditor_005Cjenginetools_005Coptimizer/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public static AppDomain Domain

_cacheDomain = new AppDomain();
// 只有编辑器才会走到这
ThreadMgr.QueueOnMainThread(async () =>
Task.Run(async () =>
{
_cacheDomain.LoadAssembly(new MemoryStream(await DllMgr.GetDllBytes(ConstMgr.MainHotDLLName, true)), null,
new PdbReaderProvider());
InitJEngine.InitializeILRuntime(_cacheDomain);
});
}).Wait();
return _cacheDomain;
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using ILRuntime.Mono.Cecil.Cil;

namespace JEngine.Editor
{
public static partial class Optimizer
{
private static string GetLdLocName(Instruction instruction)
{
var code = instruction.OpCode.Code.ToString();
if(code.StartsWith("Ldloc"))
{
if(code.EndsWith("S"))
{
return instruction.Operand.ToString();
}

return code.Substring(code.Length - 1);
}

return null;
}

private static string GetStLocName(Instruction instruction)
{
var code = instruction.OpCode.Code.ToString();
if(code.StartsWith("Stloc"))
{
if(code.EndsWith("S"))
{
return instruction.Operand.ToString();
}

return code.Substring(code.Length - 1);
}

return null;
}

private static int GetLdcI4Num(Instruction instruction)
{
var code = instruction.OpCode.Code.ToString();
if(code.StartsWith("Ldc_I4"))
{
if(code.EndsWith("S"))
{
return (sbyte)instruction.Operand;
}

if(code.EndsWith("M1"))
{
return -1;
}

if(code.EndsWith("0"))
{
return 0;
}

if(code.EndsWith("1"))
{
return 1;
}

if(code.EndsWith("2"))
{
return 2;
}

if(code.EndsWith("3"))
{
return 3;
}

if(code.EndsWith("4"))
{
return 4;
}

if(code.EndsWith("5"))
{
return 5;
}

if(code.EndsWith("6"))
{
return 6;
}

if(code.EndsWith("7"))
{
return 7;
}

if(code.EndsWith("8"))
{
return 8;
}

return (int)instruction.Operand;
}

return 0;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using ILRuntime.Mono.Cecil.Cil;

namespace JEngine.Editor
{
public static partial class Optimizer
{
private static Instruction NewLdcI4Instruction(int i)
{
switch (i)
{
case -1:
return Instruction.Create(OpCodes.Ldc_I4_M1);
case 0:
return Instruction.Create(OpCodes.Ldc_I4_0);
case 1:
return Instruction.Create(OpCodes.Ldc_I4_1);
case 2:
return Instruction.Create(OpCodes.Ldc_I4_2);
case 3:
return Instruction.Create(OpCodes.Ldc_I4_3);
case 4:
return Instruction.Create(OpCodes.Ldc_I4_4);
case 5:
return Instruction.Create(OpCodes.Ldc_I4_5);
case 6:
return Instruction.Create(OpCodes.Ldc_I4_6);
case 7:
return Instruction.Create(OpCodes.Ldc_I4_7);
case 8:
return Instruction.Create(OpCodes.Ldc_I4_8);
case var _ when i <= 127:
return Instruction.Create(OpCodes.Ldc_I4_S, (sbyte)i);
default:
return Instruction.Create(OpCodes.Ldc_I4, i);
}
}

private static Instruction NewLdcI8Instruction(long i)
{
return Instruction.Create(OpCodes.Ldc_I8, i);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 03fd117

Please sign in to comment.