ResolveOperation.h [plain text]
#ifndef ResolveOperation_h
#define ResolveOperation_h
#include "PropertyOffset.h"
#include "WriteBarrier.h"
#include <wtf/Vector.h>
namespace JSC {
class Structure;
struct ResolveOperation {
typedef enum {
Fail,
SetBaseToUndefined,
ReturnScopeAsBase,
SetBaseToScope,
SetBaseToGlobal,
GetAndReturnScopedVar,
GetAndReturnGlobalVar,
GetAndReturnGlobalVarWatchable,
SkipTopScopeNode,
SkipScopes,
ReturnGlobalObjectAsBase,
GetAndReturnGlobalProperty,
CheckForDynamicEntriesBeforeGlobalScope
} ResolveOperationType;
ResolveOperationType m_operation;
WriteBarrier<Structure> m_structure;
union {
PropertyOffset m_offset;
WriteBarrier<Unknown>* m_registerAddress;
int m_scopesToSkip;
int m_activationRegister;
};
static ResolveOperation getAndReturnScopedVar(PropertyOffset offset)
{
ResolveOperation op;
op.m_operation = GetAndReturnScopedVar;
op.m_offset = offset;
return op;
}
static ResolveOperation checkForDynamicEntriesBeforeGlobalScope()
{
ResolveOperation op;
op.m_operation = CheckForDynamicEntriesBeforeGlobalScope;
return op;
}
static ResolveOperation getAndReturnGlobalVar(WriteBarrier<Unknown>* registerAddress, bool couldBeWatched)
{
ResolveOperation op;
op.m_operation = couldBeWatched ? GetAndReturnGlobalVarWatchable : GetAndReturnGlobalVar;
op.m_registerAddress = registerAddress;
return op;
}
static ResolveOperation getAndReturnGlobalProperty()
{
ResolveOperation op;
op.m_operation = GetAndReturnGlobalProperty;
return op;
}
static ResolveOperation resolveFail()
{
ResolveOperation op;
op.m_operation = Fail;
return op;
}
static ResolveOperation skipTopScopeNode(int activationRegister)
{
ResolveOperation op;
op.m_operation = SkipTopScopeNode;
op.m_activationRegister = activationRegister;
return op;
}
static ResolveOperation skipScopes(int scopesToSkip)
{
ResolveOperation op;
op.m_operation = SkipScopes;
op.m_scopesToSkip = scopesToSkip;
return op;
}
static ResolveOperation returnGlobalObjectAsBase()
{
ResolveOperation op;
op.m_operation = ReturnGlobalObjectAsBase;
return op;
}
static ResolveOperation setBaseToGlobal()
{
ResolveOperation op;
op.m_operation = SetBaseToGlobal;
return op;
}
static ResolveOperation setBaseToUndefined()
{
ResolveOperation op;
op.m_operation = SetBaseToUndefined;
return op;
}
static ResolveOperation setBaseToScope()
{
ResolveOperation op;
op.m_operation = SetBaseToScope;
return op;
}
static ResolveOperation returnScopeAsBase()
{
ResolveOperation op;
op.m_operation = ReturnScopeAsBase;
return op;
}
};
typedef Vector<ResolveOperation> ResolveOperations;
struct PutToBaseOperation {
PutToBaseOperation(bool isStrict)
: m_kind(Uninitialised)
, m_isDynamic(false)
, m_isStrict(isStrict)
, m_predicatePointer(0)
{
}
enum Kind { Uninitialised, Generic, Readonly, GlobalVariablePut, GlobalVariablePutChecked, GlobalPropertyPut, VariablePut };
union {
Kind m_kind : 8;
uint8_t m_kindAsUint8;
};
bool m_isDynamic : 8;
bool m_isStrict : 8;
union {
bool* m_predicatePointer;
unsigned m_scopeDepth;
};
WriteBarrier<Structure> m_structure;
union {
WriteBarrier<Unknown>* m_registerAddress;
struct {
PropertyOffset m_offset;
int32_t m_offsetInButterfly;
};
};
};
}
#endif // ResolveOperation_h