backout the gethunk() again, as that breaks the assemblers

the assemblers share gethunk() cc/macbody but are compiled
without compat.c, so calls such as getenv() trigger malloc()
which does its own sbrk() calls, breaking the continuity
of the hunk.

so this change needs another revision. until then, this is
backed out.
This commit is contained in:
cinap_lenrek 2020-04-11 01:26:36 +02:00
parent 1d3644a168
commit 9d46360c9d
12 changed files with 32 additions and 60 deletions

View file

@ -1099,11 +1099,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -1121,11 +1121,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -1152,11 +1152,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -1222,11 +1222,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -1178,11 +1178,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -1196,11 +1196,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -862,10 +862,7 @@ gethunk(void)
yyerror("out of memory"); yyerror("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }

View file

@ -241,7 +241,7 @@ EXTERN long symsize;
EXTERN long staticgen; EXTERN long staticgen;
EXTERN Prog* textp; EXTERN Prog* textp;
EXTERN long textsize; EXTERN long textsize;
EXTERN uintptr thunk; EXTERN uintptr tothunk;
EXTERN char xcmp[C_NCLASS][C_NCLASS]; EXTERN char xcmp[C_NCLASS][C_NCLASS];
EXTERN int version; EXTERN int version;
EXTERN Prog zprg; EXTERN Prog zprg;

View file

@ -194,7 +194,7 @@ main(int argc, char *argv[])
out: out:
if(debug['v']) { if(debug['v']) {
Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%5.2f cpu time\n", cputime());
Bprint(&bso, "%zud memory used\n", thunk); Bprint(&bso, "%zud memory used\n", tothunk);
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
} }
@ -983,9 +983,9 @@ gethunk(void)
long nh; long nh;
nh = NHUNK; nh = NHUNK;
if(thunk >= 5L*NHUNK) { if(tothunk >= 5L*NHUNK) {
nh = 5L*NHUNK; nh = 5L*NHUNK;
if(thunk >= 25L*NHUNK) if(tothunk >= 25L*NHUNK)
nh = 25L*NHUNK; nh = 25L*NHUNK;
} }
h = mysbrk(nh); h = mysbrk(nh);
@ -993,12 +993,10 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0)
hunk = h; hunk = h;
else nhunk = nh;
nh += (h - hunk) - nhunk; tothunk += nh;
nhunk += nh;
thunk += nh;
} }
void void

View file

@ -234,7 +234,7 @@ EXTERN long symsize;
EXTERN long staticgen; EXTERN long staticgen;
EXTERN Prog* textp; EXTERN Prog* textp;
EXTERN long textsize; EXTERN long textsize;
EXTERN uintptr thunk; EXTERN uintptr tothunk;
EXTERN char xcmp[C_NCLASS][C_NCLASS]; EXTERN char xcmp[C_NCLASS][C_NCLASS];
EXTERN int version; EXTERN int version;
EXTERN Prog zprg; EXTERN Prog zprg;

View file

@ -273,7 +273,7 @@ main(int argc, char *argv[])
out: out:
if(debug['v']) { if(debug['v']) {
Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%5.2f cpu time\n", cputime());
Bprint(&bso, "%zud memory used\n", thunk); Bprint(&bso, "%zud memory used\n", tothunk);
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
} }
@ -1117,9 +1117,9 @@ gethunk(void)
long nh; long nh;
nh = NHUNK; nh = NHUNK;
if(thunk >= 5L*NHUNK) { if(tothunk >= 5L*NHUNK) {
nh = 5L*NHUNK; nh = 5L*NHUNK;
if(thunk >= 25L*NHUNK) if(tothunk >= 25L*NHUNK)
nh = 25L*NHUNK; nh = 25L*NHUNK;
} }
h = mysbrk(nh); h = mysbrk(nh);
@ -1127,12 +1127,10 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0)
hunk = h; hunk = h;
else nhunk = nh;
nh += (h - hunk) - nhunk; tothunk += nh;
nhunk += nh;
thunk += nh;
} }
void void

View file

@ -1075,11 +1075,8 @@ gethunk(void)
diag("out of memory"); diag("out of memory");
errorexit(); errorexit();
} }
if(nhunk == 0) hunk = h;
hunk = h; nhunk = nh;
else
nh += (h - hunk) - nhunk;
nhunk += nh;
thunk += nh; thunk += nh;
} }