Changeset 192935 in webkit for trunk/Source/JavaScriptCore/runtime/CodeCache.h
- Timestamp:
- Dec 1, 2015, 5:37:19 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r192914 r192935 30 30 #include "ParserModes.h" 31 31 #include "SourceCode.h" 32 #include "SourceCodeKey.h"33 32 #include "Strong.h" 34 33 #include "VariableEnvironment.h" … … 58 57 class SourceProvider; 59 58 59 class SourceCodeKey { 60 public: 61 enum CodeType { EvalType, ProgramType, FunctionType, ModuleType }; 62 63 SourceCodeKey() 64 { 65 } 66 67 SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserBuiltinMode builtinMode, 68 JSParserStrictMode strictMode, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded) 69 : m_sourceCode(sourceCode) 70 , m_name(name) 71 , m_flags( 72 (static_cast<unsigned>(codeType) << 3) 73 | (static_cast<unsigned>(builtinMode) << 2) 74 | (static_cast<unsigned>(strictMode) << 1) 75 | static_cast<unsigned>(thisTDZMode)) 76 , m_hash(string().impl()->hash()) 77 { 78 } 79 80 SourceCodeKey(WTF::HashTableDeletedValueType) 81 : m_sourceCode(WTF::HashTableDeletedValue) 82 { 83 } 84 85 bool isHashTableDeletedValue() const { return m_sourceCode.isHashTableDeletedValue(); } 86 87 unsigned hash() const { return m_hash; } 88 89 size_t length() const { return m_sourceCode.length(); } 90 91 bool isNull() const { return m_sourceCode.isNull(); } 92 93 // To save memory, we compute our string on demand. It's expected that source 94 // providers cache their strings to make this efficient. 95 String string() const { return m_sourceCode.toString(); } 96 97 bool operator==(const SourceCodeKey& other) const 98 { 99 return m_hash == other.m_hash 100 && length() == other.length() 101 && m_flags == other.m_flags 102 && m_name == other.m_name 103 && string() == other.string(); 104 } 105 106 private: 107 SourceCode m_sourceCode; 108 String m_name; 109 unsigned m_flags; 110 unsigned m_hash; 111 }; 112 113 struct SourceCodeKeyHash { 114 static unsigned hash(const SourceCodeKey& key) { return key.hash(); } 115 static bool equal(const SourceCodeKey& a, const SourceCodeKey& b) { return a == b; } 116 static const bool safeToCompareToEmptyOrDeleted = false; 117 }; 118 119 struct SourceCodeKeyHashTraits : SimpleClassHashTraits<SourceCodeKey> { 120 static const bool hasIsEmptyValueFunction = true; 121 static bool isEmptyValue(const SourceCodeKey& sourceCodeKey) { return sourceCodeKey.isNull(); } 122 }; 123 60 124 struct SourceCodeValue { 61 125 SourceCodeValue()
Note:
See TracChangeset
for help on using the changeset viewer.