Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timo committed Mar 13, 2016
1 parent cf7fe9c commit 43a819e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/vm/moar/HLL/Backend.nqp
Expand Up @@ -87,13 +87,29 @@ class HLL::Backend::MoarVM {
$escaped_squote := q{\\'};
}

my int $new-id-counter := 0;
my $id_remap := nqp::hash();
my $id_to_thing := nqp::hash();

sub post_process_call_graph_node($node) {
try {
if nqp::existskey($id_remap, $node<id>) {
$node<id> := $id_remap{$node<id>};
} else {
my str $newkey := ~($new-id-counter++);
$id_remap{$node<id>} := $newkey;
$node<id> := $newkey;
}
if nqp::existskey($node, "allocations") {
for $node<allocations> -> %alloc_info {
my $type := %alloc_info<type>;
if nqp::existskey($id_remap, %alloc_info<id>) {
%alloc_info<id> := $id_remap{%alloc_info<id>};
} else {
my str $newkey := ~($new-id-counter++);
$id_remap{%alloc_info<id>} := $newkey;
%alloc_info<id> := $newkey;
}
unless nqp::existskey($id_to_thing, %alloc_info<id>) {
$id_to_thing{%alloc_info<id>} := $type.HOW.name($type);
}
Expand Down

0 comments on commit 43a819e

Please sign in to comment.