GCAwareJITStubRoutine.cpp [plain text]
#include "config.h"
#include "GCAwareJITStubRoutine.h"
#if ENABLE(JIT)
#include "Heap.h"
#include "VM.h"
#include "JSCInlines.h"
#include "SlotVisitor.h"
#include "Structure.h"
namespace JSC {
GCAwareJITStubRoutine::GCAwareJITStubRoutine(
const MacroAssemblerCodeRef& code, VM& vm)
: JITStubRoutine(code)
, m_mayBeExecuting(false)
, m_isJettisoned(false)
{
vm.heap.m_jitStubRoutines.add(this);
}
GCAwareJITStubRoutine::~GCAwareJITStubRoutine() { }
void GCAwareJITStubRoutine::observeZeroRefCount()
{
if (m_isJettisoned) {
delete this;
return;
}
RELEASE_ASSERT(!m_refCount);
m_isJettisoned = true;
}
void GCAwareJITStubRoutine::deleteFromGC()
{
ASSERT(m_isJettisoned);
ASSERT(!m_refCount);
ASSERT(!m_mayBeExecuting);
delete this;
}
void GCAwareJITStubRoutine::markRequiredObjectsInternal(SlotVisitor&)
{
}
MarkingGCAwareJITStubRoutineWithOneObject::MarkingGCAwareJITStubRoutineWithOneObject(
const MacroAssemblerCodeRef& code, VM& vm, const JSCell* owner,
JSCell* object)
: GCAwareJITStubRoutine(code, vm)
, m_object(vm, owner, object)
{
}
MarkingGCAwareJITStubRoutineWithOneObject::~MarkingGCAwareJITStubRoutineWithOneObject()
{
}
void MarkingGCAwareJITStubRoutineWithOneObject::markRequiredObjectsInternal(SlotVisitor& visitor)
{
visitor.append(&m_object);
}
PassRefPtr<JITStubRoutine> createJITStubRoutine(
const MacroAssemblerCodeRef& code,
VM& vm,
const JSCell* owner,
bool makesCalls,
JSCell* object)
{
if (!makesCalls)
return adoptRef(new JITStubRoutine(code));
if (!object) {
return static_pointer_cast<JITStubRoutine>(
adoptRef(new GCAwareJITStubRoutine(code, vm)));
}
return static_pointer_cast<JITStubRoutine>(
adoptRef(new MarkingGCAwareJITStubRoutineWithOneObject(code, vm, owner, object)));
}
}
#endif // ENABLE(JIT)