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