-
Notifications
You must be signed in to change notification settings - Fork 0
/
computeGCTypes.js
95 lines (82 loc) · 2.36 KB
/
computeGCTypes.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -*- Mode: Javascript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
"use strict";
load('utility.js');
load('annotations.js');
function processCSU(csu, body)
{
if (!("DataField" in body))
return;
for (var field of body.DataField) {
var type = field.Field.Type;
if (type.Kind == "Pointer") {
var target = type.Type;
if (target.Kind == "CSU")
addNestedPointer(csu, target.Name);
}
if (type.Kind == "CSU") {
// Ignore nesting in classes which are AutoGCRooters. We only consider
// types with fields that may not be properly rooted.
if (type.Name == "JS::AutoGCRooter")
return;
addNestedStructure(csu, type.Name);
}
}
}
function addNestedStructure(csu, inner)
{
if (!(inner in structureParents))
structureParents[inner] = [];
structureParents[inner].push(csu);
}
function addNestedPointer(csu, inner)
{
if (!(inner in pointerParents))
pointerParents[inner] = [];
pointerParents[inner].push(csu);
}
var structureParents = {};
var pointerParents = {};
var xdb = xdbLibrary();
xdb.open("src_comp.xdb");
var minStream = xdb.min_data_stream();
var maxStream = xdb.max_data_stream();
for (var csuIndex = minStream; csuIndex <= maxStream; csuIndex++) {
var csu = xdb.read_key(csuIndex);
var data = xdb.read_entry(csu);
var json = JSON.parse(data.readString());
assert(json.length == 1);
processCSU(csu.readString(), json[0]);
xdb.free_string(csu);
xdb.free_string(data);
}
function addGCType(name)
{
print("GCThing: " + name);
if (name in structureParents) {
for (var nested of structureParents[name])
addGCType(nested);
}
if (name in pointerParents) {
for (var nested of pointerParents[name])
addGCPointer(nested);
}
}
function addGCPointer(name)
{
// Ignore types which are properly rooted.
if (isRootedTypeName(name))
return;
print("GCPointer: " + name);
if (name in structureParents) {
for (var nested of structureParents[name])
addGCPointer(nested);
}
}
addGCType('js::ObjectImpl');
addGCType('JSString');
addGCType('js::Shape');
addGCType('js::BaseShape');
addGCType('JSScript');
addGCType('js::ion::IonCode');
addGCPointer('JS::Value');
addGCPointer('jsid');