diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
commit | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch) | |
tree | e5435159cd1bf0519276363a6fe1663d1721bed3 /src/classlibnative | |
parent | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff) | |
download | coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2 coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip |
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/classlibnative')
-rw-r--r-- | src/classlibnative/bcltype/arraynative.cpp | 4 | ||||
-rw-r--r-- | src/classlibnative/bcltype/number.cpp | 6 | ||||
-rw-r--r-- | src/classlibnative/bcltype/system.cpp | 12 | ||||
-rw-r--r-- | src/classlibnative/bcltype/system.h | 1 | ||||
-rw-r--r-- | src/classlibnative/float/floatsingle.cpp | 228 | ||||
-rw-r--r-- | src/classlibnative/inc/floatsingle.h | 19 | ||||
-rw-r--r-- | src/classlibnative/inc/nlsinfo.h | 13 | ||||
-rw-r--r-- | src/classlibnative/nls/nlsinfo.cpp | 131 |
8 files changed, 271 insertions, 143 deletions
diff --git a/src/classlibnative/bcltype/arraynative.cpp b/src/classlibnative/bcltype/arraynative.cpp index b1aa6f8751..58fa4dd3e6 100644 --- a/src/classlibnative/bcltype/arraynative.cpp +++ b/src/classlibnative/bcltype/arraynative.cpp @@ -176,7 +176,6 @@ void ArrayInitializeWorker(ARRAYBASEREF * arrayRef, #ifdef _X86_ BEGIN_CALL_TO_MANAGED(); - typedef void (__fastcall * CtorFtnType)(BYTE*, BYTE*); for (SIZE_T i = 0; i < cElements; i++) { @@ -197,6 +196,7 @@ void ArrayInitializeWorker(ARRAYBASEREF * arrayRef, nop // Mark the fact that we can call managed code } #else // _DEBUG + typedef void (__fastcall * CtorFtnType)(BYTE*, BYTE*); (*(CtorFtnType)ctorFtn)(thisPtr, (BYTE*)pElemMT); #endif // _DEBUG @@ -961,7 +961,7 @@ void memmoveGCRefs(void *dest, const void *src, size_t len) } } - GCHeap::GetGCHeap()->SetCardsAfterBulkCopy((Object**)dest, len); + GCHeapUtilities::GetGCHeap()->SetCardsAfterBulkCopy((Object**)dest, len); } void ArrayNative::ArrayCopyNoTypeCheck(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) diff --git a/src/classlibnative/bcltype/number.cpp b/src/classlibnative/bcltype/number.cpp index 349bffb819..6ca24d8672 100644 --- a/src/classlibnative/bcltype/number.cpp +++ b/src/classlibnative/bcltype/number.cpp @@ -82,7 +82,7 @@ static const char* const negNumberFormats[] = { static const char posNumberFormat[] = "#"; -#if defined(_TARGET_X86_) +#if defined(_TARGET_X86_) && !defined(FEATURE_PAL) extern "C" void _cdecl /*__stdcall*/ DoubleToNumber(double value, int precision, NUMBER* number); extern "C" void _cdecl /*__stdcall*/ NumberToDouble(NUMBER* number, double* value); @@ -132,7 +132,7 @@ unsigned int Int64DivMod1E9(unsigned __int64* value) #pragma warning(default:4035) -#else // !(defined(_TARGET_X86_) +#else // _TARGET_X86_ && !FEATURE_PAL #pragma warning(disable:4273) extern "C" char* __cdecl _ecvt(double, int, int*, int*); @@ -607,7 +607,7 @@ unsigned int Int64DivMod1E9(unsigned __int64* value) -#endif // !(defined(_TARGET_X86_) +#endif // _TARGET_X86_ && !FEATURE_PAL #if defined(_MSC_VER) && defined(_TARGET_X86_) #pragma optimize("y", on) // Small critical routines, don't put in EBP frame diff --git a/src/classlibnative/bcltype/system.cpp b/src/classlibnative/bcltype/system.cpp index e902734b23..8bb3409974 100644 --- a/src/classlibnative/bcltype/system.cpp +++ b/src/classlibnative/bcltype/system.cpp @@ -63,6 +63,16 @@ FCIMPLEND; +FCIMPL0(UINT32, SystemNative::GetCurrentProcessorNumber) +{ + FCALL_CONTRACT; + + return ::GetCurrentProcessorNumber(); +} +FCIMPLEND; + + + FCIMPL0(UINT32, SystemNative::GetTickCount) { FCALL_CONTRACT; @@ -673,7 +683,7 @@ FCIMPL0(FC_BOOL_RET, SystemNative::IsServerGC) { FCALL_CONTRACT; - FC_RETURN_BOOL(GCHeap::IsServerHeap()); + FC_RETURN_BOOL(GCHeapUtilities::IsServerHeap()); } FCIMPLEND diff --git a/src/classlibnative/bcltype/system.h b/src/classlibnative/bcltype/system.h index 60355b3388..9edc595039 100644 --- a/src/classlibnative/bcltype/system.h +++ b/src/classlibnative/bcltype/system.h @@ -72,6 +72,7 @@ private: public: // Functions on the System.Environment class static FCDECL0(INT64, __GetSystemTimeAsFileTime); + static FCDECL0(UINT32, GetCurrentProcessorNumber); static FCDECL0(UINT32, GetTickCount); static FCDECL1(FC_BOOL_RET, GetOSVersion, OSVERSIONINFOObject *osVer); static FCDECL1(FC_BOOL_RET, GetOSVersionEx, OSVERSIONINFOEXObject *osVer); diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp index dd1bb43316..7e2ea0adc6 100644 --- a/src/classlibnative/float/floatsingle.cpp +++ b/src/classlibnative/float/floatsingle.cpp @@ -11,6 +11,22 @@ #define IS_FLT_INFINITY(x) (((*((INT32*)((void*)&x))) & 0x7FFFFFFF) == 0x7F800000) +// Windows x86 and Windows ARM/ARM64 may not define _isnanf() or _copysignf() but they do +// define _isnan() and _copysign(). We will redirect the macros to these other functions if +// the macro is not defined for the platform. This has the side effect of a possible implicit +// upcasting for arguments passed in and an explicit downcasting for the _copysign() call. +#if (defined(_TARGET_X86_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)) && !defined(FEATURE_PAL) + +#if !defined(_isnanf) +#define _isnanf _isnan +#endif + +#if !defined(_copysignf) +#define _copysignf (float)_copysign +#endif + +#endif + // The default compilation mode is /fp:precise, which disables floating-point intrinsics. This // default compilation mode has previously caused performance regressions in floating-point code. // We enable /fp:fast semantics for the majority of the math functions, as it will speed up performance @@ -39,6 +55,218 @@ FCIMPL1(float, COMSingle::Abs, float x) return (float)fabsf(x); FCIMPLEND +/*=====================================Acos===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Acos, float x) + FCALL_CONTRACT; + + return (float)acosf(x); +FCIMPLEND + +/*=====================================Asin===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Asin, float x) + FCALL_CONTRACT; + + return (float)asinf(x); +FCIMPLEND + +/*=====================================Atan===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Atan, float x) + FCALL_CONTRACT; + + return (float)atanf(x); +FCIMPLEND + +/*=====================================Atan2==================================== +** +==============================================================================*/ +FCIMPL2(float, COMSingle::Atan2, float y, float x) + FCALL_CONTRACT; + + // atan2f(+/-INFINITY, +/-INFINITY) produces +/-0.785398163f (x is +INFINITY) and + // +/-2.35619449f (x is -INFINITY) instead of the expected value of NaN. We handle + // that case here ourselves. + if (IS_FLT_INFINITY(y) && IS_FLT_INFINITY(x)) { + return (float)(y / x); + } + + return (float)atan2f(y, x); +FCIMPLEND + +/*====================================Ceil====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Ceil, float x) + FCALL_CONTRACT; + + return (float)ceilf(x); +FCIMPLEND + +/*=====================================Cos====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Cos, float x) + FCALL_CONTRACT; + + return (float)cosf(x); +FCIMPLEND + +/*=====================================Cosh===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Cosh, float x) + FCALL_CONTRACT; + + return (float)coshf(x); +FCIMPLEND + +/*=====================================Exp====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Exp, float x) + FCALL_CONTRACT; + + return (float)expf(x); +FCIMPLEND + +/*====================================Floor===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Floor, float x) + FCALL_CONTRACT; + + return (float)floorf(x); +FCIMPLEND + +/*=====================================Log====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Log, float x) + FCALL_CONTRACT; + + return (float)logf(x); +FCIMPLEND + +/*====================================Log10===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Log10, float x) + FCALL_CONTRACT; + + return (float)log10f(x); +FCIMPLEND + +/*=====================================ModF===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::ModF, float* iptr) + FCALL_CONTRACT; + + return (float)modff(*iptr, iptr); +FCIMPLEND + +/*=====================================Pow====================================== +** +==============================================================================*/ +FCIMPL2(float, COMSingle::Pow, float x, float y) + FCALL_CONTRACT; + + // The CRT version of pow preserves the NaN payload of x over the NaN payload of y. + + if(_isnanf(y)) { + return y; // IEEE 754-2008: NaN payload must be preserved + } + + if(_isnanf(x)) { + return x; // IEEE 754-2008: NaN payload must be preserved + } + + // The CRT version of powf does not return NaN for powf(-1.0f, +/-INFINITY) and + // instead returns +1.0f. + + if(IS_FLT_INFINITY(y) && (x == -1.0f)) { + INT32 result = CLR_NAN_32; + return (*((float*)((INT32*)&result))); + } + + return (float)powf(x, y); +FCIMPLEND + +/*====================================Round===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Round, float x) + FCALL_CONTRACT; + + // If the number has no fractional part do nothing + // This shortcut is necessary to workaround precision loss in borderline cases on some platforms + if (x == (float)((INT32)x)) { + return x; + } + + // We had a number that was equally close to 2 integers. + // We need to return the even one. + + float tempVal = (x + 0.5f); + float flrTempVal = floorf(tempVal); + + if ((flrTempVal == tempVal) && (fmodf(tempVal, 2.0f) != 0)) { + flrTempVal -= 1.0f; + } + + return _copysignf(flrTempVal, x); +FCIMPLEND + +/*=====================================Sin====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Sin, float x) + FCALL_CONTRACT; + + return (float)sinf(x); +FCIMPLEND + +/*=====================================Sinh===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Sinh, float x) + FCALL_CONTRACT; + + return (float)sinhf(x); +FCIMPLEND + +/*=====================================Sqrt===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Sqrt, float x) + FCALL_CONTRACT; + + return (float)sqrtf(x); +FCIMPLEND + +/*=====================================Tan====================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Tan, float x) + FCALL_CONTRACT; + + return (float)tanf(x); +FCIMPLEND + +/*=====================================Tanh===================================== +** +==============================================================================*/ +FCIMPL1(float, COMSingle::Tanh, float x) + FCALL_CONTRACT; + + return (float)tanhf(x); +FCIMPLEND + #ifdef _MSC_VER #pragma float_control(precise, on ) #endif diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h index 6d123ec001..f8a1dda0fd 100644 --- a/src/classlibnative/inc/floatsingle.h +++ b/src/classlibnative/inc/floatsingle.h @@ -11,6 +11,25 @@ class COMSingle { public: FCDECL1(static float, Abs, float x); + FCDECL1(static float, Acos, float x); + FCDECL1(static float, Asin, float x); + FCDECL1(static float, Atan, float x); + FCDECL2(static float, Atan2, float y, float x); + FCDECL1(static float, Ceil, float x); + FCDECL1(static float, Cos, float x); + FCDECL1(static float, Cosh, float x); + FCDECL1(static float, Exp, float x); + FCDECL1(static float, Floor, float x); + FCDECL1(static float, Log, float x); + FCDECL1(static float, Log10, float x); + FCDECL1(static float, ModF, float* iptr); + FCDECL2(static float, Pow, float x, float y); + FCDECL1(static float, Round, float x); + FCDECL1(static float, Sin, float x); + FCDECL1(static float, Sinh, float x); + FCDECL1(static float, Sqrt, float x); + FCDECL1(static float, Tan, float x); + FCDECL1(static float, Tanh, float x); }; #endif // _FLOATSINGLE_H_ diff --git a/src/classlibnative/inc/nlsinfo.h b/src/classlibnative/inc/nlsinfo.h index 1c1ff01f8a..a5dc13f9a8 100644 --- a/src/classlibnative/inc/nlsinfo.h +++ b/src/classlibnative/inc/nlsinfo.h @@ -115,19 +115,8 @@ public: static INT_PTR InternalInitVersionedSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin); static INT_PTR InternalInitVersionedSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin, DWORD sortVersion); static DWORD QCALLTYPE InternalGetSortVersion(); - static BOOL QCALLTYPE InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR lpLocaleName, NLSVERSIONINFOEX * lpVersionInformation); #endif - - -#ifndef FEATURE_CORECLR - // - // Native helper function for methods in TimeZone - // - static FCDECL0(LONG, nativeGetTimeZoneMinuteOffset); - static FCDECL0(Object*, nativeGetStandardName); - static FCDECL0(Object*, nativeGetDaylightName); - static FCDECL1(Object*, nativeGetDaylightChanges, int year); -#endif // FEATURE_CORECLR + static BOOL QCALLTYPE InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR lpLocaleName, NLSVERSIONINFOEX * lpVersionInformation); // // Native helper function for methods in EncodingTable diff --git a/src/classlibnative/nls/nlsinfo.cpp b/src/classlibnative/nls/nlsinfo.cpp index 864f998d1f..0e034c4a0c 100644 --- a/src/classlibnative/nls/nlsinfo.cpp +++ b/src/classlibnative/nls/nlsinfo.cpp @@ -1057,7 +1057,7 @@ FCIMPLEND #define CULTURETYPES_FRAMEWORKCULTURES 0x0040 -const LPWSTR WHIDBEY_FRAMEWORK_CULTURE_LIST [] = +const LPCWSTR WHIDBEY_FRAMEWORK_CULTURE_LIST [] = { W(""), W("af"), @@ -1877,127 +1877,6 @@ INT32 QCALLTYPE COMNlsInfo::InternalGetGlobalizedHashCode(INT_PTR handle, INT_PT return(iReturnHash); } -#ifndef FEATURE_CORECLR // FCalls used by System.TimeZone - -FCIMPL0(LONG, COMNlsInfo::nativeGetTimeZoneMinuteOffset) -{ - FCALL_CONTRACT; - - TIME_ZONE_INFORMATION timeZoneInfo; - - GetTimeZoneInformation(&timeZoneInfo); - - // - // In Win32, UTC = local + offset. So for Pacific Standard Time, offset = 8. - // In NLS+, Local time = UTC + offset. So for PST, offset = -8. - // So we have to reverse the sign here. - // - return (timeZoneInfo.Bias * -1); -} -FCIMPLEND - -FCIMPL0(Object*, COMNlsInfo::nativeGetStandardName) -{ - FCALL_CONTRACT; - - STRINGREF refRetVal = NULL; - HELPER_METHOD_FRAME_BEGIN_RET_1(refRetVal); - - TIME_ZONE_INFORMATION timeZoneInfo; - GetTimeZoneInformation(&timeZoneInfo); - - refRetVal = StringObject::NewString(timeZoneInfo.StandardName); - - HELPER_METHOD_FRAME_END(); - return OBJECTREFToObject(refRetVal); -} -FCIMPLEND - -FCIMPL0(Object*, COMNlsInfo::nativeGetDaylightName) -{ - FCALL_CONTRACT; - - STRINGREF refRetVal = NULL; - HELPER_METHOD_FRAME_BEGIN_RET_1(refRetVal); - - TIME_ZONE_INFORMATION timeZoneInfo; - GetTimeZoneInformation(&timeZoneInfo); - // Instead of returning null when daylight saving is not used, now we return the same result as the OS. - //In this case, if daylight saving time is used, the standard name is returned. - -#if 0 - if (result == TIME_ZONE_ID_UNKNOWN || timeZoneInfo.DaylightDate.wMonth == 0) { - // If daylight saving time is not used in this timezone, return null. - // - // Windows NT/2000: TIME_ZONE_ID_UNKNOWN is returned if daylight saving time is not used in - // the current time zone, because there are no transition dates. - // - // For Windows 9x, a zero in the wMonth in DaylightDate means daylight saving time - // is not specified. - // - // If the current timezone uses daylight saving rule, but user unchekced the - // "Automatically adjust clock for daylight saving changes", the value - // for DaylightBias will be 0. - return (I2ARRAYREF)NULL; - } -#endif // 0 - - refRetVal = StringObject::NewString(timeZoneInfo.DaylightName); - - HELPER_METHOD_FRAME_END(); - return OBJECTREFToObject(refRetVal); -} -FCIMPLEND - -FCIMPL1(Object*, COMNlsInfo::nativeGetDaylightChanges, int year) -{ - FCALL_CONTRACT; - - I2ARRAYREF pResultArray = NULL; - HELPER_METHOD_FRAME_BEGIN_RET_1(pResultArray); - - TIME_ZONE_INFORMATION timeZoneInfo; - DWORD result = GetTimeZoneInformation(&timeZoneInfo); - - if (result == TIME_ZONE_ID_UNKNOWN || timeZoneInfo.DaylightBias == 0 - || timeZoneInfo.DaylightDate.wMonth == 0 - ) { - // If daylight saving time is not used in this timezone, return null. - // - // If the current timezone uses daylight saving rule, but user unchekced the - // "Automatically adjust clock for daylight saving changes", the value - // for DaylightBias will be 0. - goto lExit; - } - - pResultArray = (I2ARRAYREF)AllocatePrimitiveArray(ELEMENT_TYPE_I2, 17); - - // - // The content of timeZoneInfo.StandardDate is 8 words, which - // contains year, month, day, dayOfWeek, hour, minute, second, millisecond. - // - memcpyNoGCRefs(pResultArray->m_Array, - (LPVOID)&timeZoneInfo.DaylightDate, - 8 * sizeof(INT16)); - - // - // The content of timeZoneInfo.DaylightDate is 8 words, which - // contains year, month, day, dayOfWeek, hour, minute, second, millisecond. - // - memcpyNoGCRefs(((INT16*)pResultArray->m_Array) + 8, - (LPVOID)&timeZoneInfo.StandardDate, - 8 * sizeof(INT16)); - - ((INT16*)pResultArray->m_Array)[16] = (INT16)timeZoneInfo.DaylightBias * -1; - -lExit: ; - HELPER_METHOD_FRAME_END(); - return OBJECTREFToObject(pResultArray); -} -FCIMPLEND - -#endif // FEATURE_CORECLR - inline BOOL IsInvariantLocale(STRINGREF localeName) { return localeName->GetStringLength() == 0; @@ -3411,7 +3290,6 @@ INT_PTR COMNlsInfo::InternalInitOsSortHandle(LPCWSTR localeName, __out INT_PTR* return pSort; } -#ifndef FEATURE_CORECLR BOOL QCALLTYPE COMNlsInfo::InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR lpLocaleName, NLSVERSIONINFOEX * lpVersionInformation) { CONTRACTL { @@ -3421,7 +3299,7 @@ BOOL QCALLTYPE COMNlsInfo::InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handl BOOL ret = FALSE; BEGIN_QCALL; - +#ifndef FEATURE_CORECLR AppDomain* curDomain = GetAppDomain(); if(curDomain->m_bUseOsSorting) @@ -3449,12 +3327,15 @@ BOOL QCALLTYPE COMNlsInfo::InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handl lpVersionInformation->dwEffectiveId = 0; ZeroMemory(&(lpVersionInformation->guidCustomVersion), sizeof(GUID)); } - +#else + ret = GetNLSVersionEx(COMPARE_STRING, lpLocaleName, lpVersionInformation); +#endif // FEATURE_CORECLR END_QCALL; return ret; } +#ifndef FEATURE_CORECLR DWORD QCALLTYPE COMNlsInfo::InternalGetSortVersion() { CONTRACTL { |