ObjectAllocationProfile.h [plain text]
#pragma once
#include "VM.h"
#include "JSGlobalObject.h"
#include "ObjectPrototype.h"
#include "SlotVisitor.h"
#include "WriteBarrier.h"
namespace JSC {
class FunctionRareData;
class ObjectAllocationProfile {
friend class LLIntOffsetsExtractor;
public:
static ptrdiff_t offsetOfAllocator() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_allocator); }
static ptrdiff_t offsetOfStructure() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_structure); }
static ptrdiff_t offsetOfInlineCapacity() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_inlineCapacity); }
ObjectAllocationProfile()
: m_inlineCapacity(0)
{
}
bool isNull() { return !m_structure; }
void initializeProfile(VM&, JSGlobalObject*, JSCell* owner, JSObject* prototype, unsigned inferredInlineCapacity, JSFunction* constructor = nullptr, FunctionRareData* = nullptr);
Structure* structure()
{
Structure* structure = m_structure.get();
WTF::loadLoadFence();
return structure;
}
JSObject* prototype()
{
JSObject* prototype = m_prototype.get();
WTF::loadLoadFence();
return prototype;
}
unsigned inlineCapacity() { return m_inlineCapacity; }
void clear()
{
m_allocator = Allocator();
m_structure.clear();
m_prototype.clear();
m_inlineCapacity = 0;
ASSERT(isNull());
}
void visitAggregate(SlotVisitor& visitor)
{
visitor.append(m_structure);
visitor.append(m_prototype);
}
private:
unsigned possibleDefaultPropertyCount(VM&, JSObject* prototype);
Allocator m_allocator; WriteBarrier<Structure> m_structure;
WriteBarrier<JSObject> m_prototype;
unsigned m_inlineCapacity;
};
}