PolymorphicAccessStructureList.h [plain text]
#ifndef PolymorphicAccessStructureList_h
#define PolymorphicAccessStructureList_h
#include "JITStubRoutine.h"
#include "Structure.h"
#include "StructureChain.h"
#include <wtf/Platform.h>
#define POLYMORPHIC_LIST_CACHE_SIZE 8
namespace JSC {
#if ENABLE(JIT)
struct PolymorphicAccessStructureList {
WTF_MAKE_FAST_ALLOCATED;
public:
struct PolymorphicStubInfo {
bool isChain;
bool isDirect;
RefPtr<JITStubRoutine> stubRoutine;
WriteBarrier<Structure> base;
union {
WriteBarrierBase<Structure> proto;
WriteBarrierBase<StructureChain> chain;
} u;
PolymorphicStubInfo()
{
u.proto.clear();
}
void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, bool isDirect)
{
stubRoutine = _stubRoutine;
base.set(vm, owner, _base);
u.proto.clear();
isChain = false;
this->isDirect = isDirect;
}
void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, Structure* _proto, bool isDirect)
{
stubRoutine = _stubRoutine;
base.set(vm, owner, _base);
u.proto.set(vm, owner, _proto);
isChain = false;
this->isDirect = isDirect;
}
void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, StructureChain* _chain, bool isDirect)
{
stubRoutine = _stubRoutine;
base.set(vm, owner, _base);
u.chain.set(vm, owner, _chain);
isChain = true;
this->isDirect = isDirect;
}
} list[POLYMORPHIC_LIST_CACHE_SIZE];
PolymorphicAccessStructureList()
{
}
PolymorphicAccessStructureList(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> stubRoutine, Structure* firstBase, bool isDirect)
{
list[0].set(vm, owner, stubRoutine, firstBase, isDirect);
}
PolymorphicAccessStructureList(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> stubRoutine, Structure* firstBase, Structure* firstProto, bool isDirect)
{
list[0].set(vm, owner, stubRoutine, firstBase, firstProto, isDirect);
}
PolymorphicAccessStructureList(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> stubRoutine, Structure* firstBase, StructureChain* firstChain, bool isDirect)
{
list[0].set(vm, owner, stubRoutine, firstBase, firstChain, isDirect);
}
bool visitWeak(int count)
{
for (int i = 0; i < count; ++i) {
PolymorphicStubInfo& info = list[i];
if (!info.base) {
ASSERT(!info.u.proto);
continue;
}
if (!Heap::isMarked(info.base.get()))
return false;
if (info.u.proto && !info.isChain
&& !Heap::isMarked(info.u.proto.get()))
return false;
if (info.u.chain && info.isChain
&& !Heap::isMarked(info.u.chain.get()))
return false;
}
return true;
}
};
#endif // ENABLE(JIT)
}
#endif // PolymorphicAccessStructureList_h