Dynamically allocate string space, and make it larger.

This increases the limit on total bytes of strings in a function, and also frees up space in the blank segment.
This commit is contained in:
Stephen Heumann 2022-06-08 22:09:30 -05:00
parent 3c2b492618
commit 161bb952e3
5 changed files with 17 additions and 13 deletions

View File

@ -209,7 +209,7 @@ const
{Note: maxlabel is also defined in CGC.asm}
maxLabel = 3200; {max # of internal labels}
maxLocalLabel = 220; {max # local variables}
maxString = 12500; {max # chars in string space}
maxString = 32760; {max # chars in string space}
{size of internal types}
{----------------------}
@ -225,6 +225,7 @@ const
type
segNameType = packed array[1..10] of char; {segment name}
stringSpaceType = packed array[1..maxstring] of char; {string space}
{p code}
{------}
@ -343,7 +344,7 @@ var
stackSize: integer; {amount of stack space to reserve}
strictVararg: boolean; {repair stack around vararg calls?}
stringsize: 0..maxstring; {amount of string space left}
stringspace: packed array[1..maxstring] of char; {string table}
stringspace: ^stringSpaceType; {string table}
symLength: integer; {length of debug symbol table}
toolParms: boolean; {generate tool format parameters?}
volatile: boolean; {has a volatile qualifier been used?}
@ -822,6 +823,9 @@ fastMath := cLineOptimize;
commonSubexpression := cLineOptimize; {not doing common subexpression elimination}
loopOptimizations := cLineOptimize; {not doing loop optimizations, yet}
{allocate string space}
new(stringspace);
{allocate the initial p-code}
code := pointer(Calloc(sizeof(intermediate_code)));
code^.optype := cgWord;

12
Gen.pas
View File

@ -5136,9 +5136,9 @@ len := debugFile^.theString.size;
if len > 255 then
len := 255;
if maxString-stringSize >= len+1 then begin
stringSpace[stringSize+1] := chr(len);
stringSpace^[stringSize+1] := chr(len);
for i := 1 to len do
stringSpace[i+stringSize+1] :=
stringSpace^[i+stringSize+1] :=
debugFile^.theString.theString[i];
stringSize := stringSize + len + 1;
end {if}
@ -5937,7 +5937,7 @@ procedure GenTree {op: icptr};
GenNative(m_pea, immediate, stringSize, nil, stringReference);
if maxString-stringSize >= op^.q then begin
for i := 1 to op^.q do
stringSpace[i+stringSize] := op^.str^.str[i];
stringSpace^[i+stringSize] := op^.str^.str[i];
stringSize := stringSize+op^.q;
end
else
@ -6375,7 +6375,7 @@ procedure GenTree {op: icptr};
GenNative(opcode, immediate, stringsize, nil, StringReference);
if maxstring-stringsize >= op^.q then begin
for i := 1 to op^.q do
stringspace[i+stringsize] := op^.str^.str[i];
stringspace^[i+stringsize] := op^.str^.str[i];
stringsize := stringsize + op^.q;
end {if}
else
@ -6491,9 +6491,9 @@ procedure GenTree {op: icptr};
{place the name in the string buffer}
if maxString-stringSize >= op^.q+1 then begin
stringSpace[stringSize+1] := chr(op^.q);
stringSpace^[stringSize+1] := chr(op^.q);
for i := 1 to op^.q do
stringSpace[i+stringSize+1] := op^.str^.str[i];
stringSpace^[i+stringSize+1] := op^.str^.str[i];
stringSize := stringSize + op^.q + 1;
end {if}
else

View File

@ -676,7 +676,7 @@ case mode of
j := sptr^.length;
if maxString-stringSize >= j then begin
for k := 1 to j do
stringSpace[k+stringSize] :=
stringSpace^[k+stringSize] :=
sptr^.str[k];
stringSize := stringSize+j;
end {if}
@ -1337,7 +1337,7 @@ Purge; {dump constant buffer}
if stringsize <> 0 then begin {define string space}
UpDate(maxLabel, pc); {define the local label for the string space}
for i := 1 to stringsize do
CnOut(ord(stringspace[i]));
CnOut(ord(stringspace^[i]));
Purge;
end; {if}
Out(0); {end the segment}

View File

@ -1176,9 +1176,9 @@ var
Out(0);
len := length(ip^.name^); {place the name in the string buffer}
if maxstring-stringsize >= len+1 then begin
stringspace[stringsize+1] := chr(len);
stringspace^[stringsize+1] := chr(len);
for j := 1 to len do
stringspace[j+stringsize+1] := ip^.name^[j];
stringspace^[j+stringsize+1] := ip^.name^[j];
stringsize := stringsize+len+1;
end {if}
else

View File

@ -144,7 +144,7 @@ Character and string constants may now have prefixes indicating they should use
p. 238
The limit on the length of a single string constant is now 32760 bytes. The limit on the total length of string constants in a single function is now 12500 bytes (larger string constants can be used to initialize static arrays).
The limits on the length of a single string constant and on the total length of string constants in a single function have both been raised to 32760 bytes.
p. 239