Skip to content

Commit 77bc98e

Browse files
committed
Update nf-interpreter sub-module
***NO_CI***
1 parent 828ef8d commit 77bc98e

File tree

101 files changed

+2785
-3415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2785
-3415
lines changed

native/nf-interpreter/CMake/Modules/FindNF_NativeAssemblies.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ option(API_System.Device.Pwm "option for System.Devic
2929
option(API_System.IO.Ports "option for System.IO.Ports API")
3030
option(API_System.Device.Spi "option for System.Device.Spi API")
3131
option(API_System.Runtime.Serialization "option for System.Runtime.Serialization API")
32-
option(API_Windows.Storage "option for Windows.Storage")
3332
option(API_nanoFramework.Graphics "option for nanoFramework.Graphics")
3433
option(API_nanoFramework.Device.Bluetooth "option for nanoFramework.Device.Bluetooth")
3534
option(API_System.Device.UsbStream "option for System.Device.UsbStream API")
@@ -453,12 +452,6 @@ if(API_System.Device.UsbStream)
453452
PerformSettingsForApiEntry("System.Device.UsbStream")
454453
endif()
455454

456-
# Windows.Storage
457-
if(API_Windows.Storage)
458-
##### API name here (doted name)
459-
PerformSettingsForApiEntry("Windows.Storage")
460-
endif()
461-
462455
# Interop assemblies
463456
ParseInteropAssemblies()
464457

native/nf-interpreter/CMake/Modules/FindSystem.IO.FileSystem.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/System.IO
88

99
if(RTOS_FREERTOS_CHECK)
1010
set(PROJECT_COMMON_PATH ${PROJECT_SOURCE_DIR}/targets/FreeRTOS/NXP/_common)
11+
set(FATFS_PLATFORM ${PROJECT_SOURCE_DIR}/targets/FreeRTOS/NXP/_FatFs)
1112
else()
1213
set(PROJECT_COMMON_PATH ${PROJECT_SOURCE_DIR}/targets/${RTOS}/_common)
1314
endif()
@@ -75,6 +76,7 @@ foreach(SRC_FILE ${System.IO.FileSystem_SRCS})
7576

7677
# FatFs
7778
${CMAKE_SOURCE_DIR}/targets/${RTOS}/_FatFs
79+
${FATFS_PLATFORM}
7880

7981
CMAKE_FIND_ROOT_PATH_BOTH
8082
)

native/nf-interpreter/CMake/Modules/FindWindows.Storage.cmake

Lines changed: 0 additions & 63 deletions
This file was deleted.

native/nf-interpreter/CMake/Modules/FreeRTOS_IMXRT10xx_GCC_options.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ macro(nf_set_compile_options)
3333
# this series has FPU
3434
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)
3535

36-
# temporarily force inclusion of Windows Storage headers
37-
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DINCLUDE_WINDOWS_STORAGE)
3836
endmacro()
3937

4038

native/nf-interpreter/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,11 @@ if(NF_FEATURE_HAS_SDCARD)
309309

310310
# this feature currently is supported only on ChibiOS, iMX.RT FreeRTOS and ESP32 FreeRTOS
311311
if(NOT RTOS_CHIBIOS_CHECK AND NOT RTOS_FREERTOS_CHECK AND NOT RTOS_ESP32_CHECK)
312-
message(FATAL_ERROR "Support for SD Card is only available for ChibiOS Cortex-M targets, iMX.RT FreeRTOS and ESP32 targets..")
312+
message(FATAL_ERROR "Support for SD Card is only available for ChibiOS Cortex-M targets, iMX.RT FreeRTOS and ESP32 targets.")
313313
endif()
314314

315-
if(RTOS_FREERTOS_CHECK)
316-
# ONLY FOR FREERTOS+NXP force inclusion of Windows.Storage API
317-
set(API_Windows.Storage ON CACHE INTERNAL "Forcing Windows.Storage API option to ON")
318-
else()
319-
# all the others RTOSes: force inclusion of System.IO.FileSystem API
320-
set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON")
321-
endif()
315+
# all RTOSes: force inclusion of System.IO.FileSystem API
316+
set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON")
322317

323318
message(STATUS "Support for SD Card is included")
324319

@@ -668,7 +663,6 @@ if( API_nanoFramework.Device.OneWire OR
668663
API_System.Device.Gpio OR
669664
API_System.IO.Ports OR
670665
API_nanoFramework.Device.Can OR
671-
API_Windows.Storage OR
672666
API_System.IO.FileSystem)
673667

674668
# these APIs requires nanoFramework.Runtime.Events

