};
typedef struct FunctionalFrame {
- m_uint pc;
VM_Code code;
- m_uint offset;
- m_uint index;
+ uint16_t pc;
+ uint16_t offset;
+ uint16_t index;
} FunctionalFrame;
ANN static inline void _init(const VM_Shred shred,
shredule(shred->tick->shreduler, shred, 0);
}
-#define MAP_CODE_OFFSET (sizeof(FunctionalFrame) + SZ_INT*4)
+#define MAP_CODE_OFFSET (sizeof(FunctionalFrame) + sizeof(struct frame_t))
static INSTR(map_run_ini) {
const m_uint offset = *(m_uint*)REG(SZ_INT);
if(offset)
FunctionalFrame *frame = &*(FunctionalFrame*)MEM(SZ_INT*3);
shred->pc++;
shred->mem += MAP_CODE_OFFSET + SZ_INT; // work in a safe memory space
- *(m_uint*)(shred->mem-SZ_INT) = 0;
- *(m_uint*)(shred->mem-SZ_INT*2) = 0;
- m_vector_get(array, frame->index, &*(m_bit**)(shred->mem + SZ_INT*6));
+ m_vector_get(array, frame->index, &*(m_bit**)(shred->mem + SZ_INT*3));
}
static INSTR(map_run_end) {
shred->pc++;
const FunctionalFrame *frame = &*(FunctionalFrame*)MEM(SZ_INT*3);
shred->mem += MAP_CODE_OFFSET + SZ_INT; // work in a safe memory space
- *(m_uint*)(shred->mem-SZ_INT) = 0;
- *(m_uint*)(shred->mem-SZ_INT*2) = 0;
- m_vector_get(ARRAY(self), frame->index, &*(m_bit**)(shred->mem + SZ_INT*4));
+ m_vector_get(ARRAY(self), frame->index, &*(m_bit**)(shred->mem + SZ_INT*2));
}
static INSTR(foldr_run_ini) {
shred->pc++;
const FunctionalFrame *frame = &*(FunctionalFrame*)MEM(SZ_INT*3);
shred->mem += MAP_CODE_OFFSET + SZ_INT; // work in a safe memory space
- *(m_uint*)(shred->mem-SZ_INT) = 0;
- *(m_uint*)(shred->mem-SZ_INT*2) = 0;
const M_Vector array = ARRAY(self);
- m_vector_get(array, ARRAY_LEN(array) - frame->index - 1, &*(m_bit**)(shred->mem + SZ_INT*4));
+ m_vector_get(array, ARRAY_LEN(array) - frame->index - 1, &*(m_bit**)(shred->mem + SZ_INT*2));
}
static INSTR(fold_run_end) {
shred->code = frame->code;
memcpy(REG(-sz), REG(0), base_sz);
} else {
- memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*2 + SZ_INT*3 + sz, shred->reg, base_sz);
+ memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*3 + sz, shred->reg, base_sz);
_next(shred, frame->offset);
}
_finish(shred, frame);
const m_uint offset = *(m_uint*)REG(SZ_INT*3 + acc_sz);
if(ARRAY_LEN(ARRAY(o))) {
_init(shred, &foldl_run_code, offset, SZ_INT);
- memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*5 + acc_sz, MEM(SZ_INT*2), acc_sz);
+ memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*3 + acc_sz, MEM(SZ_INT*2), acc_sz);
} else
memcpy((m_bit*)RETURN, MEM(SZ_INT*2), acc_sz);
}
const m_uint offset = *(m_uint*)REG(SZ_INT*3 + acc_sz);
if(ARRAY_LEN(ARRAY(o))) {
_init(shred, &foldr_run_code, offset, SZ_INT);
- memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*5 + acc_sz, MEM(SZ_INT*2), acc_sz);
+ memcpy(shred->mem + MAP_CODE_OFFSET + SZ_INT*3 + acc_sz, MEM(SZ_INT*2), acc_sz);
} else
memcpy((m_bit*)RETURN, MEM(SZ_INT*2), acc_sz);
}