-
Notifications
You must be signed in to change notification settings - Fork 67
/
VMMethodBytecodeToIRMapping.class.st
78 lines (66 loc) · 2 KB
/
VMMethodBytecodeToIRMapping.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Class {
#name : #VMMethodBytecodeToIRMapping,
#superclass : #Object,
#instVars : [
'method',
'ir',
'mappingList'
],
#category : #'VMMaker-Tools'
}
{ #category : #'instance creation' }
VMMethodBytecodeToIRMapping class >> on: aMethod [
^ self new
method: aMethod;
yourself
]
{ #category : #accessing }
VMMethodBytecodeToIRMapping >> computeIR [
| coggedResult cogit |
coggedResult := StackToRegisterMappingCogit
cog: method
selectorOrNumCopied: (method isCompiledBlock ifFalse: [ method selector ] ifTrue: [ method numTemps ])
options: #(
ObjectMemory Spur64BitCoMemoryManager
ISA aarch64
#bytecodeTableInitializer initializeBytecodeTableForSistaV1).
cogit := coggedResult second.
^ ir := (0 to: cogit getOpcodeIndex - 1) collect: [ :i | cogit abstractOpcodes at: i ]
]
{ #category : #accessing }
VMMethodBytecodeToIRMapping >> gtInspectorMappingIn: composite [
<gtInspectorPresentationOrder: 0>
^ composite fastTable
title: 'Bytecode -> IR';
display: [ :anObject | self mappingList ];
column: 'Bytecode' evaluated: [ :aMapping | aMapping bytecodeString ];
column: 'IR' evaluated: [ :aMapping | aMapping irString ]
]
{ #category : #accessing }
VMMethodBytecodeToIRMapping >> ir [
^ ir ifNil: [ self computeIR ]
]
{ #category : #accessing }
VMMethodBytecodeToIRMapping >> mappingList [
| irStream mappings |
mappingList ifNotNil: [ ^ mappingList ].
irStream := self ir readStream.
mappings := OrderedCollection new.
[ irStream atEnd ] whileFalse: [ | irInstruction bytecode mapping |
irInstruction := irStream next.
mapping := VMBytecodeToIRMapping new.
bytecode := irInstruction bcpc
ifNil: [ nil ]
ifNotNil: [ method symbolicBytecodes
detect: [ :e | e offset = (irInstruction bcpc + 1) ]
ifNone: [ 'Bad bcpc mapping?' ] ].
mapping bytecodeInstruction: bytecode.
mapping irInstruction: irInstruction.
mappings add: mapping.
].
^ mappingList := mappings
]
{ #category : #accessing }
VMMethodBytecodeToIRMapping >> method: aMethod [
method := aMethod
]