diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 565641f8cdf..d4795b32c91 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -473,9 +473,9 @@ extern double TraceWorkFactor; } \ END -extern Res TraceScanArea(ScanState ss, Word *base, Word *limit); -extern Res TraceScanAreaTagged(ScanState ss, Word *base, Word *limit, - Word mask, Word value); +extern Res TraceScanArea(ScanState ss, Word *base, Word *limit, + mps_area_scan_t scan_area, + void *closure, size_t closure_size); extern void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena, Seg seg, Ref *refIO); diff --git a/mps/code/prmci3fr.c b/mps/code/prmci3fr.c index 60392a11417..ffbe4dc3e7d 100644 --- a/mps/code/prmci3fr.c +++ b/mps/code/prmci3fr.c @@ -47,11 +47,11 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, /* This scans the root registers (.context.regroots). It also unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ - res = scan_area( + res = TraceScanArea( ss, (Word *)mfc->ucontext, (Word *)((char *)mfc->ucontext + sizeof(*(mfc->ucontext))), - closure, closure_size + scan_area, closure, closure_size ); return res; diff --git a/mps/code/prmci3li.c b/mps/code/prmci3li.c index 4b404317010..635676832d8 100644 --- a/mps/code/prmci3li.c +++ b/mps/code/prmci3li.c @@ -112,10 +112,10 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ mc = &mfc->ucontext->uc_mcontext; - res = scan_area(ss, - (Word *)mc, - (Word *)((char *)mc + sizeof(*mc)), - closure, closure_size); + res = TraceScanArea(ss, + (Word *)mc, + (Word *)((char *)mc + sizeof(*mc)), + scan_area, closure, closure_size); return res; } diff --git a/mps/code/prmci3xc.c b/mps/code/prmci3xc.c index 91507de6f8a..b133656f3b1 100644 --- a/mps/code/prmci3xc.c +++ b/mps/code/prmci3xc.c @@ -107,10 +107,10 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ mc = mfc->threadState; - res = scan_area(ss, - (Word *)mc, - (Word *)((char *)mc + sizeof(*mc)), - closure, closure_size); + res = TraceScanArea(ss, + (Word *)mc, + (Word *)((char *)mc + sizeof(*mc)), + scan_area, closure, closure_size); return res; } diff --git a/mps/code/prmci6fr.c b/mps/code/prmci6fr.c index 55212077a78..8dd2a680f6e 100644 --- a/mps/code/prmci6fr.c +++ b/mps/code/prmci6fr.c @@ -41,11 +41,11 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, /* This scans the root registers (.context.regroots). It also unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ - res = scan_area( + res = TraceScanArea( ss, (Word *)mfc->ucontext, (Word *)((char *)mfc->ucontext + sizeof(*(mfc->ucontext))), - closure, closure_size + scan_area, closure, closure_size ); return res; diff --git a/mps/code/prmci6li.c b/mps/code/prmci6li.c index a88b78211bf..ef4f0c000cc 100644 --- a/mps/code/prmci6li.c +++ b/mps/code/prmci6li.c @@ -116,10 +116,10 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ mc = &mfc->ucontext->uc_mcontext; - res = scan_area(&ss->ss_s, - (Word *)mc, - (Word *)((char *)mc + sizeof(*mc)), - closure, closure_size); + res = TraceScanArea(ss, + (Word *)mc, + (Word *)((char *)mc + sizeof(*mc)), + scan_area, closure, closure_size); return res; } diff --git a/mps/code/prmci6xc.c b/mps/code/prmci6xc.c index 309d4066b64..bbea768ceee 100644 --- a/mps/code/prmci6xc.c +++ b/mps/code/prmci6xc.c @@ -110,10 +110,10 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc, unnecessarily scans the rest of the context. The optimisation to scan only relevant parts would be machine dependent. */ mc = mfc->threadState; - res = scan_area(ss, - (Word *)mc, - (Word *)((char *)mc + sizeof(*mc)), - closure, closure_size); + res = TraceScanArea(ss, + (Word *)mc, + (Word *)((char *)mc + sizeof(*mc)), + scan_area, closure, closure_size); return res; } diff --git a/mps/code/root.c b/mps/code/root.c index 8b92a186726..43c325fd237 100644 --- a/mps/code/root.c +++ b/mps/code/root.c @@ -507,7 +507,8 @@ Res RootScan(ScanState ss, Root root) switch(root->var) { case RootTABLE: - res = TraceScanArea(ss, root->the.table.base, root->the.table.limit); + res = TraceScanArea(ss, root->the.table.base, root->the.table.limit, + mps_scan_area, NULL, 0); ss->scannedSize += AddrOffset(root->the.table.base, root->the.table.limit); if (res != ResOK) goto failScan; diff --git a/mps/code/ss.c b/mps/code/ss.c index 93ff85be103..40f367400ed 100644 --- a/mps/code/ss.c +++ b/mps/code/ss.c @@ -49,16 +49,17 @@ Res StackScanInner(ScanState ss, Word *stackBot, Word *stackTop, if (arena->stackAtArenaEnter != NULL) { AVER(stackTop < arena->stackAtArenaEnter); AVER(arena->stackAtArenaEnter < stackBot); - res = scan_area(&ss->ss_s, stackTop, stackTop + nSavedRegs, - closure, closure_size); + res = TraceScanArea(ss, stackTop, stackTop + nSavedRegs, + scan_area, closure, closure_size); if (res != ResOK) return res; - res = scan_area(&ss->ss_s, arena->stackAtArenaEnter, stackBot, - closure, closure_size); + res = TraceScanArea(ss, arena->stackAtArenaEnter, stackBot, + scan_area, closure, closure_size); if (res != ResOK) return res; } else { - res = scan_area(&ss->ss_s, stackTop, stackBot, closure, closure_size); + res = TraceScanArea(ss, stackTop, stackBot, + scan_area, closure, closure_size); if (res != ResOK) return res; } diff --git a/mps/code/thix.c b/mps/code/thix.c index eac01911f6e..8d3bfe28a5f 100644 --- a/mps/code/thix.c +++ b/mps/code/thix.c @@ -272,7 +272,8 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, /* scan stack inclusive of current sp and exclusive of * stackBot (.stack.full-descend) */ - res = scan_area(&ss->ss_s, stackBase, stackLimit, closure, closure_size); + res = TraceScanArea(ss, stackBase, stackLimit, + scan_area, closure, closure_size); if(res != ResOK) return res; diff --git a/mps/code/thw3i3.c b/mps/code/thw3i3.c index 1ce978fc274..cbe971f3e2a 100644 --- a/mps/code/thw3i3.c +++ b/mps/code/thw3i3.c @@ -106,7 +106,8 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, /* scan stack inclusive of current sp and exclusive of * stackBot (.stack.full-descend) */ - res = scan_area(ss, stackBase, stackLimit, closure, closure_size); + res = TraceScanArea(ss, stackBase, stackLimit, + scan_area, closure, closure_size); if(res != ResOK) return res; @@ -115,9 +116,9 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, * unnecessarily scans the rest of the context. The optimisation * to scan only relevant parts would be machine dependent. */ - res = scan_area(ss, (Word *)&context, - (Word *)((char *)&context + sizeof(CONTEXT)), - closure, closure_size); + res = TraceScanArea(ss, (Word *)&context, + (Word *)((char *)&context + sizeof(CONTEXT)), + scan_area, closure, closure_size); if(res != ResOK) return res; diff --git a/mps/code/thw3i6.c b/mps/code/thw3i6.c index 6377d85ac15..d1f94f37f0e 100644 --- a/mps/code/thw3i6.c +++ b/mps/code/thw3i6.c @@ -106,8 +106,8 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, /* scan stack inclusive of current sp and exclusive of * stackBot (.stack.full-descend) */ - res = scan_area(ss, stackBase, stackLimit, - void *closure, size_t closure_size); + res = TraceScanArea(ss, stackBase, stackLimit, + scan_area, closure, closure_size); if(res != ResOK) return res; @@ -116,9 +116,9 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, * unnecessarily scans the rest of the context. The optimisation * to scan only relevant parts would be machine dependent. */ - res = scan_area(ss, (Word *)&context, - (Word *)((char *)&context + sizeof(CONTEXT)), - closure, closure_size); + res = TraceScanArea(ss, (Word *)&context, + (Word *)((char *)&context + sizeof(CONTEXT)), + scan_area, closure, closure_size); if(res != ResOK) return res; diff --git a/mps/code/thxc.c b/mps/code/thxc.c index 2fcd8ab71b6..e2206ceb0c7 100644 --- a/mps/code/thxc.c +++ b/mps/code/thxc.c @@ -260,7 +260,8 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackBot, /* scan stack inclusive of current sp and exclusive of * stackBot (.stack.full-descend) */ - res = scan_area(ss, stackBase, stackLimit, closure, closure_sized); + res = TraceScanArea(ss, stackBase, stackLimit, + scan_area, closure, closure_size); if(res != ResOK) return res; diff --git a/mps/code/trace.c b/mps/code/trace.c index 324c2167eeb..8867f958a1e 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c @@ -1427,48 +1427,21 @@ void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena, * limit, inclusive of base and exclusive of limit. */ -Res TraceScanArea(ScanState ss, Word *base, Word *limit) +Res TraceScanArea(ScanState ss, Word *base, Word *limit, + mps_area_scan_t scan_area, + void *closure, size_t closure_size) { + AVERT(ScanState, ss); AVER(base != NULL); AVER(limit != NULL); AVER(base < limit); EVENT3(TraceScanArea, ss, base, limit); - return mps_scan_area(&ss->ss_s, base, limit, NULL, 0); + return scan_area(&ss->ss_s, base, limit, closure, closure_size); } -#if 0 -/* TraceScanAreaTagged -- scan contiguous area of tagged references - * - * This is as TraceScanArea except words are only fixed if they have - * the given value when masked with a mask. - * - * This has ATTRIBUTE_NO_SANITIZE_ADDRESS otherwise Clang's address - * sanitizer will think we have run off the end of an array. - */ - -Res TraceScanAreaTagged(ScanState ss, Word *base, Word *limit,Word mask, - Word pattern) -{ - mps_scan_tag_s tag; - - AVERT(ScanState, ss); - AVER(base != NULL); - AVER(limit != NULL); - AVER(base < limit); - - EVENT3(TraceScanAreaTagged, ss, base, limit); - - tag.mask = mask; - tag.pattern = pattern; - - return mps_scan_area_tagged(&ss->ss_s, base, limit, &tag, 0); -} -#endif - - /* traceCondemnAll -- condemn everything and notify all the chains */ static Res traceCondemnAll(Trace trace)