-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMForwardLiteralInMachineMethodTest.class.st
79 lines (53 loc) · 2.51 KB
/
VMForwardLiteralInMachineMethodTest.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
Class {
#name : #VMForwardLiteralInMachineMethodTest,
#superclass : #VMPrimitiveCallAbstractTest,
#pools : [
'CogRTLOpcodes'
],
#category : #'VMMakerTests-JitTests'
}
{ #category : #helpers }
VMForwardLiteralInMachineMethodTest >> initStack [
self createBaseFrame.
"Initialize Stack to the correct pointers in the selected page"
machineSimulator smalltalkStackPointerRegisterValue: interpreter stackPointer.
machineSimulator framePointerRegisterValue: interpreter framePointer.
machineSimulator baseRegisterValue: cogit varBaseAddress.
cogit setCStackPointer: interpreter rumpCStackAddress.
cogit setCFramePointer: interpreter rumpCStackAddress.
]
{ #category : #'methods under test' }
VMForwardLiteralInMachineMethodTest >> methodWithGlobal [
^ Smalltalk
]
{ #category : #tests }
VMForwardLiteralInMachineMethodTest >> testForwardLiteralInMethod [
| machineCodeMethod literal methodOop array literalValue selector associationClass valueClass literalKey |
methodOop := self createMethodOopFromHostMethod: (self findMethod: #methodWithGlobal).
selector := self newZeroSizedObject.
literal := methodBuilder literals at: 1.
literalKey := memory fetchPointer: 0 ofObject: literal.
associationClass := self newClassInOldSpaceWithSlots: 2 instSpec: Association instSpec.
memory setClassIndexOf: literal to: (memory ensureBehaviorHash: associationClass).
valueClass := self newClassInOldSpaceWithSlots: 0 instSpec: Object instSpec.
literalValue := self newObjectWithSlots: 0 classIndex: (memory ensureBehaviorHash: valueClass).
memory storePointer: 1 ofObject: literal withValue: literalValue.
self initStack.
machineCodeMethod := cogit cog: methodOop selector: selector.
array := memory newArrayWith: {literal. literalValue}.
memory moveToPermSpaceInBulk: array.
self assert: (memory isForwarded: literal).
self assert: (memory isForwarded: literalValue).
literal := memory followForwarded: literal.
literalValue := memory followForwarded: literalValue.
"We mark because we don't care about this, we care about resolving the forwarders"
memory setIsMarkedOf: methodOop to: true.
memory setIsMarkedOf: selector to: true.
memory setIsMarkedOf: associationClass to: true.
memory setIsMarkedOf: valueClass to: true.
memory setIsMarkedOf: literalKey to: true.
memory initializeMarkStack.
self assert: (cogit hasMachineCodeMethodForwardedLiterals: machineCodeMethod).
cogit markAndTraceLiteralsIn:machineCodeMethod.
self deny: (cogit hasMachineCodeMethodForwardedLiterals: machineCodeMethod)
]