ModuleNamespaceAccessCase.cpp [plain text]
#include "config.h"
#include "ModuleNamespaceAccessCase.h"
#if ENABLE(JIT)
#include "CCallHelpers.h"
#include "HeapInlines.h"
#include "JSModuleEnvironment.h"
#include "JSModuleNamespaceObject.h"
#include "PolymorphicAccess.h"
#include "StructureStubInfo.h"
namespace JSC {
ModuleNamespaceAccessCase::ModuleNamespaceAccessCase(VM& vm, JSCell* owner, JSModuleNamespaceObject* moduleNamespaceObject, JSModuleEnvironment* moduleEnvironment, ScopeOffset scopeOffset)
: Base(vm, owner, ModuleNamespaceLoad, invalidOffset, nullptr, ObjectPropertyConditionSet(), nullptr)
, m_scopeOffset(scopeOffset)
{
m_moduleNamespaceObject.set(vm, owner, moduleNamespaceObject);
m_moduleEnvironment.set(vm, owner, moduleEnvironment);
}
std::unique_ptr<AccessCase> ModuleNamespaceAccessCase::create(VM& vm, JSCell* owner, JSModuleNamespaceObject* moduleNamespaceObject, JSModuleEnvironment* moduleEnvironment, ScopeOffset scopeOffset)
{
return std::unique_ptr<AccessCase>(new ModuleNamespaceAccessCase(vm, owner, moduleNamespaceObject, moduleEnvironment, scopeOffset));
}
ModuleNamespaceAccessCase::~ModuleNamespaceAccessCase()
{
}
std::unique_ptr<AccessCase> ModuleNamespaceAccessCase::clone() const
{
std::unique_ptr<ModuleNamespaceAccessCase> result(new ModuleNamespaceAccessCase(*this));
result->resetState();
return WTFMove(result);
}
void ModuleNamespaceAccessCase::emit(AccessGenerationState& state, MacroAssembler::JumpList& fallThrough)
{
CCallHelpers& jit = *state.jit;
JSValueRegs valueRegs = state.valueRegs;
GPRReg baseGPR = state.baseGPR;
fallThrough.append(
jit.branchPtr(
CCallHelpers::NotEqual,
baseGPR,
CCallHelpers::TrustedImmPtr(m_moduleNamespaceObject.get())));
jit.loadValue(&m_moduleEnvironment->variableAt(m_scopeOffset), valueRegs);
state.failAndIgnore.append(jit.branchIfEmpty(valueRegs));
state.succeed();
}
}
#endif // ENABLE(JIT)