DFGDesiredWriteBarriers.cpp [plain text]
#include "config.h"
#include "DFGDesiredWriteBarriers.h"
#if ENABLE(DFG_JIT)
#include "CodeBlock.h"
#include "JSCInlines.h"
namespace JSC { namespace DFG {
DesiredWriteBarrier::DesiredWriteBarrier(Type type, CodeBlock* codeBlock, unsigned index, JSCell* owner)
: m_owner(owner)
, m_type(type)
, m_codeBlock(codeBlock)
{
m_which.index = index;
}
DesiredWriteBarrier::DesiredWriteBarrier(Type type, CodeBlock* codeBlock, InlineCallFrame* inlineCallFrame, JSCell* owner)
: m_owner(owner)
, m_type(type)
, m_codeBlock(codeBlock)
{
m_which.inlineCallFrame = inlineCallFrame;
}
void DesiredWriteBarrier::trigger(VM& vm)
{
switch (m_type) {
case ConstantType: {
WriteBarrier<Unknown>& barrier = m_codeBlock->constants()[m_which.index];
barrier.set(vm, m_owner, barrier.get());
return;
}
case InlineCallFrameExecutableType: {
InlineCallFrame* inlineCallFrame = m_which.inlineCallFrame;
WriteBarrier<ScriptExecutable>& executable = inlineCallFrame->executable;
executable.set(vm, m_owner, executable.get());
return;
} }
RELEASE_ASSERT_NOT_REACHED();
}
void DesiredWriteBarrier::visitChildren(SlotVisitor& visitor)
{
switch (m_type) {
case ConstantType: {
WriteBarrier<Unknown>& barrier = m_codeBlock->constants()[m_which.index];
visitor.append(&barrier);
return;
}
case InlineCallFrameExecutableType: {
InlineCallFrame* inlineCallFrame = m_which.inlineCallFrame;
WriteBarrier<ScriptExecutable>& executable = inlineCallFrame->executable;
visitor.append(&executable);
return;
} }
RELEASE_ASSERT_NOT_REACHED();
}
DesiredWriteBarriers::DesiredWriteBarriers()
{
}
DesiredWriteBarriers::~DesiredWriteBarriers()
{
}
void DesiredWriteBarriers::trigger(VM& vm)
{
for (unsigned i = 0; i < m_barriers.size(); i++)
m_barriers[i].trigger(vm);
}
void DesiredWriteBarriers::visitChildren(SlotVisitor& visitor)
{
for (unsigned i = 0; i < m_barriers.size(); i++)
m_barriers[i].visitChildren(visitor);
}
} }
#endif // ENABLE(DFG_JIT)