An InStack Array occupies 1 Stack Cell for the Untouched_DD MOM Descriptor, 2 Stack Cells for MCP Memory Links and then the number of Stack Cells given by the Array Size.
0066 (03,0038) 3 000000 000000 In-stack array marker (Array appears below) 0065 (03,0037) 0 000000 000000 0064 (03,0036) 0 000000 000000 0063 (03,0035) 0 000000 000000 0062 (03,0034) 0 000000 000000 0061 (03,0033) 0 000000 000000 0060 (03,0032) 0 000000 000000 005F (03,0031) 0 000000 000000 005E (03,0030) 0 000000 000000 005D (03,002F) 0 000000 000000 005C (03,002E) 0 000000 000000 005B (03,002D) 0 000000 000000 005A (03,002C) 0 000000 000000 0059 (03,002B) 0 000000 000000 0058 (03,002A) 0 000000 000000 0057 (03,0029) 0 000000 000000 0056 (03,0028) C 700000 101DB5 Desc: Present-copy, ASD=00EDAB, Length=15, In-stack array (Points @ offset 0057 in this stack, Mom @ 0055) 0055 (03,0027) C 600000 001DB5 Desc: Present-mom, ASD=00EDAB, Length=15, In-stack array (Contents @ offset 0057 in this stack)
An InStack Array is created by allocating a Stack Cell for the Untouched_DD MOM Descriptor, and Stack Cells for the Link Words and the Array Elements, and then calling the MCP InStackArrayDec function.
The Size in Words of the Array Elements is calculated from the Element Size.
TOTAL_BITS:=LENGTHOF(COPYOFMOM)*BITSPERSZ(COPYOFMOM.UNTOUCHEDSZF); LENGTH_IN_WORDS:= BITSTOWORDS(TOTAL_BITS);
This is the format of an Untouched Data Descriptor used for an InStack Array.
Tag 5 - UnTouched DataDesc | ||
---|---|---|
Field | Name | Description |
[47:2] | UntouchedTCBitsF | 0 |
[43:1] | UntouchedRBitF | ReadOnly Flag. |
[42:3] | UntouchedSzF | The size of the elements of the Array with (BitsPerSZ) SINGLE = 0 (48) DOUBLE = 1 (96) HEX = 2 (4) EBCDIC = 4 (8) |
[139:20] | LengthF | Number of Elements. |
If an InStack Array is declared in a Block, then BlockExit should be called and the SDTogF field of the Software Control Word should be set to ensure the array is deallocated.
The MCP makes a special case of deallocation of InStack Arrays, in the case where no SCW exists within an activation record. This allows InStack Arrays to be constructed in Stack Building Code, and be properly cleaned up in case of a fault or other event which interrupts the Stack Building code before the SCW has been created.
In InStackArrayDec at 5039710,
BEFORE WE GO AWAY, WE MUST FIRST SET THE RCW_BLOCKEXITF BIT IN THE MOM'S ENVIRONMENT. THIS GAURANTEES THAT BLOCKEXIT WILL BE CALLED IF THE STACK IS DSED BEFORE AN SCW IS LAID DOWN BY THE COMPILER. THIS IS DONE ONLY IF IT IS NOT IN MCPSTACK.
IF STKNO NEQ MCPSTACK THEN SET_AR_BLOCKEXIT_BIT(REF_TO_MOTHER);
In Flag_Search of BlockCleanup at 24529040,
IF SAVE_TAR LSS 0 THEN BEGIN
Either the compiler didn't generate an SCW or the stack was DSED in the middle of stack building code. We'll assume that there are arrays in the block and continue. Note: Pascal does not generate an SCW or BLOCKEXIT call for instack arrays if no other arrays were declared.
Since cleanup of InStack Arrays is handled specially by the MCP, a Compiler can construct an InStack Array in the Stack Building Code without worrying about block cleanup, instead of having to wait until after the SCW has been stored.
InStack Arrays are indexed from 0..SIZE(Array[*])-1;
The Untouched MOM Descriptor does not have to be in any particular location relative to the Instack Array Data, except that it must be in the same Activation Record.
The declaration of InStackArrayDec is in the MCP at 5032500,
PROCEDURE INSTACKARRAYDEC (MOTHER,FIRST_DATA_WORD,LET_IT_BE); VALUE LET_IT_BE; DESCRIPTOR MOTHER; REAL FIRST_DATA_WORD; BOOLEAN LET_IT_BE;
The Algol Compiler allocates an InStack Array at 70502962 if these conditions apply,
IF NOT NOSTACKARRAYS AND NOT HANDLINGSTRUCT THEN IF KLASS=REALARRAYID OR KLASS=BOOARRAYID OR KLASS=INTARRAYID OR KLASS=CHARARRAYID THEN IF NOT(SAVEBIT OR DIR) THEN IF CURRENT > 2 THEN IF STKARRAYCNT+NOOFID LEQ MAXSTKARRAYCNT THEN IF STKARRAYSZ+NOOFID*SZ(CSZ,UB) LEQ MAXSTKARRAYSZ THEN IF NOT INTRINSICTOG THEN INSTACKARRAY := TRUE;
MAXSTKARRAYSZ = 30 #, MAXSTKARRAYCNT = 10 #,