From dcdcaf65fc3832100cd6f87ca87cbf0b952e339f Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Tue, 17 Oct 2023 15:28:25 +0200 Subject: [PATCH 1/2] Fix method trailer problem in Pharo 12 --- src/Hermes/HEInstaller.class.st | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Hermes/HEInstaller.class.st b/src/Hermes/HEInstaller.class.st index 9599c84..d013eb0 100644 --- a/src/Hermes/HEInstaller.class.st +++ b/src/Hermes/HEInstaller.class.st @@ -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' } From 7f4511b62429daab42df77d5522fb7e5dcb66671 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Tue, 17 Oct 2023 15:57:23 +0200 Subject: [PATCH 2/2] stupid stupid Cyril -_- --- src/Hermes/HEInstaller.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hermes/HEInstaller.class.st b/src/Hermes/HEInstaller.class.st index d013eb0..c9ed8a1 100644 --- a/src/Hermes/HEInstaller.class.st +++ b/src/Hermes/HEInstaller.class.st @@ -217,7 +217,7 @@ HEInstaller >> rebuildMethod: aMethod into: aClass [ 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 + newMethod: (SystemVersion current major >= 12 ifTrue: [ aMethod bytecode size + CompiledMethod trailerSize ] ifFalse: [ aMethod bytecode size ]) header: (aMethod headerFor: extendedEnvironment).