diff options
| author | Richard Brooksby | 2023-06-07 14:57:55 +0100 |
|---|---|---|
| committer | Richard Brooksby | 2023-06-07 14:57:55 +0100 |
| commit | d137edaaa51c767c7d1d3af4b648253ad7092d13 (patch) | |
| tree | c36d0808357ac471782764974f3f9415ef9ef6bd | |
| parent | 13d10c5989d0d1ad0437b44306e5e8418bbe8b91 (diff) | |
| download | emacs-d137edaaa51c767c7d1d3af4b648253ad7092d13.tar.gz emacs-d137edaaa51c767c7d1d3af4b648253ad7092d13.zip | |
Generalising mps_addr_object, arenaaddrobject, pooladdrobject for pools that do not use segments.
| -rw-r--r-- | mps/code/addrobj.c | 4 | ||||
| -rw-r--r-- | mps/code/arena.c | 12 | ||||
| -rw-r--r-- | mps/code/mpm.h | 4 | ||||
| -rw-r--r-- | mps/code/mpmtypes.h | 2 | ||||
| -rw-r--r-- | mps/code/pool.c | 18 | ||||
| -rw-r--r-- | mps/code/poolabs.c | 6 | ||||
| -rw-r--r-- | mps/code/poolamc.c | 12 |
7 files changed, 29 insertions, 29 deletions
diff --git a/mps/code/addrobj.c b/mps/code/addrobj.c index 1e4bcbff660..eda49fc1ffe 100644 --- a/mps/code/addrobj.c +++ b/mps/code/addrobj.c | |||
| @@ -148,9 +148,7 @@ static void test_main(void) | |||
| 148 | /* Do the test */ | 148 | /* Do the test */ |
| 149 | res = mps_addr_object(&out, arena, in); | 149 | res = mps_addr_object(&out, arena, in); |
| 150 | 150 | ||
| 151 | /* We should insist MPS_RES_UNIMPL here but the Trivial Method for mps_addr_object is only reached for pools that contain objects in Segs. | 151 | Insist(res == MPS_RES_UNIMPL); |
| 152 | Since mvff does not, and the input address is not inside a Seg, the call is rejected by the Arena with MPS_RES_FAIL */ | ||
| 153 | Insist(res == MPS_RES_FAIL); | ||
| 154 | 152 | ||
| 155 | /* Final clean up */ | 153 | /* Final clean up */ |
| 156 | mps_free(mvff_pool, in, sizeof(mps_word_t)); | 154 | mps_free(mvff_pool, in, sizeof(mps_word_t)); |
diff --git a/mps/code/arena.c b/mps/code/arena.c index 9b5fc8f7a3e..7139ff4bc86 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c | |||
| @@ -1367,19 +1367,17 @@ Bool ArenaHasAddr(Arena arena, Addr addr) | |||
| 1367 | /* ArenaAddrObject -- return base pointer of managed object */ | 1367 | /* ArenaAddrObject -- return base pointer of managed object */ |
| 1368 | Res ArenaAddrObject(Addr *pReturn, Arena arena, Addr addr) | 1368 | Res ArenaAddrObject(Addr *pReturn, Arena arena, Addr addr) |
| 1369 | { | 1369 | { |
| 1370 | Seg seg; | 1370 | Tract tract; |
| 1371 | Pool pool; | ||
| 1372 | 1371 | ||
| 1373 | AVER(pReturn != NULL); | 1372 | AVER(pReturn != NULL); |
| 1374 | AVERT(Arena, arena); | 1373 | AVERT(Arena, arena); |
| 1375 | 1374 | ||
| 1376 | /* We currently assume that managed objects are inside Segments | 1375 | if (!TractOfAddr(&tract, arena, addr)) { |
| 1377 | and that pools where this feature is needed have Segments */ | 1376 | /* address does not belong to the arena */ |
| 1378 | if (!SegOfAddr(&seg, arena, addr)) | ||
| 1379 | return ResFAIL; | 1377 | return ResFAIL; |
| 1378 | } | ||
| 1380 | 1379 | ||
| 1381 | pool = SegPool(seg); | 1380 | return PoolAddrObject(pReturn, TractPool(tract), addr); |
| 1382 | return PoolAddrObject(pReturn, pool, seg, addr); | ||
| 1383 | } | 1381 | } |
| 1384 | 1382 | ||
| 1385 | 1383 | ||
diff --git a/mps/code/mpm.h b/mps/code/mpm.h index d896fe369f8..e072a7a1ea7 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h | |||
| @@ -236,7 +236,7 @@ extern Res PoolTraceBegin(Pool pool, Trace trace); | |||
| 236 | extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p); | 236 | extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p); |
| 237 | extern Size PoolTotalSize(Pool pool); | 237 | extern Size PoolTotalSize(Pool pool); |
| 238 | extern Size PoolFreeSize(Pool pool); | 238 | extern Size PoolFreeSize(Pool pool); |
| 239 | extern Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr); | 239 | extern Res PoolAddrObject(Addr *pReturn, Pool pool, Addr addr); |
| 240 | 240 | ||
| 241 | extern Res PoolAbsInit(Pool pool, Arena arena, PoolClass klass, ArgList arg); | 241 | extern Res PoolAbsInit(Pool pool, Arena arena, PoolClass klass, ArgList arg); |
| 242 | extern void PoolAbsFinish(Inst inst); | 242 | extern void PoolAbsFinish(Inst inst); |
| @@ -268,7 +268,7 @@ extern void PoolTrivFreeWalk(Pool pool, FreeBlockVisitor f, void *p); | |||
| 268 | extern PoolDebugMixin PoolNoDebugMixin(Pool pool); | 268 | extern PoolDebugMixin PoolNoDebugMixin(Pool pool); |
| 269 | extern BufferClass PoolNoBufferClass(void); | 269 | extern BufferClass PoolNoBufferClass(void); |
| 270 | extern Size PoolNoSize(Pool pool); | 270 | extern Size PoolNoSize(Pool pool); |
| 271 | extern Res PoolTrivAddr(Addr *pReturn, Pool pool, Seg seg, Addr addr); | 271 | extern Res PoolTrivAddrObject(Addr *pReturn, Pool pool, Addr addr); |
| 272 | 272 | ||
| 273 | /* See .critical.macros. */ | 273 | /* See .critical.macros. */ |
| 274 | #define PoolFreeMacro(pool, old, size) Method(Pool, pool, free)(pool, old, size) | 274 | #define PoolFreeMacro(pool, old, size) Method(Pool, pool, free)(pool, old, size) |
diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index d68134a6574..c219e908e06 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h | |||
| @@ -214,7 +214,7 @@ typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn, | |||
| 214 | Pool pool, Buffer buf); | 214 | Pool pool, Buffer buf); |
| 215 | typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf, | 215 | typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf, |
| 216 | AllocFrame frame); | 216 | AllocFrame frame); |
| 217 | typedef Res (*PoolAddrObjectMethod)(Addr *pReturn, Pool pool, Seg seg, Addr addr); | 217 | typedef Res (*PoolAddrObjectMethod)(Addr *pReturn, Pool pool, Addr addr); |
| 218 | typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockVisitor f, void *p); | 218 | typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockVisitor f, void *p); |
| 219 | typedef BufferClass (*PoolBufferClassMethod)(void); | 219 | typedef BufferClass (*PoolBufferClassMethod)(void); |
| 220 | typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool); | 220 | typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool); |
diff --git a/mps/code/pool.c b/mps/code/pool.c index 0257359e36f..fc04563175b 100644 --- a/mps/code/pool.c +++ b/mps/code/pool.c | |||
| @@ -303,16 +303,20 @@ Size PoolFreeSize(Pool pool) | |||
| 303 | return Method(Pool, pool, freeSize)(pool); | 303 | return Method(Pool, pool, freeSize)(pool); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | /* PoolAddrObject -- return base pointer from interior pointer */ | 306 | |
| 307 | Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr) | 307 | /* PoolAddrObject -- return base pointer from interior pointer |
| 308 | * | ||
| 309 | * Note: addr is not necessarily inside the pool, even though | ||
| 310 | * mps_addr_object dispatches via the tract table. This allows this | ||
| 311 | * function to be used more generally internally. The pool should | ||
| 312 | * check (it has to anyway). | ||
| 313 | */ | ||
| 314 | |||
| 315 | Res PoolAddrObject(Addr *pReturn, Pool pool, Addr addr) | ||
| 308 | { | 316 | { |
| 309 | AVER(pReturn != NULL); | 317 | AVER(pReturn != NULL); |
| 310 | AVERT(Pool, pool); | 318 | AVERT(Pool, pool); |
| 311 | AVERT(Seg, seg); | 319 | return Method(Pool, pool, addrObject)(pReturn, pool, addr); |
| 312 | AVER(pool == SegPool(seg)); | ||
| 313 | AVER(SegBase(seg) <= addr); | ||
| 314 | AVER(addr < SegLimit(seg)); | ||
| 315 | return Method(Pool, pool, addrObject)(pReturn, pool, seg, addr); | ||
| 316 | } | 320 | } |
| 317 | 321 | ||
| 318 | /* PoolDescribe -- describe a pool */ | 322 | /* PoolDescribe -- describe a pool */ |
diff --git a/mps/code/poolabs.c b/mps/code/poolabs.c index eb469e967de..d6eae2dd046 100644 --- a/mps/code/poolabs.c +++ b/mps/code/poolabs.c | |||
| @@ -173,7 +173,7 @@ DEFINE_CLASS(Pool, AbstractPool, klass) | |||
| 173 | klass->debugMixin = PoolNoDebugMixin; | 173 | klass->debugMixin = PoolNoDebugMixin; |
| 174 | klass->totalSize = PoolNoSize; | 174 | klass->totalSize = PoolNoSize; |
| 175 | klass->freeSize = PoolNoSize; | 175 | klass->freeSize = PoolNoSize; |
| 176 | klass->addrObject = PoolTrivAddr; | 176 | klass->addrObject = PoolTrivAddrObject; |
| 177 | klass->sig = PoolClassSig; | 177 | klass->sig = PoolClassSig; |
| 178 | AVERT(PoolClass, klass); | 178 | AVERT(PoolClass, klass); |
| 179 | } | 179 | } |
| @@ -476,10 +476,10 @@ Size PoolNoSize(Pool pool) | |||
| 476 | return UNUSED_SIZE; | 476 | return UNUSED_SIZE; |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | Res PoolTrivAddr(Addr *pReturn, Pool pool, Seg seg, Addr addr) | 479 | |
| 480 | Res PoolTrivAddrObject(Addr *pReturn, Pool pool, Addr addr) | ||
| 480 | { | 481 | { |
| 481 | AVERT(Pool, pool); | 482 | AVERT(Pool, pool); |
| 482 | AVERT(Seg, seg); | ||
| 483 | AVER(pReturn != NULL); | 483 | AVER(pReturn != NULL); |
| 484 | UNUSED(addr); | 484 | UNUSED(addr); |
| 485 | 485 | ||
diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index f62413b6401..4455bb9e859 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c | |||
| @@ -1926,24 +1926,24 @@ static Res amcAddrObjectSearch(Addr *pReturn, Pool pool, Addr objBase, | |||
| 1926 | return ResFAIL; | 1926 | return ResFAIL; |
| 1927 | } | 1927 | } |
| 1928 | 1928 | ||
| 1929 | |||
| 1929 | /* AMCAddrObject -- return base pointer from interior pointer */ | 1930 | /* AMCAddrObject -- return base pointer from interior pointer */ |
| 1930 | 1931 | ||
| 1931 | static Res AMCAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr) | 1932 | static Res AMCAddrObject(Addr *pReturn, Pool pool, Addr addr) |
| 1932 | { | 1933 | { |
| 1933 | Res res; | 1934 | Res res; |
| 1934 | Arena arena; | 1935 | Arena arena; |
| 1935 | Addr base, limit; | 1936 | Addr base, limit; |
| 1936 | Buffer buffer; | 1937 | Buffer buffer; |
| 1937 | 1938 | Seg seg; | |
| 1938 | 1939 | ||
| 1939 | AVER(pReturn != NULL); | 1940 | AVER(pReturn != NULL); |
| 1940 | AVERT(Pool, pool); | 1941 | AVERT(Pool, pool); |
| 1941 | AVERT(Seg, seg); | ||
| 1942 | AVER(SegPool(seg) == pool); | ||
| 1943 | AVER(SegBase(seg) <= addr); | ||
| 1944 | AVER(addr < SegLimit(seg)); | ||
| 1945 | 1942 | ||
| 1946 | arena = PoolArena(pool); | 1943 | arena = PoolArena(pool); |
| 1944 | if (!SegOfAddr(&seg, arena, addr) || SegPool(seg) != pool) | ||
| 1945 | return ResFAIL; | ||
| 1946 | |||
| 1947 | base = SegBase(seg); | 1947 | base = SegBase(seg); |
| 1948 | if (SegBuffer(&buffer, seg)) | 1948 | if (SegBuffer(&buffer, seg)) |
| 1949 | limit = BufferGetInit(buffer); | 1949 | limit = BufferGetInit(buffer); |