0 parent scope loading

This commit is contained in:
dzaima 2021-07-02 22:26:14 +03:00
parent be5c22af37
commit 3451cc48c2
2 changed files with 14 additions and 10 deletions

View File

@ -447,7 +447,7 @@ Nvm_res m_nvm(Body* body) {
u64 lsz = 0; // local variable used up space
#define ALLOCL(NAME,N) u64 NAME##Off = lsz; lsz+= (N)
ALLOCL(pscs, (body->maxPSC+1)*8);
ALLOCL(pscs, (body->maxPSC)*8);
while (((lsz+pushAm*8)&0xf) != 8) lsz++; // lazy way to make sure we're properly aligned
SUBi(R_SP, lsz);
@ -457,10 +457,12 @@ Nvm_res m_nvm(Body* body) {
#define VAR(OFF,N) (OFF##Off + (N))
#define VAR8(OFF,N) VAR(OFF,(N)*8)
MOV8mro(R_SP, R_A1, VAR(pscs,0));
for (i32 i = 1; i < body->maxPSC+1; i++) {
MOV8rmo(R_A1, R_A1, offsetof(Scope, psc));
MOV8mro(R_SP, R_A1, VAR8(pscs,i));
if (body->maxPSC) {
MOV8mro(R_SP, R_A1, VAR(pscs,0));
for (i32 i = 1; i < body->maxPSC; i++) {
MOV8rmo(R_A1, R_A1, offsetof(Scope, psc));
MOV8mro(R_SP, R_A1, VAR8(pscs,i));
}
}
if ((u64)i_RETD > I32_MAX || (u64)&gStack > I32_MAX || (u64)&envEnd > I32_MAX) thrM("JIT: Refusing to run with CBQN code outside of the 32-bit address range");

View File

@ -183,7 +183,7 @@ Block* compileBlock(B block, Comp* comp, bool* bDone, u32* bc, usz bcIA, B block
i32 ins = c[0];
i32 cdepth = c[1];
i32 cpos = c[2];
if (cdepth>mpsc) mpsc = cdepth;
if (cdepth+1 > mpsc) mpsc = cdepth+1;
if (sc && cdepth>=depth) {
Scope* csc = sc;
for (i32 i = depth; i < cdepth; i++) if (!(csc = csc->psc)) thrM("VM compiler: LOC_ has an out-of-bounds depth");
@ -213,7 +213,7 @@ Block* compileBlock(B block, Comp* comp, bool* bDone, u32* bc, usz bcIA, B block
c = n;
}
if (mpsc>U16_MAX) thrM("VM compiler: LOC_ too deep");
if (mpsc>U16_MAX) thrM("VM compiler: Block too deep");
usz blC = TSSIZE(nBlT);
BlBlocks* nBl = NULL;
@ -375,9 +375,11 @@ B evalBC(Body* b, Scope* sc) { // doesn't consume
u32* bc = b->bc;
pushEnv(sc, bc);
gsReserve(b->maxStack);
Scope* pscs[b->maxPSC+1];
pscs[0] = sc;
for (i32 i = 0; i < b->maxPSC; i++) pscs[i+1] = pscs[i]->psc;
Scope* pscs[b->maxPSC];
if (b->maxPSC) {
pscs[0] = sc;
for (i32 i = 1; i < b->maxPSC; i++) pscs[i] = pscs[i-1]->psc;
}
#ifdef GS_REALLOC
#define POP (*--gStack)
#define P(N) B N=POP;