Skip to content
Permalink
Browse files
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.


Canonical link: https://commits.webkit.org/160506@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Mar 8, 2015
1 parent 4d26afe commit 94e75392d8e816ede17d6a50bd1fd9e29015a86f
Showing with 29 additions and 2 deletions.
  1. +19 −0 Source/JavaScriptCore/ChangeLog
  2. +6 −1 Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
  3. +4 −1 Source/JavaScriptCore/builtins/BuiltinExecutables.h
@@ -1,3 +1,22 @@
2015-03-08 Andreas Kling <akling@apple.com>

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.

2015-03-07 Geoffrey Garen <ggaren@apple.com>

Use FastMalloc (bmalloc) instead of BlockAllocator for GC pages
@@ -83,11 +83,16 @@ UnlinkedFunctionExecutable* BuiltinExecutables::createBuiltinExecutable(const So
return functionExecutable;
}

void BuiltinExecutables::finalize(Handle<Unknown>, void* context)
{
static_cast<Weak<UnlinkedFunctionExecutable>*>(context)->clear();
}

#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
UnlinkedFunctionExecutable* BuiltinExecutables::name##Executable() \
{\
if (!m_##name##Executable)\
m_##name##Executable = createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName());\
m_##name##Executable = Weak<UnlinkedFunctionExecutable>(createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName()), this, &m_##name##Executable);\
return m_##name##Executable.get();\
}
JSC_FOREACH_BUILTIN(DEFINE_BUILTIN_EXECUTABLES)
@@ -29,14 +29,15 @@
#include "JSCBuiltins.h"
#include "SourceCode.h"
#include "Weak.h"
#include "WeakHandleOwner.h"

namespace JSC {

class UnlinkedFunctionExecutable;
class Identifier;
class VM;

class BuiltinExecutables {
class BuiltinExecutables final: private WeakHandleOwner {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit BuiltinExecutables(VM&);
@@ -49,6 +50,8 @@ const SourceCode& name##Source() { return m_##name##Source; }
#undef EXPOSE_BUILTIN_SOURCES

private:
void finalize(Handle<Unknown>, void* context) override;

VM& m_vm;
UnlinkedFunctionExecutable* createBuiltinExecutable(const SourceCode&, const Identifier&);
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length)\

0 comments on commit 94e7539

Please sign in to comment.