Skip to content

Commit

Permalink
Show bytecode coverage in CallTargetBrowser
Browse files Browse the repository at this point in the history
Since bytecode nodes are lazily inserted into Truffle AST, we can use this information to find out whether a bytecode has been executed or not. This displays this information in the bytecode view of the CallTargetBrowser. Red means not covered, green means covered, gray means unknown (closures are currently not supported).
  • Loading branch information
fniephaus committed Jul 14, 2021
1 parent 69dd741 commit f77d4cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
message list
selectedBytecodes
| cm text |
cm := (self selectedClassOrMetaClass compiledMethodAt: self selectedMessageName
ifAbsent: [ ^ '' asText ]).
text := cm symbolic asText.
text addAttribute: TextColor gray; yourself.
cm callTarget ifNotNil: [ :ct | | nodes index string |
nodes := ct getRootNode executeBytecodeNode bytecodeNodes.
index := 1.
string := text string.
string lineIndicesDo: [ :start :end :endWithLineEnding |
(string at: start) = Character tab ifFalse: [ | numBytesOfBytecode |
text addAttribute: (TextColor color: (
(nodes at: index)
ifNil: [ Color red ] ifNotNil: [ Color green ]) muchDarker)
from: start to: end.
numBytesOfBytecode := ((string indexOf: $> startingAt: start) -
(string indexOf: $< startingAt: start)) // 3.
index := index + numBytesOfBytecode ]]].
^ text
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"inspectCallTarget" : "fn 2/17/2021 14:50",
"mainMessageListMenu:" : "fn 2/17/2021 14:51",
"messageList" : "fn 7/8/2021 12:02",
"selectedBytecodes" : "fn 7/14/2021 21:28",
"selectedMessage" : "fn 2/17/2021 12:26",
"showCallTargetInfo:" : "fn 2/17/2021 12:28",
"showingCallTargetInfo" : "fn 2/17/2021 12:01",
Expand Down

0 comments on commit f77d4cf

Please sign in to comment.