Changeset 181248 in webkit


Ignore:
Timestamp:
Mar 8, 2015 4:47:25 PM (9 years ago)
Author:
akling@apple.com
Message:

BuiltinExecutables keeps finalized Weaks around, pinning WeakBlocks.
<https://webkit.org/b/142460>

Reviewed by Geoffrey Garen.

Make BuiltinExecutables a WeakHandleOwner so it can clear out its respective Weak members
if and when their pointees get garbage collected.

This fixes an issue I've seen locally where a WeakBlock is pinned down by a single one of
these Weak<BuiltinExecutables>.

  • builtins/BuiltinExecutables.h: Make BuiltinExecutables inherit from WeakHandleOwner.
  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::finalize): Clear out the relevant member pointer when it's been
garbage collected. We use the WeakImpl's "context" field to pass the address of the member.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r181215 r181248  
     12015-03-08  Andreas Kling  <akling@apple.com>
     2
     3        BuiltinExecutables keeps finalized Weaks around, pinning WeakBlocks.
     4        <https://webkit.org/b/142460>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Make BuiltinExecutables a WeakHandleOwner so it can clear out its respective Weak members
     9        if and when their pointees get garbage collected.
     10
     11        This fixes an issue I've seen locally where a WeakBlock is pinned down by a single one of
     12        these Weak<BuiltinExecutables>.
     13
     14        * builtins/BuiltinExecutables.h: Make BuiltinExecutables inherit from WeakHandleOwner.
     15
     16        * builtins/BuiltinExecutables.cpp:
     17        (JSC::BuiltinExecutables::finalize): Clear out the relevant member pointer when it's been
     18        garbage collected. We use the WeakImpl's "context" field to pass the address of the member.
     19
    1202015-03-07  Geoffrey Garen  <ggaren@apple.com>
    221
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r180637 r181248  
    8484}
    8585
     86void BuiltinExecutables::finalize(Handle<Unknown>, void* context)
     87{
     88    static_cast<Weak<UnlinkedFunctionExecutable>*>(context)->clear();
     89}
     90
    8691#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
    8792UnlinkedFunctionExecutable* BuiltinExecutables::name##Executable() \
    8893{\
    8994    if (!m_##name##Executable)\
    90         m_##name##Executable = createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName());\
     95        m_##name##Executable = Weak<UnlinkedFunctionExecutable>(createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName()), this, &m_##name##Executable);\
    9196    return m_##name##Executable.get();\
    9297}
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.h

    r177222 r181248  
    3030#include "SourceCode.h"
    3131#include "Weak.h"
     32#include "WeakHandleOwner.h"
    3233
    3334namespace JSC {
     
    3738class VM;
    3839
    39 class BuiltinExecutables {
     40class BuiltinExecutables final: private WeakHandleOwner {
    4041    WTF_MAKE_FAST_ALLOCATED;
    4142public:
     
    5051   
    5152private:
     53    void finalize(Handle<Unknown>, void* context) override;
     54
    5255    VM& m_vm;
    5356    UnlinkedFunctionExecutable* createBuiltinExecutable(const SourceCode&, const Identifier&);
Note: See TracChangeset for help on using the changeset viewer.