diff options
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/amcss.c | 23 | ||||
| -rw-r--r-- | mps/code/arena.c | 4 | ||||
| -rw-r--r-- | mps/code/mpmst.h | 3 | ||||
| -rw-r--r-- | mps/code/mps.h | 12 | ||||
| -rw-r--r-- | mps/code/mpsi.c | 14 | ||||
| -rw-r--r-- | mps/code/trace.c | 6 |
6 files changed, 61 insertions, 1 deletions
diff --git a/mps/code/amcss.c b/mps/code/amcss.c index 647d0525fc4..8b88dd38bec 100644 --- a/mps/code/amcss.c +++ b/mps/code/amcss.c | |||
| @@ -47,7 +47,27 @@ static mps_addr_t exactRoots[exactRootsCOUNT]; | |||
| 47 | static mps_addr_t ambigRoots[ambigRootsCOUNT]; | 47 | static mps_addr_t ambigRoots[ambigRootsCOUNT]; |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | /* report - report statistics from any messages */ | 50 | /* alert -- synchronous alert of collection start/stop */ |
| 51 | |||
| 52 | static void alertfn(int alertcode, int whycode) | ||
| 53 | { | ||
| 54 | switch(alertcode) { | ||
| 55 | case MPS_ALERT_COLLECTION_START: { | ||
| 56 | printf("\n^^^^^^ START (why: %d) ^^^^^^\n", whycode); | ||
| 57 | break; | ||
| 58 | } | ||
| 59 | case MPS_ALERT_COLLECTION_STOP: { | ||
| 60 | printf("vvvvvv STOP (why: %d) vvvvvv\n", whycode); | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | default: { | ||
| 64 | cdie(0, "unknown alertcode"); | ||
| 65 | break; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | /* report -- report statistics from any messages */ | ||
| 51 | 71 | ||
| 52 | static void report(mps_arena_t arena) | 72 | static void report(mps_arena_t arena) |
| 53 | { | 73 | { |
| @@ -313,6 +333,7 @@ int main(int argc, char **argv) | |||
| 313 | "arena_create"); | 333 | "arena_create"); |
| 314 | mps_message_type_enable(arena, mps_message_type_gc()); | 334 | mps_message_type_enable(arena, mps_message_type_gc()); |
| 315 | mps_message_type_enable(arena, mps_message_type_gc_start()); | 335 | mps_message_type_enable(arena, mps_message_type_gc_start()); |
| 336 | mps_alert_collection_set(arena, &alertfn); | ||
| 316 | die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit"); | 337 | die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit"); |
| 317 | die(mps_thread_reg(&thread, arena), "thread_reg"); | 338 | die(mps_thread_reg(&thread, arena), "thread_reg"); |
| 318 | mps_tramp(&r, test, arena, 0); | 339 | mps_tramp(&r, test, arena, 0); |
diff --git a/mps/code/arena.c b/mps/code/arena.c index dc2f008303c..0e7b89eb4d8 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c | |||
| @@ -135,6 +135,8 @@ Bool ArenaCheck(Arena arena) | |||
| 135 | CHECKD(ChunkCacheEntry, &arena->chunkCache); | 135 | CHECKD(ChunkCacheEntry, &arena->chunkCache); |
| 136 | 136 | ||
| 137 | CHECKL(LocusCheck(arena)); | 137 | CHECKL(LocusCheck(arena)); |
| 138 | |||
| 139 | /* nothing to check for alertCollection */ | ||
| 138 | 140 | ||
| 139 | return TRUE; | 141 | return TRUE; |
| 140 | } | 142 | } |
| @@ -176,6 +178,8 @@ Res ArenaInit(Arena arena, ArenaClass class) | |||
| 176 | ChunkCacheEntryInit(&arena->chunkCache); | 178 | ChunkCacheEntryInit(&arena->chunkCache); |
| 177 | 179 | ||
| 178 | LocusInit(arena); | 180 | LocusInit(arena); |
| 181 | |||
| 182 | arena->alertCollection = 0; | ||
| 179 | 183 | ||
| 180 | res = GlobalsInit(ArenaGlobals(arena)); | 184 | res = GlobalsInit(ArenaGlobals(arena)); |
| 181 | if (res != ResOK) | 185 | if (res != ResOK) |
diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index af5e2d89fd6..efc4ce18366 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h | |||
| @@ -688,6 +688,9 @@ typedef struct ArenaStruct { | |||
| 688 | Bool isFinalPool; /* indicator for finalPool */ | 688 | Bool isFinalPool; /* indicator for finalPool */ |
| 689 | Pool finalPool; /* either NULL or an MRG pool */ | 689 | Pool finalPool; /* either NULL or an MRG pool */ |
| 690 | 690 | ||
| 691 | /* alert fields <code/trace.c> */ | ||
| 692 | mps_alert_collection_fn_t alertCollection; /* client alert fn or 0 */ | ||
| 693 | |||
| 691 | /* thread fields (<code/thread.c>) */ | 694 | /* thread fields (<code/thread.c>) */ |
| 692 | RingStruct threadRing; /* ring of attached threads */ | 695 | RingStruct threadRing; /* ring of attached threads */ |
| 693 | Serial threadSerial; /* serial of next thread */ | 696 | Serial threadSerial; /* serial of next thread */ |
diff --git a/mps/code/mps.h b/mps/code/mps.h index 2852416bac8..01e556374ed 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h | |||
| @@ -550,6 +550,18 @@ extern mps_res_t mps_finalize(mps_arena_t, mps_addr_t *); | |||
| 550 | extern mps_res_t mps_definalize(mps_arena_t, mps_addr_t *); | 550 | extern mps_res_t mps_definalize(mps_arena_t, mps_addr_t *); |
| 551 | 551 | ||
| 552 | 552 | ||
| 553 | /* Alert */ | ||
| 554 | |||
| 555 | /* Alert codes. */ | ||
| 556 | enum { | ||
| 557 | MPS_ALERT_COLLECTION_START, | ||
| 558 | MPS_ALERT_COLLECTION_STOP | ||
| 559 | }; | ||
| 560 | typedef void (*mps_alert_collection_fn_t)(int, int); | ||
| 561 | extern mps_res_t mps_alert_collection_set(mps_arena_t, | ||
| 562 | mps_alert_collection_fn_t); | ||
| 563 | |||
| 564 | |||
| 553 | /* Telemetry */ | 565 | /* Telemetry */ |
| 554 | 566 | ||
| 555 | extern mps_word_t mps_telemetry_control(mps_word_t, mps_word_t); | 567 | extern mps_word_t mps_telemetry_control(mps_word_t, mps_word_t); |
diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 400ab84c486..b2193825c2d 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c | |||
| @@ -1799,6 +1799,20 @@ const char *mps_message_gc_start_why(mps_arena_t mps_arena, | |||
| 1799 | return s; | 1799 | return s; |
| 1800 | } | 1800 | } |
| 1801 | 1801 | ||
| 1802 | |||
| 1803 | /* Alert */ | ||
| 1804 | |||
| 1805 | mps_res_t mps_alert_collection_set(mps_arena_t mps_arena, | ||
| 1806 | mps_alert_collection_fn_t fn) | ||
| 1807 | { | ||
| 1808 | Arena arena = (Arena)mps_arena; | ||
| 1809 | ArenaEnter(arena); | ||
| 1810 | arena->alertCollection = fn; | ||
| 1811 | ArenaLeave(arena); | ||
| 1812 | return MPS_RES_OK; | ||
| 1813 | } | ||
| 1814 | |||
| 1815 | |||
| 1802 | /* Telemetry */ | 1816 | /* Telemetry */ |
| 1803 | 1817 | ||
| 1804 | mps_word_t mps_telemetry_control(mps_word_t resetMask, mps_word_t flipMask) | 1818 | mps_word_t mps_telemetry_control(mps_word_t resetMask, mps_word_t flipMask) |
diff --git a/mps/code/trace.c b/mps/code/trace.c index 3614f3157df..69ff0018404 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c | |||
| @@ -1056,6 +1056,9 @@ static void tracePostMessage(Trace trace) | |||
| 1056 | message->notCondemnedSize = trace->notCondemned; | 1056 | message->notCondemnedSize = trace->notCondemned; |
| 1057 | MessagePost(arena, TraceMessageMessage(message)); | 1057 | MessagePost(arena, TraceMessageMessage(message)); |
| 1058 | } | 1058 | } |
| 1059 | if(arena->alertCollection) { | ||
| 1060 | (*arena->alertCollection)(MPS_ALERT_COLLECTION_STOP, trace->why); | ||
| 1061 | } | ||
| 1059 | 1062 | ||
| 1060 | return; | 1063 | return; |
| 1061 | } | 1064 | } |
| @@ -1859,6 +1862,9 @@ void TraceStart(Trace trace, double mortality, double finishingTime) | |||
| 1859 | if(!MessageOnQueue(message)) { | 1862 | if(!MessageOnQueue(message)) { |
| 1860 | MessagePost(arena, message); | 1863 | MessagePost(arena, message); |
| 1861 | } | 1864 | } |
| 1865 | if(arena->alertCollection) { | ||
| 1866 | (*arena->alertCollection)(MPS_ALERT_COLLECTION_START, trace->why); | ||
| 1867 | } | ||
| 1862 | 1868 | ||
| 1863 | /* From the already set up white set, derive a grey set. */ | 1869 | /* From the already set up white set, derive a grey set. */ |
| 1864 | 1870 | ||