#if ENABLE(DFG_JIT)
-#include <dfg/DFGNode.h>
+#include <dfg/DFGCommon.h>
namespace JSC { namespace DFG {
{
}
+ // Attempt to allocate a register - this function finds an unlocked
+ // register, locks it, and returns it. If none can be found, this
+ // returns -1 (InvalidGPRReg or InvalidFPRReg).
+ RegID tryAllocate()
+ {
+ VirtualRegister ignored;
+
+ for (uint32_t i = m_lastAllocated + 1; i < NUM_REGS; ++i) {
+ if (!m_data[i].lockCount && m_data[i].name == InvalidVirtualRegister)
+ return allocateInternal(i, ignored);
+ }
+ // Loop over the remaining entries.
+ for (uint32_t i = 0; i <= m_lastAllocated; ++i) {
+ if (!m_data[i].lockCount && m_data[i].name == InvalidVirtualRegister)
+ return allocateInternal(i, ignored);
+ }
+
+ return (RegID)-1;
+ }
+
// Allocate a register - this function finds an unlocked register,
// locks it, and returns it. If any named registers exist, one
// of these should be selected to be allocated. If all unlocked
return allocateInternal(currentLowest, spillMe);
}
+ // Allocates the given register, even if this will force a spill.
+ VirtualRegister allocateSpecific(RegID reg)
+ {
+ unsigned index = BankInfo::toIndex(reg);
+
+ ++m_data[index].lockCount;
+ VirtualRegister name = nameAtIndex(index);
+ if (name != InvalidVirtualRegister)
+ releaseAtIndex(index);
+
+ return name;
+ }
+
// retain/release - these methods are used to associate/disassociate names
// with values in registers. retain should only be called on locked registers.
void retain(RegID reg, VirtualRegister name, SpillHint spillOrder)
// For each register, print the VirtualRegister 'name'.
for (uint32_t i =0; i < NUM_REGS; ++i) {
if (m_data[i].name != InvalidVirtualRegister)
- fprintf(stderr, "[%02d]", m_data[i].name);
+ dataLog("[%02d]", m_data[i].name);
else
- fprintf(stderr, "[--]");
+ dataLog("[--]");
}
- fprintf(stderr, "\n");
+ dataLog("\n");
}
#endif