Merge pull request #10904 from BruceForstall/ArmMergeCodegenFuncs
authorBruce Forstall <brucefo@microsoft.com>
Wed, 12 Apr 2017 16:17:17 +0000 (09:17 -0700)
committerGitHub <noreply@github.com>
Wed, 12 Apr 2017 16:17:17 +0000 (09:17 -0700)
Merge similar arm32/arm64 codegen functions

66 files changed:
buildpipeline/pipelines.json
dependencies.props
netci.groovy
src/gc/gchandletable.cpp
src/gc/gchandletableimpl.h
src/gc/gcinterface.h
src/gc/handletable.h
src/gc/objecthandle.cpp
src/gc/objecthandle.h
src/gc/sample/GCSample.cpp
src/jit/codegenxarch.cpp
src/jit/compiler.h
src/jit/emitarm.cpp
src/jit/emitarm.h
src/jit/flowgraph.cpp
src/jit/gcencode.cpp
src/jit/importer.cpp
src/jit/lsraarmarch.cpp
src/mscorlib/Resources/Strings.resx
src/mscorlib/System.Private.CoreLib.csproj
src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/mscorlib/shared/System/Runtime/Serialization/IDeserializationCallback.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/OnDeserializedAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/OnDeserializingAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/OnSerializedAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/OnSerializingAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/OptionalFieldAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs [moved from src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs with 66% similarity]
src/mscorlib/shared/System/Runtime/Serialization/SerializationInfoEnumerator.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Serialization/StreamingContext.cs [new file with mode: 0644]
src/mscorlib/shared/System/Runtime/Versioning/NonVersionableAttribute.cs [moved from src/mscorlib/src/System/Runtime/Versioning/NonVersionableAttribute.cs with 100% similarity]
src/mscorlib/shared/System/Threading/AbandonedMutexException.cs [moved from src/mscorlib/src/System/Threading/AbandonedMutexException.cs with 81% similarity]
src/mscorlib/shared/System/Threading/ApartmentState.cs [moved from src/mscorlib/src/System/Threading/ApartmentState.cs with 67% similarity]
src/mscorlib/shared/System/Threading/AsyncLocal.cs [moved from src/mscorlib/src/System/Threading/AsyncLocal.cs with 99% similarity]
src/mscorlib/shared/System/Threading/AutoResetEvent.cs [moved from src/mscorlib/src/System/Threading/AutoResetEvent.cs with 59% similarity]
src/mscorlib/shared/System/Threading/EventResetMode.cs [moved from src/mscorlib/src/System/Threading/EventResetMode.cs with 88% similarity]
src/mscorlib/shared/System/Threading/ExecutionContext.cs [moved from src/mscorlib/src/System/Threading/ExecutionContext.cs with 96% similarity]
src/mscorlib/shared/System/Threading/LazyThreadSafetyMode.cs [new file with mode: 0644]
src/mscorlib/shared/System/Threading/LockRecursionException.cs [moved from src/mscorlib/src/System/Threading/LockRecursionException.cs with 52% similarity]
src/mscorlib/shared/System/Threading/ManualResetEvent.cs [moved from src/mscorlib/src/System/Threading/ManualResetEvent.cs with 59% similarity]
src/mscorlib/shared/System/Threading/ParameterizedThreadStart.cs [moved from src/mscorlib/src/System/Threading/ParameterizedThreadStart.cs with 85% similarity]
src/mscorlib/shared/System/Threading/SemaphoreFullException.cs [moved from src/mscorlib/src/System/Threading/SemaphoreFullException.cs with 92% similarity]
src/mscorlib/shared/System/Threading/SendOrPostCallback.cs [moved from src/mscorlib/src/System/Threading/SendOrPostCallback.cs with 53% similarity]
src/mscorlib/shared/System/Threading/SynchronizationLockException.cs [moved from src/mscorlib/src/System/Threading/SynchronizationLockException.cs with 98% similarity]
src/mscorlib/shared/System/Threading/ThreadPriority.cs [moved from src/mscorlib/src/System/Threading/ThreadPriority.cs with 68% similarity]
src/mscorlib/shared/System/Threading/ThreadStart.cs [moved from src/mscorlib/src/System/Threading/ThreadStart.cs with 76% similarity]
src/mscorlib/shared/System/Threading/ThreadStartException.cs [moved from src/mscorlib/src/System/Threading/ThreadStartException.cs with 80% similarity]
src/mscorlib/shared/System/Threading/ThreadState.cs [moved from src/mscorlib/src/System/Threading/ThreadState.cs with 74% similarity]
src/mscorlib/shared/System/Threading/ThreadStateException.cs [moved from src/mscorlib/src/System/Threading/ThreadStateException.cs with 95% similarity]
src/mscorlib/shared/System/Threading/TimeoutHelper.cs [new file with mode: 0644]
src/mscorlib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs [moved from src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs with 92% similarity]
src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs [deleted file]
src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs [deleted file]
src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs [deleted file]
src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs [deleted file]
src/mscorlib/src/System/Threading/LazyInitializer.cs
src/mscorlib/src/System/Threading/SpinWait.cs
src/pal/tools/gen-buildsys-clang.sh
src/vm/appdomain.cpp
src/vm/gchandletableutilities.h
src/vm/stackwalk.cpp
tests/scripts/arm32_ci_script.sh
tests/src/Common/build_against_pkg_dependencies/project.json
tests/src/Common/targeting_pack_ref/project.json
tests/src/JIT/opt/Devirtualization/GitHub_10858.cs [new file with mode: 0644]
tests/src/JIT/opt/Devirtualization/GitHub_10858.csproj [new file with mode: 0644]

index 503d574..9ab0237 100644 (file)
@@ -17,7 +17,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "Debian 8.2",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -28,7 +30,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "RedHat 7",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -39,7 +43,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 14.04",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -50,7 +56,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 16.04",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -61,7 +69,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 16.10",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -72,7 +82,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "Fedora 24",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
@@ -83,7 +95,9 @@
           },
           "ReportingParameters": {
             "OperatingSystem": "openSUSE 42.1",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "Alpine 3.4.3",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "RedHat 7",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "OSX 10.12",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "RedHat 7",
             "Type": "build/product/",
-            "SubType": "PortableBuild"
+            "SubType": "PortableBuild",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "Windows",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "Windows",
             "Type": "build/product/",
-            "SubType" : "PortableBuild"
+            "SubType" : "PortableBuild",
+            "Architecture": "x64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "Windows",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "arm64",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "Windows",
             "Type": "build/product/",
-            "SubType" : "PortableBuild"
+            "SubType" : "PortableBuild",
+            "Architecture": "arm64",
+            "PB_BuildType": null
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "Windows",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "arm",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "Windows",
             "Type": "build/product/",
-            "SubType" : "PortableBuild"
+            "SubType" : "PortableBuild",
+            "Architecture": "arm",
+            "PB_BuildType": null
           }
         },
         {
-          "Name": "DotNet-CoreClr-Trusted-Windows-x86"
+          "Name": "DotNet-CoreClr-Trusted-Windows-x86",
+          "ReportingParameters": {
+            "OperatingSystem": "Windows",
+            "Type": "build/product/",
+            "Architecture": "x86",
+            "PB_BuildType": null
+          }
         },
         {
           "Name": "DotNet-CoreClr-Trusted-Windows-x86",
           "ReportingParameters": {
             "OperatingSystem": "Windows",
             "Type": "build/product/",
-            "SubType" : "PortableBuild"
+            "SubType" : "PortableBuild",
+            "Architecture": "x86",
+            "PB_BuildType": null
           }
         }
       ]
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 14.04",
             "SubType": "CrossBuild",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "arm",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 14.04",
             "SubType": "PortableCrossBuild",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "arm",
+            "PB_BuildType": null
           }
         },
         {
           "ReportingParameters": {
             "OperatingSystem": "Ubuntu 16.04",
             "SubType": "CrossBuild",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "Architecture": "arm",
+            "PB_BuildType": null
           }
         }
       ]
       "BuildParameters": {
         "PB_BuildType": "Release"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Release"
+      },
       "DefinitionGroupRefs": [
         "Product-Build"
       ]
       "BuildParameters": {
         "PB_BuildType": "Debug"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Debug"
+      },
       "DefinitionGroupRefs": [
         "Product-Build"
       ]
       "BuildParameters": {
         "PB_BuildType": "Checked"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Checked"
+      },
       "DefinitionGroupRefs": [
         "Product-Build"
       ]
       "BuildParameters": {
         "PB_BuildType": "Release"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Release"
+      },
       "DefinitionGroupRefs": [
         "Linux-CrossBuild"
       ]
       "BuildParameters": {
         "PB_BuildType": "Debug"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Debug"
+      },
       "DefinitionGroupRefs": [
         "Linux-CrossBuild"
       ]
       "BuildParameters": {
         "PB_BuildType": "Checked"
       },
+      "ReportingParameters": {
+        "PB_BuildType": "Checked"
+      },
       "DefinitionGroupRefs": [
         "Linux-CrossBuild"
       ]
       "BuildParameters": {
         "PB_BuildType": "Release"
       },
-      "ReportingParameters": {
-        "SubType":  "Publish",
-        "Type": "build/publish/"
-      },
       "Definitions": [
         {
           "Name": "DotNet-Trusted-Publish",
             "GitHubRepositoryName": "coreclr",
             "AzureContainerPackageGlob": "pkg\\*.nupkg",
             "AzureContainerSymbolPackageGlob": "symbolpkg\\*.nupkg"
+          },
+          "ReportingParameters": {
+            "SubType":  "Publish",
+            "Type": "build/publish/",
+            "PB_BuildType": "Release"
           }
         }
       ],
       "BuildParameters": {
         "PB_BuildType": "Debug"
       },
-      "ReportingParameters": {
-        "SubType": "Publish",
-        "Type": "build/publish/"
-      },
       "Definitions": [
         {
           "Name": "DotNet-Trusted-Publish",
           "Parameters": {
             "VstsRepositoryName": "DotNet-CoreCLR-Trusted",
             "GitHubRepositoryName": "coreclr"
+          },
+          "ReportingParameters": {
+            "SubType": "Publish",
+            "Type": "build/publish/",
+            "PB_BuildType": "Debug"
           }
         }
       ],
       "BuildParameters": {
         "PB_BuildType": "Checked"
       },
