Ignore:
Timestamp:
Jan 25, 2011, 10:44:11 AM (14 years ago)
Author:
Antti Koivisto
Message:

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.

(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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r76177 r76611  
    3030#define SourceProvider_h
    3131
     32#include "SourceProviderCache.h"
    3233#include "UString.h"
    33 #include <wtf/HashMap.h>
    3434#include <wtf/PassOwnPtr.h>
    3535#include <wtf/RefCounted.h>
     
    3737#include <wtf/text/TextPosition.h>
    3838
    39 
    4039namespace JSC {
    41 
    42     class SourceProviderCache {
    43     public:
    44         struct Item {};
    45 
    46         SourceProviderCache() : m_contentByteSize(0) {}
    47         ~SourceProviderCache() { deleteAllValues(m_map); }
    48        
    49         unsigned byteSize() const { return m_contentByteSize + sizeof(*this) + m_map.capacity() * sizeof(Item*); }
    50         void add(int sourcePosition, PassOwnPtr<Item> item, unsigned size) { m_map.add(sourcePosition, item.leakPtr()); m_contentByteSize += size; }
    51         const Item* get(int sourcePosition) const { return m_map.get(sourcePosition); }
    52 
    53     private:
    54         HashMap<int, Item*> m_map;
    55         unsigned m_contentByteSize;
    56     };
    5740
    5841    class SourceProvider : public RefCounted<SourceProvider> {
Note: See TracChangeset for help on using the changeset viewer.