From de4f791e30be4e4239b381c11745ffa4d87ddb8b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 9 Nov 2012 12:15:52 +0100 Subject: Imported WebKit commit e2c32e2f53e02d388e70b9db88b91d8d9d28fc84 (http://svn.webkit.org/repository/webkit/trunk@133952) Revert back to an older snapshot that should build on ARM --- Source/JavaScriptCore/runtime/CodeCache.h | 50 +++++-------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) (limited to 'Source/JavaScriptCore/runtime/CodeCache.h') diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h index 740aaa6df..4d4617189 100644 --- a/Source/JavaScriptCore/runtime/CodeCache.h +++ b/Source/JavaScriptCore/runtime/CodeCache.h @@ -34,7 +34,6 @@ #include #include #include -#include #include namespace JSC { @@ -52,41 +51,6 @@ struct ParserError; class SourceCode; class SourceProvider; -template class Thingy { - typedef typename HashMap::iterator iterator; -public: - Thingy() - : m_randomGenerator((static_cast(randomNumber() * UINT32_MAX))) - { - } - const EntryType* find(const KeyType& key) - { - iterator result = m_map.find(key); - if (result == m_map.end()) - return 0; - return &m_data[result->value].second; - } - void add(const KeyType& key, const EntryType& value) - { - iterator result = m_map.find(key); - if (result != m_map.end()) { - m_data[result->value].second = value; - return; - } - size_t newIndex = m_randomGenerator.getUint32() % CacheSize; - if (m_data[newIndex].second) - m_map.remove(m_data[newIndex].first); - m_map.add(key, newIndex); - m_data[newIndex].first = key; - m_data[newIndex].second = value; - ASSERT(m_map.size() <= CacheSize); - } -private: - HashMap m_map; - FixedArray, CacheSize> m_data; - WeakRandom m_randomGenerator; -}; - class CodeCache { public: static PassOwnPtr create() { return adoptPtr(new CodeCache); } @@ -95,12 +59,13 @@ public: UnlinkedEvalCodeBlock* getEvalCodeBlock(JSGlobalData&, EvalExecutable*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&); UnlinkedFunctionCodeBlock* getFunctionCodeBlock(JSGlobalData&, UnlinkedFunctionExecutable*, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, ParserError&); UnlinkedFunctionExecutable* getFunctionExecutableFromGlobalCode(JSGlobalData&, const Identifier&, const SourceCode&, ParserError&); - void usedFunctionCode(JSGlobalData&, UnlinkedFunctionCodeBlock*); ~CodeCache(); enum CodeType { EvalType, ProgramType, FunctionType }; typedef std::pair CodeBlockKey; + typedef HashMap CodeBlockIndicesMap; typedef std::pair GlobalFunctionKey; + typedef HashMap GlobalFunctionIndicesMap; private: CodeCache(); @@ -109,17 +74,18 @@ private: template inline UnlinkedCodeBlockType* getCodeBlock(JSGlobalData&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&); CodeBlockKey makeCodeBlockKey(const SourceCode&, CodeType, JSParserStrictness); + CodeBlockIndicesMap m_cachedCodeBlockIndices; GlobalFunctionKey makeGlobalFunctionKey(const SourceCode&, const String&); + GlobalFunctionIndicesMap m_cachedGlobalFunctionIndices; enum { kMaxCodeBlockEntries = 1024, - kMaxGlobalFunctionEntries = 1024, - kMaxFunctionCodeBlocks = 1024 + kMaxGlobalFunctionEntries = 1024 }; - Thingy, kMaxCodeBlockEntries> m_cachedCodeBlocks; - Thingy, kMaxGlobalFunctionEntries> m_cachedGlobalFunctions; - Thingy, kMaxFunctionCodeBlocks> m_cachedFunctionCode; + FixedArray >, kMaxCodeBlockEntries> m_cachedCodeBlocks; + FixedArray >, kMaxGlobalFunctionEntries> m_cachedGlobalFunctions; + WeakRandom m_randomGenerator; }; } -- cgit v1.2.1