Commit cbccb49c authored by Radford Neal's avatar Radford Neal

fiddle with eval, etc., including moving trace stuff out, relying on builtins...

fiddle with eval, etc., including moving trace stuff out, relying on builtins being protected by their cache
parent 2b547c05
More playing around to reduce the overhead of "eval".
......@@ -209,7 +209,6 @@
R_compress2
R_compress3
R_cpolyroot
R_current_trace_state
R_data_class2
R_dec_min_exponent
R_decompress1
......@@ -265,6 +264,7 @@
R_sysframe
R_sysfunction
R_sysparent
R_trace_call
R_unary
R_unserialize
R_warn_partial_match_args
......@@ -333,6 +333,7 @@
Rf_allocCharsxp
Rf_arg_missing_error
Rf_bd0
Rf_builtin_op
Rf_chebyshev_eval
Rf_chebyshev_init
Rf_check1arg
......@@ -348,6 +349,7 @@
Rf_evalList
Rf_evalListKeepMissing
Rf_evalListPendingOK
Rf_evalv2
Rf_findVar1
Rf_findcontext
Rf_forcePromise
......
......@@ -1250,7 +1250,6 @@ void InitEd(void);
void InitFunctionHashing(void);
void InitBaseEnv(void);
void InitGlobalEnv(void);
Rboolean R_current_trace_state(void);
Rboolean R_has_methods(SEXP);
void R_InitialData(void);
SEXP R_possible_dispatch(SEXP, SEXP, SEXP, SEXP, Rboolean);
......@@ -1330,6 +1329,7 @@ void ssort(SEXP*,int);
int StrToInternal(const char *);
SEXP strmat2intmat(SEXP, SEXP, SEXP);
SEXP substituteList(SEXP, SEXP);
void R_trace_call(SEXP, SEXP);
Rboolean tsConform(SEXP,SEXP);
SEXP tspgets(SEXP, SEXP);
SEXP type2symbol(SEXPTYPE);
......
......@@ -112,8 +112,15 @@ SEXP R_traceOnOff(SEXP onOff)
return ScalarLogical(prev);
}
Rboolean attribute_hidden
R_current_trace_state() { return GET_TRACE_STATE; }
void attribute_hidden R_trace_call (SEXP e, SEXP op)
{
if (GET_TRACE_STATE) {
PROTECT2(e,op);
Rprintf("trace: ");
PrintValue(e);
UNPROTECT(2);
}
}
/* memory tracing - no longer exists. */
......
This diff is collapsed.
......@@ -2759,7 +2759,7 @@ SEXP attribute_hidden mkPROMISE(SEXP expr, SEXP rho)
/* The value produced is cached do avoid the need for GC protection
in cases where a .Primitive is produced by unserializing or
reconstructed after a package has clobbered the value assigned to
a symbol in the base package. */
a symbol in the base package. Also relied on to protect op in "eval". */
SEXP attribute_hidden mkPRIMSXP(int offset, int eval)
{
......
......@@ -540,28 +540,32 @@ static void SetupBuiltins(void)
R_FunTab[i].name = NULL;
/* Install the primitive and internal functions. Look for fast versions
of each one. */
of the primitives (but not internals). */
for (i = 0; R_FunTab[i].name!=NULL; i++) {
SEXP (*this_cfun)() = R_FunTab[i].cfun;
int this_code = R_FunTab[i].code;
SEXP prim;
/* prim needs protect since install can (and does here) allocate */
/* prim needs protect since install can (and does here) allocate.
Except... mkPRIMSXP now caches them all, so maybe not. */
PROTECT(prim = mkPRIMSXP(i, R_FunTab[i].eval % 10));
if ((R_FunTab[i].eval % 100 )/10)
SET_INTERNAL(install(R_FunTab[i].name), prim);
else
else {
SET_SYMVALUE(install(R_FunTab[i].name), prim);
for (j = 0; FastFunTab_ptrs[j]!=NULL; j++) {
for (k = 0; FastFunTab_ptrs[j][k].slow!=0; k++) {
FASTFUNTAB *f = &FastFunTab_ptrs[j][k];
if (f->slow==this_cfun && (f->code==-1 || f->code==this_code)) {
if (f->arity==1)
SET_PRIMFUN_FAST_UNARY(prim,f->fast,f->dsptch1,f->var1);
else
SET_PRIMFUN_FAST_BINARY(prim,f->fast,
f->dsptch1,f->dsptch2,f->var1,f->var2,f->arity==3);
goto found;
for (j = 0; FastFunTab_ptrs[j]!=NULL; j++) {
for (k = 0; FastFunTab_ptrs[j][k].slow!=0; k++) {
FASTFUNTAB *f = &FastFunTab_ptrs[j][k];
if (f->slow==this_cfun
&& (f->code==-1 || f->code==this_code)) {
if (f->arity==1)
SET_PRIMFUN_FAST_UNARY (prim, f->fast, f->dsptch1,
f->var1);
else
SET_PRIMFUN_FAST_BINARY (prim, f->fast, f->dsptch1,
f->dsptch2, f->var1, f->var2, f->arity==3);
goto found;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment