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 ...@@ -1691,9 +1691,10 @@ extern "C" Box* executeInnerFromASM(ASTInterpreter& interpreter, CFGBlock* start
} }
static int calculateNumVRegs(CLFunction* clfunc) { static int calculateNumVRegs(CLFunction* clfunc) {
ScopeInfo* scope_info = clfunc->source->getScopeInfo();
SourceInfo* source_info = clfunc->source.get(); SourceInfo* source_info = clfunc->source.get();
CFG* cfg = source_info->cfg;
// Note: due to some (avoidable) restrictions, this check is pretty constrained in where // 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 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 // 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) { ...@@ -1701,11 +1702,14 @@ static int calculateNumVRegs(CLFunction* clfunc) {
// executeInner since we want the SyntaxErrors to happen *before* the stack frame is entered. // 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 // (For instance, throwing the exception will try to fetch the current statement, but we determine
// that by looking at the cfg.) // that by looking at the cfg.)
if (!source_info->cfg) if (!cfg)
source_info->cfg = computeCFG(source_info, source_info->body); cfg = source_info->cfg = computeCFG(source_info, source_info->body);
source_info->cfg->assignVRegs(clfunc->param_names, scope_info); if (!cfg->hasVregsAssigned()) {
return source_info->cfg->sym_vreg_map.size(); 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, Box* astInterpretFunction(CLFunction* clfunc, int nargs, Box* closure, Box* generator, Box* globals, Box* arg1,
......
...@@ -110,6 +110,7 @@ public: ...@@ -110,6 +110,7 @@ public:
void print(); void print();
bool hasVregsAssigned() { return has_vregs_assigned; }
void assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info); 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