CachedSpecialPropertyAdaptiveStructureWatchpoint.cpp [plain text]
#include "config.h"
#include "CachedSpecialPropertyAdaptiveStructureWatchpoint.h"
#include "JSCellInlines.h"
#include "StructureRareData.h"
namespace JSC {
CachedSpecialPropertyAdaptiveStructureWatchpoint::CachedSpecialPropertyAdaptiveStructureWatchpoint(const ObjectPropertyCondition& key, StructureRareData* structureRareData)
: Watchpoint(Watchpoint::Type::CachedSpecialPropertyAdaptiveStructure)
, m_structureRareData(structureRareData)
, m_key(key)
{
RELEASE_ASSERT(key.watchingRequiresStructureTransitionWatchpoint());
RELEASE_ASSERT(!key.watchingRequiresReplacementWatchpoint());
}
void CachedSpecialPropertyAdaptiveStructureWatchpoint::install(VM& vm)
{
RELEASE_ASSERT(m_key.isWatchable());
m_key.object()->structure(vm)->addTransitionWatchpoint(this);
}
void CachedSpecialPropertyAdaptiveStructureWatchpoint::fireInternal(VM& vm, const FireDetail&)
{
if (!m_structureRareData->isLive())
return;
if (m_key.isWatchable(PropertyCondition::EnsureWatchability)) {
install(vm);
return;
}
CachedSpecialPropertyKey key = CachedSpecialPropertyKey::ToStringTag;
if (m_key.uid() == vm.propertyNames->toStringTagSymbol.impl())
key = CachedSpecialPropertyKey::ToStringTag;
else if (m_key.uid() == vm.propertyNames->toString.impl())
key = CachedSpecialPropertyKey::ToString;
else if (m_key.uid() == vm.propertyNames->valueOf.impl())
key = CachedSpecialPropertyKey::ValueOf;
else {
ASSERT(m_key.uid() == vm.propertyNames->toPrimitiveSymbol.impl());
key = CachedSpecialPropertyKey::ToPrimitive;
}
m_structureRareData->clearCachedSpecialProperty(key);
}
}