forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mark stack overflow bug in WeakMap marking.
Summary: I figured out a bug in WeakMap marking: if mark stack overflow occurs, we shouldn't assume that reachability has been computed correctly, so we shouldn't clear WeakMap entries with unreachable keys. Reviewed By: kodafb Differential Revision: D19199569 fbshipit-source-id: b0e2a3a4a51c81133e7d62b81106635922e5fcf5
- Loading branch information
1 parent
c4e62bc
commit a174d21
Showing
7 changed files
with
77 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// RUN: %hermes -gc-init-heap=4M -O -Xhermes-internal-test-methods %s | %FileCheck --match-full-lines %s | ||
// RUN: %hermes -O -emit-binary -out %t.hbc %s && %hermes -gc-init-heap=4M -Xhermes-internal-test-methods %t.hbc | %FileCheck --match-full-lines %s | ||
|
||
// This test is specific to the implementation of GenGC. | ||
// REQUIRES: gengc | ||
|
||
"use strict" | ||
|
||
// CHECK-LABEL: Start | ||
print("Start"); | ||
|
||
// This tests that WeakMap marking works even in the presence of mark stack | ||
// overflow. (This test failed before a bug fix.) | ||
function foo7() { | ||
function makeList(n, lastVal) { | ||
if (n == 0) { | ||
return {p: lastVal}; | ||
} else { | ||
return {p: {}, tail: makeList(n-1, lastVal)}; | ||
} | ||
} | ||
var key0 = {}; | ||
var key1 = {}; | ||
var map = new WeakMap(); | ||
// 1000 is the mark stack limit; exceed that. | ||
map.set(key0, makeList(1200, key1)); | ||
map.set(key1, {y: 17}); | ||
return [map, key0]; | ||
} | ||
var pair7 = foo7(); | ||
gc(); | ||
|
||
// Make sure a mark stack overflow occurred. | ||
var stats = HermesInternal.getInstrumentedStats(); | ||
// CHECK-NEXT: 1 | ||
print(stats.js_markStackOverflows); | ||
|
||
// CHECK-NEXT: 2 | ||
print(HermesInternal.getWeakSize(pair7[0])); |