BytecodeIntrinsicRegistry.cpp [plain text]
#include "config.h"
#include "BytecodeIntrinsicRegistry.h"
#include "ArrayIteratorPrototype.h"
#include "BuiltinNames.h"
#include "BytecodeGenerator.h"
#include "IterationKind.h"
#include "JSCJSValueInlines.h"
#include "JSGeneratorFunction.h"
#include "JSGlobalObject.h"
#include "JSModuleLoader.h"
#include "JSPromise.h"
#include "Nodes.h"
#include "StrongInlines.h"
namespace JSC {
#define INITIALIZE_BYTECODE_INTRINSIC_NAMES_TO_SET(name) m_bytecodeIntrinsicMap.add(vm.propertyNames->builtinNames().name##PrivateName().impl(), &BytecodeIntrinsicNode::emit_intrinsic_##name);
BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry(VM& vm)
: m_vm(vm)
, m_bytecodeIntrinsicMap()
{
JSC_COMMON_BYTECODE_INTRINSIC_FUNCTIONS_EACH_NAME(INITIALIZE_BYTECODE_INTRINSIC_NAMES_TO_SET)
JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(INITIALIZE_BYTECODE_INTRINSIC_NAMES_TO_SET)
m_undefined.set(m_vm, jsUndefined());
m_Infinity.set(m_vm, jsDoubleNumber(std::numeric_limits<double>::infinity()));
m_iterationKindKey.set(m_vm, jsNumber(IterateKey));
m_iterationKindValue.set(m_vm, jsNumber(IterateValue));
m_iterationKindKeyValue.set(m_vm, jsNumber(IterateKeyValue));
m_MAX_ARRAY_INDEX.set(m_vm, jsNumber(MAX_ARRAY_INDEX));
m_MAX_STRING_LENGTH.set(m_vm, jsNumber(JSString::MaxLength));
m_MAX_SAFE_INTEGER.set(m_vm, jsDoubleNumber(maxSafeInteger()));
m_ModuleFetch.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Fetch)));
m_ModuleInstantiate.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Instantiate)));
m_ModuleSatisfy.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Satisfy)));
m_ModuleLink.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Link)));
m_ModuleReady.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Ready)));
m_promiseRejectionReject.set(m_vm, jsNumber(static_cast<unsigned>(JSPromiseRejectionOperation::Reject)));
m_promiseRejectionHandle.set(m_vm, jsNumber(static_cast<unsigned>(JSPromiseRejectionOperation::Handle)));
m_promiseStatePending.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)));
m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)));
m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)));
m_GeneratorResumeModeNormal.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorResumeMode::NormalMode)));
m_GeneratorResumeModeThrow.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorResumeMode::ThrowMode)));
m_GeneratorResumeModeReturn.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorResumeMode::ReturnMode)));
m_GeneratorStateCompleted.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorState::Completed)));
m_GeneratorStateExecuting.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorState::Executing)));
}
BytecodeIntrinsicNode::EmitterType BytecodeIntrinsicRegistry::lookup(const Identifier& ident) const
{
if (!m_vm.propertyNames->isPrivateName(ident))
return nullptr;
auto iterator = m_bytecodeIntrinsicMap.find(ident.impl());
if (iterator == m_bytecodeIntrinsicMap.end())
return nullptr;
return iterator->value;
}
#define JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS(name) \
JSValue BytecodeIntrinsicRegistry::name##Value(BytecodeGenerator&) \
{ \
return m_##name.get(); \
}
JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS)
#undef JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS
}