|
| 1 | +Class { |
| 2 | + #name : 'VMClassTagInlineReadTest', |
| 3 | + #superclass : 'VMPrimitiveCallAbstractTest', |
| 4 | + #pools : [ |
| 5 | + 'CogRTLOpcodes' |
| 6 | + ], |
| 7 | + #category : 'VMMakerTests-JitTests', |
| 8 | + #package : 'VMMakerTests', |
| 9 | + #tag : 'JitTests' |
| 10 | +} |
| 11 | + |
| 12 | +{ #category : 'tests' } |
| 13 | +VMClassTagInlineReadTest >> testLinkingWithEntryOffset [ |
| 14 | + |
| 15 | + | sendingMethod targetMethod callSiteReturn | |
| 16 | + sendingMethod := self |
| 17 | + jitMethod: (self findMethod: #methodWithSend) |
| 18 | + selector: memory nilObject. |
| 19 | + |
| 20 | + targetMethod := self |
| 21 | + jitMethod: (self findMethod: #yourself) |
| 22 | + selector: memory trueObject. |
| 23 | + |
| 24 | + callSiteReturn := sendingMethod address + 16r98. |
| 25 | + |
| 26 | + cogit |
| 27 | + linkSendAt: callSiteReturn |
| 28 | + in: sendingMethod |
| 29 | + to: targetMethod |
| 30 | + offset: cogit entryOffset |
| 31 | + receiver: memory falseObject. |
| 32 | + |
| 33 | + self assert: (cogit backend inlineCacheTagAt: callSiteReturn) equals:(memory classIndexOf: memory falseObject) |
| 34 | +] |
| 35 | + |
| 36 | +{ #category : 'tests' } |
| 37 | +VMClassTagInlineReadTest >> testLinkingWithEntryOffsetLargeClassIndex [ |
| 38 | + |
| 39 | + | sendingMethod targetMethod callSiteReturn | |
| 40 | + sendingMethod := self |
| 41 | + jitMethod: (self findMethod: #methodWithSend) |
| 42 | + selector: memory nilObject. |
| 43 | + |
| 44 | + targetMethod := self |
| 45 | + jitMethod: (self findMethod: #yourself) |
| 46 | + selector: memory trueObject. |
| 47 | + |
| 48 | + callSiteReturn := sendingMethod address + 16r98. |
| 49 | + |
| 50 | + obj := self newZeroSizedObject. |
| 51 | + memory setClassIndexOf: obj to: (1 << memory classIndexFieldWidth - 5). |
| 52 | + |
| 53 | + cogit |
| 54 | + linkSendAt: callSiteReturn |
| 55 | + in: sendingMethod |
| 56 | + to: targetMethod |
| 57 | + offset: cogit entryOffset |
| 58 | + receiver: obj. |
| 59 | + |
| 60 | + |
| 61 | + self assert: (cogit backend inlineCacheTagAt: callSiteReturn) equals: (1 << memory classIndexFieldWidth - 5) |
| 62 | +] |
0 commit comments