Commit eb0ab88a authored by Radford Neal's avatar Radford Neal

Merge branch '88-perf' into 89

parents ead3df16 624e1da8
......@@ -1600,6 +1600,12 @@ ConstExtern R_CONST SEXPREC R_NilValue_const; /* defined in const-objs.c */
#define R_NilValue ((SEXP) &R_NilValue_const)
#endif
/* Symbol constants. */
#if !USE_COMPRESSED_POINTERS
ConstExtern SYM_SEXPREC R_sym_consts[3]; /* defined in const-objs.c */
#endif
/* R_UnboundValue - for symbol with no value. */
LibExtern SEXP R_UnboundValue; /* Variable form, for those that need it */
......@@ -1608,12 +1614,28 @@ LibExtern SEXP R_UnboundValue; /* Variable form, for those that need it */
#if USE_COMPRESSED_POINTERS
#define R_UnboundValue ((SEXP)SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,0))
#else
ConstExtern SYM_SEXPREC R_sym_consts[1]; /* defined in const-objs.c */
#define R_UnboundValue ((SEXP) &R_sym_consts[0]) /* for sym with no value */
#endif
LibExtern SEXP R_MissingArg; /* Missing argument marker */
LibExtern SEXP R_MissingUnder; /* Missing argument marker as "_" */
/* Missing argument symbols. MissingUnder form is for "_". */
LibExtern SEXP R_MissingArg; /* Variable form, for those that need it */
/* Set in const-objs.c, as done below */
#if USE_COMPRESSED_POINTERS
#define R_MissingArg ((SEXP)SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,1))
#else
#define R_MissingArg ((SEXP) &R_sym_consts[1])
#endif
LibExtern SEXP R_MissingUnder; /* Variable form, for those that need it */
/* Set in const-objs.c, as done below */
#if USE_COMPRESSED_POINTERS
#define R_MissingUnder ((SEXP)SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,2))
#else
#define R_MissingUnder ((SEXP) &R_sym_consts[2])
#endif
/* Logical / Integer / Real Values. Defined in const-objs.c, must keep
in sync. */
......
......@@ -206,18 +206,33 @@ R_CONST ENV_SEXPREC R_env_consts[1] = {
};
/* Definition of the R_UnboundValue constant, whose address when cast to SEXP
is R_UnboundValue. Don't put in read-only memory, so won't have to special
case it when clearing LASTSYMENV and LASTENVNOTFOUND. Leave LENGTH
(if it exists) as zero. */
SYM_SEXPREC R_sym_consts[1] = {
/* Symbol constants. Defines an R_UnboundValue constant, whose address
when cast to SEXP is R_UnboundValue, and similarly R_MissingArg and
R_MissingUnder. Don't put in read-only memory, so won't have to
special case when clearing LASTSYMENV and LASTENVNOTFOUND, and so
print names can be set up later. Leave LENGTH (if it exists) as
zero here (may be changed). Set symbits to all zeros, so will be
looked for (and usually not found). */
SYM_SEXPREC R_sym_consts[3] = {
{
CONST_HEADER(SYMSXP,R_SGGC_SYM_INDEX,0),
.pname = R_NilValue,
.value = R_UnboundValue,
.symbits = 0 /* all 0s, so will always look for this */
} /* (and presumably not find it) */
.symbits = 0
},
{
CONST_HEADER(SYMSXP,R_SGGC_SYM_INDEX,1),
.pname = R_NilValue,
.value = R_UnboundValue,
.symbits = 0
},
{
CONST_HEADER(SYMSXP,R_SGGC_SYM_INDEX,2),
.pname = R_NilValue,
.value = R_UnboundValue,
.symbits = 0
}
};
......@@ -728,11 +743,11 @@ void Rf_constant_init(void)
if (SGGC_SEGMENT_INDEX(p) != R_SGGC_ENV_INDEX) abort();
/*** Symbol constant. ***/
/*** Symbol constants. ***/
p = sggc_constant (R_type_to_sggc_type[SYMSXP],
R_type_to_sggc_type[SYMSXP]+2*SGGC_N_TYPES,
1, (char *) R_sym_consts
3, (char *) R_sym_consts
#if USE_COMPRESSED_POINTERS
, (char *) sggc_length1, (char *) nilattrib
#elif USE_AUX_FOR_ATTRIB
......@@ -957,3 +972,17 @@ SEXP R_UnboundValue = SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,0);
#else
SEXP R_UnboundValue = (SEXP) &R_sym_consts[0];
#endif
#undef R_MissingArg
#if USE_COMPRESSED_POINTERS
SEXP R_MissingArg = SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,1);
#else
SEXP R_MissingArg = (SEXP) &R_sym_consts[1];
#endif
#undef R_MissingUnder
#if USE_COMPRESSED_POINTERS
SEXP R_MissingUnder = SGGC_CPTR_VAL(R_SGGC_SYM_INDEX,2);
#else
SEXP R_MissingUnder = (SEXP) &R_sym_consts[2];
#endif
......@@ -325,7 +325,7 @@ void endcontext(RCNTXT * cptr)
{
R_HandlerStack = cptr->handlerstack;
R_RestartStack = cptr->restartstack;
if (cptr->cloenv != R_NilValue && cptr->conexit != R_NilValue ) {
if (cptr->conexit != R_NilValue && cptr->cloenv != R_NilValue) {
SEXP s = cptr->conexit;
Rboolean savevis = R_Visible;
cptr->conexit = R_NilValue; /* prevent recursion */
......@@ -934,8 +934,7 @@ static SEXP attribute_noinline forcePromiseUnbound (SEXP e, int variant)
SET_PRVALUE_MACRO (e, val);
if (TYPE_ETC(val) == SYMSXP &&
(val == R_MissingArg || val == R_MissingUnder)) {
if (val == R_MissingArg || val == R_MissingUnder) {
/* Attempt to mimic past behaviour... */
if ( ! (variant & VARIANT_MISSING_OK) && TYPEOF(PRCODE(e)) == SYMSXP
......
......@@ -38,6 +38,9 @@
#include <Rinterface.h>
#include <lphash/lphash-app.h>
#undef NOT_LVALUE /* Allow PRINTNAME, etc. on left of assignment here */
#define NOT_LVALUE(x) (x) /* since it's needed to set up R_MissingUnder */
#define HSIZE (1<<14) /* Initial size of lphash symbol table (a power of 2) */
......@@ -688,12 +691,21 @@ void InitNames()
/* The SYMSXP objects below are not in the symbol table. */
/* R_MissingArg */
R_MissingArg = mkSYMSXP(R_BlankString,R_NilValue);
PRINTNAME(R_MissingArg) = R_BlankString;
IS_PRINTNAME(R_BlankString) = 1;
SET_SYMVALUE(R_MissingArg, R_MissingArg);
# if !USE_AUX_FOR_ATTRIB
LENGTH(R_MissingArg) = 1;
# endif
/* R_MissingUnder */
R_UnderscoreString = mkChar("_");
R_MissingUnder = mkSYMSXP(R_UnderscoreString,R_MissingArg);
PRINTNAME(R_MissingUnder) = R_UnderscoreString;
IS_PRINTNAME(R_UnderscoreString) = 1;
SET_SYMVALUE(R_MissingUnder, R_MissingArg);
# if !USE_AUX_FOR_ATTRIB
LENGTH(R_MissingUnder) = 1;
# endif
/* R_RestartToken */
R_RestartToken = mkSYMSXP(R_BlankString,R_NilValue);
......
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