aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/buffer.c
diff options
context:
space:
mode:
authorRichard Brooksby2012-09-07 12:58:57 +0100
committerRichard Brooksby2012-09-07 12:58:57 +0100
commit78d5f049f0e60bd0c903bc331c253f681d082cea (patch)
tree2313698d481513796220f50377bdd911fff16bad /mps/code/buffer.c
parente17fee98ea221678f40bae915dd32c91ccc71922 (diff)
downloademacs-78d5f049f0e60bd0c903bc331c253f681d082cea.tar.gz
emacs-78d5f049f0e60bd0c903bc331c253f681d082cea.zip
Eliminating type puns on scan states, location dependencies, and allocation points through the mps interface.
Now that we're recommending inlining with client code and optimising with -O2 or -O3, we can't afford any bug introduced by the strict aliasing rule. Copied from Perforce Change: 179322 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/buffer.c')
-rw-r--r--mps/code/buffer.c172
1 files changed, 88 insertions, 84 deletions
diff --git a/mps/code/buffer.c b/mps/code/buffer.c
index f446ab5b9a0..b33c08dc239 100644
--- a/mps/code/buffer.c
+++ b/mps/code/buffer.c
@@ -51,14 +51,14 @@ Bool BufferCheck(Buffer buffer)
51 CHECKL(buffer->emptySize <= buffer->fillSize); 51 CHECKL(buffer->emptySize <= buffer->fillSize);
52 CHECKL(buffer->alignment == buffer->pool->alignment); 52 CHECKL(buffer->alignment == buffer->pool->alignment);
53 CHECKL(AlignCheck(buffer->alignment)); 53 CHECKL(AlignCheck(buffer->alignment));
54 CHECKL(BoolCheck(buffer->apStruct.enabled)); 54 CHECKL(BoolCheck(buffer->ap_s._enabled));
55 55
56 if (buffer->apStruct.enabled) { 56 if (buffer->ap_s._enabled) {
57 /* no useful check for frameptr - mutator may be updating it */ 57 /* no useful check for frameptr - mutator may be updating it */
58 CHECKL(BoolCheck(buffer->apStruct.lwPopPending)); 58 CHECKL(BoolCheck(buffer->ap_s._lwpoppending));
59 } else { 59 } else {
60 CHECKL(buffer->apStruct.lwPopPending == FALSE); 60 CHECKL(buffer->ap_s._lwpoppending == FALSE);
61 CHECKL(buffer->apStruct.frameptr == NULL); 61 CHECKL(buffer->ap_s._frameptr == NULL);
62 } 62 }
63 63
64 /* If any of the buffer's fields indicate that it is reset, make */ 64 /* If any of the buffer's fields indicate that it is reset, make */
@@ -68,15 +68,15 @@ Bool BufferCheck(Buffer buffer)
68 /* nothing to check */ 68 /* nothing to check */
69 } else if ((buffer->mode & BufferModeATTACHED) == 0 69 } else if ((buffer->mode & BufferModeATTACHED) == 0
70 || buffer->base == (Addr)0 70 || buffer->base == (Addr)0
71 || buffer->apStruct.init == (Addr)0 71 || buffer->ap_s.init == (Addr)0
72 || buffer->apStruct.alloc == (Addr)0 72 || buffer->ap_s.alloc == (Addr)0
73 || buffer->poolLimit == (Addr)0) { 73 || buffer->poolLimit == (Addr)0) {
74 CHECKL((buffer->mode & BufferModeATTACHED) == 0); 74 CHECKL((buffer->mode & BufferModeATTACHED) == 0);
75 CHECKL(buffer->base == (Addr)0); 75 CHECKL(buffer->base == (Addr)0);
76 CHECKL(buffer->initAtFlip == (Addr)0); 76 CHECKL(buffer->initAtFlip == (Addr)0);
77 CHECKL(buffer->apStruct.init == (Addr)0); 77 CHECKL(buffer->ap_s.init == (Addr)0);
78 CHECKL(buffer->apStruct.alloc == (Addr)0); 78 CHECKL(buffer->ap_s.alloc == (Addr)0);
79 CHECKL(buffer->apStruct.limit == (Addr)0); 79 CHECKL(buffer->ap_s.limit == (Addr)0);
80 /* Nothing reliable to check for lightweight frame state */ 80 /* Nothing reliable to check for lightweight frame state */
81 CHECKL(buffer->poolLimit == (Addr)0); 81 CHECKL(buffer->poolLimit == (Addr)0);
82 } else { 82 } else {
@@ -88,16 +88,16 @@ Bool BufferCheck(Buffer buffer)
88 88
89 /* These fields should obey the ordering */ 89 /* These fields should obey the ordering */
90 /* base <= init <= alloc <= poolLimit */ 90 /* base <= init <= alloc <= poolLimit */
91 CHECKL(buffer->base <= buffer->apStruct.init); 91 CHECKL((mps_addr_t)buffer->base <= buffer->ap_s.init);
92 CHECKL(buffer->apStruct.init <= buffer->apStruct.alloc); 92 CHECKL(buffer->ap_s.init <= buffer->ap_s.alloc);
93 CHECKL(buffer->apStruct.alloc <= buffer->poolLimit); 93 CHECKL(buffer->ap_s.alloc <= (mps_addr_t)buffer->poolLimit);
94 94
95 /* Check that the fields are aligned to the buffer alignment. */ 95 /* Check that the fields are aligned to the buffer alignment. */
96 CHECKL(AddrIsAligned(buffer->base, buffer->alignment)); 96 CHECKL(AddrIsAligned(buffer->base, buffer->alignment));
97 CHECKL(AddrIsAligned(buffer->initAtFlip, buffer->alignment)); 97 CHECKL(AddrIsAligned(buffer->initAtFlip, buffer->alignment));
98 CHECKL(AddrIsAligned(buffer->apStruct.init, buffer->alignment)); 98 CHECKL(AddrIsAligned(buffer->ap_s.init, buffer->alignment));
99 CHECKL(AddrIsAligned(buffer->apStruct.alloc, buffer->alignment)); 99 CHECKL(AddrIsAligned(buffer->ap_s.alloc, buffer->alignment));
100 CHECKL(AddrIsAligned(buffer->apStruct.limit, buffer->alignment)); 100 CHECKL(AddrIsAligned(buffer->ap_s.limit, buffer->alignment));
101 CHECKL(AddrIsAligned(buffer->poolLimit, buffer->alignment)); 101 CHECKL(AddrIsAligned(buffer->poolLimit, buffer->alignment));
102 102
103 /* .lwcheck: If LW frames are enabled, the buffer may become */ 103 /* .lwcheck: If LW frames are enabled, the buffer may become */
@@ -106,7 +106,7 @@ Bool BufferCheck(Buffer buffer)
106 /* Read a snapshot value of the limit field. Use this to determine */ 106 /* Read a snapshot value of the limit field. Use this to determine */
107 /* if we are trapped, and to permit more useful checking when not */ 107 /* if we are trapped, and to permit more useful checking when not */
108 /* yet trapped. */ 108 /* yet trapped. */
109 aplimit = buffer->apStruct.limit; 109 aplimit = buffer->ap_s.limit;
110 110
111 /* If the buffer isn't trapped then "limit" should be the limit */ 111 /* If the buffer isn't trapped then "limit" should be the limit */
112 /* set by the owning pool. Otherwise, "init" is either at the */ 112 /* set by the owning pool. Otherwise, "init" is either at the */
@@ -117,17 +117,17 @@ Bool BufferCheck(Buffer buffer)
117 /* is kept at zero to avoid misuse (see */ 117 /* is kept at zero to avoid misuse (see */
118 /* request.dylan.170429.sol.zero). */ 118 /* request.dylan.170429.sol.zero). */
119 119
120 if ((buffer->apStruct.enabled && aplimit == (Addr)0) /* see .lwcheck */ 120 if ((buffer->ap_s._enabled && aplimit == (Addr)0) /* see .lwcheck */
121 || (!buffer->apStruct.enabled && BufferIsTrapped(buffer))) { 121 || (!buffer->ap_s._enabled && BufferIsTrapped(buffer))) {
122 /* .check.use-trapped: This checking function uses BufferIsTrapped, */ 122 /* .check.use-trapped: This checking function uses BufferIsTrapped, */
123 /* So BufferIsTrapped can't do checking as that would cause an */ 123 /* So BufferIsTrapped can't do checking as that would cause an */
124 /* infinite loop. */ 124 /* infinite loop. */
125 CHECKL(aplimit == (Addr)0); 125 CHECKL(aplimit == (Addr)0);
126 if (buffer->mode & BufferModeFLIPPED) { 126 if (buffer->mode & BufferModeFLIPPED) {
127 CHECKL(buffer->apStruct.init == buffer->initAtFlip 127 CHECKL(buffer->ap_s.init == buffer->initAtFlip
128 || buffer->apStruct.init == buffer->apStruct.alloc); 128 || buffer->ap_s.init == buffer->ap_s.alloc);
129 CHECKL(buffer->base <= buffer->initAtFlip); 129 CHECKL(buffer->base <= buffer->initAtFlip);
130 CHECKL(buffer->initAtFlip <= buffer->apStruct.init); 130 CHECKL(buffer->initAtFlip <= (Addr)buffer->ap_s.init);
131 } 131 }
132 /* Nothing special to check in the logged mode. */ 132 /* Nothing special to check in the logged mode. */
133 } else { 133 } else {
@@ -174,9 +174,9 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream)
174 " alignment $W\n", (WriteFW)buffer->alignment, 174 " alignment $W\n", (WriteFW)buffer->alignment,
175 " base $A\n", buffer->base, 175 " base $A\n", buffer->base,
176 " initAtFlip $A\n", buffer->initAtFlip, 176 " initAtFlip $A\n", buffer->initAtFlip,
177 " init $A\n", buffer->apStruct.init, 177 " init $A\n", buffer->ap_s.init,
178 " alloc $A\n", buffer->apStruct.alloc, 178 " alloc $A\n", buffer->ap_s.alloc,
179 " limit $A\n", buffer->apStruct.limit, 179 " limit $A\n", buffer->ap_s.limit,
180 " poolLimit $A\n", buffer->poolLimit, 180 " poolLimit $A\n", buffer->poolLimit,
181 NULL); 181 NULL);
182 if (res != ResOK) return res; 182 if (res != ResOK) return res;
@@ -223,12 +223,15 @@ static Res BufferInitV(Buffer buffer, BufferClass class,
223 buffer->alignment = pool->alignment; /* .trans.mod */ 223 buffer->alignment = pool->alignment; /* .trans.mod */
224 buffer->base = (Addr)0; 224 buffer->base = (Addr)0;
225 buffer->initAtFlip = (Addr)0; 225 buffer->initAtFlip = (Addr)0;
226 buffer->apStruct.init = (Addr)0; 226 /* In the next three assignements we really mean zero, not NULL, because
227 buffer->apStruct.alloc = (Addr)0; 227 the bit pattern is compared. It's pretty unlikely we'll encounter
228 buffer->apStruct.limit = (Addr)0; 228 a platform where this makes a difference. */
229 buffer->apStruct.frameptr = NULL; 229 buffer->ap_s.init = (mps_addr_t)0;
230 buffer->apStruct.enabled = FALSE; 230 buffer->ap_s.alloc = (mps_addr_t)0;
231 buffer->apStruct.lwPopPending = FALSE; 231 buffer->ap_s.limit = (mps_addr_t)0;
232 buffer->ap_s._frameptr = NULL;
233 buffer->ap_s._enabled = FALSE;
234 buffer->ap_s._lwpoppending = FALSE;
232 buffer->poolLimit = (Addr)0; 235 buffer->poolLimit = (Addr)0;
233 buffer->rampCount = 0; 236 buffer->rampCount = 0;
234 237
@@ -327,7 +330,7 @@ void BufferDetach(Buffer buffer, Pool pool)
327 Size spare; 330 Size spare;
328 331
329 buffer->mode |= BufferModeTRANSITION; 332 buffer->mode |= BufferModeTRANSITION;
330 init = buffer->apStruct.init; 333 init = buffer->ap_s.init;
331 limit = buffer->poolLimit; 334 limit = buffer->poolLimit;
332 /* Ask the owning pool to do whatever it needs to before the */ 335 /* Ask the owning pool to do whatever it needs to before the */
333 /* buffer is detached (e.g. copy buffer state into pool state). */ 336 /* buffer is detached (e.g. copy buffer state into pool state). */
@@ -353,9 +356,9 @@ void BufferDetach(Buffer buffer, Pool pool)
353 /* Reset the buffer. */ 356 /* Reset the buffer. */
354 buffer->base = (Addr)0; 357 buffer->base = (Addr)0;
355 buffer->initAtFlip = (Addr)0; 358 buffer->initAtFlip = (Addr)0;
356 buffer->apStruct.init = (Addr)0; 359 buffer->ap_s.init = (mps_addr_t)0;
357 buffer->apStruct.alloc = (Addr)0; 360 buffer->ap_s.alloc = (mps_addr_t)0;
358 buffer->apStruct.limit = (Addr)0; 361 buffer->ap_s.limit = (mps_addr_t)0;
359 buffer->poolLimit = (Addr)0; 362 buffer->poolLimit = (Addr)0;
360 buffer->mode &= 363 buffer->mode &=
361 ~(BufferModeATTACHED|BufferModeFLIPPED|BufferModeTRANSITION); 364 ~(BufferModeATTACHED|BufferModeFLIPPED|BufferModeTRANSITION);
@@ -445,7 +448,7 @@ Bool BufferIsReady(Buffer buffer)
445{ 448{
446 AVERT(Buffer, buffer); 449 AVERT(Buffer, buffer);
447 450
448 return buffer->apStruct.init == buffer->apStruct.alloc; 451 return buffer->ap_s.init == buffer->ap_s.alloc;
449} 452}
450 453
451 454
@@ -470,9 +473,9 @@ static void BufferSetUnflipped(Buffer buffer)
470 AVERT(Buffer, buffer); 473 AVERT(Buffer, buffer);
471 AVER(buffer->mode & BufferModeFLIPPED); 474 AVER(buffer->mode & BufferModeFLIPPED);
472 buffer->mode &= ~BufferModeFLIPPED; 475 buffer->mode &= ~BufferModeFLIPPED;
473 /* restore apStruct.limit if appropriate */ 476 /* restore ap_s.limit if appropriate */
474 if (!BufferIsTrapped(buffer)) { 477 if (!BufferIsTrapped(buffer)) {
475 buffer->apStruct.limit = buffer->poolLimit; 478 buffer->ap_s.limit = buffer->poolLimit;
476 } 479 }
477 buffer->initAtFlip = (Addr)0; 480 buffer->initAtFlip = (Addr)0;
478} 481}
@@ -486,16 +489,16 @@ static void BufferSetUnflipped(Buffer buffer)
486FrameState BufferFrameState(Buffer buffer) 489FrameState BufferFrameState(Buffer buffer)
487{ 490{
488 AVERT(Buffer, buffer); 491 AVERT(Buffer, buffer);
489 if (buffer->apStruct.enabled) { 492 if (buffer->ap_s._enabled) {
490 if (buffer->apStruct.lwPopPending) { 493 if (buffer->ap_s._lwpoppending) {
491 return BufferFramePOP_PENDING; 494 return BufferFramePOP_PENDING;
492 } else { 495 } else {
493 AVER(buffer->apStruct.frameptr == NULL); 496 AVER(buffer->ap_s._frameptr == NULL);
494 return BufferFrameVALID; 497 return BufferFrameVALID;
495 } 498 }
496 } else { 499 } else {
497 AVER(buffer->apStruct.frameptr == NULL); 500 AVER(buffer->ap_s._frameptr == NULL);
498 AVER(buffer->apStruct.lwPopPending == FALSE); 501 AVER(buffer->ap_s._lwpoppending == FALSE);
499 return BufferFrameDISABLED; 502 return BufferFrameDISABLED;
500 } 503 }
501} 504}
@@ -510,9 +513,9 @@ void BufferFrameSetState(Buffer buffer, FrameState state)
510{ 513{
511 AVERT(Buffer, buffer); 514 AVERT(Buffer, buffer);
512 AVER(state == BufferFrameVALID || state == BufferFrameDISABLED); 515 AVER(state == BufferFrameVALID || state == BufferFrameDISABLED);
513 buffer->apStruct.frameptr = NULL; 516 buffer->ap_s._frameptr = NULL;
514 buffer->apStruct.lwPopPending = FALSE; 517 buffer->ap_s._lwpoppending = FALSE;
515 buffer->apStruct.enabled = (state == BufferFrameVALID); 518 buffer->ap_s._enabled = (state == BufferFrameVALID);
516} 519}
517 520
518 521
@@ -528,8 +531,8 @@ void BufferSetAllocAddr(Buffer buffer, Addr addr)
528 AVER(buffer->base <= addr); 531 AVER(buffer->base <= addr);
529 AVER(buffer->poolLimit >= addr); 532 AVER(buffer->poolLimit >= addr);
530 533
531 buffer->apStruct.init = addr; 534 buffer->ap_s.init = addr;
532 buffer->apStruct.alloc = addr; 535 buffer->ap_s.alloc = addr;
533} 536}
534 537
535 538
@@ -545,13 +548,13 @@ static void BufferFrameNotifyPopPending(Buffer buffer)
545 Pool pool; 548 Pool pool;
546 AVER(BufferIsTrappedByMutator(buffer)); 549 AVER(BufferIsTrappedByMutator(buffer));
547 AVER(BufferFrameState(buffer) == BufferFramePOP_PENDING); 550 AVER(BufferFrameState(buffer) == BufferFramePOP_PENDING);
548 frame = (AllocFrame)buffer->apStruct.frameptr; 551 frame = (AllocFrame)buffer->ap_s._frameptr;
549 /* Unset PopPending state & notify the pool */ 552 /* Unset PopPending state & notify the pool */
550 BufferFrameSetState(buffer, BufferFrameVALID); 553 BufferFrameSetState(buffer, BufferFrameVALID);
551 /* If the frame is no longer trapped, undo the trap by resetting */ 554 /* If the frame is no longer trapped, undo the trap by resetting */
552 /* the AP limit pointer */ 555 /* the AP limit pointer */
553 if (!BufferIsTrapped(buffer)) { 556 if (!BufferIsTrapped(buffer)) {
554 buffer->apStruct.limit = buffer->poolLimit; 557 buffer->ap_s.limit = buffer->poolLimit;
555 } 558 }
556 pool = BufferPool(buffer); 559 pool = BufferPool(buffer);
557 (*pool->class->framePopPending)(pool, buffer, frame); 560 (*pool->class->framePopPending)(pool, buffer, frame);
@@ -571,7 +574,7 @@ Res BufferFramePush(AllocFrame *frameReturn, Buffer buffer)
571 574
572 575
573 /* Process any flip or PopPending */ 576 /* Process any flip or PopPending */
574 if (!BufferIsReset(buffer) && buffer->apStruct.limit == (Addr)0) { 577 if (!BufferIsReset(buffer) && buffer->ap_s.limit == (Addr)0) {
575 /* .fill.unflip: If the buffer is flipped then we unflip the buffer. */ 578 /* .fill.unflip: If the buffer is flipped then we unflip the buffer. */
576 if (buffer->mode & BufferModeFLIPPED) { 579 if (buffer->mode & BufferModeFLIPPED) {
577 BufferSetUnflipped(buffer); 580 BufferSetUnflipped(buffer);
@@ -622,10 +625,11 @@ Res BufferReserve(Addr *pReturn, Buffer buffer, Size size,
622 /* Is there enough room in the unallocated portion of the buffer to */ 625 /* Is there enough room in the unallocated portion of the buffer to */
623 /* satisfy the request? If so, just increase the alloc marker and */ 626 /* satisfy the request? If so, just increase the alloc marker and */
624 /* return a pointer to the area below it. */ 627 /* return a pointer to the area below it. */
625 next = AddrAdd(buffer->apStruct.alloc, size); 628 next = AddrAdd(buffer->ap_s.alloc, size);
626 if (next > buffer->apStruct.alloc && next <= buffer->apStruct.limit) { 629 if (next > (Addr)buffer->ap_s.alloc &&
627 buffer->apStruct.alloc = next; 630 next <= (Addr)buffer->ap_s.limit) {
628 *pReturn = buffer->apStruct.init; 631 buffer->ap_s.alloc = next;
632 *pReturn = buffer->ap_s.init;
629 return ResOK; 633 return ResOK;
630 } 634 }
631 635
@@ -653,13 +657,13 @@ void BufferAttach(Buffer buffer, Addr base, Addr limit,
653 /* Set up the buffer to point at the supplied region */ 657 /* Set up the buffer to point at the supplied region */
654 buffer->mode |= BufferModeATTACHED; 658 buffer->mode |= BufferModeATTACHED;
655 buffer->base = base; 659 buffer->base = base;
656 buffer->apStruct.init = init; 660 buffer->ap_s.init = init;
657 buffer->apStruct.alloc = AddrAdd(init, size); 661 buffer->ap_s.alloc = AddrAdd(init, size);
658 /* only set limit if not logged */ 662 /* only set limit if not logged */
659 if ((buffer->mode & BufferModeLOGGED) == 0) { 663 if ((buffer->mode & BufferModeLOGGED) == 0) {
660 buffer->apStruct.limit = limit; 664 buffer->ap_s.limit = limit;
661 } else { 665 } else {
662 AVER(buffer->apStruct.limit == (Addr)0); 666 AVER(buffer->ap_s.limit == (Addr)0);
663 } 667 }
664 AVER(buffer->initAtFlip == (Addr)0); 668 AVER(buffer->initAtFlip == (Addr)0);
665 buffer->poolLimit = limit; 669 buffer->poolLimit = limit;
@@ -710,7 +714,7 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
710 714
711 /* If we're here because the buffer was trapped, then we attempt */ 715 /* If we're here because the buffer was trapped, then we attempt */
712 /* the allocation here. */ 716 /* the allocation here. */
713 if (!BufferIsReset(buffer) && buffer->apStruct.limit == (Addr)0) { 717 if (!BufferIsReset(buffer) && buffer->ap_s.limit == (Addr)0) {
714 /* .fill.unflip: If the buffer is flipped then we unflip the buffer. */ 718 /* .fill.unflip: If the buffer is flipped then we unflip the buffer. */
715 if (buffer->mode & BufferModeFLIPPED) { 719 if (buffer->mode & BufferModeFLIPPED) {
716 BufferSetUnflipped(buffer); 720 BufferSetUnflipped(buffer);
@@ -722,21 +726,21 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
722 } 726 }
723 727
724 /* .fill.logged: If the buffer is logged then we leave it logged. */ 728 /* .fill.logged: If the buffer is logged then we leave it logged. */
725 next = AddrAdd(buffer->apStruct.alloc, size); 729 next = AddrAdd(buffer->ap_s.alloc, size);
726 if (next > buffer->apStruct.alloc && 730 if (next > (Addr)buffer->ap_s.alloc &&
727 next <= buffer->poolLimit) { 731 next <= (Addr)buffer->poolLimit) {
728 buffer->apStruct.alloc = next; 732 buffer->ap_s.alloc = next;
729 if (buffer->mode & BufferModeLOGGED) { 733 if (buffer->mode & BufferModeLOGGED) {
730 EVENT3(BufferReserve, buffer, buffer->apStruct.init, size); 734 EVENT3(BufferReserve, buffer, buffer->ap_s.init, size);
731 } 735 }
732 *pReturn = buffer->apStruct.init; 736 *pReturn = buffer->ap_s.init;
733 return ResOK; 737 return ResOK;
734 } 738 }
735 } 739 }
736 740
737 /* There really isn't enough room for the allocation now. */ 741 /* There really isn't enough room for the allocation now. */
738 AVER(AddrAdd(buffer->apStruct.alloc, size) > buffer->poolLimit 742 AVER(AddrAdd(buffer->ap_s.alloc, size) > buffer->poolLimit ||
739 || AddrAdd(buffer->apStruct.alloc, size) < buffer->apStruct.alloc); 743 AddrAdd(buffer->ap_s.alloc, size) < (Addr)buffer->ap_s.alloc);
740 744
741 BufferDetach(buffer, pool); 745 BufferDetach(buffer, pool);
742 746
@@ -752,7 +756,7 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
752 BufferAttach(buffer, base, limit, base, size); 756 BufferAttach(buffer, base, limit, base, size);
753 757
754 if (buffer->mode & BufferModeLOGGED) { 758 if (buffer->mode & BufferModeLOGGED) {
755 EVENT3(BufferReserve, buffer, buffer->apStruct.init, size); 759 EVENT3(BufferReserve, buffer, buffer->ap_s.init, size);
756 } 760 }
757 761
758 *pReturn = base; 762 *pReturn = base;
@@ -776,13 +780,13 @@ Bool BufferCommit(Buffer buffer, Addr p, Size size)
776 /* .commit.before: If a flip occurs before this point, when the */ 780 /* .commit.before: If a flip occurs before this point, when the */
777 /* pool reads "initAtFlip" it will point below the object, so it */ 781 /* pool reads "initAtFlip" it will point below the object, so it */
778 /* will be trashed and the commit must fail when trip is called. */ 782 /* will be trashed and the commit must fail when trip is called. */
779 AVER(p == buffer->apStruct.init); 783 AVER(p == buffer->ap_s.init);
780 AVER(AddrAdd(buffer->apStruct.init, size) == buffer->apStruct.alloc); 784 AVER(AddrAdd(buffer->ap_s.init, size) == buffer->ap_s.alloc);
781 785
782 /* .commit.update: Atomically update the init pointer to declare */ 786 /* .commit.update: Atomically update the init pointer to declare */
783 /* that the object is initialized (though it may be invalid if a */ 787 /* that the object is initialized (though it may be invalid if a */
784 /* flip occurred). */ 788 /* flip occurred). */
785 buffer->apStruct.init = buffer->apStruct.alloc; 789 buffer->ap_s.init = buffer->ap_s.alloc;
786 790
787 /* .improve.memory-barrier: Memory barrier here on the DEC Alpha */ 791 /* .improve.memory-barrier: Memory barrier here on the DEC Alpha */
788 /* (and other relaxed memory order architectures). */ 792 /* (and other relaxed memory order architectures). */
@@ -791,7 +795,7 @@ Bool BufferCommit(Buffer buffer, Addr p, Size size)
791 /* be collected. The commit must succeed when trip is called. */ 795 /* be collected. The commit must succeed when trip is called. */
792 /* The pointer "p" will have been fixed up. (@@@@ Will it?) */ 796 /* The pointer "p" will have been fixed up. (@@@@ Will it?) */
793 /* .commit.trip: Trip the buffer if a flip has occurred. */ 797 /* .commit.trip: Trip the buffer if a flip has occurred. */
794 if (buffer->apStruct.limit == 0) 798 if (buffer->ap_s.limit == 0)
795 return BufferTrip(buffer, p, size); 799 return BufferTrip(buffer, p, size);
796 800
797 /* No flip occurred, so succeed. */ 801 /* No flip occurred, so succeed. */
@@ -817,7 +821,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
817 821
818 /* The limit field should be zero, because that's how trip gets */ 822 /* The limit field should be zero, because that's how trip gets */
819 /* called. See .commit.trip. */ 823 /* called. See .commit.trip. */
820 AVER(buffer->apStruct.limit == 0); 824 AVER(buffer->ap_s.limit == 0);
821 /* Of course we should be trapped. */ 825 /* Of course we should be trapped. */
822 AVER(BufferIsTrapped(buffer)); 826 AVER(BufferIsTrapped(buffer));
823 /* But the mutator shouldn't have caused the trap */ 827 /* But the mutator shouldn't have caused the trap */
@@ -825,7 +829,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
825 829
826 /* The init and alloc fields should be equal at this point, because */ 830 /* The init and alloc fields should be equal at this point, because */
827 /* the step .commit.update has happened. */ 831 /* the step .commit.update has happened. */
828 AVER(buffer->apStruct.init == buffer->apStruct.alloc); 832 AVER(buffer->ap_s.init == buffer->ap_s.alloc);
829 833
830 /* The p parameter points at the base address of the allocated */ 834 /* The p parameter points at the base address of the allocated */
831 /* block, the end of which should now coincide with the init and */ 835 /* block, the end of which should now coincide with the init and */
@@ -835,7 +839,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
835 /* it seems like the algorithms could be modified to cope with the */ 839 /* it seems like the algorithms could be modified to cope with the */
836 /* case of the object having been copied between Commit updating i */ 840 /* case of the object having been copied between Commit updating i */
837 /* and testing limit) */ 841 /* and testing limit) */
838 AVER(AddrAdd(p, size) == buffer->apStruct.init); 842 AVER(AddrAdd(p, size) == buffer->ap_s.init);
839 843
840 pool = BufferPool(buffer); 844 pool = BufferPool(buffer);
841 845
@@ -847,13 +851,13 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
847 /* Otherwise (see .commit.after) the object is valid (will've been */ 851 /* Otherwise (see .commit.after) the object is valid (will've been */
848 /* scanned) so commit can simply succeed. */ 852 /* scanned) so commit can simply succeed. */
849 if ((buffer->mode & BufferModeFLIPPED) 853 if ((buffer->mode & BufferModeFLIPPED)
850 && buffer->apStruct.init != buffer->initAtFlip) { 854 && buffer->ap_s.init != buffer->initAtFlip) {
851 /* Reset just enough state for Reserve/Fill to work. */ 855 /* Reset just enough state for Reserve/Fill to work. */
852 /* The buffer is left trapped and we leave the untrapping */ 856 /* The buffer is left trapped and we leave the untrapping */
853 /* for the next reserve (which goes out of line to Fill */ 857 /* for the next reserve (which goes out of line to Fill */
854 /* (.fill.unflip) because the buffer is still trapped) */ 858 /* (.fill.unflip) because the buffer is still trapped) */
855 buffer->apStruct.init = p; 859 buffer->ap_s.init = p;
856 buffer->apStruct.alloc = p; 860 buffer->ap_s.alloc = p;
857 return FALSE; 861 return FALSE;
858 } 862 }
859 863
@@ -901,9 +905,9 @@ void BufferFlip(Buffer buffer)
901 && (buffer->mode & BufferModeFLIPPED) == 0 905 && (buffer->mode & BufferModeFLIPPED) == 0
902 && !BufferIsReset(buffer)) { 906 && !BufferIsReset(buffer)) {
903 AVER(buffer->initAtFlip == (Addr)0); 907 AVER(buffer->initAtFlip == (Addr)0);
904 buffer->initAtFlip = buffer->apStruct.init; 908 buffer->initAtFlip = buffer->ap_s.init;
905 /* Memory Barrier here? @@@@ */ 909 /* Memory Barrier here? @@@@ */
906 buffer->apStruct.limit = (Addr)0; 910 buffer->ap_s.limit = (Addr)0;
907 buffer->mode |= BufferModeFLIPPED; 911 buffer->mode |= BufferModeFLIPPED;
908 } 912 }
909} 913}
@@ -922,7 +926,7 @@ Addr BufferScanLimit(Buffer buffer)
922 if (buffer->mode & BufferModeFLIPPED) { 926 if (buffer->mode & BufferModeFLIPPED) {
923 return buffer->initAtFlip; 927 return buffer->initAtFlip;
924 } else { 928 } else {
925 return buffer->apStruct.init; 929 return buffer->ap_s.init;
926 } 930 }
927} 931}
928 932
@@ -984,9 +988,9 @@ Bool BufferIsTrapped(Buffer buffer)
984 988
985Bool BufferIsTrappedByMutator(Buffer buffer) 989Bool BufferIsTrappedByMutator(Buffer buffer)
986{ 990{
987 AVER(!buffer->apStruct.lwPopPending || buffer->apStruct.enabled); 991 AVER(!buffer->ap_s._lwpoppending || buffer->ap_s._enabled);
988 /* Can't check buffer, see .check.use-trapped */ 992 /* Can't check buffer, see .check.use-trapped */
989 return buffer->apStruct.lwPopPending; 993 return buffer->ap_s._lwpoppending;
990} 994}
991 995
992 996