ObjectPropertyConditionSet.h [plain text]
#pragma once
#include "ObjectPropertyCondition.h"
#include <wtf/FastMalloc.h>
#include <wtf/Vector.h>
namespace JSC {
class ObjectPropertyConditionSet {
public:
ObjectPropertyConditionSet() { }
static ObjectPropertyConditionSet invalid()
{
ObjectPropertyConditionSet result;
result.m_data = adoptRef(new Data());
return result;
}
static ObjectPropertyConditionSet create(const Vector<ObjectPropertyCondition>& vector)
{
if (vector.isEmpty())
return ObjectPropertyConditionSet();
ObjectPropertyConditionSet result;
result.m_data = adoptRef(new Data());
result.m_data->vector = vector;
return result;
}
bool isValid() const
{
return !m_data || !m_data->vector.isEmpty();
}
bool isValidAndWatchable() const;
bool isEmpty() const
{
return !m_data;
}
typedef const ObjectPropertyCondition* iterator;
iterator begin() const
{
if (!m_data)
return nullptr;
return m_data->vector.begin();
}
iterator end() const
{
if (!m_data)
return nullptr;
return m_data->vector.end();
}
ObjectPropertyCondition forObject(JSObject*) const;
ObjectPropertyCondition forConditionKind(PropertyCondition::Kind) const;
unsigned numberOfConditionsWithKind(PropertyCondition::Kind) const;
bool hasOneSlotBaseCondition() const;
ObjectPropertyCondition slotBaseCondition() const;
ObjectPropertyConditionSet mergedWith(const ObjectPropertyConditionSet& other) const;
bool structuresEnsureValidity() const;
bool structuresEnsureValidityAssumingImpurePropertyWatchpoint() const;
bool needImpurePropertyWatchpoint() const;
bool areStillLive() const;
void dumpInContext(PrintStream&, DumpContext*) const;
void dump(PrintStream&) const;
void* releaseRawPointer()
{
return static_cast<void*>(m_data.leakRef());
}
static ObjectPropertyConditionSet adoptRawPointer(void* rawPointer)
{
ObjectPropertyConditionSet result;
result.m_data = adoptRef(static_cast<Data*>(rawPointer));
return result;
}
static ObjectPropertyConditionSet fromRawPointer(void* rawPointer)
{
ObjectPropertyConditionSet result;
result.m_data = static_cast<Data*>(rawPointer);
return result;
}
class Data : public ThreadSafeRefCounted<Data> {
WTF_MAKE_NONCOPYABLE(Data);
WTF_MAKE_FAST_ALLOCATED;
public:
Data() { }
Vector<ObjectPropertyCondition> vector;
};
private:
RefPtr<Data> m_data;
};
ObjectPropertyCondition generateConditionForSelfEquivalence(
VM&, JSCell* owner, JSObject* object, UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPropertyMiss(
VM&, JSCell* owner, ExecState*, Structure* headStructure, UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPropertySetterMiss(
VM&, JSCell* owner, ExecState*, Structure* headStructure, UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPrototypePropertyHit(
VM&, JSCell* owner, ExecState*, Structure* headStructure, JSObject* prototype,
UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPrototypeEquivalenceConcurrently(
VM&, JSGlobalObject*, Structure* headStructure, JSObject* prototype,
UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPropertyMissConcurrently(
VM&, JSGlobalObject*, Structure* headStructure, UniquedStringImpl* uid);
ObjectPropertyConditionSet generateConditionsForPropertySetterMissConcurrently(
VM&, JSGlobalObject*, Structure* headStructure, UniquedStringImpl* uid);
}