Skip to content

Switching MathInternal.Min/Max to managed implementations #2815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}