@@ -837,35 +837,6 @@ void EEStartupHelper()
837
837
InitializeDebugger (); // throws on error
838
838
#endif // DEBUGGING_SUPPORTED
839
839
840
- #ifdef PROFILING_SUPPORTED
841
- // Initialize the profiling services.
842
- hr = ProfilingAPIUtility::InitializeProfiling ();
843
-
844
- _ASSERTE (SUCCEEDED (hr));
845
- IfFailGo (hr);
846
- #endif // PROFILING_SUPPORTED
847
-
848
- InitializeExceptionHandling ();
849
-
850
- //
851
- // Install our global exception filter
852
- //
853
- if (!InstallUnhandledExceptionFilter ())
854
- {
855
- IfFailGo (E_FAIL);
856
- }
857
-
858
- // throws on error
859
- SetupThread ();
860
-
861
- #ifdef DEBUGGING_SUPPORTED
862
- // Notify debugger once the first thread is created to finish initialization.
863
- if (g_pDebugInterface != NULL )
864
- {
865
- g_pDebugInterface->StartupPhase2 (GetThread ());
866
- }
867
- #endif
868
-
869
840
// This isn't done as part of InitializeGarbageCollector() above because
870
841
// debugger must be initialized before creating EE thread objects
871
842
FinalizerThread::FinalizerThreadCreate ();
@@ -882,8 +853,6 @@ void EEStartupHelper()
882
853
// of the JIT helpers.
883
854
InitJITHelpers1 ();
884
855
885
- SyncBlockCache::Attach ();
886
-
887
856
// Set up the sync block
888
857
SyncBlockCache::Start ();
889
858
@@ -898,6 +867,43 @@ void EEStartupHelper()
898
867
899
868
IfFailGo (hr);
900
869
870
+ #ifdef PROFILING_SUPPORTED
871
+ // Initialize the profiling services.
872
+ hr = ProfilingAPIUtility::InitializeProfiling ();
873
+
874
+ _ASSERTE (SUCCEEDED (hr));
875
+ IfFailGo (hr);
876
+ #endif // PROFILING_SUPPORTED
877
+
878
+ InitializeExceptionHandling ();
879
+
880
+ //
881
+ // Install our global exception filter
882
+ //
883
+ if (!InstallUnhandledExceptionFilter ())
884
+ {
885
+ IfFailGo (E_FAIL);
886
+ }
887
+
888
+ #ifdef TARGET_WINDOWS
889
+ // g_pGCHeap->Initialize() above could take nontrivial time, so by now the finalizer thread
890
+ // should have initialized FLS slot for thread cleanup notifications.
891
+ // And ensured that COM is initialized (must happen before allocating FLS slot).
892
+ // Make sure that this was done.
893
+ FinalizerThread::WaitForFinalizerThreadStart ();
894
+ #endif
895
+
896
+ // throws on error
897
+ SetupThread ();
898
+
899
+ #ifdef DEBUGGING_SUPPORTED
900
+ // Notify debugger once the first thread is created to finish initialization.
901
+ if (g_pDebugInterface != NULL )
902
+ {
903
+ g_pDebugInterface->StartupPhase2 (GetThread ());
904
+ }
905
+ #endif
906
+
901
907
#ifdef FEATURE_PERFTRACING
902
908
// Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup.
903
909
// SampleProfiler needs to cooperate with the GC which hasn't fully finished setting up in the first part of the
@@ -957,12 +963,6 @@ void EEStartupHelper()
957
963
g_MiniMetaDataBuffMaxSize, MEM_COMMIT, PAGE_READWRITE);
958
964
#endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
959
965
960
- #ifdef TARGET_WINDOWS
961
- // By now finalizer thread should have initialized FLS slot for thread cleanup notifications.
962
- // And ensured that COM is initialized (must happen before allocating FLS slot).
963
- // Make sure that this was done.
964
- FinalizerThread::WaitForFinalizerThreadStart ();
965
- #endif
966
966
g_fEEStarted = TRUE ;
967
967
g_EEStartupStatus = S_OK;
968
968
hr = S_OK;
@@ -1764,6 +1764,8 @@ void InitFlsSlot()
1764
1764
// thread - thread to attach
1765
1765
static void OsAttachThread (void * thread)
1766
1766
{
1767
+ _ASSERTE (g_flsIndex != FLS_OUT_OF_INDEXES);
1768
+
1767
1769
if (t_flsState == FLS_STATE_INVOKED)
1768
1770
{
1769
1771
_ASSERTE_ALL_BUILDS (!" Attempt to execute managed code after the .NET runtime thread state has been destroyed." );
0 commit comments