Changeset 201494 in webkit


Ignore:
Timestamp:
May 28, 2016 9:47:41 PM (8 years ago)
Author:
akling@apple.com
Message:

JSGlobalLexicalEnvironment leaks SegmentedVector due to lack of destructor.
<https://webkit.org/b/158186>

Reviewed by Saam Barati.

Give JSGlobalLexicalEnvironment a destroy() and set up a finalizer for it
like we do with JSGlobalObject. (This is needed because they don't inherit
from JSDestructibleObjects and thus can't use JSCell::needsDestruction to
ask for allocation in destructor space.)

This stops us from leaking all the SegmentedVector backing stores.

  • runtime/JSGlobalLexicalEnvironment.cpp:

(JSC::JSGlobalLexicalEnvironment::destroy):

  • runtime/JSGlobalLexicalEnvironment.h:

(JSC::JSGlobalLexicalEnvironment::create):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r201488 r201494  
     12016-05-28  Andreas Kling  <akling@apple.com>
     2
     3        JSGlobalLexicalEnvironment leaks SegmentedVector due to lack of destructor.
     4        <https://webkit.org/b/158186>
     5
     6        Reviewed by Saam Barati.
     7
     8        Give JSGlobalLexicalEnvironment a destroy() and set up a finalizer for it
     9        like we do with JSGlobalObject. (This is needed because they don't inherit
     10        from JSDestructibleObjects and thus can't use JSCell::needsDestruction to
     11        ask for allocation in destructor space.)
     12
     13        This stops us from leaking all the SegmentedVector backing stores.
     14
     15        * runtime/JSGlobalLexicalEnvironment.cpp:
     16        (JSC::JSGlobalLexicalEnvironment::destroy):
     17        * runtime/JSGlobalLexicalEnvironment.h:
     18        (JSC::JSGlobalLexicalEnvironment::create):
     19
    1202016-05-28  Skachkov Oleksandr  <gskachkov@gmail.com>
    221        [ESNext] Trailing commas in function parameters.
  • trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.cpp

    r200121 r201494  
    3333const ClassInfo JSGlobalLexicalEnvironment::s_info = { "JSGlobalLexicalEnvironment", &Base::s_info, 0, CREATE_METHOD_TABLE(JSGlobalLexicalEnvironment) };
    3434
     35void JSGlobalLexicalEnvironment::destroy(JSCell* cell)
     36{
     37    static_cast<JSGlobalLexicalEnvironment*>(cell)->JSGlobalLexicalEnvironment::~JSGlobalLexicalEnvironment();
     38}
     39
    3540bool JSGlobalLexicalEnvironment::getOwnPropertySlot(JSObject* object, ExecState*, PropertyName propertyName, PropertySlot& slot)
    3641{
  • trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h

    r200121 r201494  
    4444        result->finishCreation(vm);
    4545        result->symbolTable()->setScopeType(SymbolTable::ScopeType::GlobalLexicalScope);
     46        vm.heap.addFinalizer(result, destroy);
    4647        return result;
    4748    }
     
    4950    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
    5051    static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
     52
     53    static void destroy(JSCell*);
     54    // We don't need a destructor because we use a finalizer instead.
     55    static const bool needsDestruction = false;
    5156
    5257    bool isEmpty() const { return !symbolTable()->size(); }
Note: See TracChangeset for help on using the changeset viewer.