Skip to content

Commit 43a819e

Browse files
committed
make profile a tiny bit smaller still
by remapping IDs (which are usually 8 digits long) to the value of a counter that starts at 0.
1 parent cf7fe9c commit 43a819e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/vm/moar/HLL/Backend.nqp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,29 @@ class HLL::Backend::MoarVM {
8787
$escaped_squote := q{\\'};
8888
}
8989

90+
my int $new-id-counter := 0;
91+
my $id_remap := nqp::hash();
9092
my $id_to_thing := nqp::hash();
9193

9294
sub post_process_call_graph_node($node) {
9395
try {
96+
if nqp::existskey($id_remap, $node<id>) {
97+
$node<id> := $id_remap{$node<id>};
98+
} else {
99+
my str $newkey := ~($new-id-counter++);
100+
$id_remap{$node<id>} := $newkey;
101+
$node<id> := $newkey;
102+
}
94103
if nqp::existskey($node, "allocations") {
95104
for $node<allocations> -> %alloc_info {
96105
my $type := %alloc_info<type>;
106+
if nqp::existskey($id_remap, %alloc_info<id>) {
107+
%alloc_info<id> := $id_remap{%alloc_info<id>};
108+
} else {
109+
my str $newkey := ~($new-id-counter++);
110+
$id_remap{%alloc_info<id>} := $newkey;
111+
%alloc_info<id> := $newkey;
112+
}
97113
unless nqp::existskey($id_to_thing, %alloc_info<id>) {
98114
$id_to_thing{%alloc_info<id>} := $type.HOW.name($type);
99115
}

0 commit comments

Comments
 (0)