-
Notifications
You must be signed in to change notification settings - Fork 71
/
CMethodCacheAccessor.class.st
44 lines (40 loc) · 1.86 KB
/
CMethodCacheAccessor.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
"
I am used to simulate accesses to the methodCache so it can live partly in memory, partly in a Smalltalk Array. This is necessary because in simulation function pointers are Smalltalk symbols (under simulation primitive dispatch is done via perform:).
"
Class {
#name : #CMethodCacheAccessor,
#superclass : #CArrayOfLongsAccessor,
#instVars : [
'methodCacheArray',
'entrySize',
'functionPointerIndex'
],
#category : #'VMMaker-JITSimulation'
}
{ #category : #accessing }
CMethodCacheAccessor >> at: index [
"The special handling of functionPointerIndex is necessary because in simulation function
pointers are Smalltalk symbols (under simulation primitive dispatch is done via perform:)."
index - 1 \\ entrySize = functionPointerIndex ifTrue:
[^methodCacheArray at: index].
^objectMemory longAt: index * elementByteSize + address
]
{ #category : #accessing }
CMethodCacheAccessor >> at: index put: value [
"The special handling of functionPointerIndex is necessary because in simulation function
pointers are Smalltalk symbols (under simulation primitive dispatch is done via perform:)."
(index = 16r44F and: [value = 16r1D]) ifTrue:
[self halt].
index - 1 \\ entrySize = functionPointerIndex ifTrue:
[objectMemory longAt: index * elementByteSize + address put: (0 = value ifTrue: [value] ifFalse: [value identityHash]).
^methodCacheArray at: index put: value].
^objectMemory longAt: index * elementByteSize + address put: value
]
{ #category : #'initialize-release' }
CMethodCacheAccessor >> objectMemory: anObjectMemory at: anAddress array: cacheArray functionPointerIndex: fpIndex entrySize: wordsPerCacheEntry [
self objectMemory: anObjectMemory
at: anAddress - anObjectMemory wordSize. "implicit -1 for indices in at:[put:]; the MethodCache is one-relative"
methodCacheArray := cacheArray.
functionPointerIndex := fpIndex - 1.
entrySize := wordsPerCacheEntry
]