native/nf-interpreter/azure-pipelines.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
9797
if( ($commit.commit.author.name -eq "nfbot") -and ($commit.commit.message -like "*[version update]*") )
9898
{
99+
Write-Host "##[command] **version update commit, skipping build**"
99100
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true"
100101
}
101102
else
@@ -106,6 +107,7 @@ jobs:
106107
# check if Unit Tests for mscorlib should be run
107108
if(($commit.commit.message -like "*[run mscorlib tests]*") -or ($commit.commit.message -match "Tested against nanoframework/CoreLibrary#(\d+)"))
108109
{
110+
Write-Host "##[command] **mscorlib tests are to be runned**"
109111
echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]true"
110112
}
111113
}
@@ -1216,7 +1218,7 @@ jobs:
12161218
and(
12171219
succeeded('Build_nanoCLR_CLI'),
12181220
ne(dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true),
1219-
eq(variables['System.PullRequest.PullRequestId'], ''),
1221+
ne(variables['System.PullRequest.PullRequestId'], ''),
12201222
or(
12211223
eq(dependencies.Check_Build_Options.outputs['BuildOptions.RUN_MSCORLIB_TESTS'], true),
12221224
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
@@ -1272,6 +1274,14 @@ jobs:
12721274

12731275
- template: azure-pipelines-templates/install-nuget.yml@templates
12741276

1277+
- task: Cache@2
1278+
displayName: Cache NuGet packages
1279+
condition: succeeded()
1280+
continueOnError: true
1281+
inputs:
1282+
key: 'nuget | **/packages.lock.json'
1283+
path: $(UserProfile)/.nuget/packages
1284+
12751285
- task: NuGetCommand@2
12761286
condition: succeeded()
12771287
displayName: NuGet restore

native/nf-interpreter/src/CLR/Core/CLR_RT_HeapBlock.cpp

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
55
//
6+
67
#include "Core.h"
7-
#include <nanoHAL.h>
88
#include <nanoPAL_NativeDouble.h>
99

1010
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1102,8 +1102,21 @@ CLR_UINT32 CLR_RT_HeapBlock::GetHashCode(CLR_RT_HeapBlock *ptr, bool fRecurse, C
11021102
break;
11031103

11041104
case DATATYPE_R4:
1105-
crc = (CLR_INT32)ptr->NumericByRef().u8.LL;
1105+
{
1106+
// ensure that NaN and both zeros have the same hash code
1107+
int signBit = __signbitd(ptr->NumericByRef().r4);
1108+
1109+
if (__isnanf(ptr->NumericByRef().r4) || (signBit && ptr->NumericByRef().r4 == 0))
1110+
{
1111+
crc = (CLR_INT32)(ptr->NumericByRef().u8.LL & 0x7FFFFFFF);
1112+
}
1113+
else
1114+
{
1115+
crc = (CLR_INT32)ptr->NumericByRef().u8.LL;
1116+
}
1117+
11061118
break;
1119+
}
11071120

11081121
case DATATYPE_U8:
11091122
crc = ((CLR_INT32)ptr->NumericByRef().u8.LL ^ (CLR_INT32)ptr->NumericByRef().u8.HH);
@@ -1114,8 +1127,20 @@ CLR_UINT32 CLR_RT_HeapBlock::GetHashCode(CLR_RT_HeapBlock *ptr, bool fRecurse, C
11141127
break;
11151128

11161129
case DATATYPE_R8:
1117-
crc = ((CLR_INT32)ptr->NumericByRef().r8.LL ^ (CLR_INT32)ptr->NumericByRef().r8.HH);
1130+
{
1131+
// ensure that NaN and both zeros have the same hash code
1132+
int signBit = __signbitd((double)ptr->NumericByRef().r8);
1133+
1134+
if (__isnand((double)ptr->NumericByRef().r8) || (signBit && (double)ptr->NumericByRef().r8 == 0))
1135+
{
1136+
crc = (CLR_INT32)(ptr->NumericByRef().r8.LL ^ ((CLR_INT32)ptr->NumericByRef().r8.HH & 0x7FFFFFFF));
1137+
}
1138+
else
1139+
{
1140+
crc = ((CLR_INT32)ptr->NumericByRef().r8.LL ^ (CLR_INT32)ptr->NumericByRef().r8.HH);
1141+
}
11181142
break;
1143+
}
11191144

11201145
case DATATYPE_CLASS:
11211146
case DATATYPE_VALUETYPE:
@@ -1336,6 +1361,29 @@ bool CLR_RT_HeapBlock::ObjectsEqual(
13361361
return Compare_Values(pArgLeft, pArgRight, false) == 0;
13371362
break;
13381363

1364+
// edge cases, in .NET a NaN is equal to another NaN
1365+
// https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-double-equals?WT.mc_id=DT-MVP-5004179#nan
1366+
case DATATYPE_R4:
1367+
if (__isnanf(pArgLeft.NumericByRefConst().r4) && __isnanf(pArgRight.NumericByRefConst().r4))
1368+
{
1369+
return true;
1370+
}
1371+
else
1372+
{
1373+
return Compare_Values(pArgLeft, pArgRight, false) == 0;
1374+
}
1375+
break;
1376+
case DATATYPE_R8:
1377+
if (__isnand((double)pArgLeft.NumericByRefConst().r8) && __isnand((double)pArgRight.NumericByRefConst().r8))
1378+
{
1379+
return true;
1380+
}
1381+
else
1382+
{
1383+
return Compare_Values(pArgLeft, pArgRight, false) == 0;
1384+
}
1385+
break;
1386+
13391387
case DATATYPE_BYREF:
13401388
if (rightDataType == DATATYPE_OBJECT)
13411389
{
@@ -1655,9 +1703,9 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C
16551703
case DATATYPE_R4:
16561704

16571705
// deal with special cases:
1658-
// return 0 if the numbers are unordered (either or both are NaN)
1706+
// return 1 if the numbers are unordered (either or both are NaN)
16591707
// this is post processed in interpreter so '1' will turn into '0'
1660-
if (__isnand(left.NumericByRefConst().r4) && __isnand(right.NumericByRefConst().r4))
1708+
if (__isnanf(left.NumericByRefConst().r4) || __isnanf(right.NumericByRefConst().r4))
16611709
{
16621710
return 1;
16631711
}
@@ -1688,7 +1736,7 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C
16881736
case DATATYPE_R8:
16891737

16901738
// deal with special cases:
1691-
// return 0 if the numbers are unordered (either or both are NaN)
1739+
// return 1 if the numbers are unordered (either or both are NaN)
16921740
// this is post processed in interpreter so '1' will turn into '0'
16931741
if (__isnand((double)left.NumericByRefConst().r8) || __isnand((double)right.NumericByRefConst().r8))
16941742
{
@@ -2471,19 +2519,24 @@ void CLR_RT_HeapBlock::Debug_CheckPointer() const
24712519
void CLR_RT_HeapBlock::Debug_CheckPointer(void *ptr)
24722520
{
24732521
NATIVE_PROFILE_CLR_CORE();
2474-
switch ((size_t)ptr)
2522+
2523+
switch ((intptr_t)ptr)
24752524
{
2476-
case 0xCFCFCFCF:
2477-
case 0xCBCBCBCB:
2478-
case 0xABABABAB:
2479-
case 0xADADADAD:
2480-
case 0xDFDFDFDF:
2525+
case SENTINEL_CLUSTER_INSERT:
2526+
case SENTINEL_CLEAR_BLOCK:
2527+
case SENTINEL_NODE_APPENDED:
2528+
case SENTINEL_NODE_EXTRACTED:
2529+
case SENTINEL_RECOVERED:
24812530
NANOCLR_STOP();
24822531
break;
24832532
}
24842533
}
24852534

2486-
void CLR_RT_HeapBlock::Debug_ClearBlock(int data)
2535+
#ifdef _WIN64
2536+
void CLR_RT_HeapBlock::Debug_ClearBlock(CLR_UINT64 data)
2537+
#else
2538+
void CLR_RT_HeapBlock::Debug_ClearBlock(CLR_UINT32 data)
2539+
#endif
24872540
{
24882541
NATIVE_PROFILE_CLR_CORE();
24892542
CLR_UINT32 size = DataSize();
@@ -2492,19 +2545,25 @@ void CLR_RT_HeapBlock::Debug_ClearBlock(int data)
24922545
{
24932546
CLR_RT_HeapBlock_Raw *ptr = (CLR_RT_HeapBlock_Raw *)this;
24942547
CLR_UINT32 raw1 = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_OBJECT, 0, 1);
2495-
CLR_UINT32 raw2;
2496-
2497-
raw2 = data & 0xFF;
2498-
raw2 = raw2 | (raw2 << 8);
2499-
raw2 = raw2 | (raw2 << 16);
25002548

25012549
while (--size)
25022550
{
25032551
ptr++;
25042552

25052553
ptr->data[0] = raw1;
2506-
ptr->data[1] = raw2;
2507-
ptr->data[2] = raw2;
2554+
2555+
#ifdef _WIN64
2556+
// need to cast this to CLR_UINT32 to avoid warning
2557+
// in the end these will be pointers so the size of the data type is irrelevant
2558+
ptr->data[1] = (CLR_UINT32)data;
2559+
ptr->data[2] = (CLR_UINT32)data;
2560+
ptr->data[3] = (CLR_UINT32)data;
2561+
ptr->data[4] = (CLR_UINT32)data;
2562+
#else
2563+
ptr->data[1] = data;
2564+
ptr->data[2] = data;
2565+
2566+
#endif
25082567
}
25092568
}
25102569
}

0 commit comments

Comments
 (0)