Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix method trailer problem in Pharo 12 #26

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Hermes/HEInstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,32 @@ HEInstaller >> messageMethod: aHEMethod alreadyExistsIn: aClass [

{ #category : 'installing methods' }
HEInstaller >> rebuildMethod: aMethod into: aClass [

| newMethod literalSpace extendedEnvironment |

(self shouldBuildMethod: aMethod in: aClass) ifFalse: [ ^ self ].
(self shouldBuildMethod: aMethod in: aClass) ifFalse: [ ^ self ].

extendedEnvironment := HEExtendedEnvironment new.
extendedEnvironment inner: environment.
extendedEnvironment newClass: aClass.
extendedEnvironment newSelector: aMethod name.

newMethod := CompiledMethod newMethod: aMethod bytecode size header: (aMethod headerFor: extendedEnvironment).
self flag: #pharo11. "If Pharo12 the management of the method trailer changed and the way to create a new method changed too."
newMethod := CompiledMethod
newMethod: (SystemVersion current major >= 12
ifTrue: [ aMethod bytecode size + CompiledMethod trailerSize ]
ifFalse: [ aMethod bytecode size ])
header: (aMethod headerFor: extendedEnvironment).

extendedEnvironment newMethod: newMethod.

aMethod literals
doWithIndex:
[ :literal :idx | newMethod literalAt: idx put: (literal asLiteralIn: extendedEnvironment) ].
aMethod literals doWithIndex: [ :literal :idx | newMethod literalAt: idx put: (literal asLiteralIn: extendedEnvironment) ].

newMethod classBinding: aClass binding.
literalSpace := (aMethod literals size + 1) * Smalltalk wordSize.
literalSpace := aMethod literals size + 1 * Smalltalk wordSize.

aMethod bytecode doWithIndex: [ :e :idx | newMethod at: idx + literalSpace put: e ].

aClass
addAndClassifySelector: aMethod name
withMethod: newMethod
inProtocol: aMethod protocol
aClass addAndClassifySelector: aMethod name withMethod: newMethod inProtocol: aMethod protocol
]

{ #category : 'reporting undeclared' }
Expand Down
Loading