JITStubRoutineSet.cpp [plain text]
#include "config.h"
#include "JITStubRoutineSet.h"
#if ENABLE(JIT)
#include "GCAwareJITStubRoutine.h"
#include "SlotVisitor.h"
namespace JSC {
JITStubRoutineSet::JITStubRoutineSet() { }
JITStubRoutineSet::~JITStubRoutineSet()
{
for (size_t i = m_listOfRoutines.size(); i--;) {
GCAwareJITStubRoutine* routine = m_listOfRoutines[i];
routine->m_mayBeExecuting = false;
if (!routine->m_isJettisoned) {
routine->m_isJettisoned = true;
continue;
}
routine->deleteFromGC();
}
}
void JITStubRoutineSet::add(GCAwareJITStubRoutine* routine)
{
ASSERT(!routine->m_isJettisoned);
m_listOfRoutines.append(routine);
uintptr_t start = routine->startAddress();
uintptr_t end = routine->endAddress();
uintptr_t step = JITStubRoutine::addressStep();
for (uintptr_t iter = start; iter < end; iter += step) {
ASSERT(m_addressToRoutineMap.find(iter) == m_addressToRoutineMap.end());
m_addressToRoutineMap.add(iter, routine);
}
}
void JITStubRoutineSet::clearMarks()
{
for (size_t i = m_listOfRoutines.size(); i--;)
m_listOfRoutines[i]->m_mayBeExecuting = false;
}
void JITStubRoutineSet::markSlow(uintptr_t address)
{
HashMap<uintptr_t, GCAwareJITStubRoutine*>::iterator iter =
m_addressToRoutineMap.find(address & ~(JITStubRoutine::addressStep() - 1));
if (iter == m_addressToRoutineMap.end())
return;
iter->value->m_mayBeExecuting = true;
}
void JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines()
{
for (size_t i = 0; i < m_listOfRoutines.size(); i++) {
GCAwareJITStubRoutine* routine = m_listOfRoutines[i];
if (!routine->m_isJettisoned || routine->m_mayBeExecuting)
continue;
uintptr_t start = routine->startAddress();
uintptr_t end = routine->endAddress();
uintptr_t step = JITStubRoutine::addressStep();
for (uintptr_t iter = start; iter < end; iter += step) {
ASSERT(m_addressToRoutineMap.find(iter) != m_addressToRoutineMap.end());
ASSERT(m_addressToRoutineMap.find(iter)->value == routine);
m_addressToRoutineMap.remove(iter);
}
routine->deleteFromGC();
m_listOfRoutines[i] = m_listOfRoutines.last();
m_listOfRoutines.removeLast();
i--;
}
}
void JITStubRoutineSet::traceMarkedStubRoutines(SlotVisitor& visitor)
{
for (size_t i = m_listOfRoutines.size(); i--;) {
GCAwareJITStubRoutine* routine = m_listOfRoutines[i];
if (!routine->m_mayBeExecuting)
continue;
routine->markRequiredObjects(visitor);
}
}
}
#endif // ENABLE(JIT)