From 2f14ad8d547974b08a4231f78cb46867e011c2ea Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Wed, 15 May 2013 22:20:44 -0700 Subject: [PATCH] Remove AllocSpill/FreeSpill Doesn't work, so we shouldn't maintain it. We can add a feature like this later if we need it (although it might be easier and just as good to just increase the preallocated spill number if needed). --- hphp/doc/ir.specification | 9 ----- hphp/runtime/vm/translator/hopt/codegen.cpp | 22 ---------- hphp/runtime/vm/translator/hopt/ir.h | 2 - hphp/runtime/vm/translator/hopt/linearscan.cpp | 56 +------------------------- hphp/runtime/vm/translator/hopt/linearscan.h | 8 +--- 5 files changed, 3 insertions(+), 94 deletions(-) diff --git a/hphp/doc/ir.specification b/hphp/doc/ir.specification index 25ca8d4fe87..5f862994ae4 100644 --- a/hphp/doc/ir.specification +++ b/hphp/doc/ir.specification @@ -1258,15 +1258,6 @@ D:T = Reload S0:T Loads from a spilled temporary S0, and stores the result in D. -AllocSpill S0:ConstInt - - Allocates S0 slots of additional spill space on the stack. - Generated when the preallocated spill space is exhausted. - -FreeSpill S0:ConstInt - - Deallocates S0 slots of spill space on the stack. - 16. Continuations & Closures diff --git a/hphp/runtime/vm/translator/hopt/codegen.cpp b/hphp/runtime/vm/translator/hopt/codegen.cpp index d0ac7db2660..c4892aa6fd3 100644 --- a/hphp/runtime/vm/translator/hopt/codegen.cpp +++ b/hphp/runtime/vm/translator/hopt/codegen.cpp @@ -2352,28 +2352,6 @@ void CodeGenerator::cgFreeActRec(IRInstruction* inst) { m_regs[inst->getDst()].getReg()); } -void CodeGenerator::cgAllocSpill(IRInstruction* inst) { - SSATmp* numSlots = inst->getSrc(0); - - assert(numSlots->isConst()); - int64_t n = numSlots->getValInt(); - assert(n >= 0 && n % 2 == 0); - if (n > 0) { - m_as.sub_imm32_reg64(spillSlotsToSize(n), reg::rsp); - } -} - -void CodeGenerator::cgFreeSpill(IRInstruction* inst) { - SSATmp* numSlots = inst->getSrc(0); - - assert(numSlots->isConst()); - int64_t n = numSlots->getValInt(); - assert(n >= 0 && n % 2 == 0); - if (n > 0) { - m_as.add_imm32_reg64(spillSlotsToSize(n), reg::rsp); - } -} - void CodeGenerator::cgSpill(IRInstruction* inst) { SSATmp* dst = inst->getDst(); SSATmp* src = inst->getSrc(0); diff --git a/hphp/runtime/vm/translator/hopt/ir.h b/hphp/runtime/vm/translator/hopt/ir.h index d613cc6265f..0e5dd636b37 100644 --- a/hphp/runtime/vm/translator/hopt/ir.h +++ b/hphp/runtime/vm/translator/hopt/ir.h @@ -416,8 +416,6 @@ O(InterpOneCF, ND, S(FramePtr) S(StkPtr) \ C(Int), T|E|N|Mem|Refs|Er) \ O(Spill, DofS(0), SUnk, Mem) \ O(Reload, DofS(0), SUnk, Mem) \ -O(AllocSpill, ND, C(Int), E|Mem) \ -O(FreeSpill, ND, C(Int), E|Mem) \ O(CreateCont, D(Obj), C(TCA) \ S(FramePtr) \ C(Bool) \ diff --git a/hphp/runtime/vm/translator/hopt/linearscan.cpp b/hphp/runtime/vm/translator/hopt/linearscan.cpp index 53b70004300..928342ab07c 100644 --- a/hphp/runtime/vm/translator/hopt/linearscan.cpp +++ b/hphp/runtime/vm/translator/hopt/linearscan.cpp @@ -146,8 +146,6 @@ private: static SSATmp* getSpilledTmp(SSATmp* tmp); static SSATmp* getOrigTmp(SSATmp* tmp); uint32_t assignSpillLoc(); - void insertAllocFreeSpill(Trace* trace, uint32_t numExtraSpillLocs); - void insertAllocFreeSpillAux(Trace* trace, uint32_t numExtraSpillLocs); void rematerialize(); void rematerializeAux(); void removeUnusedSpills(); @@ -573,47 +571,6 @@ uint32_t LinearScan::assignSpillLoc() { return maxSpillLoc; } -void LinearScan::insertAllocFreeSpill(Trace* trace, - uint32_t numExtraSpillLocs) { - insertAllocFreeSpillAux(trace, numExtraSpillLocs); - for (Trace* exit : trace->getExitTraces()) { - insertAllocFreeSpillAux(exit, numExtraSpillLocs); - } -} - -void LinearScan::insertAllocFreeSpillAux(Trace* trace, - uint32_t numExtraSpillLocs) { - SSATmp* tmp = m_irFactory->gen(DefConst, Type::Int, - ConstData(numExtraSpillLocs))->getDst(); - - for (Block* block : trace->getBlocks()) { - for (auto it = block->begin(); it != block->end(); ) { - auto next = it; ++next; - IRInstruction& inst = *it; - Opcode opc = inst.op(); - if (opc == Call) { - // Insert FreeSpill and AllocSpill around each Call. - IRInstruction* allocSpill = m_irFactory->gen(AllocSpill, tmp); - IRInstruction* freeSpill = m_irFactory->gen(FreeSpill, tmp); - block->insert(it, freeSpill); - block->insert(next, allocSpill); - } else if (opc == ExitTrace || opc == ExitSlow || opc == ExitTraceCc || - opc == ExitSlowNoProgress || opc == ExitGuardFailure || - opc == LdRetAddr) { - // Insert FreeSpill at trace exits. - IRInstruction* freeSpill = m_irFactory->gen(FreeSpill, tmp); - block->insert(it, freeSpill); - } - it = next; - } - } - - // Insert AllocSpill at the start of the main trace. - if (trace->isMain()) { - trace->front()->prepend(m_irFactory->gen(AllocSpill, tmp)); - } -} - void LinearScan::collectInfo(BlockList::iterator it, Trace* trace) { m_natives.clear(); m_jmps.reset(); @@ -967,18 +924,7 @@ RegAllocInfo LinearScan::allocRegs(Trace* trace, LifetimeInfo* lifetime) { ++numSpillLocs; } if (numSpillLocs > (uint32_t)NumPreAllocatedSpillLocs) { - /* - * We only insert AllocSpill and FreeSpill when the pre-allocated - * spill locations are not enough. - * - * AllocSpill and FreeSpill take the number of extra spill locations - * besides the pre-allocated ones. - * - * TODO(#2044051) AllocSpill/FreeSpill are currently disabled - * due to bugs. - */ - PUNT(LinearScan_AllocSpill); - insertAllocFreeSpill(trace, numSpillLocs - NumPreAllocatedSpillLocs); + PUNT(LinearScan_TooManySpills); } if (m_slots.size()) genSpillStats(trace, numSpillLocs); diff --git a/hphp/runtime/vm/translator/hopt/linearscan.h b/hphp/runtime/vm/translator/hopt/linearscan.h index ebd872744d2..d8630633244 100644 --- a/hphp/runtime/vm/translator/hopt/linearscan.h +++ b/hphp/runtime/vm/translator/hopt/linearscan.h @@ -195,12 +195,8 @@ RegAllocInfo allocRegsForTrace(Trace*, IRFactory*, LifetimeInfo* = nullptr); // +---------------+ // | return addr | // +---------------+ -// | extra | <-- spill[2] -// | spill | <-- spill[1] -// | locations | <-- spill[0] -// +---------------+ <-- %rsp -// If a spill location falls into the pre-allocated region, we -// need to increase its index by 1 to avoid overwriting the +// +// We need to increase spill indexes by 1 to avoid overwriting the // return address. /* -- 2.11.4.GIT