[test] Make less memory be gated by finalization in splay_dart_finalizer_test.dart.

When the heap limit is reached, directly unreachable objects are reclaimed but objects that will be unreachable after a finalization are not, and there needs to be enough headroom between opportunities for finalizers to run (returning to the event loop).

So only do the finalization thing with the upper, high-mutation part of the splay tree and remove it from the lower, write-once part. The high-mutation part is what's more interesting for GC stress testing.

Bug: https://github.com/dart-lang/sdk/issues/50597
Change-Id: Id02b38b0ac1e9bb640954ef1b686ce3eef8370af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273300
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2022-12-02 17:04:38 +00:00 committed by Commit Queue
parent e9a1248fc2
commit 16149782ef
2 changed files with 6 additions and 40 deletions

View file

@ -27,7 +27,7 @@
// VMOptions=--verify_store_buffer
// VMOptions=--verify_after_marking
// VMOptions=--stress_write_barrier_elimination
// VMOptions=--old_gen_heap_size=300
// VMOptions=--old_gen_heap_size=150
import "splay_common.dart";
@ -41,26 +41,9 @@ class FinalizerSplay extends Splay {
Node newNode(num key, Object? value) => new FinalizerNode(key, value);
}
final payloadLeft = <Object, dynamic>{};
final payloadRight = <Object, dynamic>{};
finalizePayload(Object token) {
payloadLeft.remove(token);
payloadRight.remove(token);
}
final payloadFinalizer = new Finalizer<Object>(finalizePayload);
class Payload {
Payload(left, right) {
this.left = left;
this.right = right;
payloadFinalizer.attach(this, token, detach: this);
}
var token = new Object();
get left => payloadLeft[token];
set left(value) => payloadLeft[token] = value;
get right => payloadRight[token];
set right(value) => payloadRight[token] = value;
Payload(this.left, this.right);
var left, right;
static generate(depth, tag) {
if (depth == 0) return new Leaf(tag);

View file

@ -31,7 +31,7 @@
// VMOptions=--verify_store_buffer
// VMOptions=--verify_after_marking
// VMOptions=--stress_write_barrier_elimination
// VMOptions=--old_gen_heap_size=300
// VMOptions=--old_gen_heap_size=150
import "splay_common.dart";
@ -45,26 +45,9 @@ class FinalizerSplay extends Splay {
Node newNode(num key, Object value) => new FinalizerNode(key, value);
}
final payloadLeft = <Object, dynamic>{};
final payloadRight = <Object, dynamic>{};
finalizePayload(Object token) {
payloadLeft.remove(token);
payloadRight.remove(token);
}
final payloadFinalizer = new Finalizer<Object>(finalizePayload);
class Payload {
Payload(left, right) {
this.left = left;
this.right = right;
payloadFinalizer.attach(this, token, detach: this);
}
var token = new Object();
get left => payloadLeft[token];
set left(value) => payloadLeft[token] = value;
get right => payloadRight[token];
set right(value) => payloadRight[token] = value;
Payload(this.left, this.right);
var left, right;
static generate(depth, tag) {
if (depth == 0) return new Leaf(tag);