Skip to content

Commit

Permalink
Merge branch 'master' into feature/newcecil
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Jan 4, 2019
2 parents f8da041 + a1832ef commit 8e9fdaa
Show file tree
Hide file tree
Showing 24 changed files with 125 additions and 92 deletions.
3 changes: 2 additions & 1 deletion ILRuntime/CLR/Method/CLRMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ unsafe void FixReference(int paramCount, StackObject* esp, object[] param, IList
{
case ObjectTypes.StackObjectReference:
{
var dst = *(StackObject**)&p->Value;
var addr = *(long*)&p->Value;
var dst = (StackObject*)addr;
if (dst->ObjectType >= ObjectTypes.Object)
{
var obj = val;
Expand Down
6 changes: 3 additions & 3 deletions ILRuntime/ILRuntime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ILRuntime</RootNamespace>
<AssemblyName>ILRuntime</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DefineConstants>TRACE;DEBUG;NET_4_6</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;NET_4_6</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ internal static string GenerateConstructorWraperCode(this Type type, Constructor
{
case ObjectTypes.StackObjectReference:
{
var ___dst = *(StackObject**)&ptr_of_this_method->Value;");
var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);");

if (p.ParameterType.IsValueType && !p.ParameterType.IsPrimitive && valueTypeBinders != null && valueTypeBinders.Contains(p.ParameterType))
{
Expand Down
2 changes: 1 addition & 1 deletion ILRuntime/Runtime/CLRBinding/MethodBindingGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ internal static string GenerateMethodWraperCode(this Type type, MethodInfo[] met
{
case ObjectTypes.StackObjectReference:
{
var ___dst = *(StackObject**)&ptr_of_this_method->Value;");
var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);");

if (pt.IsValueType && !pt.IsPrimitive && valueTypeBinders != null && valueTypeBinders.Contains(pt))
{
Expand Down
13 changes: 7 additions & 6 deletions ILRuntime/Runtime/Debugger/DebugService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public unsafe string GetThisInfo(ILIntepreter intepreter)
arg--;
if (arg->ObjectType == ObjectTypes.StackObjectReference)
{
arg = *(StackObject**)&arg->Value;
var addr = *(long*)&arg->Value;
arg = (StackObject*)addr;
}
ILTypeInstance instance = arg->ObjectType != ObjectTypes.Null ? intepreter.Stack.ManagedStack[arg->Value] as ILTypeInstance : null;
if (instance == null)
Expand Down Expand Up @@ -1011,7 +1012,7 @@ internal unsafe void DumpStack(StackObject* esp, RuntimeStack stack)
if (i < esp)
{
if (i->ObjectType == ObjectTypes.ValueTypeObjectReference)
VisitValueTypeReference(*(StackObject**)&i->Value, leakVObj);
VisitValueTypeReference(ILIntepreter.ResolveReference(i), leakVObj);
}
if (isLocal)
{
Expand Down Expand Up @@ -1068,21 +1069,21 @@ unsafe void GetStackObjectText(StringBuilder sb, StackObject* esp, IList<object>
{
case ObjectTypes.StackObjectReference:
{
sb.Append(string.Format("Value:0x{0:X8}", (long)*(StackObject**)&esp->Value));
sb.Append(string.Format("Value:0x{0:X8}", (long)ILIntepreter.ResolveReference(esp)));
}
break;
case ObjectTypes.ValueTypeObjectReference:
{
object obj = null;
var dst = *(StackObject**)&esp->Value;
var dst = ILIntepreter.ResolveReference(esp);
if (dst > valueTypeEnd)
obj = StackObject.ToObject(esp, domain, mStack);
if (obj != null)
text = obj.ToString();

text += string.Format("({0})", domain.GetType(dst->Value));
}
sb.Append(string.Format("Value:0x{0:X8} Text:{1} ", (long)*(StackObject**)&esp->Value, text));
sb.Append(string.Format("Value:0x{0:X8} Text:{1} ", (long)ILIntepreter.ResolveReference(esp), text));
break;
default:
{
Expand Down Expand Up @@ -1111,7 +1112,7 @@ unsafe void VisitValueTypeReference(StackObject* esp, HashSet<long> leak)
var ptr = Minus(esp, i + 1);
if (ptr->ObjectType == ObjectTypes.ValueTypeObjectReference)
{
VisitValueTypeReference(*(StackObject**)&ptr->Value, leak);
VisitValueTypeReference(ILIntepreter.ResolveReference(ptr), leak);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions ILRuntime/Runtime/Enviorment/ValueTypeBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void CopyValueTypeToStack<K>(ref K ins, StackObject* esp, IList<object
{
case ObjectTypes.ValueTypeObjectReference:
{
var dst = *(StackObject**)&esp->Value;
var dst = ILIntepreter.ResolveReference(esp);
var vb = ((CLRType)domain.GetType(dst->Value)).ValueTypeBinder as ValueTypeBinder<K>;
if (vb != null)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ protected void AssignFromStack<K>(ref K ins, StackObject* esp, IList<object> mSt
break;
case ObjectTypes.ValueTypeObjectReference:
{
var dst = *(StackObject**)&esp->Value;
var dst = ILIntepreter.ResolveReference(esp);
var vb = ((CLRType)domain.GetType(dst->Value)).ValueTypeBinder as ValueTypeBinder<K>;
if (vb != null)
{
Expand Down Expand Up @@ -117,7 +117,7 @@ public void ParseValue(ref T value, ILIntepreter intp, StackObject* ptr_of_this_
var a = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
if (a->ObjectType == ObjectTypes.ValueTypeObjectReference)
{
var ptr = *(StackObject**)&a->Value;
var ptr = ILIntepreter.ResolveReference(a);
AssignFromStack(ref value, ptr, mStack);
if (shouldFree)
intp.FreeStackValueType(ptr_of_this_method);
Expand Down Expand Up @@ -175,7 +175,7 @@ public void WriteBackValue(ILRuntime.Runtime.Enviorment.AppDomain domain, StackO
break;
case ObjectTypes.ValueTypeObjectReference:
{
var dst = *((StackObject**)&ptr_of_this_method->Value);
var dst = ILIntepreter.ResolveReference(ptr_of_this_method);
CopyValueTypeToStack(ref instance_of_this_method, dst, mStack);
}
break;
Expand All @@ -185,7 +185,7 @@ public void WriteBackValue(ILRuntime.Runtime.Enviorment.AppDomain domain, StackO
public void PushValue(ref T value, ILIntepreter intp, StackObject* ptr_of_this_method, IList<object> mStack)
{
intp.AllocValueType(ptr_of_this_method, clrType);
var dst = *((StackObject**)&ptr_of_this_method->Value);
var dst = ILIntepreter.ResolveReference(ptr_of_this_method);
CopyValueTypeToStack(ref value, dst, mStack);
}
}
Expand Down
Loading

0 comments on commit 8e9fdaa

Please sign in to comment.