/*
- * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2012-2019 Apple Inc. All Rights Reserved.
* Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
namespace JSC {
enum class SourceCodeType { EvalType, ProgramType, FunctionType, ModuleType };
-enum class TypeProfilerEnabled { No, Yes };
-enum class ControlFlowProfilerEnabled { No, Yes };
class SourceCodeFlags {
friend class CachedSourceCodeKey;
SourceCodeFlags(
SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode,
DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
- DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled)
+ OptionSet<CodeGenerationMode> codeGenerationMode)
: m_flags(
- (static_cast<unsigned>(debuggerMode) << 8) |
- (static_cast<unsigned>(typeProfilerEnabled) << 7) |
- (static_cast<unsigned>(controlFlowProfilerEnabled) << 6) |
+ (static_cast<unsigned>(codeGenerationMode.toRaw()) << 6) |
(static_cast<unsigned>(scriptMode) << 5) |
(static_cast<unsigned>(isArrowFunctionContext) << 4) |
(static_cast<unsigned>(evalContextType) << 3) |
SourceCodeKey(
const UnlinkedSourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,
JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
- DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled, Optional<int> functionConstructorParametersEndPosition)
+ OptionSet<CodeGenerationMode> codeGenerationMode, Optional<int> functionConstructorParametersEndPosition)
: m_sourceCode(sourceCode)
, m_name(name)
- , m_flags(codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext, debuggerMode, typeProfilerEnabled, controlFlowProfilerEnabled)
+ , m_flags(codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext, codeGenerationMode)
, m_functionConstructorParametersEndPosition(functionConstructorParametersEndPosition.valueOr(-1))
, m_hash(sourceCode.hash() ^ m_flags.bits())
{
unsigned hash() const { return m_hash; }
+ const UnlinkedSourceCode& source() const { return m_sourceCode; }
+
size_t length() const { return m_sourceCode.length(); }
bool isNull() const { return m_sourceCode.isNull(); }
// providers cache their strings to make this efficient.
StringView string() const { return m_sourceCode.view(); }
+ StringView host() const { return m_sourceCode.provider().url().host(); }
+
bool operator==(const SourceCodeKey& other) const
{
return m_hash == other.m_hash
&& m_flags == other.m_flags
&& m_functionConstructorParametersEndPosition == other.m_functionConstructorParametersEndPosition
&& m_name == other.m_name
+ && host() == other.host()
&& string() == other.string();
}
struct Hash {
static unsigned hash(const SourceCodeKey& key) { return key.hash(); }
static bool equal(const SourceCodeKey& a, const SourceCodeKey& b) { return a == b; }
- static const bool safeToCompareToEmptyOrDeleted = false;
+ static constexpr bool safeToCompareToEmptyOrDeleted = false;
};
struct HashTraits : SimpleClassHashTraits<SourceCodeKey> {
- static const bool hasIsEmptyValueFunction = true;
+ static constexpr bool hasIsEmptyValueFunction = true;
static bool isEmptyValue(const SourceCodeKey& key) { return key.isNull(); }
};