-
Notifications
You must be signed in to change notification settings - Fork 67
/
CogMethodSurrogate32.class.st
106 lines (93 loc) · 2.9 KB
/
CogMethodSurrogate32.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
"
Here's a doit to generate my code:
| offset crtab |
offset := 1.
crtab := String with: Character cr with: Character tab.
CogMethod instVarNamesAndTypesForTranslationDo:
[:name :type| | isByte class |
(isByte := type = 'unsigned char') ifFalse:
[offset := (offset - 1 + 3 bitAnd: -4) + 1].
class := (CogBlockMethod instVarNames includes: name)
ifTrue: [CogBlockMethodSurrogate32]
ifFalse: [CogMethodSurrogate32].
class
compile: name, crtab, '^memory unsigned', (isByte ifTrue: ['ByteAt:'] ifFalse: ['LongAt:']), ' address + ', offset printString
classified: #accessing.
class
compile: name, ': aValue', crtab, '^memory unsigned', (isByte ifTrue: ['ByteAt:'] ifFalse: ['LongAt:']), ' address + ', offset printString,
' put: aValue'
classified: #accessing.
offset := offset + (isByte ifTrue: [1] ifFalse: [4])].
CogMethodSurrogate32 class compile: 'alignedByteSize', crtab, '^', (offset - 1 + 3 bitAnd: -4) printString classified: #'instance creation'
"
Class {
#name : #CogMethodSurrogate32,
#superclass : #CogBlockMethodSurrogate32,
#category : #'VMMaker-JITSimulation'
}
{ #category : #accessing }
CogMethodSurrogate32 class >> alignedByteSize [
^20 + self baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 class >> offsetOf: aByteSymbol [
"These should be generated!!"
| baseHeaderSize |
baseHeaderSize := self objectMemoryClass baseHeaderSize.
^aByteSymbol caseOf:
{ [#methodObject] -> [8 + baseHeaderSize].
[#methodHeader] -> [12 + baseHeaderSize].
[#selector] -> [16 + baseHeaderSize].
[#picUsage] -> [6 + baseHeaderSize].
}
]
{ #category : #accessing }
CogMethodSurrogate32 >> blockSize [
^memory unsignedShortAt: address + 4 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> blockSize: aValue [
^memory
unsignedShortAt: address + baseHeaderSize + 4
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodHeader [
^memory unsignedLong32At: address + 12 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodHeader: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 12
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodObject [
^memory unsignedLong32At: address + 8 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodObject: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 8
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> picUsage [
^memory unsignedShortAt: address + 6 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> picUsage: aValue [
^memory
unsignedShortAt: address + baseHeaderSize + 6
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> selector [
^memory unsignedLong32At: address + 16 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> selector: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 16
put: aValue
]