Skip to content

Commit

Permalink
Switching MathInternal.Min/Max to managed implementations (nanoframew…
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryCharlton authored Nov 9, 2023
1 parent ac97f68 commit 18c385b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 41 deletions.
14 changes: 7 additions & 7 deletions src/CLR/CorLib/corlib_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4,
Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4,
Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4,
NULL,
NULL,
NULL,
NULL,
Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate,
Expand Down Expand Up @@ -1320,8 +1320,8 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4,
Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4,
Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4,
NULL,
NULL,
NULL,
NULL,
Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate,
Expand Down Expand Up @@ -1483,18 +1483,18 @@ const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib =

#if (NANOCLR_REFLECTION == TRUE)

0xCCE8376E,
0x445C7AF9,

#elif (NANOCLR_REFLECTION == FALSE)

0xF60D1B13,
0xE3A4B52F,

#else
#error "NANOCLR_REFLECTION has to be define either TRUE or FALSE. Check the build options."
#endif

method_lookup,
{ 100, 5, 0, 18 }
{ 100, 5, 0, 19 }
};

// clang-format on
2 changes: 0 additions & 2 deletions src/CLR/CorLib/corlib_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,6 @@ struct Library_corlib_native_System_Guid
struct Library_corlib_native_System_MathInternal
{
NANOCLR_NATIVE_DECLARE(Abs___STATIC__I4__I4);
NANOCLR_NATIVE_DECLARE(Min___STATIC__I4__I4__I4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__I4__I4__I4);

//--//
};
Expand Down
35 changes: 3 additions & 32 deletions src/CLR/CorLib/corlib_native_System_MathInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,15 @@
//
#include "CorLib.h"

HRESULT Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4( CLR_RT_StackFrame& stack )
HRESULT Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4(CLR_RT_StackFrame &stack)
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

CLR_INT32 d = stack.Arg0().NumericByRefConst().s4;
CLR_INT32 res = abs( d );
CLR_INT32 res = abs(d);

stack.SetResult_I4( res );
stack.SetResult_I4(res);

NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_MathInternal::Max___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

CLR_INT32 x = stack.Arg0().NumericByRefConst().s4;
CLR_INT32 y = stack.Arg1().NumericByRefConst().s4;
CLR_INT32 res = x >= y ? x : y;

stack.SetResult_I4( res );

NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_MathInternal::Min___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

CLR_INT32 x = stack.Arg0().NumericByRefConst().s4;
CLR_INT32 y = stack.Arg1().NumericByRefConst().s4;
CLR_INT32 res = x <= y ? x : y;

stack.SetResult_I4( res );

NANOCLR_NOCLEANUP_NOLABEL();
}

0 comments on commit 18c385b

Please sign in to comment.