Skip to content

Commit

Permalink
[fix] 修复android平台浮点转换为无符号数的bug
Browse files Browse the repository at this point in the history
[change] 修正一些变量名误写
  • Loading branch information
pirunxi committed Apr 29, 2022
1 parent c449f71 commit 4ce18e6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/huatuo/test
20 changes: 10 additions & 10 deletions huatuo/interpreter/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -3515,7 +3515,7 @@ namespace interpreter
uint32_t methodInfo;
uint32_t argIdxs;
uint16_t ret;
uint8_t retLocaltionType;
uint8_t retLocationType;
uint8_t __pad__;
};

Expand Down Expand Up @@ -3558,7 +3558,7 @@ namespace interpreter
uint32_t methodInfo;
uint32_t argIdxs;
uint16_t ret;
uint8_t retLocaltionType;
uint8_t retLocationType;
uint8_t __pad__;
};

Expand Down Expand Up @@ -3601,7 +3601,7 @@ namespace interpreter
uint32_t methodInfo;
uint32_t argIdxs;
uint16_t ret;
uint8_t retLocaltionType;
uint8_t retLocationType;
uint8_t __pad__;
};

Expand Down Expand Up @@ -3632,7 +3632,7 @@ namespace interpreter
uint32_t argIdxs;
uint16_t ret;
uint16_t invokeParamCount;
uint8_t retLocaltionType;
uint8_t retLocationType;
uint8_t __pad__;
};

Expand Down Expand Up @@ -5582,7 +5582,7 @@ namespace interpreter
struct IRInterlockedCompareExchangeVarVarVarVar_i4 : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
uint16_t comparand;
};
Expand All @@ -5591,7 +5591,7 @@ namespace interpreter
struct IRInterlockedCompareExchangeVarVarVarVar_i8 : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
uint16_t comparand;
};
Expand All @@ -5600,7 +5600,7 @@ namespace interpreter
struct IRInterlockedCompareExchangeVarVarVarVar_pointer : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
uint16_t comparand;
};
Expand All @@ -5609,23 +5609,23 @@ namespace interpreter
struct IRInterlockedExchangeVarVarVar_i4 : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
};


struct IRInterlockedExchangeVarVarVar_i8 : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
};


struct IRInterlockedExchangeVarVarVar_pointer : IRCommon
{
uint16_t ret;
uint16_t localtion;
uint16_t location;
uint16_t value;
};

Expand Down
2 changes: 1 addition & 1 deletion huatuo/interpreter/InterpreterDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace huatuo
return GetTypeArgDesc(type).type;
}

