Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Currently, every `set` operation on a `WeakMap` results in a write to `self->valueStorage_`, even if the storage was not resized. This means that a write barrier is executed, and the `valueStorage_` is marked as a regular cell, instead of going through the special `WeakMap` marking code in the GC. This in turn means that if any value in the storage retains a `WeakMap` key (i.e. a cycle), that cycle will not be collected during a given GC run. As long as the `WeakMap` is assigned to at least once during each GC cycle, no such circular references can be collected. To mitigate this, only write the storage when it is actually resized. This avoids the write barrier in the common case and allows most collections to still collect cycles in the `WeakMap`. This is only a partial fix, since the storage can still be marked (either through the barrier or when it is in a handle), but it is still good enough to mitigate most such problems (see #1147). Reviewed By: tmikov Differential Revision: D51000231 fbshipit-source-id: 735bac55f19fd9d0a1b58a6d7d77df74c690ab92
- Loading branch information