focus-creative-games / hybridclr

HybridCLR是一个特性完整、零成本、高性能、低内存的Unity全平台原生c#热更新解决方案。 HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.
https://code-philosophy.com/
MIT License
6.63k stars 675 forks source link

几个DHE问题(2) #45

Closed AlanLiu90 closed 1 year ago

AlanLiu90 commented 1 year ago

环境

Unity 2020.3.33
il2cpp_plus 2020-DHE
hybridclr DHE
hybridclr_unity DHE
OS+Build Windows 10 64 bit
project dhe_demo (没开间接函数优化)

问题1

计算等价性时,报错:

NullReferenceException: Object reference not set to an instance of an object
HybridCLR.Editor.DHE.MethodCompareCache.CompareExceptionHandler (dnlib.DotNet.Emit.ExceptionHandler e1, dnlib.DotNet.Emit.ExceptionHandler e2) (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@8c290d286c/Editor/DHE/MethodCompareCache.cs:590)

复现代码:

class A
{
    private object mLock = new object();

    public void Func1()
    {
        lock (mLock)
        {
            var e = Func2();
            if (e != null)
                throw e;

            throw new InvalidOperationException("xxxx");
        }
    }

    private Exception Func2()
    {
        return null;
    }
}

问题2

没有变化的函数,被计算为不等价,复现代码:

class A<T> where T : UnityEngine.Object
{
    private UnityEngine.Object mObject;

    public A(UnityEngine.Object obj)
    {
        mObject = obj;
    }

    public T Object
    {
        get
        {
            return mObject as T;
        }
    }
}

输出:change mehtod:T A`1::get_Object() token:100663298

问题3

多线程情况下,GetRuntimeMetadataIl2CppType中,可能创建多个相同的dhType

问题4

s_dheTypesil2cpp::vm::GlobalMetadata::Clear中没有释放

pirunxi commented 1 year ago

我们处理一下

pirunxi commented 1 year ago

1-4均已经修复,分别更新 hybridclr_unity和 il2cpp_plus即可

AlanLiu90 commented 1 year ago

il2cpp_plus没有看到更新,请确认下

pirunxi commented 1 year ago

那个仓库我邀请你了,通过一下