Commit be333a79 authored by antti@apple.com's avatar antti@apple.com
Browse files

REGRESSION: Leak in JSParser::Scope::copyCapturedVariablesToVector()

https://bugs.webkit.org/show_bug.cgi?id=53061
         
Reviewed by Oliver Hunt.

Cache did not know about the subclass so failed to fully delete the items. 
Got rid of the subclass and moved the classes to separate files.

* CMakeLists.txt:
* GNUmakefile.am:
* JavaScriptCore.exp:
* JavaScriptCore.gypi:
* JavaScriptCore.pro:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* parser/JSParser.cpp:
(JSC::JSParser::Scope::saveFunctionInfo):
(JSC::JSParser::Scope::restoreFunctionInfo):
(JSC::JSParser::findCachedFunctionInfo):
(JSC::JSParser::parseFunctionInfo):
* parser/SourceProvider.h:
* parser/SourceProviderCache.cpp: Added.
(JSC::SourceProviderCache::~SourceProviderCache):
(JSC::SourceProviderCache::byteSize):
* parser/SourceProviderCache.h: Added.
(JSC::SourceProviderCache::SourceProviderCache):
(JSC::SourceProviderCache::add):
(JSC::SourceProviderCache::get):
* parser/SourceProviderCacheItem.h: Added.
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
(JSC::SourceProviderCacheItem::approximateByteSize):
(JSC::SourceProviderCacheItem::closeBraceToken):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8043268f
......@@ -67,6 +67,7 @@ SET(JavaScriptCore_SOURCES
parser/Nodes.cpp
parser/Parser.cpp
parser/ParserArena.cpp
parser/SourceProviderCache.cpp
pcre/pcre_compile.cpp
pcre/pcre_exec.cpp
......
2011-01-25 Antti Koivisto <antti@apple.com>
Reviewed by Oliver Hunt.
REGRESSION: Leak in JSParser::Scope::copyCapturedVariablesToVector()
https://bugs.webkit.org/show_bug.cgi?id=53061
Cache did not know about the subclass so failed to fully delete the items.
Got rid of the subclass and moved the classes to separate files.
* CMakeLists.txt:
* GNUmakefile.am:
* JavaScriptCore.exp:
* JavaScriptCore.gypi:
* JavaScriptCore.pro:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* parser/JSParser.cpp:
(JSC::JSParser::Scope::saveFunctionInfo):
(JSC::JSParser::Scope::restoreFunctionInfo):
(JSC::JSParser::findCachedFunctionInfo):
(JSC::JSParser::parseFunctionInfo):
* parser/SourceProvider.h:
* parser/SourceProviderCache.cpp: Added.
(JSC::SourceProviderCache::~SourceProviderCache):
(JSC::SourceProviderCache::byteSize):
* parser/SourceProviderCache.h: Added.
(JSC::SourceProviderCache::SourceProviderCache):
(JSC::SourceProviderCache::add):
(JSC::SourceProviderCache::get):
* parser/SourceProviderCacheItem.h: Added.
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
(JSC::SourceProviderCacheItem::approximateByteSize):
(JSC::SourceProviderCacheItem::closeBraceToken):
2011-01-25 Marcilio Mendonca <mamendonca@rim.com>
 
Reviewed by Darin Adler.
......
......@@ -202,6 +202,9 @@ javascriptcore_sources += \
Source/JavaScriptCore/parser/ResultType.h \
Source/JavaScriptCore/parser/SourceCode.h \
Source/JavaScriptCore/parser/SourceProvider.h \
Source/JavaScriptCore/parser/SourceProviderCache.cpp \
Source/JavaScriptCore/parser/SourceProviderCache.h \
Source/JavaScriptCore/parser/SourceProviderCacheItem.h \
Source/JavaScriptCore/parser/SyntaxChecker.h \
Source/JavaScriptCore/pcre/pcre_compile.cpp \
Source/JavaScriptCore/pcre/pcre_exec.cpp \
......
......@@ -193,6 +193,7 @@ __ZN3JSC18PropertyDescriptor17defaultAttributesE
__ZN3JSC18PropertyDescriptor21setAccessorDescriptorENS_7JSValueES1_j
__ZN3JSC18PropertyDescriptor9setGetterENS_7JSValueE
__ZN3JSC18PropertyDescriptor9setSetterENS_7JSValueE
__ZN3JSC19SourceProviderCacheD1Ev
__ZN3JSC19initializeThreadingEv
__ZN3JSC20MarkedArgumentBuffer10slowAppendENS_7JSValueE
__ZN3JSC20createReferenceErrorEPNS_9ExecStateERKNS_7UStringE
......@@ -516,6 +517,7 @@ __ZNK3JSC18PropertyDescriptor20isAccessorDescriptorEv
__ZNK3JSC18PropertyDescriptor6getterEv
__ZNK3JSC18PropertyDescriptor6setterEv
__ZNK3JSC18PropertyDescriptor8writableEv
__ZNK3JSC19SourceProviderCache8byteSizeEv
__ZNK3JSC24JSObjectWithGlobalObject12globalObjectEv
__ZNK3JSC4Heap10statisticsEv
__ZNK3JSC4Heap11objectCountEv
......
......@@ -144,6 +144,9 @@
'parser/ResultType.h',
'parser/SourceCode.h',
'parser/SourceProvider.h',
'parser/SourceProviderCache.cpp',
'parser/SourceProviderCache.h',
'parser/SourceProviderCacheItem.h',
'parser/SyntaxChecker.h',
'pcre/pcre.h',
'pcre/pcre_compile.cpp',
......
......@@ -115,6 +115,7 @@ SOURCES += \
parser/Nodes.cpp \
parser/ParserArena.cpp \
parser/Parser.cpp \
parser/SourceProviderCache.cpp \
profiler/Profile.cpp \
profiler/ProfileGenerator.cpp \
profiler/ProfileNode.cpp \
......
......@@ -1953,6 +1953,18 @@
RelativePath="..\..\parser\SourceProvider.h"
>
</File>
<File
RelativePath="..\..\parser\SourceProviderCache.cpp"
>
</File>
<File
RelativePath="..\..\parser\SourceProviderCache.h"
>
</File>
<File
RelativePath="..\..\parser\SourceProviderCacheItem.h"
>
</File>
<File
RelativePath="..\..\parser\SyntaxChecker.h"
>
......
......@@ -571,6 +571,9 @@
E1EE793D0D6C9B9200FEA3BA /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE793C0D6C9B9200FEA3BA /* ThreadingPthreads.cpp */; };
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EF79A80CE97BA60088D500 /* UTF8.cpp */; };
E48E0F2D0F82151700A8CA37 /* FastAllocBase.h in Headers */ = {isa = PBXBuildFile; fileRef = E48E0F2C0F82151700A8CA37 /* FastAllocBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49DC15512EF277200184A1F /* SourceProviderCache.cpp */; };
E49DC16C12EF294E00184A1F /* SourceProviderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC15112EF272200184A1F /* SourceProviderCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; };
F3BD31ED126735770065467F /* TextPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BD31D0126730180065467F /* TextPosition.h */; settings = {ATTRIBUTES = (Private, ); }; };
FDA15C1E12B0305C003A583A /* Complex.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA15C1612B03028003A583A /* Complex.h */; settings = {ATTRIBUTES = (Private, ); }; };
FE1B447A0ECCD73B004F4DD1 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -1183,6 +1186,9 @@
E1EF79A80CE97BA60088D500 /* UTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UTF8.cpp; sourceTree = "<group>"; };
E1EF79A90CE97BA60088D500 /* UTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTF8.h; sourceTree = "<group>"; };
E48E0F2C0F82151700A8CA37 /* FastAllocBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastAllocBase.h; sourceTree = "<group>"; };
E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceProviderCacheItem.h; sourceTree = "<group>"; };
E49DC15112EF272200184A1F /* SourceProviderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceProviderCache.h; sourceTree = "<group>"; };
E49DC15512EF277200184A1F /* SourceProviderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceProviderCache.cpp; sourceTree = "<group>"; };
F3BD31D0126730180065467F /* TextPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPosition.h; path = text/TextPosition.h; sourceTree = "<group>"; };
F5BB2BC5030F772101FCFE1D /* Completion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Completion.h; sourceTree = "<group>"; tabWidth = 8; };
F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCorePrefix.h; sourceTree = "<group>"; tabWidth = 8; };
......@@ -1678,6 +1684,9 @@
93052C330FB792190048FDC3 /* ParserArena.h */,
869EBCB60E8C6D4A008722CC /* ResultType.h */,
65E866EE0DD59AFA00A2B2A1 /* SourceCode.h */,
E49DC15512EF277200184A1F /* SourceProviderCache.cpp */,
E49DC15112EF272200184A1F /* SourceProviderCache.h */,
E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */,
65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */,
A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */,
);
......@@ -2418,6 +2427,8 @@
86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */,
451539B912DC994500EF7AC4 /* Yarr.h in Headers */,
E49DC16C12EF294E00184A1F /* SourceProviderCache.h in Headers */,
E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -2885,6 +2896,7 @@
86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -34,6 +34,7 @@ using namespace JSC;
#include "NodeInfo.h"
#include "ASTBuilder.h"
#include "SourceProvider.h"
#include "SourceProviderCacheItem.h"
#include <wtf/HashFunctions.h>
#include <wtf/WTFThreadData.h>
#include <utility>
......@@ -96,39 +97,6 @@ private:
bool m_isLoop;
};
struct CachedFunctionInfo : public SourceProviderCache::Item {
CachedFunctionInfo(int closeBraceLine, int closeBracePos)
: closeBraceLine(closeBraceLine)
, closeBracePos(closeBracePos)
{
}
unsigned approximateByteSize() const
{
// The identifiers are uniqued strings so most likely there are few names that actually use any additional memory.
static const unsigned assummedAverageIdentifierSize = sizeof(RefPtr<StringImpl>) + 2;
unsigned size = sizeof(*this);
size += usedVariables.size() * assummedAverageIdentifierSize;
size += writtenVariables.size() * assummedAverageIdentifierSize;
return size;
}
JSToken closeBraceToken() const
{
JSToken token;
token.m_type = CLOSEBRACE;
token.m_data.intValue = closeBracePos;
token.m_info.startOffset = closeBracePos;
token.m_info.endOffset = closeBracePos + 1;
token.m_info.line = closeBraceLine;
return token;
}
int closeBraceLine;
int closeBracePos;
bool usesEval;
Vector<RefPtr<StringImpl> > usedVariables;
Vector<RefPtr<StringImpl> > writtenVariables;
};
void next(Lexer::LexType lexType = Lexer::IdentifyReservedWords)
{
m_lastLine = m_token.m_info.line;
......@@ -463,7 +431,7 @@ private:
vector.shrinkToFit();
}
void saveFunctionInfo(CachedFunctionInfo* info)
void saveFunctionInfo(SourceProviderCacheItem* info)
{
ASSERT(m_isFunction);
info->usesEval = m_usesEval;
......@@ -471,7 +439,7 @@ private:
copyCapturedVariablesToVector(m_usedVariables, info->usedVariables);
}
void restoreFunctionInfo(const CachedFunctionInfo* info)
void restoreFunctionInfo(const SourceProviderCacheItem* info)
{
ASSERT(m_isFunction);
m_usesEval = info->usesEval;
......@@ -609,9 +577,9 @@ private:
ScopeStack m_scopeStack;
const CachedFunctionInfo* findCachedFunctionInfo(int openBracePos)
const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
{
return m_functionCache ? static_cast<const CachedFunctionInfo*>(m_functionCache->get(openBracePos)) : 0;
return m_functionCache ? m_functionCache->get(openBracePos) : 0;
}
SourceProviderCache* m_functionCache;
......@@ -1318,7 +1286,7 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
openBracePos = m_token.m_data.intValue;
bodyStartLine = tokenLine();
if (const CachedFunctionInfo* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
// If we know about this function already, we can use the cached info and skip the parser to the end of the function.
body = context.createFunctionBody(strictMode());
......@@ -1347,10 +1315,10 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
// Cache the tokenizer state and the function scope the first time the function is parsed.
// Any future reparsing can then skip the function.
static const int minimumFunctionLengthToCache = 64;
OwnPtr<CachedFunctionInfo> newInfo;
OwnPtr<SourceProviderCacheItem> newInfo;
int functionLength = closeBracePos - openBracePos;
if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) {
newInfo = adoptPtr(new CachedFunctionInfo(m_token.m_info.line, closeBracePos));
newInfo = adoptPtr(new SourceProviderCacheItem(m_token.m_info.line, closeBracePos));
functionScope->saveFunctionInfo(newInfo.get());
}
......
......@@ -29,32 +29,15 @@
#ifndef SourceProvider_h
#define SourceProvider_h
#include "SourceProviderCache.h"
#include "UString.h"
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/UnusedParam.h>
#include <wtf/text/TextPosition.h>
namespace JSC {
class SourceProviderCache {
public:
struct Item {};
SourceProviderCache() : m_contentByteSize(0) {}
~SourceProviderCache() { deleteAllValues(m_map); }
unsigned byteSize() const { return m_contentByteSize + sizeof(*this) + m_map.capacity() * sizeof(Item*); }
void add(int sourcePosition, PassOwnPtr<Item> item, unsigned size) { m_map.add(sourcePosition, item.leakPtr()); m_contentByteSize += size; }
const Item* get(int sourcePosition) const { return m_map.get(sourcePosition); }
private:
HashMap<int, Item*> m_map;
unsigned m_contentByteSize;
};
class SourceProvider : public RefCounted<SourceProvider> {
public:
SourceProvider(const UString& url, SourceProviderCache* cache = 0)
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "SourceProviderCache.h"
#include "SourceProviderCacheItem.h"
namespace JSC {
SourceProviderCache::~SourceProviderCache()
{
deleteAllValues(m_map);
}
unsigned SourceProviderCache::byteSize() const
{
return m_contentByteSize + sizeof(*this) + m_map.capacity() * sizeof(SourceProviderCacheItem*);
}
void SourceProviderCache::add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem> item, unsigned size)
{
m_map.add(sourcePosition, item.leakPtr());
m_contentByteSize += size;
}
}
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
namespace JSC {
class SourceProviderCacheItem;
class SourceProviderCache {
public:
SourceProviderCache() : m_contentByteSize(0) {}
~SourceProviderCache();
unsigned byteSize() const;
void add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem>, unsigned size);
const SourceProviderCacheItem* get(int sourcePosition) const { return m_map.get(sourcePosition); }
private:
HashMap<int, SourceProviderCacheItem*> m_map;
unsigned m_contentByteSize;
};
}
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "JSParser.h"
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class SourceProviderCacheItem {
public:
SourceProviderCacheItem(int closeBraceLine, int closeBracePos)
: closeBraceLine(closeBraceLine)
, closeBracePos(closeBracePos)
{
}
unsigned approximateByteSize() const
{
// The identifiers are uniqued strings so most likely there are few names that actually use any additional memory.
static const unsigned assummedAverageIdentifierSize = sizeof(RefPtr<StringImpl>) + 2;
unsigned size = sizeof(*this);
size += usedVariables.size() * assummedAverageIdentifierSize;
size += writtenVariables.size() * assummedAverageIdentifierSize;
return size;
}
JSToken closeBraceToken() const
{
JSToken token;
token.m_type = CLOSEBRACE;
token.m_data.intValue = closeBracePos;
token.m_info.startOffset = closeBracePos;
token.m_info.endOffset = closeBracePos + 1;
token.m_info.line = closeBraceLine;
return token;
}
int closeBraceLine;
int closeBracePos;
bool usesEval;
Vector<RefPtr<StringImpl> > usedVariables;
Vector<RefPtr<StringImpl> > writtenVariables;
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment