12013-10-30 Filip Pizlo <fpizlo@apple.com>
2
3 Assertion failure in js/dom/global-constructors-attributes-dedicated-worker.html
4 https://bugs.webkit.org/show_bug.cgi?id=123551
5
6 Reviewed by NOBODY (OOPS!).
7
8 WatchpointSets have always had this "fire everything on deletion" policy because it
9 seemed like a good fail-safe at the time I first implemented WatchpointSets. But
10 it's actually causing bugs rather than providing safety:
11
12 - Everyone who registers Watchpoints with WatchpointSets have separate mechanisms
13 for either keeping the WatchpointSets alive or noticing when they are collected.
14 So this wasn't actually providing any safety.
15
16 One example of this is Structures, where:
17
18 - CodeBlocks that register Watchpoints on Structure's WatchpointSet will also
19 register weak references to the Structure, and the GC will jettison a CodeBlock
20 if the Structure(s) it cares about dies.
21
22 - StructureStubInfos that register Watchpoints on Structure's WatchpointSet will
23 also be cleared by GC if the Structures die.
24
25 - The WatchpointSet constructor would get invoked from finalization/destruction.
26 This would then cause CodeBlock::jettison() to be called on a CodeBlock, but that
27 method requires doing things that access heap objects.
28
29 This also ensures that CodeBlock::jettison() cannot cause a GC. This is safe since
30 that method doesn't really allocate objects, and it is likely necessary because
31 jettison() may be called from deep in the stack.
32
33 * bytecode/CodeBlock.cpp:
34 (JSC::CodeBlock::jettison):
35 * bytecode/Watchpoint.cpp:
36 (JSC::WatchpointSet::~WatchpointSet):
37 * bytecode/Watchpoint.h:
38