-      "ReportingParameters": {
-        "SubType": "Publish",
-        "Type": "build/publish/"
-      },
-
       "Definitions": [
         {
           "Name": "DotNet-Trusted-Publish",
           "Parameters": {
             "VstsRepositoryName": "DotNet-CoreCLR-Trusted",
             "GitHubRepositoryName": "coreclr"
+          },
+          "ReportingParameters": {
+            "SubType": "Publish",
+            "Type": "build/publish/",
+            "PB_BuildType": "Checked"
           }
         }
       ],
           },
           "ReportingParameters": {
             "OperatingSystem": "Windows",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "PB_BuildType": "Release"
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "OSX",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "PB_BuildType": "Release"
           }
         },
         {
           },
           "ReportingParameters": {
             "OperatingSystem": "RedHat 7",
-            "Type": "build/product/"
+            "Type": "build/product/",
+            "PB_BuildType": "Release"
           }
         }
       ],
index 389a4c1..0221036 100644 (file)
@@ -2,7 +2,7 @@
   <!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
   <PropertyGroup>
     <CoreFxCurrentRef>e92f146e291cdddd764887db41dcdf95263300a8</CoreFxCurrentRef>
-    <CoreClrCurrentRef>5487e519a5becf43d50319bcaaf2734dbc6ae6ec</CoreClrCurrentRef>
+    <CoreClrCurrentRef>07f76bae460357bfea01929910911531ec50e15c</CoreClrCurrentRef>
   </PropertyGroup>
 
   <!-- Auto-upgraded properties for each build info dependency. -->
@@ -12,7 +12,7 @@
 
   <!-- Full package version strings that are used in other parts of the build. -->
   <PropertyGroup>
-    <CoreClrPackageVersion>2.0.0-preview1-25210-04</CoreClrPackageVersion>
+    <CoreClrPackageVersion>2.0.0-preview1-25212-04</CoreClrPackageVersion>
     <XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
   </PropertyGroup>
 
index 87083a6..05e5d7f 100755 (executable)
@@ -1637,7 +1637,9 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
                     // Unpack the corefx binaries
                     buildCommands += "mkdir ./bin/CoreFxBinDir"
                     buildCommands += "tar -xf ./bin/build.tar.gz -C ./bin/CoreFxBinDir"
