Shopify / seafoam

A tool for working with compiler graphs dumped by the GraalVM compiler
MIT License
126 stars 22 forks source link

Add translation of Truffle arguments to symbolic names for TruffleRuby. #72

Closed nirvdrum closed 1 year ago

nirvdrum commented 1 year ago

This PR hooks into the existing Truffle pass to provide non-indexed names for Truffle languages that pack their arguments in a consistent format. I've only added a TruffleRuby implementation in this pass, but the machinery is there for other languages.

The graphs are fairly large, so I'm using screenshots rather than mermaid here. All of the translated LoadIndexed nodes that normally get turned into T(<int>) now get turned into T(<packed_arg_name>). If a language doesn't have a translator implementation, the previous T(<int>) format is used.

The mechanism to detect the language is a fuzzy match because the graph data doesn't directly indicate the language. I've used a breadth-first search following out edges from the LoadIndexed node. If there's a more reliable search algorithm, I'm happy to adjust. I'm also not heavily invested in any of the names here, so if "translator" is too broad, please suggest an alternative and I'll update the PR.

Before

image

After

image

eregon commented 1 year ago

Very cool :)