Always select gvar ops for declared global vars, instead of only if loopy/enough-used.

This commit is contained in:
Brendan Eich 2008-07-17 14:37:25 -07:00
parent ad6b349616
commit 78677269db
3 changed files with 0 additions and 30 deletions

View File

@ -1909,18 +1909,6 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
if (fp->flags & JSFRAME_SPECIAL)
return JS_TRUE;
/*
* We are compiling a top-level script. Optimize global variable
* accesses if there are at least 100 uses in unambiguous contexts,
* or failing that, if least half of all the uses of global
* vars/consts/functions are in loops.
*/
if (!(tc->globalUses >= 100 ||
(tc->loopyGlobalUses &&
tc->loopyGlobalUses >= tc->globalUses / 2))) {
return JS_TRUE;
}
/*
* We are optimizing global variables and there may be no pre-existing
* global property named atom. If atom was declared via const or var,

View File

@ -162,8 +162,6 @@ struct JSStmtInfo {
struct JSTreeContext { /* tree context for semantic checks */
uint16 flags; /* statement state flags, see below */
uint16 ngvars; /* max. no. of global variables/regexps */
uint32 globalUses; /* optimizable global var uses in total */
uint32 loopyGlobalUses;/* optimizable global var uses in loops */
uint16 scopeDepth; /* current lexical scope chain depth */
uint16 maxScopeDepth; /* maximum lexical scope chain depth */
JSStmtInfo *topStmt; /* top of statement info stack */
@ -209,7 +207,6 @@ struct JSTreeContext { /* tree context for semantic checks */
#define TREE_CONTEXT_INIT(tc, pc) \
((tc)->flags = (tc)->ngvars = 0, \
(tc)->globalUses = (tc)->loopyGlobalUses = 0, \
(tc)->scopeDepth = (tc)->maxScopeDepth = 0, \
(tc)->topStmt = (tc)->topScopeStmt = NULL, \
(tc)->blockChain = NULL, \

View File

@ -5788,21 +5788,6 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
if (pn->pn_atom == cx->runtime->atomState.parentAtom ||
pn->pn_atom == cx->runtime->atomState.protoAtom) {
tc->flags |= TCF_FUN_HEAVYWEIGHT;
} else if (!(tc->flags & TCF_IN_FUNCTION)) {
JSAtomListElement *ale;
JSStackFrame *fp;
JSBool loopy;
/* Measure optimizable global variable uses. */
ATOM_LIST_SEARCH(ale, &tc->decls, pn->pn_atom);
if (ale &&
!(fp = cx->fp)->fun &&
fp->scopeChain == fp->varobj &&
js_IsGlobalReference(tc, pn->pn_atom, &loopy)) {
tc->globalUses++;
if (loopy)
tc->loopyGlobalUses++;
}
}
}
break;