forked from jensnicolay/jipda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagc.js
More file actions
48 lines (43 loc) · 1.39 KB
/
Copy pathagc.js
File metadata and controls
48 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const Agc = {};
Agc.collect =
function (store, rootSet)
{
const reachable = MutableHashSet.empty();
Agc.addressesReachable(rootSet, store, reachable);
if (reachable.count() === store.map.count()) // we can do this since we have subsumption
{
return store;
}
const store2 = store.narrow(reachable);
return store2;
}
Agc.addressesReachable =
function (addresses, store, reachable)
{
addresses.forEach(function (address) {Agc.addressReachable(address, store, reachable)});
}
Agc.addressReachable =
function (address, store, reachable)
{
if (reachable.contains(address))
{
return;
}
const aval = store.lookupAval(address);
const addresses = aval.addresses();
reachable.add(address);
Agc.addressesReachable(addresses, store, reachable);
}
if (typeof module !== 'undefined' && module.exports != null) {
var common = require('./common.js');
var HashMap = common.HashMap;
var ArraySet = common.ArraySet;
var Indexer = common.Indexer;
var MutableHashSet = common.MutableHashSet;
var assert = common.assert;
var assertDefinedNotNull = common.assertDefinedNotNull;
var lattice = require('./lattice.js');
var Ecma = lattice.Ecma;
var BOT = lattice.BOT;
exports.Agc = Agc;
}