-
Notifications
You must be signed in to change notification settings - Fork 171
CSE Machine: Visual garbage collector #3119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 14256302577Details
💛 - Coveralls |
I noticed some cases where the reachability logic doesn’t fully reflect actual references: 1. Indirect referencing through nested arraysfunction test_func() {
const x = [];
const y = [x];
const a = [x, y];
return a;
}
const result = test_func();
result[1][0] = 5; In this case, Source.Academy.-.Personal.-.Microsoft.Edge.2025-04-02.18-21-18.mp42. Function still referenced after returnfunction test_func() {
const x = [];
const a = d => d + 1;
return a;
}
const result = test_func();
result(5); In this example, Right now, the visualization marks the frame as unreachable as soon as Also, when Source.Academy.-.Personal.-.Microsoft.Edge.2025-04-02.18-36-28.mp4 |
unfortunately, after 12 consecutive hours, i still can't figure out why even when isReachable is true, the object does not change its color. debugging is pain. possible ideas for future:
Unfortunately changing the color of the enclosing frame for some reason doesn't work no matter what I do, yet everything else updates its color by setting isReachable. (also a word of warning: i cannot set the target of an arrow to be reachable, as the target remains undefined until countingSteps or later. console.log() did not help me, turns out it givesobject references instead of object state. i wasted way too long to find out. thanks google.)
|
After way too long debugging this, I found that the enclosing environment of the bottom More details here #3127 |
Description
Currently, frames that will no longer be referenced still show up as white in the environment, along with their associated bound objects. There was previously no mechanism to visually "garbage collect" frames which should have been dereferenced. This PR fixes this, by having the default color be faded, and for each step in the CSE Machine, we mark the current environment as reachable, and then recursively mark its parent frames (with their bindings) as reachable, up till the root parent (Global).
Type of change
How to test
Demo
Frames and bindings (such as function closures) will indicate as grey, once they will be no longer accessed.
garbagecollector.mp4
Nested referencing within ArrayUnits are also updated.
gc_array.mp4
Checklist