StructureStubClearingWatchpoint.cpp [plain text]
#include "config.h"
#include "StructureStubClearingWatchpoint.h"
#if ENABLE(JIT)
#include "CodeBlock.h"
#include "JSCInlines.h"
#include "StructureStubInfo.h"
namespace JSC {
StructureStubClearingWatchpoint::~StructureStubClearingWatchpoint()
{
for (auto current = WTFMove(m_next); current; current = WTFMove(current->m_next)) { }
}
StructureStubClearingWatchpoint* StructureStubClearingWatchpoint::push(
const ObjectPropertyCondition& key,
WatchpointsOnStructureStubInfo& holder,
std::unique_ptr<StructureStubClearingWatchpoint>& head)
{
head = std::make_unique<StructureStubClearingWatchpoint>(key, holder, WTFMove(head));
return head.get();
}
void StructureStubClearingWatchpoint::fireInternal(const FireDetail&)
{
if (!m_key || !m_key.isWatchable(PropertyCondition::EnsureWatchability)) {
ConcurrentJSLocker locker(m_holder.codeBlock()->m_lock);
m_holder.stubInfo()->reset(m_holder.codeBlock());
return;
}
if (m_key.kind() == PropertyCondition::Presence) {
VM& vm = *Heap::heap(m_key.object())->vm();
m_key.object()->structure()->startWatchingPropertyForReplacements(vm, m_key.offset());
}
m_key.object()->structure()->addTransitionWatchpoint(this);
}
WatchpointsOnStructureStubInfo::~WatchpointsOnStructureStubInfo()
{
}
StructureStubClearingWatchpoint* WatchpointsOnStructureStubInfo::addWatchpoint(const ObjectPropertyCondition& key)
{
return StructureStubClearingWatchpoint::push(key, *this, m_head);
}
StructureStubClearingWatchpoint* WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint(
std::unique_ptr<WatchpointsOnStructureStubInfo>& holderRef, CodeBlock* codeBlock,
StructureStubInfo* stubInfo, const ObjectPropertyCondition& key)
{
if (!holderRef)
holderRef = std::make_unique<WatchpointsOnStructureStubInfo>(codeBlock, stubInfo);
else {
ASSERT(holderRef->m_codeBlock == codeBlock);
ASSERT(holderRef->m_stubInfo == stubInfo);
}
return holderRef->addWatchpoint(key);
}
}
#endif // ENABLE(JIT)