@@ -1016,6 +1016,33 @@ BOOL CLRFreeLibrary(HMODULE hModule)
10161016
10171017
10181018#endif // #ifndef DACCESS_COMPILE
1019+ namespace GcNotifications
1020+ {
1021+ VOID SetNotification (GcEvtArgs ev)
1022+ {
1023+ LIMITED_METHOD_CONTRACT;
1024+ if (ev.typ == GC_MARK_END)
1025+ {
1026+ if (ev.condemnedGeneration == 0 )
1027+ g_gcNotificationFlags = 0 ;
1028+ else
1029+ g_gcNotificationFlags = (DWORD)(g_gcNotificationFlags | ev.condemnedGeneration );
1030+ }
1031+ }
1032+ BOOL GetNotification (GcEvtArgs ev)
1033+ {
1034+ LIMITED_METHOD_CONTRACT;
1035+ // check to see if we have a notification for this generation
1036+ if (ev.typ == GC_MARK_END && (ev.condemnedGeneration == 0 || (g_gcNotificationFlags & ev.condemnedGeneration ) != 0 ))
1037+ {
1038+ return TRUE ;
1039+ }
1040+ else
1041+ {
1042+ return FALSE ;
1043+ }
1044+ }
1045+ };
10191046
10201047GPTR_IMPL (JITNotification, g_pNotificationTable);
10211048GVAL_IMPL (ULONG32, g_dacNotificationFlags);
@@ -1320,155 +1347,10 @@ BOOL JITNotifications::UpdateOutOfProcTable()
13201347}
13211348#endif // DACCESS_COMPILE
13221349
1323- GPTR_IMPL (GcNotification, g_pGcNotificationTable);
1324-
1325- GcNotifications::GcNotifications (GcNotification *gcTable)
1326- {
1327- LIMITED_METHOD_CONTRACT;
1328- if (gcTable)
1329- {
1330- // Bookkeeping info is held in the first slot
1331- m_gcTable = gcTable + 1 ;
1332- }
1333- else
1334- {
1335- m_gcTable = NULL ;
1336- }
1337- }
1338-
1339- BOOL GcNotifications::FindItem (GcEvtArgs ev_, UINT *indexOut)
1340- {
1341- LIMITED_METHOD_CONTRACT;
1342- if (m_gcTable == NULL )
1343- {
1344- return FALSE ;
1345- }
1346-
1347- if (indexOut == NULL )
1348- {
1349- return FALSE ;
1350- }
1351-
1352- UINT length = Length ();
1353- for (UINT i = 0 ; i < length; i++)
1354- {
1355- if (m_gcTable[i].IsMatch (ev_))
1356- {
1357- *indexOut = i;
1358- return TRUE ;
1359- }
1360- }
1361-
1362- return FALSE ;
1363- }
1364-
1365-
1366- BOOL GcNotifications::SetNotification (GcEvtArgs ev)
1367- {
1368- if (!IsActive ())
1369- {
1370- return FALSE ;
1371- }
1372-
1373- if (ev.typ < 0 || ev.typ >= GC_EVENT_TYPE_MAX)
1374- {
1375- return FALSE ;
1376- }
1377-
1378- // build the "match" event
1379- GcEvtArgs evStar = { ev.typ };
1380- switch (ev.typ )
1381- {
1382- case GC_MARK_END:
1383- // specify mark event matching all generations
1384- evStar.condemnedGeneration = -1 ;
1385- break ;
1386- default :
1387- break ;
1388- }
1389-
1390- // look for the entry that matches the evStar argument
1391- UINT idx;
1392- if (!FindItem (evStar, &idx))
1393- {
1394- // Find first free item
1395- UINT iFirstFree = Length ();
1396- for (UINT i = 0 ; i < iFirstFree; i++)
1397- {
1398- GcNotification *pCurrent = m_gcTable + i;
1399- if (pCurrent->IsFree ())
1400- {
1401- iFirstFree = i;
1402- break ;
1403- }
1404- }
1405-
1406- if (iFirstFree == Length () &&
1407- iFirstFree == GetTableSize ())
1408- {
1409- // No more room
1410- return FALSE ;
1411- }
1412-
1413- // guarantee the free cell is zeroed out
1414- m_gcTable[iFirstFree].SetFree ();
1415- idx = iFirstFree;
1416- }
1417-
1418- // Now update the state
1419- m_gcTable[idx].ev .typ = ev.typ ;
1420- switch (ev.typ )
1421- {
1422- case GC_MARK_END:
1423- if (ev.condemnedGeneration == 0 )
1424- {
1425- m_gcTable[idx].SetFree ();
1426- }
1427- else
1428- {
1429- m_gcTable[idx].ev .condemnedGeneration |= ev.condemnedGeneration ;
1430- }
1431- break ;
1432- default :
1433- break ;
1434- }
1435-
1436- // and if needed, update the array's length
1437- if (idx == Length ())
1438- {
1439- IncrementLength ();
1440- }
1441-
1442- return TRUE ;
1443- }
14441350
14451351GARY_IMPL (size_t , g_clrNotificationArguments, MAX_CLR_NOTIFICATION_ARGS);
14461352
1447- #ifdef DACCESS_COMPILE
1448-
1449- GcNotification *GcNotifications::InitializeNotificationTable (UINT TableSize)
1450- {
1451- // We use the first entry in the table for recordkeeping info.
1452-
1453- GcNotification *retTable = new (nothrow) GcNotification[TableSize+1 ];
1454- if (retTable)
1455- {
1456- // Set the length
1457- UINT *pUint = (UINT *) &(retTable[0 ].ev .typ );
1458- *pUint = 0 ;
1459- // Set the table size
1460- ++pUint;
1461- *pUint = TableSize;
1462- }
1463- return retTable;
1464- }
1465-
1466- BOOL GcNotifications::UpdateOutOfProcTable ()
1467- {
1468- return ::UpdateOutOfProcTable<GcNotification>(g_pGcNotificationTable, m_gcTable - 1 , GetTableSize () + 1 );
1469- }
1470-
1471- #else // DACCESS_COMPILE
1353+ #ifndef DACCESS_COMPILE
14721354
14731355static CrstStatic g_clrNotificationCrst;
14741356
0 commit comments