inline void ExpandLocaltionData2StackDataByType(void* retValue, LocationDataType type)
inline void ExpandLocationData2StackDataByType(void* retValue, LocationDataType type)
{
switch (type)
{
Expand Down
72 changes: 36 additions & 36 deletions huatuo/interpreter/Interpreter_Execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,63 +1790,63 @@ else \
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int8_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int8_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_u1:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint8_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint8_t, int32_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_i2:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int16_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int16_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_u2:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint16_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint16_t, int32_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_i4:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int32_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int32_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_u4:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint32_t)((*(float*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint32_t, int32_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_i8:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int64_t*)(localVarBase + __dst)) = (int64_t)((*(float*)(localVarBase + __src)));
(*(int64_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int64_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f4_u8:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int64_t*)(localVarBase + __dst)) = (uint64_t)((*(float*)(localVarBase + __src)));
(*(int64_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint64_t, int64_t>((*(float*)(localVarBase + __src)));
ip += 6;
continue;
}
Expand All @@ -1870,63 +1870,63 @@ else \
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int8_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int8_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_u1:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint8_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint8_t, int32_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_i2:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int16_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int16_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_u2:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint16_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint16_t, int32_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_i4:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (int32_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int32_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_u4:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int32_t*)(localVarBase + __dst)) = (uint32_t)((*(double*)(localVarBase + __src)));
(*(int32_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint32_t, int32_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_i8:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int64_t*)(localVarBase + __dst)) = (int64_t)((*(double*)(localVarBase + __src)));
(*(int64_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_double_to_int<int64_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
case HiOpcodeEnum::ConvertVarVar_f8_u8:
{
uint16_t __dst = *(uint16_t*)(ip + 2);
uint16_t __src = *(uint16_t*)(ip + 4);
(*(int64_t*)(localVarBase + __dst)) = (uint64_t)((*(double*)(localVarBase + __src)));
(*(int64_t*)(localVarBase + __dst)) = il2cpp_codegen_cast_floating_point<uint64_t, int64_t>((*(double*)(localVarBase + __src)));
ip += 6;
continue;
}
Expand Down Expand Up @@ -4938,11 +4938,11 @@ else \
uint32_t __methodInfo = *(uint32_t*)(ip + 6);
uint32_t __argIdxs = *(uint32_t*)(ip + 10);
uint16_t __ret = *(uint16_t*)(ip + 14);
uint8_t __retLocaltionType = *(uint8_t*)(ip + 16);
uint8_t __retLocationType = *(uint8_t*)(ip + 16);
uint8_t ____pad__ = *(uint8_t*)(ip + 0);
void* _ret = (void*)(localVarBase + __ret);
((Managed2NativeCallMethod)imi->resolveDatas[__managed2NativeMethod])(((MethodInfo*)imi->resolveDatas[__methodInfo]), ((uint16_t*)&imi->resolveDatas[__argIdxs]), localVarBase, _ret);
ExpandLocaltionData2StackDataByType(_ret, (LocationDataType)__retLocaltionType);
ExpandLocationData2StackDataByType(_ret, (LocationDataType)__retLocationType);
ip += 18;
continue;
}
Expand Down Expand Up @@ -5031,7 +5031,7 @@ else \
uint32_t __methodInfo = *(uint32_t*)(ip + 6);
uint32_t __argIdxs = *(uint32_t*)(ip + 10);
uint16_t __ret = *(uint16_t*)(ip + 14);
uint8_t __retLocaltionType = *(uint8_t*)(ip + 16);
uint8_t __retLocationType = *(uint8_t*)(ip + 16);
uint8_t ____pad__ = *(uint8_t*)(ip + 0);
uint16_t* _argIdxData = ((uint16_t*)&imi->resolveDatas[__argIdxs]);
StackObject* _objPtr = localVarBase + _argIdxData[0];
Expand All @@ -5056,7 +5056,7 @@ else \
else
{
((Managed2NativeCallMethod)imi->resolveDatas[__managed2NativeMethod])(_actualMethod, _argIdxData, localVarBase, _ret);
ExpandLocaltionData2StackDataByType(_ret, (LocationDataType)__retLocaltionType);
ExpandLocationData2StackDataByType(_ret, (LocationDataType)__retLocationType);
ip += 18;
}
continue;
Expand Down Expand Up @@ -5114,11 +5114,11 @@ else \
uint32_t __methodInfo = *(uint32_t*)(ip + 6);
uint32_t __argIdxs = *(uint32_t*)(ip + 10);
uint16_t __ret = *(uint16_t*)(ip + 14);
uint8_t __retLocaltionType = *(uint8_t*)(ip + 16);
uint8_t __retLocationType = *(uint8_t*)(ip + 16);
uint8_t ____pad__ = *(uint8_t*)(ip + 0);
void* _ret = (void*)(localVarBase + __ret);
((Managed2NativeCallMethod)imi->resolveDatas[__managed2NativeMethod])(((MethodInfo*)imi->resolveDatas[__methodInfo]), ((uint16_t*)&imi->resolveDatas[__argIdxs]), localVarBase, _ret);
ExpandLocaltionData2StackDataByType(_ret, (LocationDataType)__retLocaltionType);
ExpandLocationData2StackDataByType(_ret, (LocationDataType)__retLocationType);
ip += 18;
continue;
}
Expand Down Expand Up @@ -5155,13 +5155,13 @@ else \
uint32_t __argIdxs = *(uint32_t*)(ip + 10);
uint16_t __ret = *(uint16_t*)(ip + 14);
uint16_t __invokeParamCount = *(uint16_t*)(ip + 16);
uint8_t __retLocaltionType = *(uint8_t*)(ip + 18);
uint8_t __retLocationType = *(uint8_t*)(ip + 18);
uint8_t ____pad__ = *(uint8_t*)(ip + 0);
uint16_t* _resolvedArgIdxs = ((uint16_t*)&imi->resolveDatas[__argIdxs]);
Il2CppObject* __obj = localVarBase[_resolvedArgIdxs[0]].obj;
void* _ret = (void*)(localVarBase + __ret);
HiCallDelegate((Il2CppMulticastDelegate*)__obj, __invokeParamCount, ((Managed2NativeCallMethod)imi->resolveDatas[__managed2NativeStaticMethod]), ((Managed2NativeCallMethod)imi->resolveDatas[__managed2NativeInstanceMethod]), _resolvedArgIdxs, localVarBase, _ret);
ExpandLocaltionData2StackDataByType(_ret, (LocationDataType)__retLocaltionType);
ExpandLocationData2StackDataByType(_ret, (LocationDataType)__retLocationType);
ip += 20;
continue;
}
Expand Down Expand Up @@ -7578,57 +7578,57 @@ else \
case HiOpcodeEnum::InterlockedCompareExchangeVarVarVarVar_i4:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
uint16_t __comparand = *(uint16_t*)(ip + 8);
(*(int32_t*)(localVarBase + __ret)) = HiInterlockedCompareExchange((int32_t*)(*(void**)(localVarBase + __localtion)), (*(int32_t*)(localVarBase + __value)), (*(int32_t*)(localVarBase + __comparand)));
(*(int32_t*)(localVarBase + __ret)) = HiInterlockedCompareExchange((int32_t*)(*(void**)(localVarBase + __location)), (*(int32_t*)(localVarBase + __value)), (*(int32_t*)(localVarBase + __comparand)));
ip += 10;
continue;
}
case HiOpcodeEnum::InterlockedCompareExchangeVarVarVarVar_i8:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
uint16_t __comparand = *(uint16_t*)(ip + 8);
(*(int64_t*)(localVarBase + __ret)) = HiInterlockedCompareExchange((int64_t*)(*(void**)(localVarBase + __localtion)), (*(int64_t*)(localVarBase + __value)), (*(int64_t*)(localVarBase + __comparand)));
(*(int64_t*)(localVarBase + __ret)) = HiInterlockedCompareExchange((int64_t*)(*(void**)(localVarBase + __location)), (*(int64_t*)(localVarBase + __value)), (*(int64_t*)(localVarBase + __comparand)));
ip += 10;
continue;
}
case HiOpcodeEnum::InterlockedCompareExchangeVarVarVarVar_pointer:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
uint16_t __comparand = *(uint16_t*)(ip + 8);
(*(void**)(localVarBase + __ret)) = HiInterlockedCompareExchange((void**)(*(void**)(localVarBase + __localtion)), (*(void**)(localVarBase + __value)), (*(void**)(localVarBase + __comparand)));
(*(void**)(localVarBase + __ret)) = HiInterlockedCompareExchange((void**)(*(void**)(localVarBase + __location)), (*(void**)(localVarBase + __value)), (*(void**)(localVarBase + __comparand)));
ip += 10;
continue;
}
case HiOpcodeEnum::InterlockedExchangeVarVarVar_i4:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
(*(int32_t*)(localVarBase + __ret)) = HiInterlockedExchange((int32_t*)(*(void**)(localVarBase + __localtion)), (*(int32_t*)(localVarBase + __value)));
(*(int32_t*)(localVarBase + __ret)) = HiInterlockedExchange((int32_t*)(*(void**)(localVarBase + __location)), (*(int32_t*)(localVarBase + __value)));
ip += 8;
continue;
}
case HiOpcodeEnum::InterlockedExchangeVarVarVar_i8:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
(*(int64_t*)(localVarBase + __ret)) = HiInterlockedExchange((int64_t*)(*(void**)(localVarBase + __localtion)), (*(int64_t*)(localVarBase + __value)));
(*(int64_t*)(localVarBase + __ret)) = HiInterlockedExchange((int64_t*)(*(void**)(localVarBase + __location)), (*(int64_t*)(localVarBase + __value)));
ip += 8;
continue;
}
case HiOpcodeEnum::InterlockedExchangeVarVarVar_pointer:
{
uint16_t __ret = *(uint16_t*)(ip + 2);
uint16_t __localtion = *(uint16_t*)(ip + 4);
uint16_t __location = *(uint16_t*)(ip + 4);
uint16_t __value = *(uint16_t*)(ip + 6);
(*(void**)(localVarBase + __ret)) = HiInterlockedExchange((void**)(*(void**)(localVarBase + __localtion)), (*(void**)(localVarBase + __value)));
(*(void**)(localVarBase + __ret)) = HiInterlockedExchange((void**)(*(void**)(localVarBase + __location)), (*(void**)(localVarBase + __value)));
ip += 8;
continue;
}
Expand Down
Loading

0 comments on commit 4ce18e6

Please sign in to comment.