summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/CodeCache.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/CodeCache.h
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/CodeCache.h')
-rw-r--r--Source/JavaScriptCore/runtime/CodeCache.h56
1 files changed, 21 insertions, 35 deletions
diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h
index af7dac7e4..f3ff7478d 100644
--- a/Source/JavaScriptCore/runtime/CodeCache.h
+++ b/Source/JavaScriptCore/runtime/CodeCache.h
@@ -30,20 +30,19 @@
#include "ParserModes.h"
#include "SourceCode.h"
#include "Strong.h"
-#include "VariableEnvironment.h"
#include "WeakRandom.h"
#include <wtf/CurrentTime.h>
#include <wtf/Forward.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/RandomNumber.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class EvalExecutable;
-class FunctionMetadataNode;
+class FunctionBodyNode;
class Identifier;
class JSScope;
-class ParserError;
class ProgramExecutable;
class UnlinkedCodeBlock;
class UnlinkedEvalCodeBlock;
@@ -51,6 +50,7 @@ class UnlinkedFunctionCodeBlock;
class UnlinkedFunctionExecutable;
class UnlinkedProgramCodeBlock;
class VM;
+struct ParserError;
class SourceCode;
class SourceProvider;
@@ -62,15 +62,10 @@ public:
{
}
- SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserBuiltinMode builtinMode,
- JSParserStrictMode strictMode, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded)
+ SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserStrictness jsParserStrictness)
: m_sourceCode(sourceCode)
, m_name(name)
- , m_flags(
- (static_cast<unsigned>(codeType) << 3)
- | (static_cast<unsigned>(builtinMode) << 2)
- | (static_cast<unsigned>(strictMode) << 1)
- | static_cast<unsigned>(thisTDZMode))
+ , m_flags((codeType << 1) | jsParserStrictness)
, m_hash(string().impl()->hash())
{
}
@@ -150,15 +145,18 @@ public:
{
}
- SourceCodeValue* findCacheAndUpdateAge(const SourceCodeKey& key)
+ AddResult add(const SourceCodeKey& key, const SourceCodeValue& value)
{
prune();
- iterator findResult = m_map.find(key);
- if (findResult == m_map.end())
- return nullptr;
+ AddResult addResult = m_map.add(key, value);
+ if (addResult.isNewEntry) {
+ m_size += key.length();
+ m_age += key.length();
+ return addResult;
+ }
- int64_t age = m_age - findResult->value.age;
+ int64_t age = m_age - addResult.iterator->value.age;
if (age > m_capacity) {
// A requested object is older than the cache's capacity. We can
// infer that requested objects are subject to high eviction probability,
@@ -173,20 +171,7 @@ public:
m_capacity = m_minCapacity;
}
- findResult->value.age = m_age;
- m_age += key.length();
-
- return &findResult->value;
- }
-
- AddResult addCache(const SourceCodeKey& key, const SourceCodeValue& value)
- {
- prune();
-
- AddResult addResult = m_map.add(key, value);
- ASSERT(addResult.isNewEntry);
-
- m_size += key.length();
+ addResult.iterator->value.age = m_age;
m_age += key.length();
return addResult;
}
@@ -250,14 +235,13 @@ private:
// Caches top-level code such as <script>, eval(), new Function, and JSEvaluateScript().
class CodeCache {
- WTF_MAKE_FAST_ALLOCATED;
public:
- CodeCache();
- ~CodeCache();
+ static PassOwnPtr<CodeCache> create() { return adoptPtr(new CodeCache); }
- UnlinkedProgramCodeBlock* getProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, DebuggerMode, ProfilerMode, ParserError&);
- UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
+ UnlinkedProgramCodeBlock* getProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);
+ UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);
UnlinkedFunctionExecutable* getFunctionExecutableFromGlobalCode(VM&, const Identifier&, const SourceCode&, ParserError&);
+ ~CodeCache();
void clear()
{
@@ -265,8 +249,10 @@ public:
}
private:
+ CodeCache();
+
template <class UnlinkedCodeBlockType, class ExecutableType>
- UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
+ UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);
CodeCacheMap m_sourceCode;
};