-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
FLCompiledMethodCluster.class.st
100 lines (77 loc) · 3.12 KB
/
FLCompiledMethodCluster.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
"
I am a cluster for CompiledMethod instances.
How CompiledMethod trailers are serialized can be established using methods in 'configurating' class-side protocol.
"
Class {
#name : #FLCompiledMethodCluster,
#superclass : #FLCompiledCodeCluster,
#classInstVars : [
'transformationForSerializing'
],
#category : #'Fuel-Core-Clusters'
}
{ #category : #cleanup }
FLCompiledMethodCluster class >> cleanUp [
self initialize
]
{ #category : #analyzing }
FLCompiledMethodCluster class >> clusterBucketIn: aClusterization [
^aClusterization primitivesBucket
]
{ #category : #'class initialization' }
FLCompiledMethodCluster class >> initialize [
self setTrailerWithSourceCode
]
{ #category : #configuring }
FLCompiledMethodCluster class >> setTrailerWithNoChange [
"Make compiled methods be serialized as they are."
^ self transformationForSerializing: [:aCompiledMethod | aCompiledMethod ]
]
{ #category : #configuring }
FLCompiledMethodCluster class >> setTrailerWithNoSource [
"Make compiled methods be serialized without source code."
^ self transformationForSerializing: [:aCompiledMethod |
aCompiledMethod copyWithTrailerBytes: CompiledMethodTrailer empty ]
]
{ #category : #configuring }
FLCompiledMethodCluster class >> setTrailerWithSourceCode [
"Make compiled methods be serialized with embedded source code."
^ self transformationForSerializing: [:aCompiledMethod |
aCompiledMethod copyWithTrailerBytes:
(CompiledMethodTrailer new sourceCode: aCompiledMethod sourceCode) ]
]
{ #category : #accessing }
FLCompiledMethodCluster class >> transformationForSerializing [
"Answer a block closure that receives a CompiledMethod and returns another or the same CompiledMethod ready for being serialized."
^ transformationForSerializing
]
{ #category : #accessing }
FLCompiledMethodCluster class >> transformationForSerializing: aBlockWithOneArgument [
transformationForSerializing := aBlockWithOneArgument
]
{ #category : #'serialize/materialize' }
FLCompiledMethodCluster >> materializeInstanceWith: aDecoder [
| compiledMethod header bytecodesPlusTrailerSize |
header := aDecoder nextEncodedInt64.
bytecodesPlusTrailerSize := aDecoder nextEncodedUint16.
compiledMethod := CompiledMethod newMethod: bytecodesPlusTrailerSize header: header.
compiledMethod initialPC to: compiledMethod size
do: [ :index | compiledMethod at: index put: aDecoder nextEncodedByte ].
^ compiledMethod
]
{ #category : #'serialize/materialize' }
FLCompiledMethodCluster >> serializeInstance: aCompiledMethodToSerialize with: anEncoder [
| header bytecodesPlusTrailerSize cmSize cmInitialPC aCompiledMethod |
"In 64 bit VMs the header is actually 64 bits wide but only 32 bits
contain information."
aCompiledMethod := self class transformationForSerializing value: aCompiledMethodToSerialize.
header := aCompiledMethod header.
cmSize := aCompiledMethod size.
cmInitialPC := aCompiledMethod initialPC.
bytecodesPlusTrailerSize := cmSize - cmInitialPC + 1.
anEncoder
encodeInt64: header; "Signed int as of Pharo 40"
encodeUint16: bytecodesPlusTrailerSize.
cmInitialPC to: cmSize
do: [ :index | anEncoder encodeByte: (aCompiledMethod at: index) ]
]