-                    buildCommands += "chmod a+x ./bin/CoreFxBinDir/corerun"
+                    if (os != 'Tizen') {
+                        buildCommands += "chmod a+x ./bin/CoreFxBinDir/corerun"
+                    }
 
                     // Call the ARM CI script to cross build and test using docker
                     buildCommands += """./tests/scripts/arm32_ci_script.sh \\
index f8222b1..accc72d 100644 (file)
@@ -54,4 +54,19 @@ OBJECTHANDLE GCHandleTable::CreateDependentHandle(void* table, Object* primary,
     ::SetDependentHandleSecondary(handle, ObjectToOBJECTREF(secondary));
 
     return handle;
-}
\ No newline at end of file
+}
+
+void GCHandleTable::DestroyHandleOfType(OBJECTHANDLE handle, int type)
+{
+    ::HndDestroyHandle(::HndGetHandleTable(handle), type, handle);
+}
+
+void GCHandleTable::DestroyHandleOfUnknownType(OBJECTHANDLE handle)
+{
+    ::HndDestroyHandleOfUnknownType(::HndGetHandleTable(handle), handle);
+}
+
+void* GCHandleTable::GetExtraInfoFromHandle(OBJECTHANDLE handle)
+{
+    return (void*)::HndGetHandleExtraInfo(handle);
+}
index 787e0c1..350ae58 100644 (file)
@@ -25,6 +25,12 @@ public:
     virtual OBJECTHANDLE CreateDependentHandle(void* table, Object* primary, Object* secondary);
 
     virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type);
+
+    virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type);
+
+    virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
+
+    virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
 };
 
 #endif  // GCHANDLETABLE_H_
index d0fa879..b10e081 100644 (file)
@@ -420,6 +420,12 @@ public:
     virtual OBJECTHANDLE CreateDependentHandle(void* table, Object* primary, Object* secondary) = 0;
 
     virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type) = 0;
+
+    virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type) = 0;
+
+    virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0;
+
+    virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0;
 };
 
 // IGCHeap is the interface that the VM will use when interacting with the GC.
index 5b0299f..ebf8c62 100644 (file)
@@ -216,18 +216,6 @@ FORCEINLINE BOOL HndIsNull(OBJECTHANDLE handle)
 }
 
 
-
-/*
- * inline handle checking
- */
-FORCEINLINE BOOL HndCheckForNullUnchecked(OBJECTHANDLE handle)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    return (handle == NULL || (*(_UNCHECKED_OBJECTREF *)handle) == NULL);
-}
-
-
 /*
  *
  * Checks handle value for null or special value used for free handles in cache.
index a100037..5df53ba 100644 (file)
@@ -1856,51 +1856,6 @@ bool HandleTableBucket::Contains(OBJECTHANDLE handle)
     return FALSE;
 }
 
-void DestroySizedRefHandle(OBJECTHANDLE handle)
-{ 
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        SO_TOLERANT;
-        MODE_ANY;
-    }
-    CONTRACTL_END;
-
-    HHANDLETABLE hTable = HndGetHandleTable(handle);
-    HndDestroyHandle(hTable , HNDTYPE_SIZEDREF, handle);
-    AppDomain* pDomain = SystemDomain::GetAppDomainAtIndex(HndGetHandleTableADIndex(hTable));
-    pDomain->DecNumSizedRefHandles();
-}
-
-#ifdef FEATURE_COMINTEROP
-
-void DestroyWinRTWeakHandle(OBJECTHANDLE handle)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-        CAN_TAKE_LOCK;
-        SO_TOLERANT;
-    }
-    CONTRACTL_END;
-
-    // Release the WinRT weak reference if we have one.  We're assuming that this will not reenter the
-    // runtime, since if we are pointing at a managed object, we should not be using a HNDTYPE_WEAK_WINRT
-    // but rather a HNDTYPE_WEAK_SHORT or HNDTYPE_WEAK_LONG.
-    IWeakReference* pWinRTWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle));
-    if (pWinRTWeakReference != NULL)
-    {
-        pWinRTWeakReference->Release();
-    }
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_WINRT, handle);
-}
-
-#endif // FEATURE_COMINTEROP
-
 #endif // !DACCESS_COMPILE
 
 OBJECTREF GetDependentHandleSecondary(OBJECTHANDLE handle)
index 73d363f..12124f8 100644 (file)
@@ -30,8 +30,6 @@
 #define StoreObjectInHandle(handle, object)        HndAssignHandle(handle, object)
 #define InterlockedCompareExchangeObjectInHandle(handle, object, oldObj)        HndInterlockedCompareExchangeHandle(handle, object, oldObj)
 #define StoreFirstObjectInHandle(handle, object)   HndFirstAssignHandle(handle, object)
-#define ObjectHandleIsNull(handle)                 HndIsNull(handle)
-#define IsHandleNullUnchecked(handle)              HndCheckForNullUnchecked(handle)
 
 typedef DPTR(struct HandleTableMap) PTR_HandleTableMap;
 typedef DPTR(struct HandleTableBucket) PTR_HandleTableBucket;
@@ -73,119 +71,10 @@ struct HandleTableBucket
                                     (flag == VHT_STRONG)     || \
                                     (flag == VHT_PINNED))
 
-#ifndef DACCESS_COMPILE
-/*
- * Convenience macros and prototypes for the various handle types we define
- */
-
-inline void DestroyTypedHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandleOfUnknownType(HndGetHandleTable(handle), handle);
-}
-
-inline void DestroyHandle(OBJECTHANDLE handle)
-{ 
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-        CAN_TAKE_LOCK;
-        SO_TOLERANT;
-    }
-    CONTRACTL_END;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, handle);
-}
-
-inline void DestroyWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_DEFAULT, handle);
-}
-
-inline void DestroyShortWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_SHORT, handle);
-}
-
-inline void DestroyLongWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_LONG, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyLongWeakHandle> LongWeakHandleHolder;
-#endif
-
-inline void DestroyStrongHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_STRONG, handle);
-}
-
-inline void DestroyPinningHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_PINNED, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyPinningHandle, NULL> PinningHandleHolder;
-#endif
-
-inline void DestroyAsyncPinningHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_ASYNCPINNED, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyAsyncPinningHandle, NULL> AsyncPinningHandleHolder;
-#endif
-
-void DestroySizedRefHandle(OBJECTHANDLE handle);
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroySizedRefHandle, NULL> SizeRefHandleHolder;
-#endif
-
-#ifdef FEATURE_COMINTEROP
-
-inline void DestroyRefcountedHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_REFCOUNTED, handle);
-}
-
-void DestroyWinRTWeakHandle(OBJECTHANDLE handle);
-
-#endif // FEATURE_COMINTEROP
-
-#endif // !DACCESS_COMPILE
-
 OBJECTREF GetDependentHandleSecondary(OBJECTHANDLE handle);
 
 #ifndef DACCESS_COMPILE
 void SetDependentHandleSecondary(OBJECTHANDLE handle, OBJECTREF secondary);
-
-inline void DestroyDependentHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-       HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEPENDENT, handle);
-}
 #endif // !DACCESS_COMPILE
 
 #ifndef DACCESS_COMPILE
@@ -193,130 +82,14 @@ uint32_t     GetVariableHandleType(OBJECTHANDLE handle);
 void         UpdateVariableHandleType(OBJECTHANDLE handle, uint32_t type);
 uint32_t     CompareExchangeVariableHandleType(OBJECTHANDLE handle, uint32_t oldType, uint32_t newType);
 
-inline void  DestroyVariableHandle(OBJECTHANDLE handle)
-{
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_VARIABLE, handle);
-}
-
 void GCHandleValidatePinnedObject(OBJECTREF obj);
 
 /*
- * Holder for OBJECTHANDLE
- */
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyHandle > OHWrapper;
-
-class OBJECTHANDLEHolder : public OHWrapper
-{
-public:
-    FORCEINLINE OBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : OHWrapper(p)
-    {
-        LIMITED_METHOD_CONTRACT;
-    }
-    FORCEINLINE void operator=(OBJECTHANDLE p)
-    {
-        WRAPPER_NO_CONTRACT;
-
-        OHWrapper::operator=(p);
-    }
-};
-#endif
-
-#ifdef FEATURE_COMINTEROP
-
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyRefcountedHandle> RefCountedOHWrapper;
-
-class RCOBJECTHANDLEHolder : public RefCountedOHWrapper
-{
-public:
-    FORCEINLINE RCOBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : RefCountedOHWrapper(p)
-    {
-        LIMITED_METHOD_CONTRACT;
-    }
-    FORCEINLINE void operator=(OBJECTHANDLE p)
-    {
-        WRAPPER_NO_CONTRACT;
-
-        RefCountedOHWrapper::operator=(p);
-    }
-};
-
-#endif // FEATURE_COMINTEROP
-/*
  * Convenience prototypes for using the global handles
  */
 
 int GetCurrentThreadHomeHeapNumber();
 
-inline void DestroyGlobalTypedHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandleOfUnknownType(HndGetHandleTable(handle), handle);
-}
-
-inline void DestroyGlobalHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, handle);
-}
-
-inline void DestroyGlobalWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_DEFAULT, handle);
-}
-
-inline void DestroyGlobalShortWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_SHORT, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyGlobalShortWeakHandle> GlobalShortWeakHandleHolder;
-#endif
-
-inline void DestroyGlobalLongWeakHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_LONG, handle);
-}
-
-inline void DestroyGlobalStrongHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_STRONG, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyGlobalStrongHandle> GlobalStrongHandleHolder;
-#endif
-
-inline void DestroyGlobalPinningHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_PINNED, handle);
-}
-
-#ifdef FEATURE_COMINTEROP
-inline void DestroyGlobalRefcountedHandle(OBJECTHANDLE handle)
-{ 
-    WRAPPER_NO_CONTRACT;
-
-    HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_REFCOUNTED, handle);
-}
-#endif // FEATURE_COMINTEROP
-
 inline void ResetOBJECTHANDLE(OBJECTHANDLE handle)
 {
     WRAPPER_NO_CONTRACT;
index ed67e89..2914ee1 100644 (file)
@@ -229,7 +229,7 @@ int __cdecl main(int argc, char* argv[])
         return -1;
 
     // Destroy the strong handle so that nothing will be keeping out object alive
-    DestroyGlobalHandle(oh);
+    HndDestroyHandle(HndGetHandleTable(oh), HNDTYPE_DEFAULT, oh);
 
     // Explicitly trigger full GC
     pGCHeap->GarbageCollect();
index 5c23cb5..23c2a18 100644 (file)
@@ -5310,9 +5310,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
         gcInfo.gcMarkRegSetNpt(RBM_INTRET);
     }
 
-    unsigned stackAdjustBias = 0;
-
-#if defined(_TARGET_X86_)
+#if !FEATURE_EH_FUNCLETS
     //-------------------------------------------------------------------------
     // Create a label for tracking of region protected by the monitor in synchronized methods.
     // This needs to be here, rather than above where fPossibleSyncHelperCall is set,
@@ -5340,7 +5338,11 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
                 break;
         }
     }
+#endif // !FEATURE_EH_FUNCLETS
+
+    unsigned stackAdjustBias = 0;
 
+#if defined(_TARGET_X86_)
     // Is the caller supposed to pop the arguments?
     if (fCallerPop && (stackArgBytes != 0))
     {
index 1071f4d..9ca0e1a 100644 (file)
@@ -3646,7 +3646,7 @@ public:
 
     GenTreePtr fgGetCritSectOfStaticMethod();
 
-#if !defined(_TARGET_X86_)
+#if FEATURE_EH_FUNCLETS
 
     void fgAddSyncMethodEnterExit();
 
@@ -3654,7 +3654,7 @@ public:
 
     void fgConvertSyncReturnToLeave(BasicBlock* block);
 
-#endif // !_TARGET_X86_
+#endif // FEATURE_EH_FUNCLETS
 
     void fgAddReversePInvokeEnterExit();
 
index ebefa27..53ee88b 100644 (file)
@@ -1422,6 +1422,20 @@ DONE:
 
 /*****************************************************************************
  *
+ *  emitIns_valid_imm_for_ldst_offset() returns true when the immediate 'imm'
+ *   can be encoded as the offset in a ldr/str instruction.
+ */
+/*static*/ bool emitter::emitIns_valid_imm_for_ldst_offset(int imm, emitAttr size)
+{
+    if ((imm & 0x0fff) == imm)
+        return true; // encodable using IF_T2_K1
+    if (unsigned_abs(imm) <= 0x0ff)
+        return true; // encodable using IF_T2_H0
+    return false;
+}
+
+/*****************************************************************************
+ *
  *  Add an instruction with no operands.
  */
 
@@ -7608,10 +7622,26 @@ void emitter::emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataR
                 }
             }
         }
-        else
+        else // no Index
         {
-            // TODO check offset is valid for encoding
-            emitIns_R_R_I(ins, attr, dataReg, memBase->gtRegNum, offset);
+            if (emitIns_valid_imm_for_ldst_offset(offset, attr))
+            {
+                // Then load/store dataReg from/to [memBase + offset]
+                emitIns_R_R_I(ins, attr, dataReg, memBase->gtRegNum, offset);
+            }
+            else
+            {
+                // We require a tmpReg to hold the offset
+                regMaskTP tmpRegMask = indir->gtRsvdRegs;
+                regNumber tmpReg     = genRegNumFromMask(tmpRegMask);
+                noway_assert(tmpReg != REG_NA);
+
+                // First load/store tmpReg with the large offset constant
+                codeGen->instGen_Set_Reg_To_Imm(EA_PTRSIZE, tmpReg, offset);
+
+                // Then load/store dataReg from/to [memBase + tmpReg]
+                emitIns_R_R_R(ins, attr, dataReg, memBase->gtRegNum, tmpReg);
+            }
         }
     }
     else
index ec42667..1e286e8 100644 (file)
@@ -250,6 +250,7 @@ static bool emitIns_valid_imm_for_small_mov(regNumber reg, int imm, insFlags fla
 static bool emitIns_valid_imm_for_add(int imm, insFlags flags);
 static bool emitIns_valid_imm_for_cmp(int imm, insFlags flags);
 static bool emitIns_valid_imm_for_add_sp(int imm);
+static bool emitIns_valid_imm_for_ldst_offset(int imm, emitAttr size);
 
 void emitIns(instruction ins);
 
index 90e37bd..3374b8c 100644 (file)
@@ -7630,7 +7630,7 @@ GenTreePtr Compiler::fgGetCritSectOfStaticMethod()
     return tree;
 }
 
-#if !defined(_TARGET_X86_)
+#if FEATURE_EH_FUNCLETS
 
 /*****************************************************************************
  *
@@ -8005,7 +8005,7 @@ void Compiler::fgConvertSyncReturnToLeave(BasicBlock* block)
 #endif
 }
 
-#endif // !_TARGET_X86_
+#endif // FEATURE_EH_FUNCLETS
 
 //------------------------------------------------------------------------
 // fgAddReversePInvokeEnterExit: Add enter/exit calls for reverse PInvoke methods
@@ -8266,7 +8266,7 @@ void Compiler::fgAddInternal()
         }
     }
 
-#if !defined(_TARGET_X86_)
+#if FEATURE_EH_FUNCLETS
     // Add the synchronized method enter/exit calls and try/finally protection. Note
     // that this must happen before the one BBJ_RETURN block is created below, so the
     // BBJ_RETURN block gets placed at the top-level, not within an EH region. (Otherwise,
@@ -8276,7 +8276,7 @@ void Compiler::fgAddInternal()
     {
         fgAddSyncMethodEnterExit();
     }
-#endif // !_TARGET_X86_
+#endif // FEATURE_EH_FUNCLETS
 
     if (oneReturn)
     {
@@ -8495,7 +8495,7 @@ void Compiler::fgAddInternal()
 #endif
     }
 
-#if defined(_TARGET_X86_)
+#if !FEATURE_EH_FUNCLETS
 
     /* Is this a 'synchronized' method? */
 
@@ -8571,7 +8571,7 @@ void Compiler::fgAddInternal()
         syncEndEmitCookie   = NULL;
     }
 
-#endif // _TARGET_X86_
+#endif // !FEATURE_EH_FUNCLETS
 
     /* Do we need to do runtime call out to check the security? */
 
index 1e9f288..4c300ac 100644 (file)
@@ -1318,6 +1318,8 @@ size_t GCInfo::gcInfoBlockHdrSave(
 
     header->syncStartOffset = INVALID_SYNC_OFFSET;
     header->syncEndOffset   = INVALID_SYNC_OFFSET;
+#ifndef UNIX_X86_ABI
+    // JIT is responsible for synchronization on funclet-based EH model that x86/Linux uses.
     if (compiler->info.compFlags & CORINFO_FLG_SYNCH)
     {
         assert(compiler->syncStartEmitCookie != NULL);
@@ -1332,6 +1334,7 @@ size_t GCInfo::gcInfoBlockHdrSave(
         // synchronized methods can't have more than 1 epilog
         assert(header->epilogCount <= 1);
     }
+#endif
 
     header->revPInvokeOffset = INVALID_REV_PINVOKE_OFFSET;
 
index c6f3e10..2cb1916 100644 (file)
@@ -10109,7 +10109,11 @@ void Compiler::impImportBlockCode(BasicBlock* block)
                     const bool isSingleILStoreLocal =
                         !lvaTable[lclNum].lvHasMultipleILStoreOp && !lvaTable[lclNum].lvHasLdAddrOp;
 
-                    if (isSingleILStoreLocal)
+                    // Conservative check that there is just one
+                    // definition that reaches this store.
+                    const bool hasSingleReachingDef = (block->bbStackDepthOnEntry() == 0);
+
+                    if (isSingleILStoreLocal && hasSingleReachingDef)
                     {
                         lvaUpdateClass(lclNum, op1, clsHnd);
                     }
index 11fc490..7d999d8 100644 (file)
@@ -291,19 +291,13 @@ void Lowering::TreeNodeInfoInitIndir(GenTreePtr indirTree)
     if (index != nullptr && !modifiedSources)
     {
         info->srcCount++;
-
-#ifdef _TARGET_ARM_
-        info->internalIntCount++;
-#endif // _TARGET_ARM_
     }
 
-#ifdef _TARGET_ARM64_
-
-    // On ARM64 we may need a single internal register
+    // On ARM we may need a single internal register
     // (when both conditions are true then we still only need a single internal register)
     if ((index != nullptr) && (cns != 0))
     {
-        // ARM64 does not support both Index and offset so we need an internal register
+        // ARM does not support both Index and offset so we need an internal register
         info->internalIntCount = 1;
     }
     else if (!emitter::emitIns_valid_imm_for_ldst_offset(cns, emitTypeSize(indirTree)))
@@ -311,8 +305,6 @@ void Lowering::TreeNodeInfoInitIndir(GenTreePtr indirTree)
         // This offset can't be contained in the ldr/str instruction, so we need an internal register
         info->internalIntCount = 1;
     }
-
-#endif // _TARGET_ARM64_
 }
 
 //------------------------------------------------------------------------
index a0f814e..cb9474f 100644 (file)
   <data name="Arg_SecurityException" xml:space="preserve">
     <value>Security error.</value>
   </data>
-  <data name="Arg_SerializationException" xml:space="preserve">
+  <data name="SerializationException" xml:space="preserve">
     <value>Serialization error.</value>
   </data>
   <data name="Arg_SetMethNotFnd" xml:space="preserve">
index 14f0c7b..3a0917f 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationAssembly.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="$(BclSourcesRoot)\System\Threading\AbandonedMutexException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\AsyncLocal.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\AutoResetEvent.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\SendOrPostCallback.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationContext.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\EventResetMode.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\EventWaitHandle.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ExecutionContext.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Interlocked.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\LockRecursionException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ManualResetEvent.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Mutex.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Overlapped.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ParameterizedThreadStart.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Semaphore.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\SemaphoreFullException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationLockException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Thread.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadInterruptedException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPriority.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadStart.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadState.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadStateException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadStartException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Timer.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Volatile.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandleCannotBeOpenedException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ApartmentState.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\SpinLock.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\SpinWait.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\LazyInitializer.cs" />
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\FormatterConverter.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\FormatterServices.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\IDeserializationCallback.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\SerializationAttributes.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\SerializationException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\SerializationInfo.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\SerializationInfoEnumerator.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Serialization\StreamingContext.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\Versioning\NonVersionableAttribute.cs" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Runtime\Remoting\ObjectHandle.cs" />
index a481ef4..6ef7fc1 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedFunctionPointerAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedType.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\VarEnum.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\IDeserializationCallback.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\IFormatterConverter.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\IObjectReference.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\ISafeSerializationData.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\ISerializable.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\OnDeserializedAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\OnDeserializingAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\OnSerializedAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\OnSerializingAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\OptionalFieldAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\SafeSerializationEventArgs.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\SerializationException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\SerializationInfoEnumerator.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\StreamingContext.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\NonVersionableAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\TargetFrameworkAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Security\AllowPartiallyTrustedCallersAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Security\CryptographicException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF8Encoding.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ThreadAttributes.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\AbandonedMutexException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ApartmentState.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\AsyncLocal.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\AutoResetEvent.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\DeferredDisposableLifetime.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventResetMode.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ExecutionContext.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LazyThreadSafetyMode.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LockRecursionException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEvent.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ParameterizedThreadStart.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\SemaphoreFullException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\SendOrPostCallback.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\SynchronizationLockException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCanceledException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskExtensions.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskSchedulerException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadAbortException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPriority.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadStart.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadStartException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadState.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadStateException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Timeout.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\TimeoutHelper.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\WaitHandleCannotBeOpenedException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ThreadStaticAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\TimeoutException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\TimeZone.cs"/>
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/IDeserializationCallback.cs b/src/mscorlib/shared/System/Runtime/Serialization/IDeserializationCallback.cs
new file mode 100644 (file)
index 0000000..a1c1671
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    public interface IDeserializationCallback
+    {
+        void OnDeserialization(object sender);
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/OnDeserializedAttribute.cs b/src/mscorlib/shared/System/Runtime/Serialization/OnDeserializedAttribute.cs
new file mode 100644 (file)
index 0000000..408a55c
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class OnDeserializedAttribute : Attribute
+    {
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/OnDeserializingAttribute.cs b/src/mscorlib/shared/System/Runtime/Serialization/OnDeserializingAttribute.cs
new file mode 100644 (file)
index 0000000..162857e
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class OnDeserializingAttribute : Attribute
+    {
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/OnSerializedAttribute.cs b/src/mscorlib/shared/System/Runtime/Serialization/OnSerializedAttribute.cs
new file mode 100644 (file)
index 0000000..020dd02
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class OnSerializedAttribute : Attribute
+    {
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/OnSerializingAttribute.cs b/src/mscorlib/shared/System/Runtime/Serialization/OnSerializingAttribute.cs
new file mode 100644 (file)
index 0000000..8dc8af3
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class OnSerializingAttribute : Attribute
+    {
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/OptionalFieldAttribute.cs b/src/mscorlib/shared/System/Runtime/Serialization/OptionalFieldAttribute.cs
new file mode 100644 (file)
index 0000000..84daa53
--- /dev/null
@@ -0,0 +1,25 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [AttributeUsage(AttributeTargets.Field, Inherited = false)]
+    public sealed class OptionalFieldAttribute : Attribute
+    {
+        private int _versionAdded = 1;
+
+        public int VersionAdded
+        {
+            get { return _versionAdded; }
+            set
+            {
+                if (value < 1)
+                {
+                    throw new ArgumentException(SR.Serialization_OptionalFieldVersionValue);
+                }
+                _versionAdded = value;
+            }
+        }
+    }
+}
@@ -2,18 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*=============================================================================
-**
-**
-**
-** Purpose: Thrown when something goes wrong during serialization or 
-**          deserialization.
-**
-**
-=============================================================================*/
-
-
-using System;
 using System.Runtime.Serialization;
 
 namespace System.Runtime.Serialization
@@ -21,12 +9,12 @@ namespace System.Runtime.Serialization
     [Serializable]
     public class SerializationException : SystemException
     {
-        private static String _nullMessage = SR.Arg_SerializationException;
+        private static String s_nullMessage = SR.SerializationException;
 
         // Creates a new SerializationException with its message 
         // string set to a default message.
         public SerializationException()
-            : base(_nullMessage)
+            : base(s_nullMessage)
         {
             HResult = __HResults.COR_E_SERIALIZATION;
         }
@@ -37,12 +25,14 @@ namespace System.Runtime.Serialization
             HResult = __HResults.COR_E_SERIALIZATION;
         }
 
-        public SerializationException(String message, Exception innerException) : base(message, innerException)
+        public SerializationException(String message, Exception innerException)
+            : base(message, innerException)
         {
             HResult = __HResults.COR_E_SERIALIZATION;
         }
 
-        protected SerializationException(SerializationInfo info, StreamingContext context) : base(info, context)
+        protected SerializationException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
         }
     }
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/SerializationInfoEnumerator.cs b/src/mscorlib/shared/System/Runtime/Serialization/SerializationInfoEnumerator.cs
new file mode 100644 (file)
index 0000000..6399510
--- /dev/null
@@ -0,0 +1,127 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections;
+using System.Diagnostics;
+
+namespace System.Runtime.Serialization
+{
+    public struct SerializationEntry
+    {
+        private string _name;
+        private object _value;
+        private Type _type;
+
+        internal SerializationEntry(string entryName, object entryValue, Type entryType)
+        {
+            _name = entryName;
+            _value = entryValue;
+            _type = entryType;
+        }
+
+        public object Value => _value;
+        public string Name => _name;
+        public Type ObjectType => _type;
+    }
+
+    public sealed class SerializationInfoEnumerator : IEnumerator
+    {
+        private readonly string[] _members;
+        private readonly object[] _data;
+        private readonly Type[] _types;
+        private readonly int _numItems;
+        private int _currItem;
+        private bool _current;
+
+        internal SerializationInfoEnumerator(string[] members, object[] info, Type[] types, int numItems)
+        {
+            Debug.Assert(members != null, "[SerializationInfoEnumerator.ctor]members!=null");
+            Debug.Assert(info != null, "[SerializationInfoEnumerator.ctor]info!=null");
+            Debug.Assert(types != null, "[SerializationInfoEnumerator.ctor]types!=null");
+            Debug.Assert(numItems >= 0, "[SerializationInfoEnumerator.ctor]numItems>=0");
+            Debug.Assert(members.Length >= numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems");
+            Debug.Assert(info.Length >= numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems");
+            Debug.Assert(types.Length >= numItems, "[SerializationInfoEnumerator.ctor]types.Length>=numItems");
+
+            _members = members;
+            _data = info;
+            _types = types;
+
+            //The MoveNext semantic is much easier if we enforce that [0..m_numItems] are valid entries
+            //in the enumerator, hence we subtract 1.
+            _numItems = numItems - 1;
+            _currItem = -1;
+            _current = false;
+        }
+
+        public bool MoveNext()
+        {
+            if (_currItem < _numItems)
+            {
+                _currItem++;
+                _current = true;
+            }
+            else
+            {
+                _current = false;
+            }
+
+            return _current;
+        }
+
+        object IEnumerator.Current => Current;
+
+        public SerializationEntry Current
+        {
+            get
+            {
+                if (_current == false)
+                {
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
+                }
+                return new SerializationEntry(_members[_currItem], _data[_currItem], _types[_currItem]);
+            }
+        }
+
+        public void Reset()
+        {
+            _currItem = -1;
+            _current = false;
+        }
+
+        public string Name
+        {
+            get
+            {
+                if (_current == false)
+                {
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
+                }
+                return _members[_currItem];
+            }
+        }
+        public object Value
+        {
+            get
+            {
+                if (_current == false)
+                {
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
+                }
+                return _data[_currItem];
+            }
+        }
+        public Type ObjectType
+        {
+            get
+            {
+                if (_current == false)
+                {
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
+                }
+                return _types[_currItem];
+            }
+        }
+    }
+}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/StreamingContext.cs b/src/mscorlib/shared/System/Runtime/Serialization/StreamingContext.cs
new file mode 100644 (file)
index 0000000..1026a87
--- /dev/null
@@ -0,0 +1,53 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.Serialization
+{
+    [Serializable]
+    public struct StreamingContext
+    {
+        private readonly object _additionalContext;
+        private readonly StreamingContextStates _state;
+
+        public StreamingContext(StreamingContextStates state) : this(state, null)
+        {
+        }
+
+        public StreamingContext(StreamingContextStates state, object additional)
+        {
+            _state = state;
+            _additionalContext = additional;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (!(obj is StreamingContext))
+            {
+                return false;
+            }
+            StreamingContext ctx = (StreamingContext)obj;
+            return ctx._additionalContext == _additionalContext && ctx._state == _state;
+        }
+
+        public override int GetHashCode() => (int)_state;
+
+        public StreamingContextStates State => _state;
+
+        public object Context => _additionalContext;
+    }
+
+    [Flags]
+    public enum StreamingContextStates
+    {
+        CrossProcess = 0x01,
+        CrossMachine = 0x02,
+        File = 0x04,
+        Persistence = 0x08,
+        Remoting = 0x10,
+        Other = 0x20,
+        Clone = 0x40,
+        CrossAppDomain = 0x80,
+        All = 0xFF,
+    }
+}
@@ -1,28 +1,24 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
-
-//
 //
 // AbandonedMutexException
 // Thrown when a wait completes because one or more mutexes was abandoned.
 // AbandonedMutexs indicate serious error in user code or machine state.
 ////////////////////////////////////////////////////////////////////////////////
 
-
 using System;
-using System.Runtime.Serialization;
 using System.Threading;
 using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
 
 namespace System.Threading
 {
     [Serializable]
-    [ComVisibleAttribute(false)]
     public class AbandonedMutexException : SystemException
     {
-        private int m_MutexIndex = -1;
-        private Mutex m_Mutex = null;
+        private int _mutexIndex = -1;
+        private Mutex _mutex = null;
 
         public AbandonedMutexException()
             : base(SR.Threading_AbandonedMutexException)
@@ -63,32 +59,19 @@ namespace System.Threading
             SetupException(location, handle);
         }
 
-        private void SetupException(int location, WaitHandle handle)
+        protected AbandonedMutexException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
-            m_MutexIndex = location;
-            if (handle != null)
-                m_Mutex = handle as Mutex;
         }
 
-        protected AbandonedMutexException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-        }
-
-        public Mutex Mutex
+        private void SetupException(int location, WaitHandle handle)
         {
-            get
-            {
-                return m_Mutex;
-            }
+            _mutexIndex = location;
+            if (handle != null)
+                _mutex = handle as Mutex;
         }
 
-        public int MutexIndex
-        {
-            get
-            {
-                return m_MutexIndex;
-            }
-        }
+        public Mutex Mutex => _mutex;
+        public int MutexIndex => _mutexIndex;
     }
 }
-
@@ -2,19 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-/*=============================================================================
-**
-**
-**
-** Purpose: Enum to represent the different threading models
-**
-**
-=============================================================================*/
-
 namespace System.Threading
 {
-    [Serializable]
     public enum ApartmentState
     {
         /*=========================================================================
@@ -2,11 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Diagnostics.Contracts;
-using System.Security;
 
 namespace System.Threading
 {
@@ -2,19 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-/*=============================================================================
-**
-**
-**
-** Purpose: An example of a WaitHandle class
-**
-**
-=============================================================================*/
-
-using System;
-using System.Runtime.InteropServices;
-
 namespace System.Threading
 {
     public sealed class AutoResetEvent : EventWaitHandle
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
 /*=============================================================================
 **
 ** Enum: EventResetMode
 **
 =============================================================================*/
 
-
-using System.Runtime.InteropServices;
-
 namespace System.Threading
 {
-    [ComVisibleAttribute(false)]
     public enum EventResetMode
     {
         AutoReset = 0,
@@ -1,29 +1,22 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
+
 /*============================================================
 **
 **
 **
 ** Purpose: Capture execution  context for a thread
 **
-** 
+**
 ===========================================================*/
 
-using System;
-using System.Security;
-using System.Runtime.Remoting;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-using System.Runtime.Serialization;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
 using System.Diagnostics;
 using System.Diagnostics.Contracts;
-using System.Diagnostics.CodeAnalysis;
+using System.Runtime.ExceptionServices;
+using System.Runtime.Serialization;
+
+using Thread = Internal.Runtime.Augments.RuntimeThread;
 
 namespace System.Threading
 {
@@ -147,7 +140,6 @@ namespace System.Threading
             return executionContext != null && executionContext.m_isFlowSuppressed;
         }
 
-        [HandleProcessCorruptedStateExceptions]
         public static void Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         {
             if (executionContext == null)
@@ -165,7 +157,7 @@ namespace System.Threading
             {
                 // Note: we have a "catch" rather than a "finally" because we want
                 // to stop the first pass of EH here.  That way we can restore the previous
-                // context before any of our callers' EH filters run.  That means we need to 
+                // context before any of our callers' EH filters run.  That means we need to
                 // end the scope separately in the non-exceptional case below.
                 ecsw.Undo(currentThread);
                 throw;
@@ -190,7 +182,7 @@ namespace System.Threading
             }
         }
 
-        static internal void EstablishCopyOnWriteScope(Thread currentThread, ref ExecutionContextSwitcher ecsw)
+        internal static void EstablishCopyOnWriteScope(Thread currentThread, ref ExecutionContextSwitcher ecsw)
         {
             Debug.Assert(currentThread == Thread.CurrentThread);
 
@@ -198,7 +190,6 @@ namespace System.Threading
             ecsw.m_sc = currentThread.SynchronizationContext;
         }
 
-        [HandleProcessCorruptedStateExceptions]
         private static void OnContextChanged(ExecutionContext previous, ExecutionContext current)
         {
             Debug.Assert(previous != null);
@@ -377,5 +368,3 @@ namespace System.Threading
         }
     }
 }
-
-
diff --git a/src/mscorlib/shared/System/Threading/LazyThreadSafetyMode.cs b/src/mscorlib/shared/System/Threading/LazyThreadSafetyMode.cs
new file mode 100644 (file)
index 0000000..2d13f23
--- /dev/null
@@ -0,0 +1,44 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
+//
+// a set of lightweight static helpers for lazy initialization.
+//
+// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+namespace System.Threading
+{
+    /// <summary>
+    /// Specifies how a <see cref="T:System.Threading.Lazy{T}"/> instance should synchronize access among multiple threads.
+    /// </summary>
+    public enum LazyThreadSafetyMode
+    {
+        /// <summary>
+        /// This mode makes no guarantees around the thread-safety of the <see cref="T:System.Threading.Lazy{T}"/> instance.  If used from multiple threads, the behavior of the <see cref="T:System.Threading.Lazy{T}"/> is undefined.
+        /// This mode should be used when a <see cref="T:System.Threading.Lazy{T}"/> is guaranteed to never be initialized from more than one thread simultaneously and high performance is crucial. 
+        /// If valueFactory throws an exception when the <see cref="T:System.Threading.Lazy{T}"/> is initialized, the exception will be cached and returned on subsequent accesses to Value. Also, if valueFactory recursively
+        /// accesses Value on this <see cref="T:System.Threading.Lazy{T}"/> instance, a <see cref="T:System.InvalidOperationException"/> will be thrown.
+        /// </summary>
+        None,
+
+        /// <summary>
+        /// When multiple threads attempt to simultaneously initialize a <see cref="T:System.Threading.Lazy{T}"/> instance, this mode allows each thread to execute the
+        /// valueFactory but only the first thread to complete initialization will be allowed to set the final value of the  <see cref="T:System.Threading.Lazy{T}"/>.
+        /// Once initialized successfully, any future calls to Value will return the cached result.  If valueFactory throws an exception on any thread, that exception will be
+        /// propagated out of Value. If any thread executes valueFactory without throwing an exception and, therefore, successfully sets the value, that value will be returned on
+        /// subsequent accesses to Value from any thread.  If no thread succeeds in setting the value, IsValueCreated will remain false and subsequent accesses to Value will result in
+        /// the valueFactory delegate re-executing.  Also, if valueFactory recursively accesses Value on this  <see cref="T:System.Threading.Lazy{T}"/> instance, an exception will NOT be thrown.
+        /// </summary>
+        PublicationOnly,
+
+        /// <summary>
+        /// This mode uses locks to ensure that only a single thread can initialize a <see cref="T:System.Threading.Lazy{T}"/> instance in a thread-safe manner.  In general,
+        /// taken if this mode is used in conjunction with a <see cref="T:System.Threading.Lazy{T}"/> valueFactory delegate that uses locks internally, a deadlock can occur if not
+        /// handled carefully.  If valueFactory throws an exception when the<see cref="T:System.Threading.Lazy{T}"/> is initialized, the exception will be cached and returned on
+        /// subsequent accesses to Value. Also, if valueFactory recursively accesses Value on this <see cref="T:System.Threading.Lazy{T}"/> instance, a  <see cref="T:System.InvalidOperationException"/> will be thrown.
+        /// </summary>
+        ExecutionAndPublication
+    }
+}
@@ -2,28 +2,28 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-//
-//
-//
-// Purpose: 
-// This exception represents a failed attempt to recursively
-// acquire a lock, because the particular lock kind doesn't
-// support it in its current state.
-============================================================*/
-
 using System;
 using System.Runtime.Serialization;
-using System.Runtime.CompilerServices;
 
 namespace System.Threading
 {
     [Serializable]
     public class LockRecursionException : System.Exception
     {
-        public LockRecursionException() { }
-        public LockRecursionException(string message) : base(message) { }
+        public LockRecursionException()
+        {
+        }
+
+        public LockRecursionException(string message)
+            : base(message)
+        {
+        }
+
+        public LockRecursionException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+
         protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context) { }
-        public LockRecursionException(string message, Exception innerException) : base(message, innerException) { }
     }
 }
@@ -2,19 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-/*=============================================================================
-**
-**
-**
-** Purpose: An example of a WaitHandle class
-**
-**
-=============================================================================*/
-
-using System;
-using System.Runtime.InteropServices;
-
 namespace System.Threading
 {
     public sealed class ManualResetEvent : EventWaitHandle
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
 /*=============================================================================
 **
 **
 **
 =============================================================================*/
 
-
-using System.Threading;
-using System.Runtime.InteropServices;
-
 namespace System.Threading
 {
-    [ComVisibleAttribute(false)]
     public delegate void ParameterizedThreadStart(object obj);
 }
@@ -4,12 +4,10 @@
 
 using System;
 using System.Runtime.Serialization;
-using System.Runtime.InteropServices;
 
 namespace System.Threading
 {
     [Serializable]
-    [ComVisibleAttribute(false)]
     public class SemaphoreFullException : SystemException
     {
         public SemaphoreFullException() : base(SR.Threading_SemaphoreFullException)
@@ -29,4 +27,3 @@ namespace System.Threading
         }
     }
 }
-
@@ -1,14 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
-/*============================================================
-**
-**
-**
-** Purpose: Represents a method to be called when a message is to be dispatched to a synchronization context. 
-**
-** 
-===========================================================*/
 
 namespace System.Threading
 {
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
 /*=============================================================================
 **
 **
@@ -13,8 +12,6 @@
 **
 =============================================================================*/
 
-
-using System;
 using System.Runtime.Serialization;
 
 namespace System.Threading
@@ -45,5 +42,3 @@ namespace System.Threading
         }
     }
 }
-
-
@@ -2,21 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-/*=============================================================================
-**
-**
-**
-** Purpose: Enums for the priorities of a Thread
-**
-**
-=============================================================================*/
-
-using System.Threading;
-
 namespace System.Threading
 {
-    [Serializable]
     public enum ThreadPriority
     {
         /*=========================================================================
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
 /*=============================================================================
 **
 **
 **
 =============================================================================*/
 
-using System.Threading;
-
 namespace System.Threading
 {
-    // Define the delegate
-    // NOTE: If you change the signature here, there is code in COMSynchronization
-    //  that invokes this delegate in native.
     public delegate void ThreadStart();
 }
@@ -2,35 +2,28 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-
-using System;
 using System.Runtime.Serialization;
-using System.Runtime.InteropServices;
 
 namespace System.Threading
 {
     [Serializable]
     public sealed class ThreadStartException : SystemException
     {
-        private ThreadStartException()
+        internal ThreadStartException()
             : base(SR.Arg_ThreadStartException)
         {
             HResult = __HResults.COR_E_THREADSTART;
         }
 
-        private ThreadStartException(Exception reason)
+        internal ThreadStartException(Exception reason)
             : base(SR.Arg_ThreadStartException, reason)
         {
             HResult = __HResults.COR_E_THREADSTART;
         }
 
-        //required for serialization
         internal ThreadStartException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
         }
     }
 }
-
-
@@ -2,19 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-/*=============================================================================
-**
-**
-**
-** Purpose: Enum to represent the different thread states
-**
-**
-=============================================================================*/
-
 namespace System.Threading
 {
-    [Serializable]
     [Flags]
     public enum ThreadState
     {
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
 /*=============================================================================
 **
 **
@@ -13,7 +12,6 @@
 **
 =============================================================================*/
 
-using System;
 using System.Runtime.Serialization;
 
 namespace System.Threading
@@ -39,7 +37,8 @@ namespace System.Threading
             HResult = __HResults.COR_E_THREADSTATE;
         }
 
-        protected ThreadStateException(SerializationInfo info, StreamingContext context) : base(info, context)
+        protected ThreadStateException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
         }
     }
diff --git a/src/mscorlib/shared/System/Threading/TimeoutHelper.cs b/src/mscorlib/shared/System/Threading/TimeoutHelper.cs
new file mode 100644 (file)
index 0000000..c66c9ad
--- /dev/null
@@ -0,0 +1,54 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System.Threading
+{
+    /// <summary>
+    /// A helper class to capture a start time using Environment.TickCout as a time in milliseconds, also updates a given timeout bu subtracting the current time from
+    /// the start time
+    /// </summary>
+    internal static class TimeoutHelper
+    {
+        /// <summary>
+        /// Returns the Environment.TickCount as a start time in milliseconds as a uint, TickCount tools over from postive to negative every ~ 25 days
+        /// then ~25 days to back to positive again, uint is sued to ignore the sign and double the range to 50 days
+        /// </summary>
+        /// <returns></returns>
+        public static uint GetTime()
+        {
+            return (uint)Environment.TickCount;
+        }
+
+        /// <summary>
+        /// Helper function to measure and update the elapsed time
+        /// </summary>
+        /// <param name="startTime"> The first time (in milliseconds) observed when the wait started</param>
+        /// <param name="originalWaitMillisecondsTimeout">The orginal wait timeoutout in milliseconds</param>
+        /// <returns>The new wait time in milliseconds, -1 if the time expired</returns>
+        public static int UpdateTimeOut(uint startTime, int originalWaitMillisecondsTimeout)
+        {
+            // The function must be called in case the time out is not infinite
+            Debug.Assert(originalWaitMillisecondsTimeout != Timeout.Infinite);
+
+            uint elapsedMilliseconds = (GetTime() - startTime);
+
+            // Check the elapsed milliseconds is greater than max int because this property is uint
+            if (elapsedMilliseconds > int.MaxValue)
+            {
+                return 0;
+            }
+
+            // Subtract the elapsed time from the current wait time
+            int currentWaitTimeout = originalWaitMillisecondsTimeout - (int)elapsedMilliseconds; ;
+            if (currentWaitTimeout <= 0)
+            {
+                return 0;
+            }
+
+            return currentWaitTimeout;
+        }
+    }
+}
@@ -2,17 +2,11 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-
-using System;
 using System.Runtime.Serialization;
-using System.Runtime.InteropServices;
 
 namespace System.Threading
 {
     [Serializable]
-    [ComVisibleAttribute(false)]
-
     public class WaitHandleCannotBeOpenedException : ApplicationException
     {
         public WaitHandleCannotBeOpenedException() : base(SR.Threading_WaitHandleCannotBeOpenedException)
@@ -35,4 +29,3 @@ namespace System.Threading
         }
     }
 }
-
diff --git a/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs b/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs
deleted file mode 100644 (file)
index 2b07ce9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-** Interface: IDeserializationEventListener
-**
-**
-** Purpose: Implemented by any class that wants to indicate that
-**          it wishes to receive deserialization events.
-**
-**
-===========================================================*/
-
-using System;
-
-namespace System.Runtime.Serialization
-{
-    // Interface does not need to be marked with the serializable attribute    
-    public interface IDeserializationCallback
-    {
-        void OnDeserialization(Object sender);
-    }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs
deleted file mode 100644 (file)
index be9f4ae..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: Various Attributes for Serialization 
-**
-**
-============================================================*/
-
-using System;
-using System.Diagnostics.Contracts;
-using System.Reflection;
-
-namespace System.Runtime.Serialization
-{
-    [AttributeUsage(AttributeTargets.Field, Inherited = false)]
-    public sealed class OptionalFieldAttribute : Attribute
-    {
-        private int versionAdded = 1;
-        public OptionalFieldAttribute() { }
-
-        public int VersionAdded
-        {
-            get
-            {
-                return versionAdded;
-            }
-            set
-            {
-                if (value < 1)
-                    throw new ArgumentException(SR.Serialization_OptionalFieldVersionValue);
-                Contract.EndContractBlock();
-                versionAdded = value;
-            }
-        }
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class OnSerializingAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class OnSerializedAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class OnDeserializingAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class OnDeserializedAttribute : Attribute
-    {
-    }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs
deleted file mode 100644 (file)
index 791f7a8..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: A formatter-friendly mechanism for walking all of
-** the data in a SerializationInfo.  Follows the IEnumerator 
-** mechanism from Collections.
-**
-**
-============================================================*/
-
-using System;
-using System.Diagnostics;
-using System.Collections;
-using System.Diagnostics.Contracts;
-
-namespace System.Runtime.Serialization
-{
-    //
-    // The tuple returned by SerializationInfoEnumerator.Current.
-    //
-    public struct SerializationEntry
-    {
-        private Type m_type;
-        private Object m_value;
-        private String m_name;
-
-        public Object Value
-        {
-            get
-            {
-                return m_value;
-            }
-        }
-
-        public String Name
-        {
-            get
-            {
-                return m_name;
-            }
-        }
-
-        public Type ObjectType
-        {
-            get
-            {
-                return m_type;
-            }
-        }
-
-        internal SerializationEntry(String entryName, Object entryValue, Type entryType)
-        {
-            m_value = entryValue;
-            m_name = entryName;
-            m_type = entryType;
-        }
-    }
-
-    //
-    // A simple enumerator over the values stored in the SerializationInfo.
-    // This does not snapshot the values, it just keeps pointers to the 
-    // member variables of the SerializationInfo that created it.
-    //
-    public sealed class SerializationInfoEnumerator : IEnumerator
-    {
-        private String[] m_members;
-        private Object[] m_data;
-        private Type[] m_types;
-        private int m_numItems;
-        private int m_currItem;
-        private bool m_current;
-
-        internal SerializationInfoEnumerator(String[] members, Object[] info, Type[] types, int numItems)
-        {
-            Debug.Assert(members != null, "[SerializationInfoEnumerator.ctor]members!=null");
-            Debug.Assert(info != null, "[SerializationInfoEnumerator.ctor]info!=null");
-            Debug.Assert(types != null, "[SerializationInfoEnumerator.ctor]types!=null");
-            Debug.Assert(numItems >= 0, "[SerializationInfoEnumerator.ctor]numItems>=0");
-            Debug.Assert(members.Length >= numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems");
-            Debug.Assert(info.Length >= numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems");
-            Debug.Assert(types.Length >= numItems, "[SerializationInfoEnumerator.ctor]types.Length>=numItems");
-
-            m_members = members;
-            m_data = info;
-            m_types = types;
-            //The MoveNext semantic is much easier if we enforce that [0..m_numItems] are valid entries
-            //in the enumerator, hence we subtract 1.
-            m_numItems = numItems - 1;
-            m_currItem = -1;
-            m_current = false;
-        }
-
-        public bool MoveNext()
-        {
-            if (m_currItem < m_numItems)
-            {
-                m_currItem++;
-                m_current = true;
-            }
-            else
-            {
-                m_current = false;
-            }
-            return m_current;
-        }
-
-        Object IEnumerator.Current
-        { //Actually returns a SerializationEntry
-            get
-            {
-                if (m_current == false)
-                {
-                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
-                }
-                return (Object)(new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem]));
-            }
-        }
-
-        public SerializationEntry Current
-        { //Actually returns a SerializationEntry
-            get
-            {
-                if (m_current == false)
-                {
-                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
-                }
-                return (new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem]));
-            }
-        }
-
-        public void Reset()
-        {
-            m_currItem = -1;
-            m_current = false;
-        }
-
-        public String Name
-        {
-            get
-            {
-                if (m_current == false)
-                {
-                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
-                }
-                return m_members[m_currItem];
-            }
-        }
-        public Object Value
-        {
-            get
-            {
-                if (m_current == false)
-                {
-                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
-                }
-                return m_data[m_currItem];
-            }
-        }
-        public Type ObjectType
-        {
-            get
-            {
-                if (m_current == false)
-                {
-                    throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
-                }
-                return m_types[m_currItem];
-            }
-        }
-    }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs b/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs
deleted file mode 100644 (file)
index 12a7631..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-** ValueType: StreamingContext
-**
-**
-** Purpose: A value type indicating the source or destination of our streaming.
-**
-**
-===========================================================*/
-
-using System.Runtime.Remoting;
-using System;
-
-namespace System.Runtime.Serialization
-{
-    [Serializable]
-    public struct StreamingContext
-    {
-        internal Object m_additionalContext;
-        internal StreamingContextStates m_state;
-
-        public StreamingContext(StreamingContextStates state)
-            : this(state, null)
-        {
-        }
-
-        public StreamingContext(StreamingContextStates state, Object additional)
-        {
-            m_state = state;
-            m_additionalContext = additional;
-        }
-
-        public Object Context
-        {
-            get { return m_additionalContext; }
-        }
-
-        public override bool Equals(Object obj)
-        {
-            if (!(obj is StreamingContext))
-            {
-                return false;
-            }
-            if (((StreamingContext)obj).m_additionalContext == m_additionalContext &&
-                ((StreamingContext)obj).m_state == m_state)
-            {
-                return true;
-            }
-            return false;
-        }
-
-        public override int GetHashCode()
-        {
-            return (int)m_state;
-        }
-
-        public StreamingContextStates State
-        {
-            get { return m_state; }
-        }
-    }
-
-    // **********************************************************
-    // Keep these in sync with the version in vm\runtimehandles.h
-    // **********************************************************
-    [Serializable]
-    [Flags]
-    public enum StreamingContextStates
-    {
-        CrossProcess = 0x01,
-        CrossMachine = 0x02,
-        File = 0x04,
-        Persistence = 0x08,
-        Remoting = 0x10,
-        Other = 0x20,
-        Clone = 0x40,
-        CrossAppDomain = 0x80,
-        All = 0xFF,
-    }
-}
index e264a8f..d585ba6 100644 (file)
@@ -17,37 +17,6 @@ using System.Diagnostics.Contracts;
 namespace System.Threading
 {
     /// <summary>
-    /// Specifies how a <see cref="T:System.Threading.Lazy{T}"/> instance should synchronize access among multiple threads.
-    /// </summary>
-    public enum LazyThreadSafetyMode
-    {
-        /// <summary>
-        /// This mode makes no guarantees around the thread-safety of the <see cref="T:System.Threading.Lazy{T}"/> instance.  If used from multiple threads, the behavior of the <see cref="T:System.Threading.Lazy{T}"/> is undefined.
-        /// This mode should be used when a <see cref="T:System.Threading.Lazy{T}"/> is guaranteed to never be initialized from more than one thread simultaneously and high performance is crucial. 
-        /// If valueFactory throws an exception when the <see cref="T:System.Threading.Lazy{T}"/> is initialized, the exception will be cached and returned on subsequent accesses to Value. Also, if valueFactory recursively
-        /// accesses Value on this <see cref="T:System.Threading.Lazy{T}"/> instance, a <see cref="T:System.InvalidOperationException"/> will be thrown.
-        /// </summary>
-        None,
-
-        /// <summary>
-        /// When multiple threads attempt to simultaneously initialize a <see cref="T:System.Threading.Lazy{T}"/> instance, this mode allows each thread to execute the
-        /// valueFactory but only the first thread to complete initialization will be allowed to set the final value of the  <see cref="T:System.Threading.Lazy{T}"/>.
-        /// Once initialized successfully, any future calls to Value will return the cached result.  If valueFactory throws an exception on any thread, that exception will be
-        /// propagated out of Value. If any thread executes valueFactory without throwing an exception and, therefore, successfully sets the value, that value will be returned on
-        /// subsequent accesses to Value from any thread.  If no thread succeeds in setting the value, IsValueCreated will remain false and subsequent accesses to Value will result in
-        /// the valueFactory delegate re-executing.  Also, if valueFactory recursively accesses Value on this  <see cref="T:System.Threading.Lazy{T}"/> instance, an exception will NOT be thrown.
-        /// </summary>
-        PublicationOnly,
-
-        /// <summary>
-        /// This mode uses locks to ensure that only a single thread can initialize a <see cref="T:System.Threading.Lazy{T}"/> instance in a thread-safe manner.  In general,
-        /// taken if this mode is used in conjunction with a <see cref="T:System.Threading.Lazy{T}"/> valueFactory delegate that uses locks internally, a deadlock can occur if not
-        /// handled carefully.  If valueFactory throws an exception when the<see cref="T:System.Threading.Lazy{T}"/> is initialized, the exception will be cached and returned on
-        /// subsequent accesses to Value. Also, if valueFactory recursively accesses Value on this <see cref="T:System.Threading.Lazy{T}"/> instance, a  <see cref="T:System.InvalidOperationException"/> will be thrown.
-        /// </summary>
-        ExecutionAndPublication
-    }
-    /// <summary>
     /// Provides lazy initialization routines.
     /// </summary>
     /// <remarks>
index ae490e8..30d7aa6 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Threading
     /// <remarks>
     /// <para>
     /// <see cref="SpinWait"/> encapsulates common spinning logic. On single-processor machines, yields are
-    /// always used instead of busy waits, and on computers with Intel� processors employing Hyper-Threading�
+    /// always used instead of busy waits, and on computers with Intel processors employing Hyper-Threading
     /// technology, it helps to prevent hardware thread starvation. SpinWait encapsulates a good mixture of
     /// spinning and true yielding.
     /// </para>
@@ -312,50 +312,4 @@ namespace System.Threading
             get { return ProcessorCount == 1; }
         }
     }
-
-    /// <summary>
-    /// A helper class to capture a start time using Environment.TickCout as a time in milliseconds, also updates a given timeout bu subtracting the current time from
-    /// the start time
-    /// </summary>
-    internal static class TimeoutHelper
-    {
-        /// <summary>
-        /// Returns the Environment.TickCount as a start time in milliseconds as a uint, TickCount tools over from postive to negative every ~ 25 days
-        /// then ~25 days to back to positive again, uint is sued to ignore the sign and double the range to 50 days
-        /// </summary>
-        /// <returns></returns>
-        public static uint GetTime()
-        {
-            return (uint)Environment.TickCount;
-        }
-
-        /// <summary>
-        /// Helper function to measure and update the elapsed time
-        /// </summary>
-        /// <param name="startTime"> The first time (in milliseconds) observed when the wait started</param>
-        /// <param name="originalWaitMillisecondsTimeout">The orginal wait timeoutout in milliseconds</param>
-        /// <returns>The new wait time in milliseconds, -1 if the time expired</returns>
-        public static int UpdateTimeOut(uint startTime, int originalWaitMillisecondsTimeout)
-        {
-            // The function must be called in case the time out is not infinite
-            Debug.Assert(originalWaitMillisecondsTimeout != Timeout.Infinite);
-
-            uint elapsedMilliseconds = (GetTime() - startTime);
-
-            // Check the elapsed milliseconds is greater than max int because this property is uint
-            if (elapsedMilliseconds > int.MaxValue)
-            {
-                return 0;
-            }
-
-            // Subtract the elapsed time from the current wait time
-            int currentWaitTimeout = originalWaitMillisecondsTimeout - (int)elapsedMilliseconds; ;
-            if (currentWaitTimeout <= 0)
-            {
-                return 0;
-            }
-
-            return currentWaitTimeout;
-        }
-    }
 }
index 924a365..762a199 100755 (executable)
@@ -155,10 +155,14 @@ if [ "$build_arch" == "armel" ]; then
     cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
 fi
 
-if [ "$build_arch" == "arm" -o "$build_arch" == "armel" ]; then
-    overridefile=clang-compiler-override-arm.txt  
+clang_version=$(echo $CC | awk -F- '{ print $NF }')
+# Use O1 option when the clang version is smaller than 3.9
+# Otherwise use O3 option in release build
+if [[ ( ${clang_version%.*} -eq 3  &&  ${clang_version#*.} -lt 9 ) &&
+      (  "$build_arch" == "arm" || "$build_arch" == "armel" ) ]]; then
+    overridefile=clang-compiler-override-arm.txt
 else
-    overridefile=clang-compiler-override.txt  
+    overridefile=clang-compiler-override.txt
 fi
 
 cmake \
index 5664740..167db2d 100644 (file)
@@ -4067,11 +4067,6 @@ AppDomain::AppDomain()
     m_dwThreadEnterCount = 0;
     m_dwThreadsStillInAppDomain = (ULONG)-1;
 
-    m_pSecDesc = NULL;
-    m_hHandleTableBucket=NULL;
-
-    m_ExposedObject = NULL;
-
 #ifdef FEATURE_COMINTEROP
     m_pRefDispIDCache = NULL;
     m_hndMissing = NULL;
@@ -4091,7 +4086,7 @@ AppDomain::AppDomain()
     m_dwRefTakers=0;
     m_dwCreationHolders=0;
 #endif
-    
+
 #ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING
     m_ullTotalProcessorUsage = 0;
     m_pullAllocBytes = NULL;
index a631b55..003136f 100644 (file)
@@ -45,6 +45,21 @@ inline OBJECTREF ObjectFromHandle(OBJECTHANDLE handle)
     return UNCHECKED_OBJECTREF_TO_OBJECTREF(*PTR_UNCHECKED_OBJECTREF(handle));
 }
 
+// Quick inline check for whether a handle is null
+inline BOOL IsHandleNullUnchecked(OBJECTHANDLE handle)
+{
+    LIMITED_METHOD_CONTRACT;
+
+    return (handle == NULL || (*(_UNCHECKED_OBJECTREF *)handle) == NULL);
+}
+
+inline BOOL ObjectHandleIsNull(OBJECTHANDLE handle)
+{
+    LIMITED_METHOD_CONTRACT;
+
+    return *(Object **)handle == NULL;
+}
+
 #ifndef DACCESS_COMPILE
 
 // Handle creation convenience functions
@@ -155,6 +170,179 @@ inline OBJECTHANDLE CreateVariableHandle(HHANDLETABLE table, OBJECTREF object, u
                                                                                  (void*)((uintptr_t)type));
 }
 
+// Handle destruction convenience functions
+
+inline void DestroyHandle(OBJECTHANDLE handle)
+{
+    CONTRACTL
+    {
+        NOTHROW;
+        GC_NOTRIGGER;
+        MODE_ANY;
+        CAN_TAKE_LOCK;
+        SO_TOLERANT;
+    }
+    CONTRACTL_END;
+
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_DEFAULT);
+}
+
+inline void DestroyWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_DEFAULT);
+}
+
+inline void DestroyShortWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_SHORT);
+}
+
+inline void DestroyLongWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_LONG);
+}
+
+inline void DestroyStrongHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_STRONG);
+}
+
+inline void DestroyPinningHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_PINNED);
+}
+
+inline void DestroyAsyncPinningHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_ASYNCPINNED);
+}
+
+inline void DestroyRefcountedHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_REFCOUNTED);
+}
+
+inline void DestroyDependentHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_DEPENDENT);
+}
+
+inline void  DestroyVariableHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_VARIABLE);
+}
+
+inline void DestroyGlobalHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_DEFAULT);
+}
+
+inline void DestroyGlobalWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_DEFAULT);
+}
+
+inline void DestroyGlobalShortWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_SHORT);
+}
+
+inline void DestroyGlobalLongWeakHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_LONG);
+}
+
+inline void DestroyGlobalStrongHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_STRONG);
+}
+
+inline void DestroyGlobalPinningHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_PINNED);
+}
+
+inline void DestroyGlobalRefcountedHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_REFCOUNTED);
+}
+
+inline void DestroyTypedHandle(OBJECTHANDLE handle)
+{
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfUnknownType(handle);
+}
+
+#ifdef FEATURE_COMINTEROP
+inline void DestroyWinRTWeakHandle(OBJECTHANDLE handle)
+{
+    CONTRACTL
+    {
+        NOTHROW;
+        GC_NOTRIGGER;
+        MODE_ANY;
+        CAN_TAKE_LOCK;
+        SO_TOLERANT;
+    }
+    CONTRACTL_END;
+
+    // Release the WinRT weak reference if we have one. We're assuming that this will not reenter the
+    // runtime, since if we are pointing at a managed object, we should not be using HNDTYPE_WEAK_WINRT
+    // but rather HNDTYPE_WEAK_SHORT or HNDTYPE_WEAK_LONG.
+    void* pExtraInfo = GCHandleTableUtilities::GetGCHandleTable()->GetExtraInfoFromHandle(handle);
+    IWeakReference* pWinRTWeakReference = reinterpret_cast<IWeakReference*>(pExtraInfo);
+    if (pWinRTWeakReference != nullptr)
+    {
+        pWinRTWeakReference->Release();
+    }
+
+    GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleOfType(handle, HNDTYPE_WEAK_WINRT);
+}
+#endif
+
+// Handle holders/wrappers
+
+#ifndef FEATURE_REDHAWK
+typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyHandle>                   OHWrapper;
+typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyPinningHandle, NULL>      PinningHandleHolder;
+typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyAsyncPinningHandle, NULL> AsyncPinningHandleHolder;
+typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyRefcountedHandle>         RefCountedOHWrapper;
+
+typedef Holder<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyLongWeakHandle>            LongWeakHandleHolder;
+typedef Holder<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyGlobalStrongHandle>        GlobalStrongHandleHolder;
+typedef Holder<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyGlobalShortWeakHandle>     GlobalShortWeakHandleHolder;
+
+class RCOBJECTHANDLEHolder : public RefCountedOHWrapper
+{
+public:
+    FORCEINLINE RCOBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : RefCountedOHWrapper(p)
+    {
+        LIMITED_METHOD_CONTRACT;
+    }
+    FORCEINLINE void operator=(OBJECTHANDLE p)
+    {
+        WRAPPER_NO_CONTRACT;
+
+        RefCountedOHWrapper::operator=(p);
+    }
+};
+
+class OBJECTHANDLEHolder : public OHWrapper
+{
+public:
+    FORCEINLINE OBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : OHWrapper(p)
+    {
+        LIMITED_METHOD_CONTRACT;
+    }
+    FORCEINLINE void operator=(OBJECTHANDLE p)
+    {
+        WRAPPER_NO_CONTRACT;
+
+        OHWrapper::operator=(p);
+    }
+};
+
+#endif // !FEATURE_REDHAWK
+
 #endif // !DACCESS_COMPILE
 
 #endif // _GCHANDLETABLEUTILITIES_H_
index dacc85f..31e233c 100644 (file)
@@ -3149,7 +3149,10 @@ void StackFrameIterator::PreProcessingForManagedFrames(void)
 
     INDEBUG(m_crawl.pThread->DebugLogStackWalkInfo(&m_crawl, "CONSIDER", m_uFramesProcessed));
 
-#if defined(_DEBUG) && defined(_TARGET_X86_) && !defined(DACCESS_COMPILE)
+#if defined(_DEBUG) && !defined(WIN64EXCEPTIONS) && !defined(DACCESS_COMPILE)
+    //
+    // VM is responsible for synchronization on non-funclet EH model.
+    //
     // m_crawl.GetThisPointer() requires full unwind
     // In GC's relocate phase, objects is not verifiable
     if ( !(m_flags & (LIGHTUNWIND | QUICKUNWIND | ALLOW_INVALID_OBJECTS)) && 
@@ -3173,7 +3176,7 @@ void StackFrameIterator::PreProcessingForManagedFrames(void)
 
         END_GCX_ASSERT_COOP;
     }
-#endif // _DEBUG && _TARGET_X86_ && !DACCESS_COMPILE
+#endif // _DEBUG && !WIN64EXCEPTIONS && !DACCESS_COMPILE
 
     m_frameState = SFITER_FRAMELESS_METHOD;
 } // StackFrameIterator::PreProcessingForManagedFrames()
index 58d1402..3124cc8 100755 (executable)
@@ -246,13 +246,13 @@ function cross_build_coreclr_with_docker {
         # TODO: For arm, we are going to embed RootFS inside Docker image.
         case $__linuxCodeName in
         trusty)
-            __dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1404_cross_prereqs_v3"
+            __dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu-14.04-cross-0cd4667-20172211042239"
             __skipRootFS=1
             __dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/arm"
             __runtimeOS="ubuntu.14.04"
         ;;
         xenial)
-            __dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1604_cross_prereqs_v3"
+            __dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu-16.04-cross-ef0ac75-20175511035548"
             __skipRootFS=1
             __dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/arm"
             __runtimeOS="ubuntu.16.04"
@@ -265,7 +265,7 @@ function cross_build_coreclr_with_docker {
         # For armel Tizen, we are going to construct RootFS on the fly.
         case $__linuxCodeName in
         tizen)
-            __dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v3"
+            __dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v4"
             __runtimeOS="tizen.4.0.0"
         ;;
         *)
@@ -289,7 +289,7 @@ function cross_build_coreclr_with_docker {
 
     # Cross building coreclr with rootfs in Docker
     (set +x; echo "Start cross build coreclr for $__buildArch $__linuxCodeName")
-    __buildCmd="./build.sh $__buildArch cross $__verboseFlag $__skipMscorlib $__buildConfig -rebuild"
+    __buildCmd="./build.sh $__buildArch cross $__verboseFlag $__skipMscorlib $__buildConfig -rebuild clang3.9"
     $__dockerCmd $__buildCmd
     sudo chown -R $(id -u -n) ./bin
 }
index 6b979a4..501dfec 100644 (file)
@@ -1,10 +1,10 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.ILAsm": "2.0.0-preview1-25210-04",
-    "Microsoft.NETCore.ILDAsm": "2.0.0-preview1-25210-04",
-    "Microsoft.NETCore.Jit": "2.0.0-preview1-25210-04",
-    "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-preview1-25210-04",
-    "Microsoft.NETCore.TestHost": "2.0.0-preview1-25210-04"
+    "Microsoft.NETCore.ILAsm": "2.0.0-preview1-25212-04",
+    "Microsoft.NETCore.ILDAsm": "2.0.0-preview1-25212-04",
+    "Microsoft.NETCore.Jit": "2.0.0-preview1-25212-04",
+    "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-preview1-25212-04",
+    "Microsoft.NETCore.TestHost": "2.0.0-preview1-25212-04"
   },
   "frameworks": {
     "netcoreapp2.0": {
index 7147437..ea49ba3 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.TargetingPack.Private.CoreCLR": "2.0.0-preview1-25210-04"
+    "Microsoft.TargetingPack.Private.CoreCLR": "2.0.0-preview1-25212-04"
   },
   "frameworks": {
     "netcoreapp1.1": {
diff --git a/tests/src/JIT/opt/Devirtualization/GitHub_10858.cs b/tests/src/JIT/opt/Devirtualization/GitHub_10858.cs
new file mode 100644 (file)
index 0000000..a02d025
--- /dev/null
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+class B 
+{
+    public virtual string F() { return "B"; }
+}
+
+sealed class D : B
+{
+    public override string F() { return "D"; }
+}
+
+sealed class E : B
+{
+    public override string F() { return "E"; }
+}
+
+class X
+{
+    public static int Main(string[] args)
+    {
+        // When optimizing IL, CSC will leave the newobj's on the stack
+        // across the branches to the common def point.
+        B b1 = (args.Length > 0) ? (B)new E() : (B)new D();
+        B b2 = null;
+
+        // Conditional flow here to forces b1 to a local instead of
+        // remaining on the stack. So we have a single def point with
+        // two reaching values.
+        if (args.Length > 0)
+        {
+            b2 = new D();
+        }
+        else
+        {
+            b2 = new E();
+        }
+
+        // We should not be able to devirtualize either call.
+        return b2.F()[0] + b1.F()[0] - 37;
+    }
+}
diff --git a/tests/src/JIT/opt/Devirtualization/GitHub_10858.csproj b/tests/src/JIT/opt/Devirtualization/GitHub_10858.csproj
new file mode 100644 (file)
index 0000000..fdf04a2
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="GitHub_10858.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>