diff --git a/mps/code/arena.c b/mps/code/arena.c index e4871d7f997..67db06ababf 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -75,9 +75,7 @@ static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream, Count depth) * .null: Most abstract class methods are set to NULL. See * . */ -typedef ArenaClassStruct AbstractArenaClassStruct; - -DEFINE_CLASS(AbstractArena, class) +DEFINE_CLASS(Arena, AbstractArena, class) { INHERIT_CLASS(&class->protocol, AbstractArena, Inst); class->size = 0; diff --git a/mps/code/arenacl.c b/mps/code/arenacl.c index 405b9ecca2e..ec4e7a63ca4 100644 --- a/mps/code/arenacl.c +++ b/mps/code/arenacl.c @@ -447,7 +447,7 @@ static void ClientArenaFree(Addr base, Size size, Pool pool) /* ClientArenaClass -- The Client arena class definition */ -DEFINE_ARENA_CLASS(ClientArena, this) +DEFINE_CLASS(Arena, ClientArena, this) { INHERIT_CLASS(this, ClientArena, AbstractArena); this->size = sizeof(ClientArenaStruct); @@ -459,7 +459,6 @@ DEFINE_ARENA_CLASS(ClientArena, this) this->free = ClientArenaFree; this->chunkInit = ClientChunkInit; this->chunkFinish = ClientChunkFinish; - AVERT(ArenaClass, this); } diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c index 7ece0809684..3f5d5e92ef8 100644 --- a/mps/code/arenavm.c +++ b/mps/code/arenavm.c @@ -1181,7 +1181,7 @@ mps_res_t mps_arena_vm_growth(mps_arena_t mps_arena, /* VMArenaClass -- The VM arena class definition */ -DEFINE_ARENA_CLASS(VMArena, this) +DEFINE_CLASS(Arena, VMArena, this) { INHERIT_CLASS(this, VMArena, AbstractArena); this->size = sizeof(VMArenaStruct); @@ -1196,7 +1196,6 @@ DEFINE_ARENA_CLASS(VMArena, this) this->compact = VMCompact; this->describe = VMArenaDescribe; this->pagesMarkAllocated = VMPagesMarkAllocated; - AVERT(ArenaClass, this); } diff --git a/mps/code/buffer.c b/mps/code/buffer.c index 0ec6ae8eb47..dc4d1c7a6b1 100644 --- a/mps/code/buffer.c +++ b/mps/code/buffer.c @@ -1192,7 +1192,7 @@ Bool BufferClassCheck(BufferClass class) * * See . */ -DEFINE_CLASS(Buffer, class) +DEFINE_CLASS(Buffer, Buffer, class) { INHERIT_CLASS(&class->protocol, Buffer, Inst); class->size = sizeof(BufferStruct); @@ -1207,7 +1207,6 @@ DEFINE_CLASS(Buffer, class) class->setRankSet = bufferNoSetRankSet; class->reassignSeg = bufferNoReassignSeg; class->sig = BufferClassSig; - AVERT(BufferClass, class); } @@ -1448,9 +1447,7 @@ static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth) * Supports an association with a single segment when attached. See * . */ -typedef BufferClassStruct SegBufClassStruct; - -DEFINE_CLASS(SegBuf, class) +DEFINE_CLASS(Buffer, SegBuf, class) { INHERIT_CLASS(class, SegBuf, Buffer); class->size = sizeof(SegBufStruct); @@ -1463,7 +1460,6 @@ DEFINE_CLASS(SegBuf, class) class->rankSet = segBufRankSet; class->setRankSet = segBufSetRankSet; class->reassignSeg = segBufReassignSeg; - AVERT(BufferClass, class); } @@ -1516,14 +1512,11 @@ static Res rankBufInit(Buffer buffer, Pool pool, ArgList args) * * Supports initialization to a rank supplied at creation time. */ -typedef BufferClassStruct RankBufClassStruct; - -DEFINE_CLASS(RankBuf, class) +DEFINE_CLASS(Buffer, RankBuf, class) { INHERIT_CLASS(class, RankBuf, SegBuf); class->varargs = rankBufVarargs; class->init = rankBufInit; - AVERT(BufferClass, class); } diff --git a/mps/code/cbs.c b/mps/code/cbs.c index ef725375274..d9089ffe0ef 100644 --- a/mps/code/cbs.c +++ b/mps/code/cbs.c @@ -1164,7 +1164,7 @@ static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth) return res; } -DEFINE_LAND_CLASS(CBSLand, class) +DEFINE_CLASS(Land, CBSLand, class) { INHERIT_CLASS(class, CBSLand, Land); class->size = sizeof(CBSStruct); @@ -1180,21 +1180,18 @@ DEFINE_LAND_CLASS(CBSLand, class) class->findLargest = cbsFindLargest; class->findInZones = cbsFindInZones; class->describe = cbsDescribe; - AVERT(LandClass, class); } -DEFINE_LAND_CLASS(CBSFastLand, class) +DEFINE_CLASS(Land, CBSFastLand, class) { INHERIT_CLASS(class, CBSFastLand, CBSLand); class->init = cbsInitFast; - AVERT(LandClass, class); } -DEFINE_LAND_CLASS(CBSZonedLand, class) +DEFINE_CLASS(Land, CBSZonedLand, class) { INHERIT_CLASS(class, CBSZonedLand, CBSFastLand); class->init = cbsInitZoned; - AVERT(LandClass, class); } diff --git a/mps/code/failover.c b/mps/code/failover.c index 7caffc6e9ee..5ccd61e6750 100644 --- a/mps/code/failover.c +++ b/mps/code/failover.c @@ -301,7 +301,7 @@ static Res failoverDescribe(Land land, mps_lib_FILE *stream, Count depth) } -DEFINE_LAND_CLASS(FailoverLand, class) +DEFINE_CLASS(Land, FailoverLand, class) { INHERIT_CLASS(class, FailoverLand, Land); class->size = sizeof(FailoverStruct); @@ -316,7 +316,6 @@ DEFINE_LAND_CLASS(FailoverLand, class) class->findLargest = failoverFindLargest; class->findInZones = failoverFindInZones; class->describe = failoverDescribe; - AVERT(LandClass, class); } diff --git a/mps/code/fotest.c b/mps/code/fotest.c index 4664a819111..fbbf94604fc 100644 --- a/mps/code/fotest.c +++ b/mps/code/fotest.c @@ -61,13 +61,12 @@ static Res oomAlloc(Addr *pReturn, Pool pool, Size size) } DECLARE_CLASS(Pool, OOMPool); -DEFINE_POOL_CLASS(OOMPool, this) +DEFINE_CLASS(Pool, OOMPool, this) { INHERIT_CLASS(this, OOMPool, AbstractPool); this->alloc = oomAlloc; this->free = PoolTrivFree; this->size = sizeof(PoolStruct); - AVERT(PoolClass, this); } diff --git a/mps/code/freelist.c b/mps/code/freelist.c index 8569cf0c83d..7fc896f9985 100644 --- a/mps/code/freelist.c +++ b/mps/code/freelist.c @@ -809,7 +809,7 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth) } -DEFINE_LAND_CLASS(FreelistLand, class) +DEFINE_CLASS(Land, FreelistLand, class) { INHERIT_CLASS(class, FreelistLand, Land); class->size = sizeof(FreelistStruct); @@ -825,7 +825,6 @@ DEFINE_LAND_CLASS(FreelistLand, class) class->findLargest = freelistFindLargest; class->findInZones = freelistFindInZones; class->describe = freelistDescribe; - AVERT(LandClass, class); } diff --git a/mps/code/land.c b/mps/code/land.c index ab92c85ba85..d3ab5b83b60 100644 --- a/mps/code/land.c +++ b/mps/code/land.c @@ -574,7 +574,7 @@ static Res landTrivDescribe(Land land, mps_lib_FILE *stream, Count depth) return ResOK; } -DEFINE_CLASS(Land, class) +DEFINE_CLASS(Land, Land, class) { INHERIT_CLASS(&class->protocol, Land, Inst); class->size = sizeof(LandStruct); @@ -591,7 +591,6 @@ DEFINE_CLASS(Land, class) class->findInZones = landNoFindInZones; class->describe = landTrivDescribe; class->sig = LandClassSig; - AVERT(LandClass, class); } diff --git a/mps/code/mpm.h b/mps/code/mpm.h index f0b99ce68a6..a437a0e7f15 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -310,9 +310,6 @@ DECLARE_CLASS(AbstractCollectPool, AbstractCollectPool); * * Convenience macro -- see . */ -#define DEFINE_POOL_CLASS(className, var) \ - DEFINE_ALIAS_CLASS(className, Pool, var) - #define POOL_SUPERCLASS(className) \ ((PoolClass)SUPERCLASS(className)) @@ -492,9 +489,6 @@ extern void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena, * * Convenience macro -- see . */ -#define DEFINE_ARENA_CLASS(className, var) \ - DEFINE_ALIAS_CLASS(className, Arena, var) - #define ARENA_SUPERCLASS(className) \ ((ArenaClass)SUPERCLASS(className)) @@ -706,10 +700,6 @@ extern void SegClassMixInNoSplitMerge(SegClass class); /* DEFINE_SEG_CLASS -- define a segment class */ -#define DEFINE_SEG_CLASS(className, var) \ - DEFINE_ALIAS_CLASS(className, Seg, var) - - #define SEG_SUPERCLASS(className) \ ((SegClass)SUPERCLASS(className)) @@ -822,9 +812,6 @@ extern void BufferFrameSetState(Buffer buffer, FrameState state); /* DEFINE_BUFFER_CLASS -- define a buffer class */ -#define DEFINE_BUFFER_CLASS(className, var) \ - DEFINE_ALIAS_CLASS(className, Buffer, var) - #define BUFFER_SUPERCLASS(className) \ ((BufferClass)SUPERCLASS(className)) @@ -1026,8 +1013,6 @@ extern Size LandSlowSize(Land land); extern Bool LandClassCheck(LandClass class); DECLARE_CLASS(Land, Land); #define LAND_SUPERCLASS(className) ((LandClass)SUPERCLASS(className)) -#define DEFINE_LAND_CLASS(className, var) \ - DEFINE_ALIAS_CLASS(className, Land, var) #define IsLandSubclass(land, className) \ IsSubclassPoly((land)->class, className ## Get()) diff --git a/mps/code/poolabs.c b/mps/code/poolabs.c index 7995efcbe4f..e870fbc9a3e 100644 --- a/mps/code/poolabs.c +++ b/mps/code/poolabs.c @@ -111,7 +111,7 @@ void PoolClassMixInCollect(PoolClass class) /* Classes */ -DEFINE_CLASS(AbstractPool, class) +DEFINE_CLASS(Pool, AbstractPool, class) { INHERIT_CLASS(&class->protocol, AbstractPool, Inst); class->size = 0; @@ -149,25 +149,25 @@ DEFINE_CLASS(AbstractPool, class) class->sig = PoolClassSig; } -DEFINE_CLASS(AbstractBufferPool, class) +DEFINE_CLASS(Pool, AbstractBufferPool, class) { INHERIT_CLASS(class, AbstractBufferPool, AbstractPool); PoolClassMixInBuffer(class); } -DEFINE_CLASS(AbstractSegBufPool, class) +DEFINE_CLASS(Pool, AbstractSegBufPool, class) { INHERIT_CLASS(class, AbstractSegBufPool, AbstractBufferPool); class->bufferClass = SegBufClassGet; } -DEFINE_CLASS(AbstractScanPool, class) +DEFINE_CLASS(Pool, AbstractScanPool, class) { INHERIT_CLASS(class, AbstractScanPool, AbstractSegBufPool); PoolClassMixInScan(class); } -DEFINE_CLASS(AbstractCollectPool, class) +DEFINE_CLASS(Pool, AbstractCollectPool, class) { INHERIT_CLASS(class, AbstractCollectPool, AbstractScanPool); PoolClassMixInCollect(class); diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 99f775d9c51..d49c17731aa 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -341,14 +341,13 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth) /* amcSegClass -- Class definition for AMC segments */ -DEFINE_SEG_CLASS(amcSeg, class) +DEFINE_CLASS(Seg, amcSeg, class) { INHERIT_CLASS(class, amcSeg, GCSeg); SegClassMixInNoSplitMerge(class); /* no support for this (yet) */ class->size = sizeof(amcSegStruct); class->init = AMCSegInit; class->describe = AMCSegDescribe; - AVERT(SegClass, class); } @@ -564,13 +563,12 @@ static void AMCBufFinish(Buffer buffer) /* amcBufClass -- The class definition */ -DEFINE_BUFFER_CLASS(amcBuf, class) +DEFINE_CLASS(Buffer, amcBuf, class) { INHERIT_CLASS(class, amcBuf, SegBuf); class->size = sizeof(amcBufStruct); class->init = AMCBufInit; class->finish = AMCBufFinish; - AVERT(BufferClass, class); } @@ -2102,7 +2100,7 @@ static Res AMCDescribe(Pool pool, mps_lib_FILE *stream, Count depth) /* AMCZPoolClass -- the class definition */ -DEFINE_POOL_CLASS(AMCZPool, this) +DEFINE_CLASS(Pool, AMCZPool, this) { INHERIT_CLASS(this, AMCZPool, AbstractSegBufPool); PoolClassMixInFormat(this); @@ -2126,19 +2124,17 @@ DEFINE_POOL_CLASS(AMCZPool, this) this->totalSize = AMCTotalSize; this->freeSize = AMCFreeSize; this->describe = AMCDescribe; - AVERT(PoolClass, this); } /* AMCPoolClass -- the class definition */ -DEFINE_POOL_CLASS(AMCPool, this) +DEFINE_CLASS(Pool, AMCPool, this) { INHERIT_CLASS(this, AMCPool, AMCZPool); PoolClassMixInScan(this); this->init = AMCInit; this->scan = AMCScan; - AVERT(PoolClass, this); } diff --git a/mps/code/poolams.c b/mps/code/poolams.c index 7e6dd766411..a7ad2b74e76 100644 --- a/mps/code/poolams.c +++ b/mps/code/poolams.c @@ -623,7 +623,7 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth) /* AMSSegClass -- Class definition for AMS segments */ -DEFINE_CLASS(AMSSeg, class) +DEFINE_CLASS(Seg, AMSSeg, class) { INHERIT_CLASS(class, AMSSeg, GCSeg); class->size = sizeof(AMSSegStruct); @@ -1746,7 +1746,7 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth) /* contains the type definition. Hence the use */ /* of DEFINE_CLASS rather than DEFINE_POOL_CLASS */ -DEFINE_CLASS(AMSPool, this) +DEFINE_CLASS(Pool, AMSPool, this) { INHERIT_CLASS(this, AMSPool, AbstractCollectPool); PoolClassMixInFormat(this); @@ -1788,14 +1788,13 @@ static PoolDebugMixin AMSDebugMixin(Pool pool) /* AMSDebugPoolClass -- the class definition for the debug version */ -DEFINE_POOL_CLASS(AMSDebugPool, this) +DEFINE_CLASS(Pool, AMSDebugPool, this) { INHERIT_CLASS(this, AMSDebugPool, AMSPool); PoolClassMixInDebug(this); this->size = sizeof(AMSDebugStruct); this->varargs = AMSDebugVarargs; this->debugMixin = AMSDebugMixin; - AVERT(PoolClass, this); } diff --git a/mps/code/poolawl.c b/mps/code/poolawl.c index 12dc804a7b8..4c3db4707b7 100644 --- a/mps/code/poolawl.c +++ b/mps/code/poolawl.c @@ -284,14 +284,13 @@ static void AWLSegFinish(Seg seg) /* AWLSegClass -- Class definition for AWL segments */ -DEFINE_SEG_CLASS(AWLSeg, class) +DEFINE_CLASS(Seg, AWLSeg, class) { INHERIT_CLASS(class, AWLSeg, GCSeg); SegClassMixInNoSplitMerge(class); /* no support for this (yet) */ class->size = sizeof(AWLSegStruct); class->init = AWLSegInit; class->finish = AWLSegFinish; - AVERT(SegClass, class); } @@ -1317,7 +1316,7 @@ static Size AWLFreeSize(Pool pool) /* AWLPoolClass -- the class definition */ -DEFINE_POOL_CLASS(AWLPool, this) +DEFINE_CLASS(Pool, AWLPool, this) { INHERIT_CLASS(this, AWLPool, AbstractCollectPool); PoolClassMixInFormat(this); @@ -1339,7 +1338,6 @@ DEFINE_POOL_CLASS(AWLPool, this) this->walk = AWLWalk; this->totalSize = AWLTotalSize; this->freeSize = AWLFreeSize; - AVERT(PoolClass, this); } diff --git a/mps/code/poollo.c b/mps/code/poollo.c index d6102c6f7ab..4874ecf444a 100644 --- a/mps/code/poollo.c +++ b/mps/code/poollo.c @@ -66,14 +66,13 @@ static Count loSegGrains(LOSeg loseg); /* LOSegClass -- Class definition for LO segments */ -DEFINE_SEG_CLASS(LOSeg, class) +DEFINE_CLASS(Seg, LOSeg, class) { INHERIT_CLASS(class, LOSeg, GCSeg); SegClassMixInNoSplitMerge(class); class->size = sizeof(LOSegStruct); class->init = loSegInit; class->finish = loSegFinish; - AVERT(SegClass, class); } @@ -818,7 +817,7 @@ static Size LOFreeSize(Pool pool) /* LOPoolClass -- the class definition */ -DEFINE_POOL_CLASS(LOPool, this) +DEFINE_CLASS(Pool, LOPool, this) { INHERIT_CLASS(this, LOPool, AbstractSegBufPool); PoolClassMixInFormat(this); @@ -836,7 +835,6 @@ DEFINE_POOL_CLASS(LOPool, this) this->walk = LOWalk; this->totalSize = LOTotalSize; this->freeSize = LOFreeSize; - AVERT(PoolClass, this); } diff --git a/mps/code/poolmfs.c b/mps/code/poolmfs.c index 3b0e0f496d3..63ff9c0b0e8 100644 --- a/mps/code/poolmfs.c +++ b/mps/code/poolmfs.c @@ -356,7 +356,7 @@ static Res MFSDescribe(Pool pool, mps_lib_FILE *stream, Count depth) } -DEFINE_POOL_CLASS(MFSPool, this) +DEFINE_CLASS(Pool, MFSPool, this) { INHERIT_CLASS(this, MFSPool, AbstractPool); this->size = sizeof(MFSStruct); @@ -368,7 +368,6 @@ DEFINE_POOL_CLASS(MFSPool, this) this->totalSize = MFSTotalSize; this->freeSize = MFSFreeSize; this->describe = MFSDescribe; - AVERT(PoolClass, this); } diff --git a/mps/code/poolmrg.c b/mps/code/poolmrg.c index dc63ef3bb91..539099dde54 100644 --- a/mps/code/poolmrg.c +++ b/mps/code/poolmrg.c @@ -296,25 +296,23 @@ static Res MRGRefSegInit(Seg seg, Pool pool, Addr base, Size size, ArgList args) /* MRGLinkSegClass -- Class definition */ -DEFINE_SEG_CLASS(MRGLinkSeg, class) +DEFINE_CLASS(Seg, MRGLinkSeg, class) { INHERIT_CLASS(class, MRGLinkSeg, Seg); SegClassMixInNoSplitMerge(class); /* no support for this */ class->size = sizeof(MRGLinkSegStruct); class->init = MRGLinkSegInit; - AVERT(SegClass, class); } /* MRGRefSegClass -- Class definition */ -DEFINE_SEG_CLASS(MRGRefSeg, class) +DEFINE_CLASS(Seg, MRGRefSeg, class) { INHERIT_CLASS(class, MRGRefSeg, GCSeg); SegClassMixInNoSplitMerge(class); /* no support for this */ class->size = sizeof(MRGRefSegStruct); class->init = MRGRefSegInit; - AVERT(SegClass, class); } @@ -867,7 +865,7 @@ static Res MRGScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg) } -DEFINE_POOL_CLASS(MRGPool, this) +DEFINE_CLASS(Pool, MRGPool, this) { INHERIT_CLASS(this, MRGPool, AbstractPool); this->size = sizeof(MRGStruct); @@ -877,7 +875,6 @@ DEFINE_POOL_CLASS(MRGPool, this) this->blacken = PoolTrivBlacken; this->scan = MRGScan; this->describe = MRGDescribe; - AVERT(PoolClass, this); } diff --git a/mps/code/poolmv.c b/mps/code/poolmv.c index d3c15758380..538d77c13ea 100644 --- a/mps/code/poolmv.c +++ b/mps/code/poolmv.c @@ -842,7 +842,7 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth) /* Pool class MV */ -DEFINE_POOL_CLASS(MVPool, this) +DEFINE_CLASS(Pool, MVPool, this) { INHERIT_CLASS(this, MVPool, AbstractBufferPool); this->size = sizeof(MVStruct); @@ -854,11 +854,10 @@ DEFINE_POOL_CLASS(MVPool, this) this->totalSize = MVTotalSize; this->freeSize = MVFreeSize; this->describe = MVDescribe; - AVERT(PoolClass, this); } -MVPoolClass PoolClassMV(void) +PoolClass PoolClassMV(void) { return CLASS(MVPool); } @@ -866,14 +865,13 @@ MVPoolClass PoolClassMV(void) /* Pool class MVDebug */ -DEFINE_POOL_CLASS(MVDebugPool, this) +DEFINE_CLASS(Pool, MVDebugPool, this) { INHERIT_CLASS(this, MVDebugPool, MVPool); PoolClassMixInDebug(this); this->size = sizeof(MVDebugStruct); this->varargs = MVDebugVarargs; this->debugMixin = MVDebugMixin; - AVERT(PoolClass, this); } diff --git a/mps/code/poolmv2.c b/mps/code/poolmv2.c index 540dd3900c1..e4dbd80eaae 100644 --- a/mps/code/poolmv2.c +++ b/mps/code/poolmv2.c @@ -133,7 +133,7 @@ typedef struct MVTStruct } MVTStruct; -DEFINE_POOL_CLASS(MVTPool, this) +DEFINE_CLASS(Pool, MVTPool, this) { INHERIT_CLASS(this, MVTPool, AbstractBufferPool); this->size = sizeof(MVTStruct); @@ -146,7 +146,6 @@ DEFINE_POOL_CLASS(MVTPool, this) this->totalSize = MVTTotalSize; this->freeSize = MVTFreeSize; this->describe = MVTDescribe; - AVERT(PoolClass, this); } /* Macros */ diff --git a/mps/code/poolmvff.c b/mps/code/poolmvff.c index 22a840195ed..da551d733fd 100644 --- a/mps/code/poolmvff.c +++ b/mps/code/poolmvff.c @@ -704,7 +704,7 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream, Count depth) } -DEFINE_POOL_CLASS(MVFFPool, this) +DEFINE_CLASS(Pool, MVFFPool, this) { INHERIT_CLASS(this, MVFFPool, AbstractPool); PoolClassMixInBuffer(this); @@ -719,7 +719,6 @@ DEFINE_POOL_CLASS(MVFFPool, this) this->totalSize = MVFFTotalSize; this->freeSize = MVFFFreeSize; this->describe = MVFFDescribe; - AVERT(PoolClass, this); } @@ -731,14 +730,13 @@ PoolClass PoolClassMVFF(void) /* Pool class MVFFDebug */ -DEFINE_POOL_CLASS(MVFFDebugPool, this) +DEFINE_CLASS(Pool, MVFFDebugPool, this) { INHERIT_CLASS(this, MVFFDebugPool, MVFFPool); PoolClassMixInDebug(this); this->size = sizeof(MVFFDebugStruct); this->varargs = MVFFDebugVarargs; this->debugMixin = MVFFDebugMixin; - AVERT(PoolClass, this); } diff --git a/mps/code/pooln.c b/mps/code/pooln.c index 4cb884937ac..d45e564beda 100644 --- a/mps/code/pooln.c +++ b/mps/code/pooln.c @@ -261,7 +261,7 @@ static void NTraceEnd(Pool pool, Trace trace) /* NPoolClass -- pool class definition for N */ -DEFINE_POOL_CLASS(NPool, this) +DEFINE_CLASS(Pool, NPool, this) { INHERIT_CLASS(this, NPool, AbstractPool); this->size = sizeof(PoolNStruct); diff --git a/mps/code/poolsnc.c b/mps/code/poolsnc.c index 4030cbcaf57..e7e77720803 100644 --- a/mps/code/poolsnc.c +++ b/mps/code/poolsnc.c @@ -176,13 +176,12 @@ static void SNCBufFinish(Buffer buffer) /* SNCBufClass -- The class definition */ -DEFINE_BUFFER_CLASS(SNCBuf, class) +DEFINE_CLASS(Buffer, SNCBuf, class) { INHERIT_CLASS(class, SNCBuf, RankBuf); class->size = sizeof(SNCBufStruct); class->init = SNCBufInit; class->finish = SNCBufFinish; - AVERT(BufferClass, class); } @@ -251,13 +250,12 @@ static Res sncSegInit(Seg seg, Pool pool, Addr base, Size size, ArgList args) /* SNCSegClass -- Class definition for SNC segments */ -DEFINE_SEG_CLASS(SNCSeg, class) +DEFINE_CLASS(Seg, SNCSeg, class) { INHERIT_CLASS(class, SNCSeg, GCSeg); SegClassMixInNoSplitMerge(class); /* no support for this (yet) */ class->size = sizeof(SNCSegStruct); class->init = sncSegInit; - AVERT(SegClass, class); } @@ -704,7 +702,7 @@ static Size SNCFreeSize(Pool pool) /* SNCPoolClass -- the class definition */ -DEFINE_POOL_CLASS(SNCPool, this) +DEFINE_CLASS(Pool, SNCPool, this) { INHERIT_CLASS(this, SNCPool, AbstractScanPool); PoolClassMixInFormat(this); @@ -722,7 +720,6 @@ DEFINE_POOL_CLASS(SNCPool, this) this->bufferClass = SNCBufClassGet; this->totalSize = SNCTotalSize; this->freeSize = SNCFreeSize; - AVERT(PoolClass, this); } diff --git a/mps/code/protocol.c b/mps/code/protocol.c index 580b4d2c792..bf4ac2233a6 100644 --- a/mps/code/protocol.c +++ b/mps/code/protocol.c @@ -53,7 +53,7 @@ Bool ProtocolIsSubclass(InstClass sub, InstClass super) /* The class definition for the root of the hierarchy */ -DEFINE_CLASS(Inst, theClass) +DEFINE_CLASS(Inst, Inst, theClass) { theClass->sig = InstClassSig; theClass->name = "Inst"; diff --git a/mps/code/protocol.h b/mps/code/protocol.h index 4c78dd69e4d..a1f012ef6c3 100644 --- a/mps/code/protocol.h +++ b/mps/code/protocol.h @@ -27,8 +27,7 @@ #define CLASS_STRUCT(ident) ident ## ClassStruct #define CLASS_ENSURE(ident) ident ## ClassGet #define CLASS_INIT(ident) ident ## ClassInit -#define CLASS_GUARDIAN(ident) ident ## ClassGuardian -#define CLASS_STATIC(ident) static ## ident ## ClassStruct +#define CLASS_CHECK(ident) ident ## ClassCheck /* DECLARE_CLASS -- declare the existence of a protocol class */ @@ -38,27 +37,27 @@ extern void CLASS_INIT(ident)(CLASS_TYPE(kind) var) -/* DEFINE_CLASS -- the standard macro for defining a InstClass */ +/* DEFINE_CLASS -- define a protocol class */ -#define DEFINE_CLASS(ident, var) \ - DECLARE_CLASS(ident, ident); \ - void CLASS_INIT(ident)(CLASS_TYPE(ident)); \ - CLASS_TYPE(ident) CLASS_ENSURE(ident)(void) \ +#define DEFINE_CLASS(kind, ident, var) \ + DECLARE_CLASS(kind, ident); \ + void CLASS_INIT(ident)(CLASS_TYPE(kind)); \ + CLASS_TYPE(kind) CLASS_ENSURE(ident)(void) \ { \ - static Bool CLASS_GUARDIAN(ident) = FALSE; \ - static CLASS_STRUCT(ident) CLASS_STATIC(ident); \ - if (CLASS_GUARDIAN(ident) == FALSE) { \ + static guardian = FALSE; \ + static CLASS_STRUCT(kind) classStruct; \ + if (guardian == FALSE) { \ LockClaimGlobalRecursive(); \ - if (CLASS_GUARDIAN(ident) == FALSE) { \ - CLASS_INIT(ident) \ - (&CLASS_STATIC(ident)); \ - CLASS_GUARDIAN(ident) = TRUE; \ + if (guardian == FALSE) { \ + CLASS_INIT(ident)(&classStruct); \ + AVER(CLASS_CHECK(kind)); \ + guardian = TRUE; \ } \ LockReleaseGlobalRecursive(); \ } \ - return &CLASS_STATIC(ident); \ + return &classStruct; \ } \ - void CLASS_INIT(ident)(CLASS_TYPE(ident) var) + void CLASS_INIT(ident)(CLASS_TYPE(kind) var) /* CLASS -- expression for getting a class */ @@ -79,28 +78,16 @@ typedef enum ProtocolClassIndexEnum { #define INHERIT_CLASS(this, _class, super) \ BEGIN \ - InstClass protocolClass = (InstClass)(this); \ + InstClass instClass = (InstClass)(this); \ CLASS_INIT(super)(this); \ - protocolClass->superclass = (InstClass)CLASS(super); \ - protocolClass->name = #_class; \ - protocolClass->typeId = \ + instClass->superclass = (InstClass)CLASS(super); \ + instClass->name = #_class; \ + instClass->typeId = \ ProtocolPrime[ProtocolClassIndex ## _class] * \ - protocolClass->superclass->typeId; \ + instClass->superclass->typeId; \ END -/* DEFINE_ALIAS_CLASS -- define a new class for the same type - * - * A convenience macro. Aliases the structure and pointer types - * for className to be the same as typeName, and then defines - * the class className. - */ -#define DEFINE_ALIAS_CLASS(ident, other, var) \ - typedef CLASS_TYPE(other) CLASS_TYPE(ident); \ - typedef CLASS_STRUCT(other) CLASS_STRUCT(ident); \ - DEFINE_CLASS(ident, var) - - #define InstClassSig ((Sig)0x519B60C7) /* SIGnature PROtocol CLass */ #define InstSig ((Sig)0x519B6014) /* SIGnature PROtocol INst */ diff --git a/mps/code/seg.c b/mps/code/seg.c index 088f4fc1a9a..11b2c2db3e9 100644 --- a/mps/code/seg.c +++ b/mps/code/seg.c @@ -1626,7 +1626,7 @@ Bool SegClassCheck(SegClass class) /* SegClass -- the vanilla segment class definition */ -DEFINE_CLASS(Seg, class) +DEFINE_CLASS(Seg, Seg, class) { INHERIT_CLASS(&class->protocol, Seg, Inst); class->size = sizeof(SegStruct); @@ -1651,7 +1651,7 @@ DEFINE_CLASS(Seg, class) typedef SegClassStruct GCSegClassStruct; -DEFINE_CLASS(GCSeg, class) +DEFINE_CLASS(Seg, GCSeg, class) { INHERIT_CLASS(class, GCSeg, Seg); class->size = sizeof(GCSegStruct); diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c index 0cd9561a17b..cf716ba9920 100644 --- a/mps/code/segsmss.c +++ b/mps/code/segsmss.c @@ -273,7 +273,7 @@ failSuper: /* AMSTSegClass -- Class definition for AMST segments */ -DEFINE_SEG_CLASS(AMSTSeg, class) +DEFINE_CLASS(Seg, AMSTSeg, class) { INHERIT_CLASS(class, AMSTSeg, AMSSeg); class->size = sizeof(AMSTSegStruct); @@ -662,14 +662,13 @@ static void AMSTStressBufferedSeg(Seg seg, Buffer buffer) /* AMSTPoolClass -- the pool class definition */ -DEFINE_POOL_CLASS(AMSTPool, this) +DEFINE_CLASS(Pool, AMSTPool, this) { INHERIT_CLASS(this, AMSTPool, AMSPool); this->size = sizeof(AMSTStruct); this->init = AMSTInit; this->finish = AMSTFinish; this->bufferFill = AMSTBufferFill; - AVERT(PoolClass, this); } diff --git a/mps/design/protocol.txt b/mps/design/protocol.txt index 5f91c97434e..f2103f12d58 100644 --- a/mps/design/protocol.txt +++ b/mps/design/protocol.txt @@ -148,23 +148,12 @@ methods and other fields from superclasses. _`.overview.naming`: There are some strict naming conventions which must be followed when defining and using classes. The use is obligatory because it is assumed by the macros which support the -definition and inheritance mechanism. For every class ``Foo``, +definition and inheritance mechanism. For every kind ``Foo``, we insist upon the following naming conventions:- -* ``FooClassStruct`` +* ``FooClass`` names the type that points to a ``FooClassStruct`` - names the type of the structure for the protocol class. This might - be a ``typedef`` which aliases the type to the type of the - superclass, but if the class has extended the protocols of the - superclass the it will be a type which contains the new class - fields. - -* ``FooClass`` - - names the type ``*SomeClassStruct``. This might be a ``typedef`` - which aliases the type to the type of the superclass, but if the - class has extended the protocols of the superclass then it will be - a type which contains the new class fields. +* ``FooClassStruct`` names the structure for the protocol class. Interface @@ -184,63 +173,35 @@ definition elsewhere. It is intended for use in headers. Class definition ................ -``DEFINE_CLASS(className, var)`` +``DEFINE_CLASS(kind, className, var)`` _`.int.define-class`: Class definition is performed by the macro ``DEFINE_CLASS()``. A call to the macro must be followed by a body of initialization code in braces ``{}``. The parameter ``className`` is used to name the class being defined. The parameter ``var`` is used to -name a local variable of type ``classNameClass``, which is defined by -the macro; it refers to the canonical storage for the class being -defined. This variable may be used in the initialization code. (The -macro doesn't just pick a name implicitly because of the danger of a -name clash with other names used by the programmer). A call to -``DEFINE_CLASS(SomeClass, var)`` defines the ensure function for the -class alond with some static storage for the canonical class object, -and some other things to ensure the class gets initialized exactly -once. - -``DEFINE_ALIAS_CLASS(className, typeName, var)`` - -_`.int.define-alias-class`: A convenience macro -``DEFINE_ALIAS_CLASS()`` is provided which both performs the class -definition and defines the types ``SomeClass`` and ``SomeClass -struct`` as aliases for some other class types. This is particularly -useful for classes which simply inherit, and don't extend protocols. -The macro call ``DEFINE_ALIAS_CLASS(className, superName, var)`` is -exactly equivalent to the following:: - - typedef superName className; - typedef superNameStruct classNameStruct; - DEFINE_CLASS(className, var) - -_`.int.define-special`: If classes are particularly likely to be -subclassed without extension, the class implementor may choose to -provide a convenience macro which expands into ``DEFINE_ALIAS_CLASS()`` -with an appropriate name for the superclass. For example, there might -be a macro for defining pool classes such that the macro call -``DEFINE_POOL_CLASS(className, var)`` is exactly equivalent to the -macro call ``DEFINE_ALIAS_CLASS(className, PoolClass, var)``. It may -also be convenient to define a static superclass accessor macro at the -same time (see `.int.static-superclass.special`_). +name a local variable of type ``kindClass``, which is defined by the +macro; it refers to the canonical storage for the class being defined. +This variable may be used in the initialization code. (The macro +doesn't just pick a name implicitly because of the danger of a name +clash with other names used by the programmer). A call to the macro +defines the ensure function for the class alond with some static +storage for the canonical class object, and some other things to +ensure the class gets initialized exactly once. Single inheritance .................. -``INHERIT_CLASS(thisClassCoerced, className, parentName)`` +``INHERIT_CLASS(this, className, parentName)`` _`.int.inheritance`: Class inheritance details must be provided in the class initialization code (see `.int.define-class`_). Inheritance is performed by the macro ``INHERIT_CLASS``. A call to this macro will make the class being defined a direct subclass of ``parentClassName`` -by ensuring that all the fields of the parent class are copied into -``thisClass``, and setting the superclass field of ``thisClass`` to be -the parent class object. The parameter ``thisClassCoerced`` must be of -type ``parentClassName``. If the class definition defines an alias -class (see `.int.define-alias-class`_), then the variable named as the -second parameter to ``DEFINE_CLASS()`` will be appropriate to pass to -``INHERIT_CLASS()``. +by ensuring that all the fields of the parent class are initialized by +the parent class, and setting the superclass field of ``this`` to be +the canonical parent class object. The parameter ``this`` must be the +the same kind as ``parentClassName``. Specialization @@ -269,11 +230,11 @@ Introspection _`.introspect.c-lang`: The design includes a number of introspection functions for dynamically examining class relationships. These functions are polymorphic and accept arbitrary subclasses of -``ProtocolClass``. C doesn't support such polymorphism. So although -these have the semantics of functions (and could be implemented as -functions in another language with compatible calling conventions) -they are actually implemented as macros. The macros are named as -method-style macros despite the fact that this arguably contravenes +``InstClass``. C doesn't support such polymorphism. So although these +have the semantics of functions (and could be implemented as functions +in another language with compatible calling conventions) they are +actually implemented as macros. The macros are named as method-style +macros despite the fact that this arguably contravenes guide.impl.c.macro.method. The justification for this is that this design is intended to promote the use of polymorphism, and it breaks the abstraction for the users to need to be aware of what can and @@ -353,25 +314,21 @@ Example _`.example.inheritance`: The following example class definition shows both inheritance and specialization. It shows the definition of the -class ``EPDRPoolClass``, which inherits from ``EPDLPoolClass`` and has -specialized values of the ``name``, ``init``, and ``alloc`` fields. -The type ``EPDLPoolClass`` is an alias for ``PoolClass``. :: +class ``EPDRPool``, which inherits from ``EPDLPool`` of kind ``Pool`` +and has specialized values of the ``name``, ``init``, and ``alloc`` +fields. :: - typedef EPDLPoolClass EPDRPoolClass; - typedef EPDLPoolClassStruct EPDRPoolClassStruct; - - DEFINE_CLASS(EPDRPoolClass, this) + DEFINE_CLASS(Pool, EPDRPool, this) { - INHERIT_CLASS(this, EPDLPoolClass); - this->name = "EPDR"; + INHERIT_CLASS(this, EPDRPool, EPDLPool); this->init = EPDRInit; this->alloc = EPDRAlloc; } _`.example.extension`: The following (hypothetical) example class definition shows inheritance, specialization and also extension. It -shows the definition of the class ``EPDLDebugPoolClass``, which -inherits from ``EPDLPoolClass``, but also implements a method for +shows the definition of the class ``EPDLDebugPool``, which inherits +from ``EPDLPool`` of kind ``Pool``, but also implements a method for checking properties of the pool. :: typedef struct EPDLDebugPoolClassStruct { @@ -382,11 +339,10 @@ checking properties of the pool. :: typedef EPDLDebugPoolClassStruct *EPDLDebugPoolClass; - DEFINE_CLASS(EPDLDebugPoolClass, this) + DEFINE_CLASS(EPDLDebugPool, EPDLDebugPool, this) { EPDLPoolClass epdl = &this->epdl; - INHERIT_CLASS(epdl, EPDLPoolClass); - epdl->name = "EPDLDBG"; + INHERIT_CLASS(epdl, EPDLDebugPool, EPDLPoolClass); this->check = EPDLDebugCheck; this->sig = EPDLDebugSig; } @@ -446,26 +402,20 @@ _`.impl.derived-names`: The ``DEFINE_CLASS()`` macro derives some additional names from the class name as part of it's implementation. These should not appear in the source code - but it may be useful to know about this for debugging purposes. For each class definition for -class ``SomeClass``, the macro defines the following: +class ``SomeClass`` of kind ``SomeKind``, the macro defines the +following: -* ``extern SomeClass EnsureSomeClass(void);`` +* ``extern SomeKind SomeClassGet(void);`` - The class accessor function. See `.overview.naming`_. + The class accessor function. See `.overview.naming`_. This function + contains local static storage and a guardian to ensure the storage + is initialized exactly once. -* ``static Bool protocolSomeClassGuardian;`` +* ``static void SomeClassInit(SomeKind);`` - A Boolean which indicates whether the class has been initialized - yet. - -* ``static void protocolEnsureSomeClass(SomeClass);`` - - A function called by ``EnsureSomeClass()``. All the class + A function called by ``SomeClassGet()``. All the class initialization code is actually in this function. -* ``static SomeClassStruct protocolSomeClassStruct;`` - - Static storage for the canonical class object. - _`.impl.init-once`: Class objects only behave according to their definition after they have been initialized, and class protocols may not be used before initialization has happened. The only code which is @@ -476,19 +426,19 @@ class has been initialized, the class might have a client. The class must not be initialized again when this has happened, because the state is not necessarily consistent in the middle of an initialization function. The initialization state for each class is stored in a -Boolean "guardian" variable whose name is derived from the class name -(see `.impl.derived-names`_). This ensures the initialization happens -only once. The path through the ``EnsureSomeClass()`` function should be -very fast for the common case when this variable is ``TRUE``, and the -class has already been initialized, as the canonical static storage -can simply be returned in that case. However, when the value of the -guardian is ``FALSE``, the class is not initialized. In this case, a -call to ``EnsureSomeClass()`` must first execute the initialization code -and then set the guardian to ``TRUE``. However, this must happen -atomically (see `.impl.init-lock`_). +Boolean "guardian" variable local to the accessor function. This +ensures the initialization happens only once. The path through the +``SomeClassGet`` function should be very fast for the common case when +this variable is ``TRUE``, and the class has already been initialized, +as the canonical static storage can simply be returned in that +case. However, when the value of the guardian is ``FALSE``, the class +is not initialized. In this case, a call to ``SomeClassGet`` must +first execute ``SomeClassInit`` and then set the guardian to +``TRUE``. However, this must happen atomically (see +`.impl.init-lock`_). _`.impl.init-lock`: There would be the possibility of a race condition -if ``EnsureSomeClass()`` were called concurrently on separate threads +if ``SomeClassGet`` were called concurrently on separate threads before ``SomeClass`` has been initialized. The class must not be initialized more than once, so the sequence test-guard, init-class, set-guard must be run as a critical region. It's not sufficient to use @@ -529,6 +479,8 @@ B. Document History - 2016-04-07 RB_ Removing never-used multiple inheritance speculation. +- 2016-04-08 RB_ Substantial reorgnisation. + .. _RB: http://www.ravenbrook.com/consultants/rb/ .. _GDR: http://www.ravenbrook.com/consultants/gdr/