diff options
| author | Gareth Rees | 2013-05-29 12:19:19 +0100 |
|---|---|---|
| committer | Gareth Rees | 2013-05-29 12:19:19 +0100 |
| commit | 87019f4ee25a7724c5ed483a40b0b39d46cf9ee8 (patch) | |
| tree | 8b32b03548df4e22d43f30c7164ebaf0bce4b33b /mps/code | |
| parent | 2be56a898f14d6d8a181642e9c0cc5edada1b9a4 (diff) | |
| download | emacs-87019f4ee25a7724c5ed483a40b0b39d46cf9ee8.tar.gz emacs-87019f4ee25a7724c5ed483a40b0b39d46cf9ee8.zip | |
Fix review comments from <https://info.ravenbrook.com/mail/2013/05/28/22-21-11/0/>:
* Rename RangeOverlap to RangesOverlap.
* MVFF shouldn't assume that CBSInsert and CBSDelete can't fail.
* Remove unused function mps_mvff_stat.
* Don't call range methods in RangeCheck.
* RangeInit can't fail, so return void.
Copied from Perforce
Change: 182297
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/poolmv2.c | 2 | ||||
| -rw-r--r-- | mps/code/poolmvff.c | 39 | ||||
| -rw-r--r-- | mps/code/range.c | 10 | ||||
| -rw-r--r-- | mps/code/range.h | 4 |
4 files changed, 20 insertions, 35 deletions
diff --git a/mps/code/poolmv2.c b/mps/code/poolmv2.c index f49880023b9..ac0e4e87b50 100644 --- a/mps/code/poolmv2.c +++ b/mps/code/poolmv2.c | |||
| @@ -605,7 +605,7 @@ static Bool MVTDeleteOverlapping(ABQDisposition *dispositionReturn, | |||
| 605 | oldRange = element; | 605 | oldRange = element; |
| 606 | newRange = closureP; | 606 | newRange = closureP; |
| 607 | 607 | ||
| 608 | if (RangeOverlap(oldRange, newRange)) { | 608 | if (RangesOverlap(oldRange, newRange)) { |
| 609 | *dispositionReturn = ABQDispositionDELETE; | 609 | *dispositionReturn = ABQDispositionDELETE; |
| 610 | } else { | 610 | } else { |
| 611 | *dispositionReturn = ABQDispositionKEEP; | 611 | *dispositionReturn = ABQDispositionKEEP; |
diff --git a/mps/code/poolmvff.c b/mps/code/poolmvff.c index f557a4e4da7..95e09d90b26 100644 --- a/mps/code/poolmvff.c +++ b/mps/code/poolmvff.c | |||
| @@ -80,7 +80,7 @@ typedef MVFFDebugStruct *MVFFDebug; | |||
| 80 | * | 80 | * |
| 81 | * Updates MVFF counters for additional free space. Returns maximally | 81 | * Updates MVFF counters for additional free space. Returns maximally |
| 82 | * coalesced range containing given range. Does not attempt to free | 82 | * coalesced range containing given range. Does not attempt to free |
| 83 | * segments (see MVFFFreeSegs). Cannot(!) fail. | 83 | * segments (see MVFFFreeSegs). |
| 84 | */ | 84 | */ |
| 85 | static void MVFFAddToFreeList(Addr *baseIO, Addr *limitIO, MVFF mvff) { | 85 | static void MVFFAddToFreeList(Addr *baseIO, Addr *limitIO, MVFF mvff) { |
| 86 | Res res; | 86 | Res res; |
| @@ -94,6 +94,10 @@ static void MVFFAddToFreeList(Addr *baseIO, Addr *limitIO, MVFF mvff) { | |||
| 94 | AVER(limit > base); | 94 | AVER(limit > base); |
| 95 | 95 | ||
| 96 | res = CBSInsert(baseIO, limitIO, CBSOfMVFF(mvff), base, limit); | 96 | res = CBSInsert(baseIO, limitIO, CBSOfMVFF(mvff), base, limit); |
| 97 | if (ResIsAllocFailure(res)) | ||
| 98 | /* CBS ran out of memory for splay nodes: lose freed range. */ | ||
| 99 | return; | ||
| 100 | |||
| 97 | AVER(res == ResOK); | 101 | AVER(res == ResOK); |
| 98 | mvff->free += AddrOffset(base, limit); | 102 | mvff->free += AddrOffset(base, limit); |
| 99 | 103 | ||
| @@ -138,6 +142,10 @@ static void MVFFFreeSegs(MVFF mvff, Addr base, Addr limit) | |||
| 138 | if (segBase >= base) { /* segment starts in range */ | 142 | if (segBase >= base) { /* segment starts in range */ |
| 139 | Addr oldBase, oldLimit; | 143 | Addr oldBase, oldLimit; |
| 140 | res = CBSDelete(&oldBase, &oldLimit, CBSOfMVFF(mvff), segBase, segLimit); | 144 | res = CBSDelete(&oldBase, &oldLimit, CBSOfMVFF(mvff), segBase, segLimit); |
| 145 | if (ResIsAllocFailure(res)) | ||
| 146 | /* CBS ran out of memory for splay nodes: can't delete. */ | ||
| 147 | return; | ||
| 148 | |||
| 141 | AVER(res == ResOK); | 149 | AVER(res == ResOK); |
| 142 | AVER(oldBase <= segBase); | 150 | AVER(oldBase <= segBase); |
| 143 | AVER(segLimit <= oldLimit); | 151 | AVER(segLimit <= oldLimit); |
| @@ -367,6 +375,10 @@ static Res MVFFBufferFill(Addr *baseReturn, Addr *limitReturn, | |||
| 367 | Addr newBase, newLimit; | 375 | Addr newBase, newLimit; |
| 368 | foundBlock = FALSE; | 376 | foundBlock = FALSE; |
| 369 | res = CBSInsert(&newBase, &newLimit, CBSOfMVFF(mvff), base, limit); | 377 | res = CBSInsert(&newBase, &newLimit, CBSOfMVFF(mvff), base, limit); |
| 378 | if (ResIsAllocFailure(res)) | ||
| 379 | /* CBS ran out of memory for splay nodes: lose block. */ | ||
| 380 | return res; | ||
| 381 | |||
| 370 | AVER(newBase == base); | 382 | AVER(newBase == base); |
| 371 | AVER(newLimit == limit); | 383 | AVER(newLimit == limit); |
| 372 | AVER(res == ResOK); | 384 | AVER(res == ResOK); |
| @@ -722,31 +734,6 @@ static Bool MVFFCheck(MVFF mvff) | |||
| 722 | } | 734 | } |
| 723 | 735 | ||
| 724 | 736 | ||
| 725 | /* mps_mvff_stat -- a hack to get statistics emitted | ||
| 726 | * | ||
| 727 | * .stat: The SW temp pool cannot be destroyed, so we're providing this | ||
| 728 | * to get the statistics. It breaks modularity to access CBS internals. | ||
| 729 | */ | ||
| 730 | |||
| 731 | #include "meter.h" | ||
| 732 | extern void mps_mvff_stat(mps_pool_t pool); | ||
| 733 | |||
| 734 | void mps_mvff_stat(mps_pool_t mps_pool) | ||
| 735 | { | ||
| 736 | Pool pool; | ||
| 737 | MVFF mvff; | ||
| 738 | |||
| 739 | pool = (Pool)mps_pool; | ||
| 740 | AVERT(Pool, pool); | ||
| 741 | mvff = Pool2MVFF(pool); | ||
| 742 | AVERT(MVFF, mvff); | ||
| 743 | |||
| 744 | METER_EMIT(&CBSOfMVFF(mvff)->splaySearch); | ||
| 745 | /* FIXME: METER_EMIT(&CBSOfMVFF(mvff)->eblSearch); */ | ||
| 746 | /* FIXME: METER_EMIT(&CBSOfMVFF(mvff)->eglSearch); */ | ||
| 747 | } | ||
| 748 | |||
| 749 | |||
| 750 | /* C. COPYRIGHT AND LICENSE | 737 | /* C. COPYRIGHT AND LICENSE |
| 751 | * | 738 | * |
| 752 | * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. | 739 | * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. |
diff --git a/mps/code/range.c b/mps/code/range.c index 739b11f5b5e..60a8b0da367 100644 --- a/mps/code/range.c +++ b/mps/code/range.c | |||
| @@ -16,14 +16,13 @@ SRCID(range, "$Id$"); | |||
| 16 | Bool RangeCheck(Range range) | 16 | Bool RangeCheck(Range range) |
| 17 | { | 17 | { |
| 18 | CHECKS(Range, range); | 18 | CHECKS(Range, range); |
| 19 | CHECKL(range != NULL); | 19 | CHECKL(range->base != NULL); |
| 20 | CHECKL(RangeBase(range) != NULL); | 20 | CHECKL(range->base <= range->limit); |
| 21 | CHECKL(RangeBase(range) <= RangeLimit(range)); | ||
| 22 | 21 | ||
| 23 | return TRUE; | 22 | return TRUE; |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | Res RangeInit(Range range, Addr base, Addr limit) | 25 | void RangeInit(Range range, Addr base, Addr limit) |
| 27 | { | 26 | { |
| 28 | AVER(range != NULL); | 27 | AVER(range != NULL); |
| 29 | AVER(base != NULL); | 28 | AVER(base != NULL); |
| @@ -34,7 +33,6 @@ Res RangeInit(Range range, Addr base, Addr limit) | |||
| 34 | 33 | ||
| 35 | range->sig = RangeSig; | 34 | range->sig = RangeSig; |
| 36 | AVERT(Range, range); | 35 | AVERT(Range, range); |
| 37 | return ResOK; | ||
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | void RangeFinish(Range range) | 38 | void RangeFinish(Range range) |
| @@ -64,7 +62,7 @@ Res RangeDescribe(Range range, mps_lib_FILE *stream) | |||
| 64 | return ResOK; | 62 | return ResOK; |
| 65 | } | 63 | } |
| 66 | 64 | ||
| 67 | Bool RangeOverlap(Range range1, Range range2) | 65 | Bool RangesOverlap(Range range1, Range range2) |
| 68 | { | 66 | { |
| 69 | AVERT(Range, range1); | 67 | AVERT(Range, range1); |
| 70 | AVERT(Range, range2); | 68 | AVERT(Range, range2); |
diff --git a/mps/code/range.h b/mps/code/range.h index 298cb01ff89..c6c70ddb1c4 100644 --- a/mps/code/range.h +++ b/mps/code/range.h | |||
| @@ -27,12 +27,12 @@ typedef struct RangeStruct *Range; | |||
| 27 | #define RangeLimit(range) ((range)->limit) | 27 | #define RangeLimit(range) ((range)->limit) |
| 28 | #define RangeSize(range) (AddrOffset(RangeBase(range), RangeLimit(range))) | 28 | #define RangeSize(range) (AddrOffset(RangeBase(range), RangeLimit(range))) |
| 29 | 29 | ||
| 30 | extern Res RangeInit(Range range, Addr base, Addr limit); | 30 | extern void RangeInit(Range range, Addr base, Addr limit); |
| 31 | extern void RangeFinish(Range range); | 31 | extern void RangeFinish(Range range); |
| 32 | extern Res RangeDescribe(Range range, mps_lib_FILE *stream); | 32 | extern Res RangeDescribe(Range range, mps_lib_FILE *stream); |
| 33 | extern Bool RangeCheck(Range range); | 33 | extern Bool RangeCheck(Range range); |
| 34 | extern Bool RangeIsAligned(Range range, Align align); | 34 | extern Bool RangeIsAligned(Range range, Align align); |
| 35 | extern Bool RangeOverlap(Range range1, Range range2); | 35 | extern Bool RangesOverlap(Range range1, Range range2); |
| 36 | extern Addr (RangeBase)(Range range); | 36 | extern Addr (RangeBase)(Range range); |
| 37 | extern Addr (RangeLimit)(Range range); | 37 | extern Addr (RangeLimit)(Range range); |
| 38 | extern Size (RangeSize)(Range range); | 38 | extern Size (RangeSize)(Range range); |