cache slot objects

This commit is contained in:
Yuichi Nishiwaki 2015-07-07 14:57:44 +09:00
parent 1e104921eb
commit 976a44185d
3 changed files with 42 additions and 1 deletions

View File

@ -108,6 +108,9 @@ struct pic_state {
pic_value pCONS, pCAR, pCDR, pNILP, pPAIRP, pSYMBOLP, pNOT; pic_value pCONS, pCAR, pCDR, pNILP, pPAIRP, pSYMBOLP, pNOT;
pic_value pADD, pSUB, pMUL, pDIV, pEQ, pLT, pLE, pGT, pGE; pic_value pADD, pSUB, pMUL, pDIV, pEQ, pLT, pLE, pGT, pGE;
pic_value cCONS, cCAR, cCDR, cNILP, cPAIRP, cSYMBOLP, cNOT;
pic_value cADD, cSUB, cMUL, cDIV, cEQ, cLT, cLE, cGT, cGE;
struct pic_lib *PICRIN_BASE; struct pic_lib *PICRIN_BASE;
struct pic_lib *PICRIN_USER; struct pic_lib *PICRIN_USER;

View File

@ -118,6 +118,9 @@ pic_features(pic_state *pic)
#define VM(uid, name) \ #define VM(uid, name) \
pic_define_syntactic_keyword_(pic, pic->lib->env, pic_intern_cstr(pic, name), uid) pic_define_syntactic_keyword_(pic, pic->lib->env, pic_intern_cstr(pic, name), uid)
#define VM3(name) \
pic->c##name = pic_vm_gref_slot(pic, pic->u##name);
#define VM2(proc, name) \ #define VM2(proc, name) \
proc = pic_ref(pic, pic->lib, name) proc = pic_ref(pic, pic->lib, name)
@ -125,6 +128,7 @@ static void
pic_init_core(pic_state *pic) pic_init_core(pic_state *pic)
{ {
void pic_define_syntactic_keyword_(pic_state *, struct pic_env *, pic_sym *, pic_sym *); void pic_define_syntactic_keyword_(pic_state *, struct pic_env *, pic_sym *, pic_sym *);
pic_value pic_vm_gref_slot(pic_state *, pic_sym *);
pic_init_features(pic); pic_init_features(pic);
@ -182,6 +186,23 @@ pic_init_core(pic_state *pic)
pic_init_attr(pic); DONE; pic_init_attr(pic); DONE;
pic_init_reg(pic); DONE; pic_init_reg(pic); DONE;
VM3(CONS);
VM3(CAR);
VM3(CDR);
VM3(NILP);
VM3(SYMBOLP);
VM3(PAIRP);
VM3(NOT);
VM3(ADD);
VM3(SUB);
VM3(MUL);
VM3(DIV);
VM3(EQ);
VM3(LT);
VM3(LE);
VM3(GT);
VM3(GE);
VM2(pic->pCONS, "cons"); VM2(pic->pCONS, "cons");
VM2(pic->pCAR, "car"); VM2(pic->pCAR, "car");
VM2(pic->pCDR, "cdr"); VM2(pic->pCDR, "cdr");
@ -420,6 +441,23 @@ pic_open(pic_allocf allocf, void *userdata)
/* turn on GC */ /* turn on GC */
pic->gc_enable = true; pic->gc_enable = true;
pic->cCONS = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cCAR = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cCDR = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cNILP = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cSYMBOLP = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cPAIRP = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cNOT = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cADD = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cSUB = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cMUL = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cDIV = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cEQ = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cLT = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cLE = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cGT = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic->cGE = pic_cons(pic, pic_false_value(), pic_invalid_value());
pic_init_core(pic); pic_init_core(pic);
pic_gc_arena_restore(pic, ai); pic_gc_arena_restore(pic, ai);

View File

@ -856,7 +856,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args)
} }
#define check_condition(name, n) do { \ #define check_condition(name, n) do { \
if (! pic_eq_p(pic->p##name, vm_gref(pic, pic_vm_gref_slot(pic, pic->u##name)))) \ if (! pic_eq_p(pic->p##name, pic_cdr(pic, pic->c##name))) \
goto L_CALL; \ goto L_CALL; \
if (c.u.i != n + 1) \ if (c.u.i != n + 1) \
goto L_CALL; \ goto L_CALL; \