-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle JSWeakMap semantics.
Summary: We were not properly handling the semantics of JSWeakMap. The spec says (http://www.ecma-international.org/ecma-262/#sec-weakmap-objects) that if an object used a key is only reachable from the the corresponding value, then the key should not be considered reachable, and the key/value pair should (eventually) be removed from the table. This diff fixes that. We modify marking to recognize JSWeakMaps. When these are found reachable, we collect those in a vector, but do not mark through them. When the marking transitive closure is otherwise complete, we consider the JSWeakMaps. We find entries with reachable keys, and mark transitively from the corresponding values. This is done carefully to ensure we reach a full transitive closure. After this we clear the keys and values of entries with unreachable keys. Normal weak ref processing will mark the table as having freeable slots. A subsequent diffs may optimize this basic idea: if we consider a map multiple times, it is wasteful to scan all the entries. So we should keep track of entries whose keys are not yet known to be unreachable, and consider only them. Minor things: * Modify HermesValue::getWeakSize to check if a JSWeakMap has freeable slots, and free those before getting the size, to get a consistent value. * Factor out "CompleteMarkState::pushCell", now that there's a second use. Also, assert that the cell pushed is valid, which found a problem in my debugging. Reviewed By: dulinriley Differential Revision: D18651375 fbshipit-source-id: 79c06875330147ecf15434bea2c92d3d3141ced9
- Loading branch information
1 parent
f651218
commit d09005e
Showing
10 changed files
with
398 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.