Changeset 181250 in webkit


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

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

Reviewed by Darin Adler.

Make JITThunks a WeakHandleOwner so it can keep its host function map free of stale entries.
This fixes an issue I was seeing where a bunch of WeakBlocks stuck around with nothing but
finalized Weak<NativeExecutable> entries.

  • jit/JITThunks.h:
  • jit/JITThunks.cpp:

(JSC::JITThunks::finalize): Make JITThunks inherit from WeakHandleOwner so it can receive
a callback when the NativeExecutables get garbage collected.

(JSC::JITThunks::hostFunctionStub): Pass 'this' as the handle owner when creating Weaks.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r181248 r181250  
     12015-03-08  Andreas Kling  <akling@apple.com>
     2
     3        JITThunks keeps finalized Weaks around, pinning WeakBlocks.
     4        <https://webkit.org/b/142454>
     5
     6        Reviewed by Darin Adler.
     7
     8        Make JITThunks a WeakHandleOwner so it can keep its host function map free of stale entries.
     9        This fixes an issue I was seeing where a bunch of WeakBlocks stuck around with nothing but
     10        finalized Weak<NativeExecutable> entries.
     11
     12        * jit/JITThunks.h:
     13        * jit/JITThunks.cpp:
     14        (JSC::JITThunks::finalize): Make JITThunks inherit from WeakHandleOwner so it can receive
     15        a callback when the NativeExecutables get garbage collected.
     16
     17        (JSC::JITThunks::hostFunctionStub): Pass 'this' as the handle owner when creating Weaks.
     18
    1192015-03-08  Andreas Kling  <akling@apple.com>
    220
  • trunk/Source/JavaScriptCore/jit/JITThunks.cpp

    r177130 r181250  
    7777}
    7878
     79void JITThunks::finalize(Handle<Unknown> handle, void*)
     80{
     81    auto* nativeExecutable = jsCast<NativeExecutable*>(handle.get().asCell());
     82    weakRemove(*m_hostFunctionStubMap, std::make_pair(nativeExecutable->function(), nativeExecutable->constructor()), nativeExecutable);
     83}
     84
    7985NativeExecutable* JITThunks::hostFunctionStub(VM* vm, NativeFunction function, NativeFunction constructor)
    8086{
     
    9096        adoptRef(new NativeJITCode(MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), JITCode::HostCallThunk)),
    9197        constructor, NoIntrinsic);
    92     weakAdd(*m_hostFunctionStubMap, std::make_pair(function, constructor), Weak<NativeExecutable>(nativeExecutable));
     98    weakAdd(*m_hostFunctionStubMap, std::make_pair(function, constructor), Weak<NativeExecutable>(nativeExecutable, this));
    9399    return nativeExecutable;
    94100}
     
    112118   
    113119    NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, forCall, function, forConstruct, callHostFunctionAsConstructor, intrinsic);
    114     weakAdd(*m_hostFunctionStubMap, std::make_pair(function, &callHostFunctionAsConstructor), Weak<NativeExecutable>(nativeExecutable));
     120    weakAdd(*m_hostFunctionStubMap, std::make_pair(function, &callHostFunctionAsConstructor), Weak<NativeExecutable>(nativeExecutable, this));
    115121    return nativeExecutable;
    116122}
  • trunk/Source/JavaScriptCore/jit/JITThunks.h

    r177130 r181250  
    3535#include "ThunkGenerator.h"
    3636#include "Weak.h"
     37#include "WeakHandleOwner.h"
    3738#include "WeakInlines.h"
    3839#include <wtf/HashMap.h>
     
    4546class NativeExecutable;
    4647
    47 class JITThunks {
     48class JITThunks final : private WeakHandleOwner {
    4849public:
    4950    JITThunks();
    50     ~JITThunks();
     51    virtual ~JITThunks();
    5152
    5253    MacroAssemblerCodePtr ctiNativeCall(VM*);
     
    6566    typedef Mutex Lock;
    6667    typedef MutexLocker Locker;
     68
     69    void finalize(Handle<Unknown>, void* context) override;
    6770   
    6871    typedef HashMap<ThunkGenerator, MacroAssemblerCodeRef> CTIStubMap;
Note: See TracChangeset for help on using the changeset viewer.