Increase maximum inlining depth from 1 to 2 (bug 729920, r=dvander)

This commit is contained in:
Jan de Mooij 2012-02-24 10:44:07 +01:00
parent e70856b2f8
commit bbcba1e9ac
3 changed files with 32 additions and 19 deletions

View File

@ -62,6 +62,7 @@ IonBuilder::IonBuilder(JSContext *cx, JSObject *scopeChain, TempAllocator &temp,
initialScopeChain_(scopeChain),
loopDepth_(loopDepth),
callerResumePoint_(NULL),
callerBuilder_(NULL),
oracle(oracle),
inliningDepth(inliningDepth)
{
@ -173,6 +174,16 @@ IonBuilder::getInliningTarget(uint32 argc, jsbytecode *pc, JSFunction **out)
JSScript *inlineScript = fun->script();
// Allow inlining of recursive calls, but only one level deep.
IonBuilder *builder = callerBuilder_;
while (builder) {
if (builder->script == inlineScript) {
IonSpew(IonSpew_Inlining, "Not inlining recursive call");
return true;
}
builder = builder->callerBuilder_;
}
bool canInline = oracle->canEnterInlinedScript(inlineScript);
if (!canInline) {
@ -281,8 +292,8 @@ IonBuilder::build()
}
bool
IonBuilder::buildInline(MResumePoint *callerResumePoint, MDefinition *thisDefn,
MDefinitionVector &argv)
IonBuilder::buildInline(IonBuilder *callerBuilder, MResumePoint *callerResumePoint,
MDefinition *thisDefn, MDefinitionVector &argv)
{
current = newBlock(pc);
if (!current)
@ -291,6 +302,7 @@ IonBuilder::buildInline(MResumePoint *callerResumePoint, MDefinition *thisDefn,
IonSpew(IonSpew_MIR, "Inlining script %s:%d (%p)",
script->filename, script->lineno, (void *) script);
callerBuilder_ = callerBuilder;
callerResumePoint_ = callerResumePoint;
MBasicBlock *predecessor = callerResumePoint->block();
predecessor->end(MGoto::New(current));
@ -2264,10 +2276,10 @@ IonBuilder::jsop_call_inline(uint32 argc, IonBuilder &inlineBuilder, InliningDat
MDefinition *thisDefn = argv[0];
// Build the graph.
if (!inlineBuilder.buildInline(inlineResumePoint, thisDefn, argv))
if (!inlineBuilder.buildInline(this, inlineResumePoint, thisDefn, argv))
return false;
MIRGraphExits &exits = inlineBuilder.graph().getExitAccumulator();
MIRGraphExits &exits = *inlineBuilder.graph().exitAccumulator();
// Create a |bottom| block for all the callee subgraph exits to jump to.
JS_ASSERT(*pc == JSOP_CALL);
@ -2330,14 +2342,16 @@ IonBuilder::jsop_call_inline(uint32 argc, IonBuilder &inlineBuilder, InliningDat
class AutoAccumulateExits
{
MIRGraph &graph;
MIRGraph &graph_;
MIRGraphExits *prev_;
public:
AutoAccumulateExits(MIRGraph &graph, MIRGraphExits &exits) : graph(graph) {
graph.setExitAccumulator(&exits);
AutoAccumulateExits(MIRGraph &graph, MIRGraphExits &exits) : graph_(graph) {
prev_ = graph_.exitAccumulator();
graph_.setExitAccumulator(&exits);
}
~AutoAccumulateExits() {
graph.setExitAccumulator(NULL);
graph_.setExitAccumulator(prev_);
}
};
@ -2377,7 +2391,7 @@ IonBuilder::maybeInline(uint32 argc)
if (!makeInliningDecision(argc, &data))
return InliningStatus_Error;
if (!data.shouldInline || inliningDepth >= 1)
if (!data.shouldInline || inliningDepth >= 2)
return InliningStatus_NotInlined;
IonSpew(IonSpew_Inlining, "Recursively building");

View File

@ -191,7 +191,7 @@ class IonBuilder : public MIRGenerator
TypeOracle *oracle, CompileInfo &info, size_t inliningDepth = 0, uint32 loopDepth = 0);
bool build();
bool buildInline(MResumePoint *callerResumePoint, MDefinition *thisDefn,
bool buildInline(IonBuilder *callerBuilder, MResumePoint *callerResumePoint, MDefinition *thisDefn,
MDefinitionVector &args);
private:
@ -359,6 +359,7 @@ class IonBuilder : public MIRGenerator
jsbytecode *callerPC() {
return callerResumePoint_ ? callerResumePoint_->pc() : NULL;
}
IonBuilder *callerBuilder_;
Vector<CFGState, 8, IonAllocPolicy> cfgStack_;
Vector<ControlFlowInfo, 4, IonAllocPolicy> loops_;

View File

@ -487,7 +487,7 @@ class MIRGraph
{
InlineList<MBasicBlock> blocks_;
TempAllocator &alloc_;
MIRGraphExits *exitAccumulator;
MIRGraphExits *exitAccumulator_;
uint32 blockIdGen_;
uint32 idGen_;
MBasicBlock *osrBlock_;
@ -499,7 +499,7 @@ class MIRGraph
public:
MIRGraph(TempAllocator &alloc)
: alloc_(alloc),
exitAccumulator(NULL),
exitAccumulator_(NULL),
blockIdGen_(0),
idGen_(0),
osrBlock_(NULL),
@ -518,19 +518,17 @@ class MIRGraph
void unmarkBlocks();
void setExitAccumulator(MIRGraphExits *accum) {
exitAccumulator = accum;
exitAccumulator_ = accum;
}
MIRGraphExits &getExitAccumulator() {
JS_ASSERT(exitAccumulator);
return *exitAccumulator;
MIRGraphExits *exitAccumulator() const {
return exitAccumulator_;
}
bool addExit(MBasicBlock *exitBlock) {
if (!exitAccumulator)
if (!exitAccumulator_)
return true;
return exitAccumulator->append(exitBlock);
return exitAccumulator_->append(exitBlock);
}
MBasicBlock *entryBlock() {