mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
Allow variables in memoized code (in addition to glocs).
(scm_lookupcar): Handle variables in lost races. Replace symbol with variable directly, do not make a gloc. (scm_unmemocar): Rewrite variables using a reverse lookup, just like glocs. (scm_ceval, scm_deval): Deal with variables in SCM_IM_SET and in the main switch.
This commit is contained in:
parent
6d9ad98a17
commit
d22a0ea164
1 changed files with 19 additions and 3 deletions
|
@ -372,6 +372,8 @@ scm_lookupcar (SCM vloc, SCM genv, int check)
|
|||
var = SCM_CAR (vloc);
|
||||
if (SCM_ITAG3 (var) == scm_tc3_cons_gloc)
|
||||
return SCM_GLOC_VAL_LOC (var);
|
||||
if (SCM_VARIABLEP (var))
|
||||
return SCM_VARIABLE_LOC (var);
|
||||
#ifdef MEMOIZE_LOCALS
|
||||
if (SCM_ITAG7 (var) == SCM_ITAG7 (SCM_ILOC00))
|
||||
return scm_ilookup (var, genv);
|
||||
|
@ -385,7 +387,7 @@ scm_lookupcar (SCM vloc, SCM genv, int check)
|
|||
}
|
||||
#endif /* USE_THREADS */
|
||||
|
||||
SCM_SET_CELL_WORD_0 (vloc, SCM_UNPACK (real_var) + scm_tc3_cons_gloc);
|
||||
SCM_SETCAR (vloc, real_var);
|
||||
return SCM_VARIABLE_LOC (real_var);
|
||||
}
|
||||
}
|
||||
|
@ -421,6 +423,14 @@ scm_unmemocar (SCM form, SCM env)
|
|||
sym = sym_three_question_marks;
|
||||
SCM_SETCAR (form, sym);
|
||||
}
|
||||
else if (SCM_VARIABLEP (c))
|
||||
{
|
||||
SCM sym =
|
||||
scm_module_reverse_lookup (scm_env_module (env), c);
|
||||
if (SCM_EQ_P (sym, SCM_BOOL_F))
|
||||
sym = sym_three_question_marks;
|
||||
SCM_SETCAR (form, sym);
|
||||
}
|
||||
#ifdef MEMOIZE_LOCALS
|
||||
#ifdef DEBUG_EXTENSIONS
|
||||
else if (SCM_ILOCP (c))
|
||||
|
@ -2193,7 +2203,10 @@ dispatch:
|
|||
switch (SCM_ITAG3 (proc))
|
||||
{
|
||||
case scm_tc3_cons:
|
||||
t.lloc = scm_lookupcar (x, env, 1);
|
||||
if (SCM_VARIABLEP (proc))
|
||||
t.lloc = SCM_VARIABLE_LOC (proc);
|
||||
else
|
||||
t.lloc = scm_lookupcar (x, env, 1);
|
||||
break;
|
||||
case scm_tc3_cons_gloc:
|
||||
t.lloc = SCM_GLOC_VAL_LOC (proc);
|
||||
|
@ -2546,6 +2559,9 @@ dispatch:
|
|||
case scm_tcs_subrs:
|
||||
RETURN (x);
|
||||
|
||||
case scm_tc7_variable:
|
||||
return SCM_VARIABLE_REF(x);
|
||||
|
||||
#ifdef MEMOIZE_LOCALS
|
||||
case SCM_BIT8(SCM_ILOC00):
|
||||
proc = *scm_ilookup (SCM_CAR (x), env);
|
||||
|
@ -2558,7 +2574,7 @@ dispatch:
|
|||
break;
|
||||
#endif /* ifdef MEMOIZE_LOCALS */
|
||||
|
||||
|
||||
|
||||
case scm_tcs_cons_gloc: {
|
||||
scm_t_bits vcell = SCM_STRUCT_VTABLE_DATA (x) [scm_vtable_index_vcell];
|
||||
if (vcell == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue