Skip to content

Commit

Permalink
Add ability to show coverage based on Truffle ASTs
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jul 15, 2021
1 parent f77d4cf commit 319e5dc
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
what to show
aboutToStyle: aStyler
^ self showCoverage not and: [ super aboutToStyle: aStyler ]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ mainMessageListMenu: aMenu
add: 'sort by known call site count' action: #sortByKnownCallSiteCount;
add: 'sort by non-trivial node count' action: #sortByNonTrivialNodeCount;
addLine;
add: 'toggle coverage based on Truffle ASTs' action: #toggleCoverage;
addLine;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
showCoverage: anObject

showCoverage := anObject.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
showCoverage

^ showCoverage ifNil: [ false ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
message list
sourceStringPrettifiedAndDiffed
| text |
text := super sourceStringPrettifiedAndDiffed.
(self showCoverage and: [ contentsSymbol = #source ]) ifFalse: [ ^ text ].
currentCompiledMethod callTarget ifNotNil: [ :ct | | map nodes initialPC scanner client |
map := DebuggerMethodMap forMethod: currentCompiledMethod.
nodes := ct getRootNode executeBytecodeNode bytecodeNodes.
initialPC := currentCompiledMethod initialPC.
scanner := InstructionStream on: currentCompiledMethod.
client := InstructionClient new.
[ scanner pc <= currentCompiledMethod endPC ] whileTrue: [ | pc range attribute |
pc := scanner pc.
(scanner willSend or: [ scanner willReturn ]) ifTrue: [
range := map rangeForPC: pc in: currentCompiledMethod contextIsActiveContext: true.
attribute := TextColor color: (
(nodes at: (1 + pc - initialPC))
ifNil: [ Color red ] ifNotNil: [ Color green ]) muchDarker.
text addAttribute: attribute from: range first to: range last ].
scanner interpretNextInstructionFor: client ] ].
^ text
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions
toggleCoverage
self showCoverage: self showCoverage not.
self changed: #contents
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
self-updating
updateListsAndCodeIn: aWindow
super updateListsAndCodeIn: aWindow.
self showingCallTargetInfo ifTrue: [
(self showingCallTargetInfo or: [ self showCoverage ]) ifTrue: [
self setContentsToForceRefetch.
self contentsChanged ]
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
"showMessageIcons" : "fn 2/16/2021 22:17",
"textColorFor:with:" : "fn 3/12/2021 11:14" },
"instance" : {
"aboutToStyle:" : "fn 7/15/2021 10:24",
"callTargetInfoContents" : "fn 3/12/2021 11:08",
"contentsSymbolQuints" : "fn 2/17/2021 12:00",
"countsToMessages:" : "fn 3/12/2021 11:48",
"defaultBrowserTitle" : "fn 2/16/2021 16:54",
"formattedLabel:forSelector:inClass:" : "fn 2/16/2021 22:10",
"inspectCallTarget" : "fn 2/17/2021 14:50",
"mainMessageListMenu:" : "fn 2/17/2021 14:51",
"mainMessageListMenu:" : "fn 7/15/2021 10:22",
"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",
"showCoverage" : "fn 7/15/2021 10:23",
"showCoverage:" : "fn 7/15/2021 10:22",
"showingCallTargetInfo" : "fn 2/17/2021 12:01",
"showingCallTargetInfoString" : "fn 2/17/2021 12:01",
"sortAlphabetically" : "fn 2/16/2021 17:44",
Expand All @@ -27,5 +30,7 @@
"sortByCallCount" : "fn 2/16/2021 17:30",
"sortByKnownCallSiteCount" : "fn 2/16/2021 17:39",
"sortByNonTrivialNodeCount" : "fn 2/16/2021 17:39",
"sourceStringPrettifiedAndDiffed" : "fn 7/15/2021 10:25",
"toggleCallTargetInfo" : "fn 2/17/2021 12:28",
"updateListsAndCodeIn:" : "fn 2/21/2021 15:59" } }
"toggleCoverage" : "fn 7/15/2021 10:27",
"updateListsAndCodeIn:" : "fn 7/15/2021 10:34" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
],
"commentStamp" : "",
"instvars" : [
"sortBy" ],
"sortBy",
"showCoverage" ],
"name" : "CallTargetBrowser",
"pools" : [
],
Expand Down

0 comments on commit 319e5dc

Please sign in to comment.