diff --git a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testCallTarget.st b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testCallTarget.st new file mode 100644 index 000000000..678e035bd --- /dev/null +++ b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testCallTarget.st @@ -0,0 +1,11 @@ +testing +testCallTarget + | method string | + Java primitiveIsHostLookupAllowed ifFalse: [ ^ false ]. + + method := SmallInteger >> #/. + + self deny: method callTarget isNil. + + string := CallTargetBrowser callTargetInfoStringFor: method. + self assert: (string includesSubstring: 'knownCallSiteCount') \ No newline at end of file diff --git a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json index 5a701157f..aff9acf48 100644 --- a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json +++ b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json @@ -5,6 +5,7 @@ "assertSorted:name:" : "fn 1/25/2020 15:24", "testAdoptInstanceArrays" : "fn 1/31/2020 10:20", "testArrayStatistics" : "fn 5/13/2020 17:37", + "testCallTarget" : "fn 2/18/2021 09:20", "testLayoutStatistics" : "fn 5/13/2020 17:37", "testTestMapConsistency" : "fn 12/17/2020 19:52", "testVMIntrospection" : "fn 2/1/2021 15:00" } } diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/README.md b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/callTargetInfoStringFor..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/callTargetInfoStringFor..st new file mode 100644 index 000000000..98321eaf4 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/callTargetInfoStringFor..st @@ -0,0 +1,27 @@ +helpers +callTargetInfoStringFor: aCompiledMethod + ^ aCompiledMethod callTarget + ifNil: [ 'no call target available' ] + ifNotNil: [ :c | +'name: {1} +callCount: {2} +callAndLoopCount: {3} +knownCallSiteCount: {4} +nonTrivialNodeCount: {5} +profiled return value: {6} +profiled arguments: {7}' format: { + c getName asString. + c getCallCount. + c getCallAndLoopCount. + c getKnownCallSiteCount. + c getNonTrivialNodeCount. + c returnProfile + ifNil: [ 'unknown' ] + ifNotNil: [ :p | p getType ifNil: [ 'unknown' ] ifNotNil: [ :e | e getSimpleName asString ]]. + c argumentsProfile + ifNil: [ 'all unknown' ] + ifNotNil: [ :p | p getTypes + ifNil: [ 'all unknown' ] + ifNotNil: [ :t | ((t asCollection allButFirst: 3) collect: [ :ea | ea + ifNil: ['unknown'] + ifNotNil: [ ea getSimpleName asString ]]) joinSeparatedBy: ', ' ] ] } ] diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showClassIcons.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showClassIcons.st new file mode 100644 index 000000000..0d38e12db --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showClassIcons.st @@ -0,0 +1,3 @@ +preferences +showClassIcons + ^ false \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showMessageIcons.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showMessageIcons.st new file mode 100644 index 000000000..070aaa7a8 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/class/showMessageIcons.st @@ -0,0 +1,3 @@ +preferences +showMessageIcons + ^ false \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/callTargetInfoContents.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/callTargetInfoContents.st new file mode 100644 index 000000000..ed3c9f726 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/callTargetInfoContents.st @@ -0,0 +1,6 @@ +message list +callTargetInfoContents + ^ contents := self selectedClassOrMetaClass methodDict + at: self selectedMessageName + ifPresent: [ :cm | self class callTargetInfoStringFor: cm ] + ifAbsent: [ 'not found' ] diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/contentsSymbolQuints.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/contentsSymbolQuints.st new file mode 100644 index 000000000..83c5d9e60 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/contentsSymbolQuints.st @@ -0,0 +1,4 @@ +controls +contentsSymbolQuints + ^ super contentsSymbolQuints, #(#- + (callTargetInfo toggleCallTargetInfo showingCallTargetInfoString 'call target' 'information on underlying call target')) \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/countsToMessages..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/countsToMessages..st new file mode 100644 index 000000000..835eb35a8 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/countsToMessages..st @@ -0,0 +1,16 @@ +helpers +countsToMessages: aMessageList + | result | + result := Dictionary new. + aMessageList do: [ :ea | | callTarget | + callTarget := (self selectedClassOrMetaClass >> ea asSymbol) callTarget. + result + at: (callTarget ifNil: [-1] ifNotNil: [ :c | + self sortBy caseOf: { + [#callCount] -> [ c getCallCount ln ]. + [#callAndLoopCount] -> [ c getCallAndLoopCount ln ]. + [#knownCallSiteCount] -> [ c getKnownCallSiteCount ]. + [#nonTrivialNodeCount] -> [ c getNonTrivialNodeCount ] } ] ) + ifPresent: [ :v | v add: ea ] + ifAbsentPut: [ OrderedCollection with: ea ] ]. + ^ result \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/defaultBrowserTitle.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/defaultBrowserTitle.st new file mode 100644 index 000000000..e5d7d2655 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/defaultBrowserTitle.st @@ -0,0 +1,3 @@ +initialize-release +defaultBrowserTitle + ^ 'CallTarget Browser' \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/formattedLabel.forSelector.inClass..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/formattedLabel.forSelector.inClass..st new file mode 100644 index 000000000..bd61fc67f --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/formattedLabel.forSelector.inClass..st @@ -0,0 +1,3 @@ +message list +formattedLabel: aString forSelector: aSymbol inClass: aClass + ^ aString \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/inspectCallTarget.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/inspectCallTarget.st new file mode 100644 index 000000000..1877db596 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/inspectCallTarget.st @@ -0,0 +1,6 @@ +message functions +inspectCallTarget + (self selectedClassOrMetaClass + compiledMethodAt: self selectedMessageName + ifAbsent: []) ifNotNil: + [:method| method callTarget inspect] \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/mainMessageListMenu..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/mainMessageListMenu..st new file mode 100644 index 000000000..d74adf039 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/mainMessageListMenu..st @@ -0,0 +1,12 @@ +message functions +mainMessageListMenu: aMenu + ^ (super mainMessageListMenu: aMenu) + add: 'inspect call target' action: #inspectCallTarget; + addLine; + add: 'sort alphabetically' action: #sortAlphabetically; + add: 'sort by call and loop count (default)' action: #sortByCallAndLoopCount; + add: 'sort by call count' action: #sortByCallCount; + add: 'sort by known call site count' action: #sortByKnownCallSiteCount; + add: 'sort by non-trivial node count' action: #sortByNonTrivialNodeCount; + addLine; + yourself \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/messageList.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/messageList.st new file mode 100644 index 000000000..0b6f5b353 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/messageList.st @@ -0,0 +1,16 @@ +message list +messageList + | messages countsToMessages sortedCounts highestCount result | + messages := super messageList. + (self sortBy == #alphabetically or: [ messages isEmpty]) + ifTrue: [ ^ messages ]. + countsToMessages := self countsToMessages: messages. + result := OrderedCollection new. + sortedCounts := countsToMessages keysInOrder reversed. + highestCount := sortedCounts first. + sortedCounts do: [ :count | + result addAll: ((countsToMessages at: count) collect: [ :ea | + ea asText + addAttribute: (self textColorFor: count with: highestCount) + yourself])]. + ^ result \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/selectedMessage.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/selectedMessage.st new file mode 100644 index 000000000..c3f2e5b68 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/selectedMessage.st @@ -0,0 +1,8 @@ +message list +selectedMessage + contents == nil ifFalse: [^ contents copy]. + + self showingCallTargetInfo ifTrue: + [ ^ self callTargetInfoContents ]. + + ^ super selectedMessage \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showCallTargetInfo..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showCallTargetInfo..st new file mode 100644 index 000000000..a71848a63 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showCallTargetInfo..st @@ -0,0 +1,3 @@ +what to show +showCallTargetInfo: aBoolean + self contentsSymbol: (aBoolean ifFalse: [#source] ifTrue: [#callTargetInfo]) \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfo.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfo.st new file mode 100644 index 000000000..d73d5cc5f --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfo.st @@ -0,0 +1,3 @@ +what to show +showingCallTargetInfo + ^ contentsSymbol == #callTargetInfo \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfoString.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfoString.st new file mode 100644 index 000000000..25cb07f3b --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/showingCallTargetInfoString.st @@ -0,0 +1,9 @@ +what to show +showingCallTargetInfoString + "Answer a string telling whether the receiver is showing plain source" + + ^ (self showingCallTargetInfo + ifTrue: + [''] + ifFalse: + ['']), 'call target' \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortAlphabetically.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortAlphabetically.st new file mode 100644 index 000000000..7e4c35fe8 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortAlphabetically.st @@ -0,0 +1,3 @@ +actions +sortAlphabetically + self sortBy: #alphabetically \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy..st new file mode 100644 index 000000000..c3bd9197a --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy..st @@ -0,0 +1,4 @@ +accessing +sortBy: anObject + + sortBy := anObject. \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy.st new file mode 100644 index 000000000..bb0bc6203 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortBy.st @@ -0,0 +1,4 @@ +accessing +sortBy + + ^ sortBy ifNil: [ sortBy := #callAndLoopCount ] \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallAndLoopCount.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallAndLoopCount.st new file mode 100644 index 000000000..000af1a1b --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallAndLoopCount.st @@ -0,0 +1,3 @@ +actions +sortByCallAndLoopCount + self sortBy: #callAndLoopCount \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallCount.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallCount.st new file mode 100644 index 000000000..819917256 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByCallCount.st @@ -0,0 +1,3 @@ +actions +sortByCallCount + self sortBy: #callCount \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByKnownCallSiteCount.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByKnownCallSiteCount.st new file mode 100644 index 000000000..6e9a53344 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByKnownCallSiteCount.st @@ -0,0 +1,3 @@ +actions +sortByKnownCallSiteCount + self sortBy: #knownCallSiteCount \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByNonTrivialNodeCount.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByNonTrivialNodeCount.st new file mode 100644 index 000000000..398b657e1 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/sortByNonTrivialNodeCount.st @@ -0,0 +1,3 @@ +actions +sortByNonTrivialNodeCount + self sortBy: #nonTrivialNodeCount \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/textColorFor.with..st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/textColorFor.with..st new file mode 100644 index 000000000..3c59a1327 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/textColorFor.with..st @@ -0,0 +1,11 @@ +helpers +textColorFor: aCount with: aMax + + ^ aCount >= 0 + ifTrue: [ | r | + r := 1.0 * aCount / aMax. + TextColor color: (Color + r: r + g: 0 + b: 1.0 - r) ] + ifFalse: [ TextColor gray] \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/toggleCallTargetInfo.st b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/toggleCallTargetInfo.st new file mode 100644 index 000000000..e045e9a2a --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/instance/toggleCallTargetInfo.st @@ -0,0 +1,9 @@ +what to show +toggleCallTargetInfo + | wasShowing | + self okToChange ifTrue: + [wasShowing := self showingCallTargetInfo. + self restoreTextualCodingPane. + self showCallTargetInfo: wasShowing not. + self setContentsToForceRefetch. + self contentsChanged] \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/methodProperties.json b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/methodProperties.json new file mode 100644 index 000000000..026cfd164 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/methodProperties.json @@ -0,0 +1,27 @@ +{ + "class" : { + "callTargetInfoStringFor:" : "fn 2/18/2021 09:14", + "showClassIcons" : "fn 2/16/2021 22:17", + "showMessageIcons" : "fn 2/16/2021 22:17" }, + "instance" : { + "callTargetInfoContents" : "fn 2/18/2021 10:12", + "contentsSymbolQuints" : "fn 2/17/2021 12:00", + "countsToMessages:" : "fn 2/17/2021 14:33", + "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", + "messageList" : "fn 2/16/2021 22:13", + "selectedMessage" : "fn 2/17/2021 12:26", + "showCallTargetInfo:" : "fn 2/17/2021 12:28", + "showingCallTargetInfo" : "fn 2/17/2021 12:01", + "showingCallTargetInfoString" : "fn 2/17/2021 12:01", + "sortAlphabetically" : "fn 2/16/2021 17:44", + "sortBy" : "fn 2/16/2021 17:33", + "sortBy:" : "fn 2/16/2021 17:27", + "sortByCallAndLoopCount" : "fn 2/16/2021 17:33", + "sortByCallCount" : "fn 2/16/2021 17:30", + "sortByKnownCallSiteCount" : "fn 2/16/2021 17:39", + "sortByNonTrivialNodeCount" : "fn 2/16/2021 17:39", + "textColorFor:with:" : "fn 2/17/2021 11:08", + "toggleCallTargetInfo" : "fn 2/17/2021 12:28" } } diff --git a/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/properties.json b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/properties.json new file mode 100644 index 000000000..2199beded --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CallTargetBrowser.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "TruffleSqueak-Utilities", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "sortBy" ], + "name" : "CallTargetBrowser", + "pools" : [ + ], + "super" : "Browser", + "type" : "normal" } diff --git a/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/instance/callTarget.st b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/instance/callTarget.st new file mode 100644 index 000000000..52bfa0d97 --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/instance/callTarget.st @@ -0,0 +1,4 @@ +*TruffleSqueak-Utilities +callTarget + + ^ nil \ No newline at end of file diff --git a/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/methodProperties.json b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/methodProperties.json new file mode 100644 index 000000000..a5b49dc0b --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + "callTarget" : "fn 2/16/2021 17:00" } } diff --git a/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/properties.json b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/properties.json new file mode 100644 index 000000000..c19cf97ea --- /dev/null +++ b/src/TruffleSqueak-Utilities.package/CompiledMethod.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "CompiledMethod" }