Commit d6edebb1 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Micro-optimize calculateNumVRegs

I don't think it's that important overall but it seems to be a decent percentage
of the time to enter the interpreter/bjit; this commit saves about 10% in a silly
ubenchmark.
parent c070938c
......@@ -1691,9 +1691,10 @@ extern "C" Box* executeInnerFromASM(ASTInterpreter& interpreter, CFGBlock* start
}
static int calculateNumVRegs(CLFunction* clfunc) {
ScopeInfo* scope_info = clfunc->source->getScopeInfo();
SourceInfo* source_info = clfunc->source.get();
CFG* cfg = source_info->cfg;
// Note: due to some (avoidable) restrictions, this check is pretty constrained in where
// it can go, due to the fact that it can throw an exception.
// It can't go in the ASTInterpreter constructor, since that will cause the C++ runtime to
......@@ -1701,11 +1702,14 @@ static int calculateNumVRegs(CLFunction* clfunc) {
// executeInner since we want the SyntaxErrors to happen *before* the stack frame is entered.
// (For instance, throwing the exception will try to fetch the current statement, but we determine
// that by looking at the cfg.)
if (!source_info->cfg)
source_info->cfg = computeCFG(source_info, source_info->body);
if (!cfg)
cfg = source_info->cfg = computeCFG(source_info, source_info->body);
source_info->cfg->assignVRegs(clfunc->param_names, scope_info);
return source_info->cfg->sym_vreg_map.size();
if (!cfg->hasVregsAssigned()) {
ScopeInfo* scope_info = clfunc->source->getScopeInfo();
cfg->assignVRegs(clfunc->param_names, scope_info);
}
return cfg->sym_vreg_map.size();
}
Box* astInterpretFunction(CLFunction* clfunc, int nargs, Box* closure, Box* generator, Box* globals, Box* arg1,
......
......@@ -110,6 +110,7 @@ public:
void print();
bool hasVregsAssigned() { return has_vregs_assigned; }
void assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info);
};
......
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