#include "config.h"
#include "B3Effects.h"
#if ENABLE(B3_JIT)
#include <wtf/CommaPrinter.h>
#include <wtf/DataLog.h>
namespace JSC { namespace B3 {
namespace {
bool interferesWithTerminal(const Effects& terminal, const Effects& other)
{
if (!terminal.terminal)
return false;
return other.terminal || other.controlDependent || other.writesLocalState || other.writes;
}
bool interferesWithExitSideways(const Effects& exitsSideways, const Effects& other)
{
if (!exitsSideways.exitsSideways)
return false;
return other.controlDependent || other.writes;
}
bool interferesWithWritesLocalState(const Effects& writesLocalState, const Effects& other)
{
if (!writesLocalState.writesLocalState)
return false;
return other.writesLocalState || other.readsLocalState;
}
}
bool Effects::interferes(const Effects& other) const
{
if (interferesWithTerminal(*this, other) || interferesWithTerminal(other, *this))
return true;
if (interferesWithExitSideways(*this, other) || interferesWithExitSideways(other, *this))
return true;
if (interferesWithWritesLocalState(*this, other) || interferesWithWritesLocalState(other, *this))
return true;
return writes.overlaps(other.writes)
|| writes.overlaps(other.reads)
|| reads.overlaps(other.writes);
}
void Effects::dump(PrintStream& out) const
{
CommaPrinter comma("|");
if (terminal)
out.print(comma, "Terminal");
if (exitsSideways)
out.print(comma, "ExitsSideways");
if (controlDependent)
out.print(comma, "ControlDependent");
if (writesLocalState)
out.print(comma, "WritesLocalState");
if (readsLocalState)
out.print(comma, "ReadsLocalState");
if (writes)
out.print(comma, "Writes:", writes);
if (reads)
out.print(comma, "Reads:", reads);
}
} }
#endif // ENABLE(B3_JIT)