Skip to content
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

Don't use weak refs #647

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions libraries/js/effekt_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ function Arena(_region) {
fresh: function(init) {
const cell = Cell(init);
// region keeps track what to backup, but we do not need to backup unreachable cells
region.push(new WeakRef(cell))
region.push(cell) // new WeakRef(cell))
return cell;
},
region: _region,
newRegion: function() {
// a region aggregates weak references
const nested = Arena([])
// this doesn't work yet, since Arena.backup doesn't return a thunk
region.push(new WeakRef(nested))
region.push(nested) //new WeakRef(nested))
return nested;
},
backup: function() {
const _backup = []
let nextIndex = 0;
for (const ref of region) {
// console.log(ref)
const cell = ref.deref()
const cell = ref //.deref()
// only backup live cells
if (cell) {
_backup[nextIndex] = cell.backup()
Expand All @@ -50,7 +49,7 @@ function Arena(_region) {
const region = []
let nextIndex = 0;
for (const restoreCell of _backup) {
region[nextIndex] = new WeakRef(restoreCell())
region[nextIndex] = restoreCell() // new WeakRef(restoreCell())
nextIndex++
}
return Arena(region)
Expand Down