From 43e1f360eb073c9fc67256a1df7a1c8b80920336 Mon Sep 17 00:00:00 2001 From: Mike Danes Date: Sat, 25 Feb 2017 11:45:02 +0200 Subject: [PATCH] Treat BitConverter.IsLittleEndian as an intrinsic Commit migrated from https://github.com/dotnet/coreclr/commit/9c6657e2339e9889d0680ec72c299ace4f33199b --- src/coreclr/src/inc/corinfo.h | 3 +++ src/coreclr/src/jit/importer.cpp | 14 ++++++++++++++ src/coreclr/src/vm/jitinterface.cpp | 5 +++++ src/coreclr/src/vm/mscorlib.h | 2 ++ src/coreclr/src/zap/zapinfo.cpp | 1 + 5 files changed, 25 insertions(+) diff --git a/src/coreclr/src/inc/corinfo.h b/src/coreclr/src/inc/corinfo.h index 492dbec..af01631 100644 --- a/src/coreclr/src/inc/corinfo.h +++ b/src/coreclr/src/inc/corinfo.h @@ -1719,6 +1719,9 @@ enum CORINFO_FIELD_ACCESSOR CORINFO_FIELD_INTRINSIC_ZERO, // intrinsic zero (IntPtr.Zero, UIntPtr.Zero) CORINFO_FIELD_INTRINSIC_EMPTY_STRING, // intrinsic emptry string (String.Empty) +#if COR_JIT_EE_VERSION > 460 + CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN, // intrinsic BitConverter.IsLittleEndian +#endif }; // Set of flags returned in CORINFO_FIELD_INFO::fieldFlags diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index cfd2785..adc06b2 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -13263,6 +13263,20 @@ void Compiler::impImportBlockCode(BasicBlock* block) } break; +#if COR_JIT_EE_VERSION > 460 + case CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN: + { + assert(aflags & CORINFO_ACCESS_GET); +#if BIGENDIAN + op1 = gtNewIconNode(0, lclTyp); +#else + op1 = gtNewIconNode(1, lclTyp); +#endif + goto FIELD_DONE; + } + break; +#endif + default: assert(!"Unexpected fieldAccessor"); } diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index 1e84115..322614d 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -1439,6 +1439,11 @@ static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc * field) { return CORINFO_FIELD_INTRINSIC_ZERO; } + else + if (MscorlibBinder::GetField(FIELD__BITCONVERTER__ISLITTLEENDIAN) == field) + { + return CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN; + } return (CORINFO_FIELD_ACCESSOR)-1; } diff --git a/src/coreclr/src/vm/mscorlib.h b/src/coreclr/src/vm/mscorlib.h index 1d006b5..38ce80e 100644 --- a/src/coreclr/src/vm/mscorlib.h +++ b/src/coreclr/src/vm/mscorlib.h @@ -1005,6 +1005,8 @@ DEFINE_FIELD(INTPTR, ZERO, Zero) // DEFINE_CLASS(UINTPTR, System, UIntPtr) DEFINE_FIELD(UINTPTR, ZERO, Zero) +DEFINE_CLASS(BITCONVERTER, System, BitConverter) +DEFINE_FIELD(BITCONVERTER, ISLITTLEENDIAN, IsLittleEndian) // Defined as element type alias // DEFINE_CLASS(STRING, System, String) DEFINE_FIELD(STRING, M_FIRST_CHAR, m_firstChar) diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index 2095524..b203c55 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -3029,6 +3029,7 @@ void ZapInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, case CORINFO_FIELD_INTRINSIC_ZERO: case CORINFO_FIELD_INTRINSIC_EMPTY_STRING: + case CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN: break; default: -- 2.7.4