diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/JavaScriptCore/parser/SourceProviderCacheItem.h | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore/parser/SourceProviderCacheItem.h')
-rw-r--r-- | Source/JavaScriptCore/parser/SourceProviderCacheItem.h | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/Source/JavaScriptCore/parser/SourceProviderCacheItem.h b/Source/JavaScriptCore/parser/SourceProviderCacheItem.h index 8d35a3d27..81d221b39 100644 --- a/Source/JavaScriptCore/parser/SourceProviderCacheItem.h +++ b/Source/JavaScriptCore/parser/SourceProviderCacheItem.h @@ -27,22 +27,27 @@ #define SourceProviderCacheItem_h #include "ParserTokens.h" -#include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> +#include <wtf/text/UniquedStringImpl.h> #include <wtf/text/WTFString.h> namespace JSC { struct SourceProviderCacheItemCreationParameters { - unsigned functionStart; - unsigned closeBraceLine; - unsigned closeBraceOffset; - unsigned closeBraceLineStartOffset; + unsigned functionNameStart; + unsigned lastTockenLine; + unsigned lastTockenStartOffset; + unsigned lastTockenEndOffset; + unsigned lastTockenLineStartOffset; + unsigned endFunctionOffset; + unsigned parameterCount; bool needsFullActivation; bool usesEval; bool strictMode; - Vector<RefPtr<StringImpl> > usedVariables; - Vector<RefPtr<StringImpl> > writtenVariables; + Vector<RefPtr<UniquedStringImpl>> usedVariables; + Vector<RefPtr<UniquedStringImpl>> writtenVariables; + bool isBodyArrowExpression { false }; + JSTokenType tokenType { CLOSEBRACE }; }; #if COMPILER(MSVC) @@ -53,43 +58,49 @@ struct SourceProviderCacheItemCreationParameters { class SourceProviderCacheItem { WTF_MAKE_FAST_ALLOCATED; public: - static PassOwnPtr<SourceProviderCacheItem> create(const SourceProviderCacheItemCreationParameters&); + static std::unique_ptr<SourceProviderCacheItem> create(const SourceProviderCacheItemCreationParameters&); ~SourceProviderCacheItem(); - JSToken closeBraceToken() const + JSToken endFunctionToken() const { JSToken token; - token.m_type = CLOSEBRACE; - token.m_data.offset = closeBraceOffset; - token.m_location.startOffset = closeBraceOffset; - token.m_location.endOffset = closeBraceOffset + 1; - token.m_location.line = closeBraceLine; - token.m_location.lineStartOffset = closeBraceLineStartOffset; + token.m_type = isBodyArrowExpression ? tokenType : CLOSEBRACE; + token.m_data.offset = lastTockenStartOffset; + token.m_location.startOffset = lastTockenStartOffset; + token.m_location.endOffset = lastTockenEndOffset; + token.m_location.line = lastTockenLine; + token.m_location.lineStartOffset = lastTockenLineStartOffset; // token.m_location.sourceOffset is initialized once by the client. So, // we do not need to set it here. return token; } - unsigned functionStart : 31; + unsigned functionNameStart : 31; bool needsFullActivation : 1; + + unsigned endFunctionOffset : 31; + unsigned lastTockenLine : 31; + unsigned lastTockenStartOffset : 31; + unsigned lastTockenEndOffset: 31; + unsigned parameterCount; - unsigned closeBraceLine : 31; bool usesEval : 1; - unsigned closeBraceOffset : 31; bool strictMode : 1; - unsigned closeBraceLineStartOffset; + unsigned lastTockenLineStartOffset; unsigned usedVariablesCount; unsigned writtenVariablesCount; - StringImpl** usedVariables() const { return const_cast<StringImpl**>(m_variables); } - StringImpl** writtenVariables() const { return const_cast<StringImpl**>(&m_variables[usedVariablesCount]); } + UniquedStringImpl** usedVariables() const { return const_cast<UniquedStringImpl**>(m_variables); } + UniquedStringImpl** writtenVariables() const { return const_cast<UniquedStringImpl**>(&m_variables[usedVariablesCount]); } + bool isBodyArrowExpression; + JSTokenType tokenType; private: SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters&); - StringImpl* m_variables[0]; + UniquedStringImpl* m_variables[0]; }; inline SourceProviderCacheItem::~SourceProviderCacheItem() @@ -98,24 +109,29 @@ inline SourceProviderCacheItem::~SourceProviderCacheItem() m_variables[i]->deref(); } -inline PassOwnPtr<SourceProviderCacheItem> SourceProviderCacheItem::create(const SourceProviderCacheItemCreationParameters& parameters) +inline std::unique_ptr<SourceProviderCacheItem> SourceProviderCacheItem::create(const SourceProviderCacheItemCreationParameters& parameters) { size_t variableCount = parameters.writtenVariables.size() + parameters.usedVariables.size(); - size_t objectSize = sizeof(SourceProviderCacheItem) + sizeof(StringImpl*) * variableCount; + size_t objectSize = sizeof(SourceProviderCacheItem) + sizeof(UniquedStringImpl*) * variableCount; void* slot = fastMalloc(objectSize); - return adoptPtr(new (slot) SourceProviderCacheItem(parameters)); + return std::unique_ptr<SourceProviderCacheItem>(new (slot) SourceProviderCacheItem(parameters)); } inline SourceProviderCacheItem::SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters& parameters) - : functionStart(parameters.functionStart) + : functionNameStart(parameters.functionNameStart) , needsFullActivation(parameters.needsFullActivation) - , closeBraceLine(parameters.closeBraceLine) + , endFunctionOffset(parameters.endFunctionOffset) + , lastTockenLine(parameters.lastTockenLine) + , lastTockenStartOffset(parameters.lastTockenStartOffset) + , lastTockenEndOffset(parameters.lastTockenEndOffset) + , parameterCount(parameters.parameterCount) , usesEval(parameters.usesEval) - , closeBraceOffset(parameters.closeBraceOffset) , strictMode(parameters.strictMode) - , closeBraceLineStartOffset(parameters.closeBraceLineStartOffset) + , lastTockenLineStartOffset(parameters.lastTockenLineStartOffset) , usedVariablesCount(parameters.usedVariables.size()) , writtenVariablesCount(parameters.writtenVariables.size()) + , isBodyArrowExpression(parameters.isBodyArrowExpression) + , tokenType(parameters.tokenType) { unsigned j = 0; for (unsigned i = 0; i < usedVariablesCount; ++i, ++j) { |