summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/CodeCache.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-11-09 12:15:52 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-11-09 12:16:06 +0100
commitde4f791e30be4e4239b381c11745ffa4d87ddb8b (patch)
tree885e3a5d6670828b454cf676b4d42f78e28b1f0e /Source/JavaScriptCore/runtime/CodeCache.h
parentb022df48697d40cdabdeafb2c29bb14fe489b6fe (diff)
downloadqtwebkit-de4f791e30be4e4239b381c11745ffa4d87ddb8b.tar.gz
Imported WebKit commit e2c32e2f53e02d388e70b9db88b91d8d9d28fc84 (http://svn.webkit.org/repository/webkit/trunk@133952)
Revert back to an older snapshot that should build on ARM
Diffstat (limited to 'Source/JavaScriptCore/runtime/CodeCache.h')
-rw-r--r--Source/JavaScriptCore/runtime/CodeCache.h50
1 files changed, 8 insertions, 42 deletions
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 <wtf/FixedArray.h>
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
-#include <wtf/RandomNumber.h>
#include <wtf/text/WTFString.h>
namespace JSC {
@@ -52,41 +51,6 @@ struct ParserError;
class SourceCode;
class SourceProvider;
-template <typename KeyType, typename EntryType, int CacheSize> class Thingy {
- typedef typename HashMap<KeyType, unsigned>::iterator iterator;
-public:
- Thingy()
- : m_randomGenerator((static_cast<uint32_t>(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<KeyType, unsigned> m_map;
- FixedArray<std::pair<KeyType, EntryType>, CacheSize> m_data;
- WeakRandom m_randomGenerator;
-};
-
class CodeCache {
public:
static PassOwnPtr<CodeCache> 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<String, unsigned> CodeBlockKey;
+ typedef HashMap<CodeBlockKey, unsigned> CodeBlockIndicesMap;
typedef std::pair<String, String> GlobalFunctionKey;
+ typedef HashMap<GlobalFunctionKey, unsigned> GlobalFunctionIndicesMap;
private:
CodeCache();
@@ -109,17 +74,18 @@ private:
template <class UnlinkedCodeBlockType, class ExecutableType> 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<CodeBlockKey, Strong<UnlinkedCodeBlock>, kMaxCodeBlockEntries> m_cachedCodeBlocks;
- Thingy<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable>, kMaxGlobalFunctionEntries> m_cachedGlobalFunctions;
- Thingy<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_cachedFunctionCode;
+ FixedArray<std::pair<CodeBlockKey, Strong<UnlinkedCodeBlock> >, kMaxCodeBlockEntries> m_cachedCodeBlocks;
+ FixedArray<std::pair<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable> >, kMaxGlobalFunctionEntries> m_cachedGlobalFunctions;
+ WeakRandom m_randomGenerator;
};
}