From 373f8a9b54d74b316eda338090b762fc3b8fec4c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 18 Oct 2012 16:23:59 +0100 Subject: Mps_shift_t is not used in the external interface, so following discussion with rb, remove it. Copied from Perforce Change: 179944 ServerID: perforce.ravenbrook.com --- mps/code/mps.h | 1 - 1 file changed, 1 deletion(-) (limited to 'mps/code') diff --git a/mps/code/mps.h b/mps/code/mps.h index 6d0edbb75d2..2072db7cdd0 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -70,7 +70,6 @@ typedef struct mps_frame_s typedef MPS_T_WORD mps_word_t; /* pointer-sized word */ typedef int mps_bool_t; /* boolean (int) */ typedef int mps_res_t; /* result code (int) */ -typedef unsigned mps_shift_t; /* shift amount (unsigned int) */ typedef void *mps_addr_t; /* managed address (void *) */ typedef size_t mps_align_t; /* alignment (size_t) */ typedef unsigned mps_rm_t; /* root mode (unsigned) */ -- cgit v1.2.1 From 3bada6378bae8561a421316409e2367b347013c3 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 19 Oct 2012 16:47:49 +0100 Subject: Based on discussion with rb, reverse the sense of the comments on mps_ap_fill and mps_ap_trip. Copied from Perforce Change: 179971 ServerID: perforce.ravenbrook.com --- mps/code/mpsi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mps/code') diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 15bc692ee00..033297f4c9b 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -941,8 +941,9 @@ mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame) /* mps_ap_fill -- called by mps_reserve when an AP hasn't enough arena * - * .ap.fill.internal: Note that mps_ap_fill should never be "called" - * directly by the client code. It is invoked by the mps_reserve macro. */ + * .ap.fill.internal: mps_ap_fill is normally invoked by the + * mps_reserve macro, but may be "called" directly by the client code + * if necessary. See */ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size) { @@ -1007,8 +1008,9 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap, /* mps_ap_trip -- called by mps_commit when an AP is tripped * - * .ap.trip.internal: Note that mps_ap_trip should never be "called" - * directly by the client code. It is invoked by the mps_commit macro. */ + * .ap.trip.internal: mps_ap_trip is normally invoked by the + * mps_commit macro, but may be "called" directly by the client code + * if necessary. See */ mps_bool_t mps_ap_trip(mps_ap_t mps_ap, mps_addr_t p, size_t size) { -- cgit v1.2.1 From 88bcefa962fd5319c5ac61cce0dbfb776347434e Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 19 Oct 2012 19:34:05 +0100 Subject: Use a typedef for the type of the function passed to mps_amc_apply to make the documentation clearer while remaining backwards-compatible. Copied from Perforce Change: 179975 ServerID: perforce.ravenbrook.com --- mps/code/mpscamc.h | 4 ++-- mps/code/poolamc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'mps/code') diff --git a/mps/code/mpscamc.h b/mps/code/mpscamc.h index 8d33ee4bb6a..710eea2f261 100644 --- a/mps/code/mpscamc.h +++ b/mps/code/mpscamc.h @@ -12,8 +12,8 @@ extern mps_class_t mps_class_amc(void); extern mps_class_t mps_class_amcz(void); -extern void mps_amc_apply(mps_pool_t, - void (*)(mps_addr_t, void *, size_t), +typedef void (*mps_amc_apply_stepper_t)(mps_addr_t, void *, size_t); +extern void mps_amc_apply(mps_pool_t, mps_amc_apply_stepper_t, void *, size_t); #endif /* mpscamc_h */ diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 1617c2e4f0a..55306cc9a06 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -2429,7 +2429,7 @@ mps_class_t mps_class_amcz(void) */ typedef struct mps_amc_apply_closure_s { - void (*f)(mps_addr_t object, void *p, size_t s); + mps_amc_apply_stepper_t f; void *p; size_t s; } mps_amc_apply_closure_s; @@ -2449,7 +2449,7 @@ static void mps_amc_apply_iter(Addr addr, Format format, Pool pool, } void mps_amc_apply(mps_pool_t mps_pool, - void (*f)(mps_addr_t object, void *p, size_t s), + mps_amc_apply_stepper_t f, void *p, size_t s) { Pool pool = (Pool)mps_pool; -- cgit v1.2.1 From 07d0aaf1135294adad13d66c2636c7bc9392a7b6 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 23 Oct 2012 14:28:22 +0100 Subject: Remove reporting features from eventcnv, as discussed with rb. eventcnv was always intended to be a simple tool that just translates events, not a report generator. in particular: * Remove -e option and associated event specification parsing. * Remove -b option and bucket statistics. * Don't intern labels (always print addresses). * Remove -v option (events are always output). * If -h or -? is specified, exit after printing help message. * Help text refer to the "Telemetry" section of reference manual. Copied from Perforce Change: 180028 ServerID: perforce.ravenbrook.com --- mps/code/eventcnv.c | 282 +++------------------------------------------------- 1 file changed, 16 insertions(+), 266 deletions(-) (limited to 'mps/code') diff --git a/mps/code/eventcnv.c b/mps/code/eventcnv.c index fcd569add74..397b4350f47 100644 --- a/mps/code/eventcnv.c +++ b/mps/code/eventcnv.c @@ -13,7 +13,7 @@ * will run the amcss test program and emit a file with event kinds 0, 1, 2. * The file can then be converted into text format with a command like: * - * eventcnv -v | sort + * eventcnv | sort * * Note that the eventcnv program can only read streams that come from an * MPS compiled on the same platform. @@ -51,26 +51,11 @@ typedef unsigned long ulong; static EventClock eventTime; /* current event time */ - - -/* event counters */ - -typedef unsigned long eventCountArray[EventCodeMAX+1]; -static unsigned long bucketEventCount[EventCodeMAX+1]; -static unsigned long totalEventCount[EventCodeMAX+1]; - - static char *prog; /* program name */ -/* command-line arguments */ - -static Bool verbose = FALSE; /* style: '\0' for human-readable, 'L' for Lisp, 'C' for CDF. */ static char style = '\0'; -static Bool reportStats = FALSE; -static Bool eventEnabled[EventCodeMAX+1]; -static Word bucketSize = 0; /* everror -- error signalling */ @@ -95,8 +80,8 @@ static void everror(const char *format, ...) static void usage(void) { fprintf(stderr, - "Usage: %s [-f logfile] [-p] [-v] [-e events] [-b size]" - " [-S[LC]] [-?]\nSee guide.mps.telemetry for instructions.\n", + "Usage: %s [-f logfile] [-S[LC]] [-h]\n" + "See \"Telemetry\" in the reference manual for instructions.\n", prog); } @@ -110,36 +95,6 @@ static void usageError(void) } -/* parseEventSpec -- parses an event spec - * - * The spec is of the form: [(+|-)]... - * The first name can be 'all'. - */ - -static void parseEventSpec(const char *arg) -{ - size_t arglen; - EventCode i; - const char *end; - char name[EventNameMAX+1]; - Bool enabled = TRUE; - - end = arg + strlen(arg); - for(i = 0; i <= EventCodeMAX; ++i) - eventEnabled[i] = FALSE; - do { - arglen = strcspn(arg, "+-"); - strncpy(name, arg, arglen); name[arglen] = '\0'; - if (strcmp(name, "all") == 0) { - for(i = 0; i <= EventCodeMAX; ++i) - eventEnabled[i] = EventCodeIsValid(i); - } else - eventEnabled[EventName2Code(name)] = enabled; - enabled = (arg[arglen] == '+'); arg += arglen + 1; - } while (arg < end); -} - - /* parseArgs -- parse command line arguments, return log file name */ static char *parseArgs(int argc, char *argv[]) @@ -162,34 +117,12 @@ static char *parseArgs(int argc, char *argv[]) else name = argv[i]; break; - case 'v': /* verbosity */ - verbose = TRUE; - break; - case 'e': { /* event statistics */ - reportStats = TRUE; - ++ i; - if (i == argc) - usageError(); - else - parseEventSpec(argv[i]); - } break; - case 'b': { /* bucket size */ - ++ i; - if (i == argc) - usageError(); - else { - int n; - - n = sscanf(argv[i], "%lu", &bucketSize); - if (n != 1) usageError(); - } - } break; case 'S': /* style */ style = argv[i][2]; /* '\0' for human-readable, 'L' for Lisp, */ break; /* 'C' for CDF. */ case '?': case 'h': /* help */ usage(); - break; + exit(EXIT_SUCCESS); default: usageError(); } @@ -200,33 +133,6 @@ static char *parseArgs(int argc, char *argv[]) } -/* recordEvent -- record event - * - * This is the beginning of a system to model MPS state as events are read, - * but for the moment it just records which strings have been interned - * and which addresses have been labelled with them. - * - * NOTE: Since branch/2012-08-21/diagnostic-telemetry events are no longer - * in order in the event stream, so eventcnv would need some serious - * rethinking to model state. It's questionable that it should attempt it - * or event try to label addresses, but instead leave that to later stages of - * processing. RB 2012-09-07 - */ - -static void recordEvent(EventProc proc, Event event, EventClock etime) -{ - Res res; - - res = EventRecord(proc, event, etime); - if (res != ResOK) - everror("Can't record event: error %d.", res); - switch(event->any.code) { - default: - break; - } -} - - /* Printing routines */ @@ -250,96 +156,11 @@ static void printStr(const char *str, Bool quotes) static void printAddr(EventProc proc, Addr addr) { - Word label; - - label = AddrLabel(proc, addr); - if (label != 0 && addr != 0) { - /* We assume labelling zero is meant to record a point in time */ - const char *sym = LabelText(proc, label); - if (sym != NULL) { - putchar(' '); - printStr(sym, (style == 'C')); - } else { - printf((style == '\0') ? - " sym%05"PRIXLONGEST : - " \"sym %"PRIXLONGEST"\"", - (ulongest_t)label); - } - } else - printf(style != 'C' ? - " %0"PRIwWORD PRIXLONGEST : - " %"PRIuLONGEST, - (ulongest_t)addr); -} - - -/* reportEventResults -- report event counts from a count array */ - -static void reportEventResults(eventCountArray eventCounts) -{ - EventCode i; - unsigned long total = 0; - - for(i = 0; i <= EventCodeMAX; ++i) { - total += eventCounts[i]; - if (eventEnabled[i]) - switch (style) { - case '\0': - printf(" %5lu", eventCounts[i]); - break; - case 'L': - printf(" %lX", eventCounts[i]); - break; - case 'C': - printf(", %lu", eventCounts[i]); - break; - } - } - switch (style) { - case '\0': - printf(" %5lu\n", total); - break; - case 'L': - printf(" %lX)\n", total); - break; - case 'C': - printf(", %lu\n", total); - break; - } -} - - -/* reportBucketResults -- report results of the current bucket */ - -static void reportBucketResults(EventClock bucketLimit) -{ - switch (style) { - case '\0': - EVENT_CLOCK_PRINT(stdout, bucketLimit); - putchar(':'); - break; - case 'L': - putchar('('); - EVENT_CLOCK_PRINT(stdout, bucketLimit); - break; - case 'C': - EVENT_CLOCK_PRINT(stdout, bucketLimit); - break; - } - if (reportStats) { - reportEventResults(bucketEventCount); - } -} - - -/* clearBucket -- clear bucket */ - -static void clearBucket(void) -{ - EventCode i; - - for(i = 0; i <= EventCodeMAX; ++i) - bucketEventCount[i] = 0; + UNUSED(proc); + printf(style != 'C' ? + " %0"PRIwWORD PRIXLONGEST : + " %"PRIuLONGEST, + (ulongest_t)addr); } @@ -397,7 +218,6 @@ static void printParamS(EventProc proc, char *styleConv, const char *s) static void printParamB(EventProc proc, char *styleConv, Bool b) { - UNUSED(proc); UNUSED(proc); printf(styleConv, (ulongest_t)b); } @@ -405,35 +225,17 @@ static void printParamB(EventProc proc, char *styleConv, Bool b) /* readLog -- read and parse log * - * This is the heart of eventcnv: It reads an event log using EventRead. - * It updates the counters. If verbose is true, it looks up the format, - * parses the arguments, and prints a representation of the event. Each - * argument is printed using printArg (see RELATION, below), except for - * some event types that are handled specially. + * This is the heart of eventcnv: It reads an event log using + * EventRead. It updates the counters. It looks up the format, + * parses the arguments, and prints a representation of the event. + * Each argument is printed using printArg (see RELATION, below), + * except for some event types that are handled specially. */ static void readLog(EventProc proc) { - EventCode c; - Word bucketLimit = bucketSize; char *styleConv = NULL; /* suppress uninit warning */ - /* Print event count header. */ - if (reportStats) { - if (style == '\0') { - printf(" bucket:"); - for(c = 0; c <= EventCodeMAX; ++c) - if (eventEnabled[c]) - printf(" %04X", (unsigned)c); - printf(" all\n"); - } - } - - /* Init event counts. */ - for(c = 0; c <= EventCodeMAX; ++c) - totalEventCount[c] = 0; - clearBucket(); - /* Init style. */ switch (style) { case '\0': @@ -458,21 +260,8 @@ static void readLog(EventProc proc) eventTime = event->any.clock; code = event->any.code; - /* Output bucket, if necessary, and update counters */ - if (bucketSize != 0 && eventTime >= bucketLimit) { - reportBucketResults(bucketLimit-1); - clearBucket(); - do { - bucketLimit += bucketSize; - } while (eventTime >= bucketLimit); - } - if (reportStats) { - ++bucketEventCount[code]; - ++totalEventCount[code]; - } - /* Output event. */ - if (verbose) { + { if (style == 'L') putchar('('); switch (style) { @@ -588,47 +377,8 @@ static void readLog(EventProc proc) putchar('\n'); fflush(stdout); } - recordEvent(proc, event, eventTime); EventDestroy(proc, event); } /* while(!feof(input)) */ - - /* report last bucket (partial) */ - if (bucketSize != 0) { - reportBucketResults(eventTime); - } - if (reportStats) { - /* report totals */ - switch (style) { - case '\0': - printf("\n run:"); - break; - case 'L': - printf("(t"); - break; - case 'C': - { - /* FIXME: This attempted to print the event stats on a row that - resembled a kind of final event, but the event clock no longer runs - monotonically upwards. */ - EventClock last = eventTime + 1; - EVENT_CLOCK_PRINT(stdout, last); - } - break; - } - reportEventResults(totalEventCount); - - /* explain event codes */ - if (style == '\0') { - printf("\n"); - for(c = 0; c <= EventCodeMAX; ++c) - if (eventEnabled[c]) - printf(" %04X %s\n", (unsigned)c, EventCode2Name(c)); - if (bucketSize == 0) - printf("\nevent clock stopped at "); - EVENT_CLOCK_PRINT(stdout, eventTime); - printf("\n"); - } - } } @@ -688,7 +438,7 @@ int main(int argc, char *argv[]) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2012 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * -- cgit v1.2.1