-
Notifications
You must be signed in to change notification settings - Fork 68
/
VMJittedLookupTest.class.st
157 lines (127 loc) · 4.54 KB
/
VMJittedLookupTest.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Class {
#name : #VMJittedLookupTest,
#superclass : #VMSimpleStackBasedCogitAbstractTest,
#instVars : [
'methodOop',
'selectorOop',
'receiver',
'receiverClass'
],
#category : #'VMMakerTests-JitTests'
}
{ #category : #tests }
VMJittedLookupTest >> installSelector: aSelectorOop method: aMethodOop inMethodDictionary: aMethodDictionary [
| anArrayOfMethods |
anArrayOfMethods := memory fetchPointer: MethodArrayIndex ofObject: aMethodDictionary.
memory
storePointer: (memory methodDictionaryHash: aSelectorOop mask: 11) + 2
ofObject: aMethodDictionary
withValue: aSelectorOop.
memory
storePointer: (memory methodDictionaryHash: aSelectorOop mask: 11)
ofObject: anArrayOfMethods
withValue: aMethodOop
]
{ #category : #tests }
VMJittedLookupTest >> setArrayClassIntoClassTable [
| aClass |
aClass := self
newClassInOldSpaceWithSlots: 0
instSpec: Array instSpec.
memory setHashBitsOf: aClass to: ClassArrayCompactIndex.
memory
storePointer: ClassArrayCompactIndex
ofObject: memory classTableFirstPage
withValue: aClass
]
{ #category : #tests }
VMJittedLookupTest >> setMessageClassIntoClassTable [
| aClass |
aClass := self
newClassInOldSpaceWithSlots: MessageSend allSlots size
instSpec: MessageSend instSpec.
memory setHashBitsOf: aClass to: ClassMessageCompactIndex.
memory
storePointer: ClassMessageCompactIndex
ofObject: memory classTableFirstPage
withValue: aClass
]
{ #category : #tests }
VMJittedLookupTest >> setUpClassAndMethod [
methodOop := methodBuilder newMethod buildMethod.
selectorOop := self
newClassInOldSpaceWithSlots: 0
instSpec: memory nonIndexablePointerFormat.
receiver := memory integerObjectOf: 56.
receiverClass := self setSmallIntegerClassIntoClassTable
]
{ #category : #tests }
VMJittedLookupTest >> setUpMethodDictionaryIn: aClass [
"2 instances variables the array of methods and the tally
and 12 entries to put elemetns of the collection"
| aMethodDictionary anArrayOfMethods |
aMethodDictionary := self
newObjectWithSlots: 2 + 12
format: MethodDictionary instSpec
classIndex: memory arrayClassIndexPun.
anArrayOfMethods := self
newObjectWithSlots: 12
format: Array instSpec
classIndex: memory arrayClassIndexPun.
memory
storePointer: MethodDictionaryIndex
ofObject: aClass
withValue: aMethodDictionary.
memory
storePointer: MethodArrayIndex
ofObject: aMethodDictionary
withValue: anArrayOfMethods.
]
{ #category : #tests }
VMJittedLookupTest >> testLookUpMNUShouldJItCompile [
| superclass superclassMethodDictionary foundMethod |
self setUpTrampolines.
cogit computeEntryOffsets.
self setUpClassAndMethod.
self setArrayClassIntoClassTable.
self setMessageClassIntoClassTable.
self setUpMethodDictionaryIn: receiverClass.
superclass := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
self setUpMethodDictionaryIn: superclass.
superclassMethodDictionary := memory fetchPointer: MethodDictionaryIndex ofObject: superclass.
memory storePointer: SuperclassIndex ofObject: receiverClass withValue: superclass.
self installSelector: selectorOop method: methodOop inMethodDictionary: superclassMethodDictionary.
interpreter methodDictLinearSearchLimit: 3.
interpreter setBreakSelector: nil.
interpreter messageSelector: selectorOop.
"Install the selector as a DNU selector"
memory splObj: SelectorDoesNotUnderstand put: selectorOop.
foundMethod := interpreter mnuMethodOrNilFor: receiver.
self assert: foundMethod equals: methodOop
]
{ #category : #tests }
VMJittedLookupTest >> testLookUpMNUWithAnyNonMethodObjectShouldNotJItCompile [
| superclass superclassMethodDictionary foundMethod |
self setUpTrampolines.
cogit computeEntryOffsets.
self setUpClassAndMethod.
self setArrayClassIntoClassTable.
self setMessageClassIntoClassTable.
self setUpMethodDictionaryIn: receiverClass.
superclass := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
self setUpMethodDictionaryIn: superclass.
superclassMethodDictionary := memory fetchPointer: MethodDictionaryIndex ofObject: superclass.
memory storePointer: SuperclassIndex ofObject: receiverClass withValue: superclass.
self installSelector: selectorOop method: (memory integerValueOf: 37) inMethodDictionary: superclassMethodDictionary.
interpreter methodDictLinearSearchLimit: 3.
interpreter setBreakSelector: nil.
interpreter messageSelector: selectorOop.
"Install the selector as a DNU selector"
memory splObj: SelectorDoesNotUnderstand put: selectorOop.
foundMethod := interpreter mnuMethodOrNilFor: receiver.
self assert: foundMethod isNil
]