Re: [Pharo-dev] [Vm-dev] VM Maker: VMMaker.oscog-eem.1609.mcz
Hi All, the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X: â Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. â On Thu, Dec 17, 2015 at 10:42 AM, <commits@source.squeak.org> wrote:
Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1609.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1609 Author: eem Time: 17 December 2015, 10:41:49.192 am UUID: 771cdc25-5d27-4818-8943-2ba5c0e31791 Ancestors: VMMaker.oscog-eem.1608
Cogit: Fix the (arguably bogus) register save/restore code for safe trampolines, including the ceScheduleScavenge call.
=============== Diff against VMMaker.oscog-eem.1608 ===============
Item was added: + ----- Method: CogARMCompiler>>genSaveRegForCCall (in category 'abi') ----- + genSaveRegForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline." + "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." + "cogit gen: STMFD operand: 16r7F"!
Item was removed: - ----- Method: CogARMCompiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." - "cogit gen: STMFD operand: 16r7F"!
Item was added: + ----- Method: CogARMCompiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a trampoline call." + "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." + "cogit gen: STMFD operand: 16r7F" + self flag: 'this will change with Sista when we hope to be able to allocate arbitrary registers'!
Item was removed: - ----- Method: CogAbstractInstruction>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - self subclassResponsibility!
Item was changed: ----- Method: CogIA32Compiler>>genRestoreRegsExcept: (in category 'abi') ----- genRestoreRegsExcept: abstractReg | realReg | realReg := self concreteRegister: abstractReg. self assert: (EDI > EAX and: [EDI - EAX + 1 = 6]). EAX to: EDI do: [:reg| + (reg between: ESP and: EBP) ifFalse: + [realReg = reg + ifTrue: [cogit AddCq: 4 R: ESP] + ifFalse: [cogit PopR: reg]]]. - realReg = reg ifTrue: [cogit AddCq: 4 R: ESP] ifFalse: [cogit PopR: reg]]. ^0!
Item was removed: - ----- Method: CogIA32Compiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - - self assert: (EDI > EAX and: [EDI - EAX + 1 = 8]). - EDI to: EAX by: -1 do: - [:reg| - (reg between: ESP and: EBP) ifFalse: - [cogit PushR: reg]]. - ^0!
Item was added: + ----- Method: CogIA32Compiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline." + + self assert: (EDI > EAX and: [EDI - EAX + 1 = 8]). + EDI to: EAX by: -1 do: + [:reg| + (reg between: ESP and: EBP) ifFalse: + [cogit PushR: reg]]. + ^0!
Item was removed: - ----- Method: CogMIPSELCompiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "This method is poorly named. Is this for a Smalltalk -> C call or C -> Smalltalk call? - If the former we don't need to do anything because all of the abstract registers are - allocated to C preserved registers." - self flag: #bogus.!
Item was added: + ----- Method: CogMIPSELCompiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline. + We don't need to do anything because all of the abstract registers are + allocated to C preserved registers." + self flag: 'this will change with Sista when we hope to be able to allocate arbitrary registers'!
Item was changed: ----- Method: CogX64Compiler>>genRestoreRegs (in category 'abi') ----- genRestoreRegs "Restore the general purpose registers for a trampoline call. c.f. genSaveRegisters" + RAX to: R15 do: + [:reg| + (reg between: RSP and: RBP) ifFalse: + [cogit PopR: reg]]. - cogit - PopR: RAX; - PopR: RBX; - PopR: RCX; - PopR: RDX; - PopR: RSI; - PopR: RDI; - PopR: R8; - PopR: R9; - PopR: R10; - PopR: R11; - PopR: R12; - PopR: R13; - PopR: R14; - PopR: R15. ^0!
Item was changed: ----- Method: CogX64Compiler>>genRestoreRegsExcept: (in category 'abi') ----- genRestoreRegsExcept: abstractReg | realReg | realReg := self concreteRegister: abstractReg. self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). RAX to: R15 do: [:reg| + (reg between: RSP and: RBP) ifFalse: + [realReg = reg + ifTrue: [cogit AddCq: 8 R: RSP] + ifFalse: [cogit PopR: reg]]]. - realReg = reg ifTrue: [cogit AddCq: 4 R: RSP] ifFalse: [cogit PopR: reg]]. ^0!
Item was removed: - ----- Method: CogX64Compiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - - self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). - R15 to: RAX by: -1 do: [:reg| cogit PushR: reg]. - ^0!
Item was added: + ----- Method: CogX64Compiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a trampoline call." + + self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). + R15 to: RAX by: -1 do: + [:reg| + (reg between: RSP and: RBP) ifFalse: + [cogit PushR: reg]]. + ^0!
Item was changed: ----- Method: Cogit>>compileCallFor:numArgs:arg:arg:arg:arg:resultReg:saveRegs: (in category 'initialization') ----- compileCallFor: aRoutine numArgs: numArgs arg: regOrConst0 arg: regOrConst1 arg: regOrConst2 arg: regOrConst3 resultReg: resultRegOrNone saveRegs: saveRegs "Generate a call to aRoutine with up to 4 arguments. If resultRegOrNone is not NoReg assign the C result to resultRegOrNone. If saveRegs, save all registers. Hack: a negative arg value indicates an abstract register, a non-negative value indicates a constant." <var: #aRoutine type: #'void *'> <inline: false> cStackAlignment > objectMemory wordSize ifTrue: [backEnd genAlignCStackSavingRegisters: saveRegs numArgs: numArgs wordAlignment: cStackAlignment / objectMemory wordSize]. saveRegs ifTrue: + [backEnd genSaveRegsForCCall]. - [backEnd genSaveRegisters]. backEnd genMarshallNArgs: numArgs arg: regOrConst0 arg: regOrConst1 arg: regOrConst2 arg: regOrConst3. self CallFullRT: (self cCode: [aRoutine asUnsignedInteger] inSmalltalk: [self simulatedTrampolineFor: aRoutine]). resultRegOrNone ~= NoReg ifTrue: [backEnd genWriteCResultIntoReg: resultRegOrNone]. saveRegs ifTrue: [numArgs > 0 ifTrue: [backEnd genRemoveNArgsFromStack: numArgs]. resultRegOrNone ~= NoReg ifTrue: [backEnd genRestoreRegsExcept: resultRegOrNone] ifFalse: [backEnd genRestoreRegs]]!
-- _,,,^..^,,,_ best, Eliot
Fantastic! cheers -ben On Fri, Dec 18, 2015 at 3:12 AM, Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. â
On Thu, Dec 17, 2015 at 11:12:35AM -0800, Eliot Miranda wrote:
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
???
Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. ???
Outstanding! Congratulations. Dave
This is great news! Thierry Le 17/12/2015 20:12, Eliot Miranda a écrit :
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
â
Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. â
Can't wait esp for the 64-bit address space ;-)
On 18 Dec 2015, at 06:46, Thierry Goubier <thierry.goubier@gmail.com> wrote:
This is great news!
Thierry
Le 17/12/2015 20:12, Eliot Miranda a écrit :
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
â
Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. â
SmallInteger maxVal highBit -> 60. 3 bits reserved for immediate tags, 1 bit for sign, 60 remaining for positive magnitude... 2015-12-20 11:56 GMT+01:00 stepharo <stepharo@free.fr>:
Super !!! Eliot what will be
1 class maxval then?
Stef
Le 17/12/15 20:12, Eliot Miranda a écrit :
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
:) So is it correct to think that a lot of number oriented computation will go faster because not on large positive integers? Stef Le 20/12/15 13:39, Nicolas Cellier a écrit :
SmallInteger maxVal highBit -> 60. 3 bits reserved for immediate tags, 1 bit for sign, 60 remaining for positive magnitude...
2015-12-20 11:56 GMT+01:00 stepharo <stepharo@free.fr <mailto:stepharo@free.fr>>:
Super !!! Eliot what will be
1 class maxval then?
Stef
Le 17/12/15 20:12, Eliot Miranda a écrit :
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
Hmm, for micro-benchmark maybe, but this has to be measured once the JIT is ready.
From the stack VM, I can notice a slight slowdown w.r.t. 32 bits stack. But it doesn't really matter, stak is too slow compared to COG, so let's wait.
2015-12-21 21:24 GMT+01:00 stepharo <stepharo@free.fr>:
:) So is it correct to think that a lot of number oriented computation will go faster because not on large positive integers?
Stef
Le 20/12/15 13:39, Nicolas Cellier a écrit :
SmallInteger maxVal highBit -> 60. 3 bits reserved for immediate tags, 1 bit for sign, 60 remaining for positive magnitude...
2015-12-20 11:56 GMT+01:00 stepharo <stepharo@free.fr>:
Super !!! Eliot what will be
1 class maxval then?
Stef
Le 17/12/15 20:12, Eliot Miranda a écrit :
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
Merry Christmas to you, too :)! Doru
On Dec 17, 2015, at 8:12 PM, Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi All,
the real Cog 64-bit Spur x64 VM just evaluated 3+4 correctly on Mac OS X:
<Screen Shot 2015-12-17 at 11.10.14.png> â
Early days yet. This is a debug VM. The optimised VM does not yet display the prompt. But we can be confident that a 64-bit JIT for Spur will be available some time in January. â
On Thu, Dec 17, 2015 at 10:42 AM, <commits@source.squeak.org> wrote:
Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1609.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1609 Author: eem Time: 17 December 2015, 10:41:49.192 am UUID: 771cdc25-5d27-4818-8943-2ba5c0e31791 Ancestors: VMMaker.oscog-eem.1608
Cogit: Fix the (arguably bogus) register save/restore code for safe trampolines, including the ceScheduleScavenge call.
=============== Diff against VMMaker.oscog-eem.1608 ===============
Item was added: + ----- Method: CogARMCompiler>>genSaveRegForCCall (in category 'abi') ----- + genSaveRegForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline." + "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." + "cogit gen: STMFD operand: 16r7F"!
Item was removed: - ----- Method: CogARMCompiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." - "cogit gen: STMFD operand: 16r7F"!
Item was added: + ----- Method: CogARMCompiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a trampoline call." + "Save none, because the ARM ABI only defines callee saved registers, no caller-saved regs." + "cogit gen: STMFD operand: 16r7F" + self flag: 'this will change with Sista when we hope to be able to allocate arbitrary registers'!
Item was removed: - ----- Method: CogAbstractInstruction>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - self subclassResponsibility!
Item was changed: ----- Method: CogIA32Compiler>>genRestoreRegsExcept: (in category 'abi') ----- genRestoreRegsExcept: abstractReg | realReg | realReg := self concreteRegister: abstractReg. self assert: (EDI > EAX and: [EDI - EAX + 1 = 6]). EAX to: EDI do: [:reg| + (reg between: ESP and: EBP) ifFalse: + [realReg = reg + ifTrue: [cogit AddCq: 4 R: ESP] + ifFalse: [cogit PopR: reg]]]. - realReg = reg ifTrue: [cogit AddCq: 4 R: ESP] ifFalse: [cogit PopR: reg]]. ^0!
Item was removed: - ----- Method: CogIA32Compiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - - self assert: (EDI > EAX and: [EDI - EAX + 1 = 8]). - EDI to: EAX by: -1 do: - [:reg| - (reg between: ESP and: EBP) ifFalse: - [cogit PushR: reg]]. - ^0!
Item was added: + ----- Method: CogIA32Compiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline." + + self assert: (EDI > EAX and: [EDI - EAX + 1 = 8]). + EDI to: EAX by: -1 do: + [:reg| + (reg between: ESP and: EBP) ifFalse: + [cogit PushR: reg]]. + ^0!
Item was removed: - ----- Method: CogMIPSELCompiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "This method is poorly named. Is this for a Smalltalk -> C call or C -> Smalltalk call? - If the former we don't need to do anything because all of the abstract registers are - allocated to C preserved registers." - self flag: #bogus.!
Item was added: + ----- Method: CogMIPSELCompiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a call into the C run-time from a trampoline. + We don't need to do anything because all of the abstract registers are + allocated to C preserved registers." + self flag: 'this will change with Sista when we hope to be able to allocate arbitrary registers'!
Item was changed: ----- Method: CogX64Compiler>>genRestoreRegs (in category 'abi') ----- genRestoreRegs "Restore the general purpose registers for a trampoline call. c.f. genSaveRegisters" + RAX to: R15 do: + [:reg| + (reg between: RSP and: RBP) ifFalse: + [cogit PopR: reg]]. - cogit - PopR: RAX; - PopR: RBX; - PopR: RCX; - PopR: RDX; - PopR: RSI; - PopR: RDI; - PopR: R8; - PopR: R9; - PopR: R10; - PopR: R11; - PopR: R12; - PopR: R13; - PopR: R14; - PopR: R15. ^0!
Item was changed: ----- Method: CogX64Compiler>>genRestoreRegsExcept: (in category 'abi') ----- genRestoreRegsExcept: abstractReg | realReg | realReg := self concreteRegister: abstractReg. self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). RAX to: R15 do: [:reg| + (reg between: RSP and: RBP) ifFalse: + [realReg = reg + ifTrue: [cogit AddCq: 8 R: RSP] + ifFalse: [cogit PopR: reg]]]. - realReg = reg ifTrue: [cogit AddCq: 4 R: RSP] ifFalse: [cogit PopR: reg]]. ^0!
Item was removed: - ----- Method: CogX64Compiler>>genSaveRegisters (in category 'abi') ----- - genSaveRegisters - "Save the general purpose registers for a trampoline call." - - self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). - R15 to: RAX by: -1 do: [:reg| cogit PushR: reg]. - ^0!
Item was added: + ----- Method: CogX64Compiler>>genSaveRegsForCCall (in category 'abi') ----- + genSaveRegsForCCall + "Save the general purpose registers for a trampoline call." + + self assert: (R15 > RAX and: [R15 - RAX + 1 = 16]). + R15 to: RAX by: -1 do: + [:reg| + (reg between: RSP and: RBP) ifFalse: + [cogit PushR: reg]]. + ^0!
Item was changed: ----- Method: Cogit>>compileCallFor:numArgs:arg:arg:arg:arg:resultReg:saveRegs: (in category 'initialization') ----- compileCallFor: aRoutine numArgs: numArgs arg: regOrConst0 arg: regOrConst1 arg: regOrConst2 arg: regOrConst3 resultReg: resultRegOrNone saveRegs: saveRegs "Generate a call to aRoutine with up to 4 arguments. If resultRegOrNone is not NoReg assign the C result to resultRegOrNone. If saveRegs, save all registers. Hack: a negative arg value indicates an abstract register, a non-negative value indicates a constant." <var: #aRoutine type: #'void *'> <inline: false> cStackAlignment > objectMemory wordSize ifTrue: [backEnd genAlignCStackSavingRegisters: saveRegs numArgs: numArgs wordAlignment: cStackAlignment / objectMemory wordSize]. saveRegs ifTrue: + [backEnd genSaveRegsForCCall]. - [backEnd genSaveRegisters]. backEnd genMarshallNArgs: numArgs arg: regOrConst0 arg: regOrConst1 arg: regOrConst2 arg: regOrConst3. self CallFullRT: (self cCode: [aRoutine asUnsignedInteger] inSmalltalk: [self simulatedTrampolineFor: aRoutine]). resultRegOrNone ~= NoReg ifTrue: [backEnd genWriteCResultIntoReg: resultRegOrNone]. saveRegs ifTrue: [numArgs > 0 ifTrue: [backEnd genRemoveNArgsFromStack: numArgs]. resultRegOrNone ~= NoReg ifTrue: [backEnd genRestoreRegsExcept: resultRegOrNone] ifFalse: [backEnd genRestoreRegs]]!
-- _,,,^..^,,,_ best, Eliot
-- www.tudorgirba.com www.feenk.com "We cannot reach the flow of things unless we let go."
participants (8)
-
Ben Coman -
David T. Lewis -
Eliot Miranda -
Nicolas Cellier -
stepharo -
Sven Van Caekenberghe -
Thierry Goubier -
Tudor Girba