[Vm-dev] VM Maker: VMMaker.oscog-eem.1544.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Dec 3 23:15:15 UTC 2015
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1544.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1544
Author: eem
Time: 3 December 2015, 11:53:57.341 am
UUID: 2c5a349c-21ac-4949-bc39-5a93f5eb243a
Ancestors: VMMaker.oscog-eem.1543
x64 Cogit:
Implement or fix OpCqR MulRR, relocation machinery etc.
Add tests for OpCqR (to x86 also). Use assert:equals: and override in AbstractInstructionTests to do a case-insensitive comparison for strings.
More facade machinery for in-image compilation.
Update smallFloatValueOf: for running on 64-bit Spur (reduce the result to SmallFloat if possible).
=============== Diff against VMMaker.oscog-eem.1543 ===============
Item was added:
+ ----- Method: AbstractInstructionTests>>assert:equals: (in category 'accessing') -----
+ assert: expected equals: actual
+ "Override to use a case-insensitive comparison for strings."
+ ^self
+ assert: (expected isString
+ ifTrue: [expected sameAs: actual]
+ ifFalse: [expected = actual])
+ description: [ self comparingStringBetween: expected and: actual ]
+ !
Item was changed:
+ ----- Method: AbstractInstructionTests>>previousInstruction (in category 'accessing') -----
- ----- Method: AbstractInstructionTests>>previousInstruction (in category 'as yet unclassified') -----
previousInstruction
<returnTypeC: #'AbstractInstruction *'>
^opcodes last!
Item was changed:
----- Method: CogIA32Compiler>>relocateMethodReferenceBeforeAddress:by: (in category 'inline cacheing') -----
relocateMethodReferenceBeforeAddress: pc by: delta
+ <inline: true>
self relocateCallBeforeReturnPC: pc by: delta!
Item was added:
+ ----- Method: CogIA32CompilerTests>>testAddCqR (in category 'tests') -----
+ testAddCqR
+ "self new testAddCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: AddCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'addl $0x', (const printStringBase: 16 length: 8 padded: true), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testAndCqR (in category 'tests') -----
testAndCqR
"self new testAndCqR"
+ self concreteCompilerClass registersWithNamesDo:
- CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
[:const| | inst len|
inst := self gen: AndCqR operand: const operand: reg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'andl $0x', (const printStringBase: 16 length: 8 padded: true), ', ', regname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testCMPXCHGAwR (in category 'tests') -----
testCMPXCHGAwR
"self new testCMPXCHGAwR"
| cmpxchgAwR |
cmpxchgAwR := CogIA32Compiler classPool at: #CMPXCHGAwR.
CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: cmpxchgAwR operand: addr operand: reg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'cmpxchgl ', regname, ', 0x', (addr hex allButFirst: 3).
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testCMPXCHGMwrR (in category 'tests') -----
testCMPXCHGMwrR
"self new testCMPXCHGMwrR"
| cmpxchgMwrR lock |
cmpxchgMwrR := CogIA32Compiler classPool at: #CMPXCHGMwrR.
lock := CogIA32Compiler classPool at: #LOCK.
CogIA32CompilerForTests registersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset|
#(false true) do:
[:prefixLock| | memory |
self resetGen.
prefixLock ifTrue: [self gen: lock].
self gen: cmpxchgMwrR operand: offset operand: sreg operand: dreg.
memory := self generateInstructions.
self processor
disassembleInstructionAt: 0
In: memory
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := (prefixLock ifTrue: ['lock '] ifFalse: ['']),
'cmpxchgl ', drname, ', 0x', (offset hex allButFirst: 3), '(', srname, ')'.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: memory size = sz]]]]]!
Item was added:
+ ----- Method: CogIA32CompilerTests>>testCmpCqR (in category 'tests') -----
+ testCmpCqR
+ "self new testCmpCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: CmpCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'cmpl $0x', (const printStringBase: 16 length: 8 padded: true), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]!
Item was added:
+ ----- Method: CogIA32CompilerTests>>testLogicalShiftRightCqR (in category 'tests') -----
+ testLogicalShiftRightCqR
+ "CogIA32CompilerTests new testLogicalShiftRightCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ 1 to: 31 do:
+ [:shift| | inst len |
+ inst := self gen: LogicalShiftRightCqR operand: shift operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'shrl $', (shift > 1
+ ifTrue: ['0x', (shift printStringBase: 16 length: 2 padded: true)]
+ ifFalse: [shift asInteger]), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveAbR (in category 'tests') -----
testMoveAbR
"self new testMoveAbR"
CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: MoveAbR operand: addr operand: reg.
len := inst concretizeAt: 0.
self assert: inst byteReadsZeroExtend.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'movzbl 0x', (addr hex allButFirst: 3), ', ', regname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveAwR (in category 'tests') -----
testMoveAwR
"self new testMoveAwR"
CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: MoveAwR operand: addr operand: reg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'movl 0x', (addr hex allButFirst: 3), ', ', regname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveM64rRd (in category 'tests') -----
testMoveM64rRd
"self new testMoveM64rRd"
CogIA32CompilerForTests registersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests xmmRegistersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveM64rRd operand: offset operand: sreg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movsd 0x', (offset hex allButFirst: 3), '(', srname, '), ', drname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveMbrR (in category 'tests') -----
testMoveMbrR
"self new testMoveMbrR"
CogIA32CompilerForTests registersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveMbrR operand: offset operand: sreg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movzbl 0x', (offset hex allButFirst: 3), '(', srname, '), ', drname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveMwrR (in category 'tests') -----
testMoveMwrR
"self new testMoveMwrR"
self concreteCompilerClass registersWithNamesDo:
[:sreg :srname|
self concreteCompilerClass registersWithNamesDo:
[:dreg :drname| | inst len |
#(0 64 65536 -64 -65536) do:
[:offset|
inst := self gen: MoveMwrR operand: offset operand: sreg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended po |
plainJane := self strip: str.
po := offset bitAnd: 1 << self processor bitsInWord - 1.
herIntended := 'movl ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16)]), '(', srname, '), ', drname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]
"| failures |
failures := Dictionary new.
self concreteCompilerClass registersWithNamesDo:
[:sreg :srname|
self concreteCompilerClass registersWithNamesDo:
[:dreg :drname| | inst len |
#(0 64 65536 -64 -65536) do:
[:offset|
inst := self gen: MoveMwrR operand: offset operand: sreg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended po |
plainJane := self strip: str.
po := offset bitAnd: 1 << self processor bitsInWord - 1.
herIntended := 'movl ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16)]), '(', srname, '), ', drname.
((plainJane match: herIntended) and: [len = sz]) ifFalse:
[failures at: herIntended put: plainJane]]]]].
failures"!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveRAb (in category 'tests') -----
testMoveRAb
"self new testMoveRAb"
CogIA32CompilerForTests byteRegistersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: MoveRAb operand: reg operand: addr.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movb ', regname, ', 0x', (addr hex allButFirst: 3).
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveRAw (in category 'tests') -----
testMoveRAw
"self new testMoveRAw"
CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: MoveRAw operand: reg operand: addr.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movl ', regname, ', 0x', (addr hex allButFirst: 3).
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveRMbr (in category 'tests') -----
testMoveRMbr
"self new testMoveRMbr"
CogIA32CompilerForTests byteRegistersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveRMbr operand: sreg operand: offset operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movb ', srname, ', 0x', (offset hex allButFirst: 3), '(', drname, ')'.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveRMwr (in category 'tests') -----
testMoveRMwr
"self new testMoveRMwr"
self concreteCompilerClass registersWithNamesDo:
[:sreg :srname|
self concreteCompilerClass registersWithNamesDo:
[:dreg :drname| | inst len |
#(0 64 65536 -64 -65536) do:
[:offset|
inst := self gen: MoveRMwr operand: sreg operand: offset operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended po |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
po := offset bitAnd: 1 << self processor bitsInWord - 1.
herIntended := 'movl ', srname, ', ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16)]), '(',drname,')'.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]
"| failures |
failures := Dictionary new.
self concreteCompilerClass registersWithNamesDo:
[:sreg :srname|
self concreteCompilerClass registersWithNamesDo:
[:dreg :drname| | inst len |
#(0 64 65536 -64 -65536) do:
[:offset|
inst := self gen: MoveRMwr operand: sreg operand: offset operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended po |
plainJane := self strip: str.
po := offset bitAnd: 1 << self processor bitsInWord - 1.
herIntended := 'movl ', srname, ', ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16)]), '(',drname,')'.
((plainJane match: herIntended) and: [len = sz]) ifFalse:
[failures at: herIntended put: plainJane]]]]].
failures"!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveRdM64r (in category 'tests') -----
testMoveRdM64r
"self new testMoveRdM64r"
CogIA32CompilerForTests xmmRegistersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveRdM64r operand: sreg operand: offset operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'movsd ', srname, ', 0x', (offset hex allButFirst: 3), '(', drname, ')'.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveXbrRR (in category 'tests') -----
testMoveXbrRR
"self new testMoveXbrRR"
CogIA32CompilerForTests registersWithNamesDo:
[:idxreg :irname|
irname ~= '%esp' ifTrue:
[CogIA32CompilerForTests registersWithNamesDo:
[:basereg :brname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveXbrRR operand: idxreg operand: basereg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movzbl %ds:(%eax,%eax,1), %eax : 0F B6 04 00 ' to 'movzbl (%eax,%eax,1)'"
plainJane := self strip: str.
herIntended := 'movzbl (', brname, ',', irname, ',1), ',drname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testMoveXwrRR (in category 'tests') -----
testMoveXwrRR
"self new testMoveXwrRR"
CogIA32CompilerForTests registersWithNamesDo:
[:idxreg :irname|
irname ~= '%esp' ifTrue:
[CogIA32CompilerForTests registersWithNamesDo:
[:basereg :brname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | inst len |
inst := self gen: MoveXwrRR operand: idxreg operand: basereg operand: dreg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'movl (', brname, ',', irname, ',4), ',drname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]]]]!
Item was added:
+ ----- Method: CogIA32CompilerTests>>testOrCqR (in category 'tests') -----
+ testOrCqR
+ "self new testOrCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: OrCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'orl $0x', (const printStringBase: 16 length: 8 padded: true), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]!
Item was added:
+ ----- Method: CogIA32CompilerTests>>testSubCqR (in category 'tests') -----
+ testSubCqR
+ "self new testSubCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: SubCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'subl $0x', (const printStringBase: 16 length: 8 padded: true), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testTstCqR (in category 'tests') -----
testTstCqR
"self new testTstCqR"
+ self concreteCompilerClass registersWithNamesDo:
- CogIA32CompilerForTests registersWithNamesDo:
[:reg :theRegname|
#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
[:const| | op regname inst len constString|
inst := self gen: TstCqR operand: const operand: reg.
len := inst concretizeAt: 0.
((inst isQuick: const) and: [reg < 4])
ifTrue:
[op := 'testb'.
regname := #('%al' '%cl' '%dl' '%bl') at: reg + 1.
constString := const printStringBase: 16 length: 2 padded: true]
ifFalse:
[op := 'testl'.
regname := theRegname.
constString := const printStringBase: 16 length: 8 padded: true].
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := op, ' $0x', constString, ', ', regname.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testXCHGAwR (in category 'tests') -----
testXCHGAwR
"self new testXCHGAwR"
| xchgAwR |
xchgAwR := CogIA32Compiler classPool at: #XCHGAwR.
CogIA32CompilerForTests registersWithNamesDo:
[:reg :regname|
#(16r555555 16rAAAAAA) do:
[:addr| | inst len |
inst := self gen: xchgAwR operand: addr operand: reg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
plainJane := self strip: str.
herIntended := 'xchgl ', regname, ', 0x', (addr hex allButFirst: 3).
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was changed:
----- Method: CogIA32CompilerTests>>testXCHGMwrR (in category 'tests') -----
testXCHGMwrR
"self new testXCHGMwrR"
| xchgMwrR |
xchgMwrR := CogIA32Compiler classPool at: #XCHGMwrR.
CogIA32CompilerForTests registersWithNamesDo:
[:sreg :srname|
CogIA32CompilerForTests registersWithNamesDo:
[:dreg :drname|
((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
[:offset| | memory |
self resetGen.
self gen: xchgMwrR operand: offset operand: sreg operand: dreg.
memory := self generateInstructions.
self processor
disassembleInstructionAt: 0
In: memory
into: [:str :sz| | plainJane herIntended |
plainJane := self strip: str.
herIntended := 'xchgl ', drname, ', 0x', (offset hex allButFirst: 3), '(', srname, ')'.
+ self assert: herIntended equals: plainJane.
- self assert: (plainJane match: herIntended).
self assert: memory size = sz]]]]!
Item was changed:
----- Method: CogObjectRepresentationFor64BitSpur>>genGetHashFieldNonImmOf:asSmallIntegerInto: (in category 'compile abstract instructions') -----
genGetHashFieldNonImmOf: instReg asSmallIntegerInto: destReg
"Fetch the instance's identity hash into destReg, encoded as a SmallInteger."
cogit
MoveMw: 0 r: instReg R: destReg;
"Shift and mask the field leaving room for the SmallInteger tag."
+ LogicalShiftRightCq: objectMemory identityHashFullWordShift - self numTagBits R: destReg;
- LogicalShiftRightCq: objectMemory identityHashFullWordShift - objectMemory numTagBits R: destReg;
AndCq: objectMemory identityHashHalfWordMask << objectMemory numTagBits R: destReg;
AddCq: objectMemory smallIntegerTag R: destReg.
^0!
Item was added:
+ ----- Method: CogObjectRepresentationFor64BitSpur>>genShiftAwaySmallIntegerTagsInScratchReg: (in category 'compile abstract instructions') -----
+ genShiftAwaySmallIntegerTagsInScratchReg: scratchReg
+ cogit ArithmeticShiftRightCq: self numTagBits R: scratchReg.
+ ^0!
Item was added:
+ ----- Method: CogX64Compiler>>canMulRR (in category 'testing') -----
+ canMulRR
+ <inline: true>
+ ^true!
Item was changed:
----- Method: CogX64Compiler>>computeMaximumSize (in category 'generate machine code') -----
(excessive size, no diff calculated)
Item was removed:
- ----- Method: CogX64Compiler>>computeShiftCqRegSize (in category 'generate machine code') -----
- computeShiftCqRegSize
- "Immediate shifts are limited to a maximum of 31."
- <inline: true>
- | distance |
- distance := operands at: 0.
- distance = 1 ifTrue:
- [^3].
- distance <= 31 ifTrue:
- [^4].
- distance = 32 ifTrue:
- [^7].
- ^8!
Item was added:
+ ----- Method: CogX64Compiler>>concretizeMulRR (in category 'generate machine code') -----
+ concretizeMulRR
+ "Will get inlined into concretizeAt: switch."
+ <inline: true>
+ | reg1 reg2 |
+ reg1 := self concreteRegister: (operands at: 0).
+ reg2 := self concreteRegister: (operands at: 1).
+ machineCode
+ at: 0 put: (self rexR: reg2 x: 0 b: reg1);
+ at: 1 put: 16r0F;
+ at: 2 put: 16rAF;
+ at: 3 put: (self mod: ModReg RM: reg1 RO: reg2).
+ ^machineCodeSize := 4!
Item was changed:
----- Method: CogX64Compiler>>concretizeShiftCqRegOpcode: (in category 'generate machine code') -----
concretizeShiftCqRegOpcode: regOpcode
"Will get inlined into concretizeAt: switch."
<inline: true>
| distance reg |
distance := operands at: 0.
self assert: (distance between: 1 and: 63).
reg := self concreteRegister: (operands at: 1).
+ machineCode at: 0 put: (self rexR: 0 x: 0 b: reg).
- machineCode
- at: 0 put: (self rexR: 0 x: 0 b: reg).
distance = 1 ifTrue:
[machineCode
at: 1 put: 16rD1;
at: 2 put: (self mod: ModReg RM: reg RO: regOpcode).
^machineCodeSize := 3].
machineCode
at: 1 put: 16rC1;
at: 2 put: (self mod: ModReg RM: reg RO: regOpcode);
+ at: 3 put: distance.
+ ^machineCodeSize := 4!
- at: 3 put: (distance min: 31).
- distance <= 31 ifTrue:
- [^machineCodeSize := 4].
- distance = 32 ifTrue:
- [machineCode
- at: 4 put: 16rD1;
- at: 5 put: (self mod: ModReg RM: reg RO: regOpcode).
- ^machineCodeSize := 7].
- machineCode
- at: 4 put: 16rC1;
- at: 5 put: (self mod: ModReg RM: reg RO: regOpcode);
- at: 6 put: distance - 31.
- ^machineCodeSize := 8!
Item was added:
+ ----- Method: CogX64Compiler>>relocateCallBeforeReturnPC:by: (in category 'inline cacheing') -----
+ relocateCallBeforeReturnPC: retpc by: delta
+ | distance |
+ delta ~= 0 ifTrue:
+ [distance := ((objectMemory byteAt: retpc - 1) << 24)
+ + ((objectMemory byteAt: retpc - 2) << 16)
+ + ((objectMemory byteAt: retpc - 3) << 8)
+ + (objectMemory byteAt: retpc - 4).
+ distance := distance + delta.
+ objectMemory
+ byteAt: retpc - 1 put: (distance >> 24 bitAnd: 16rFF);
+ byteAt: retpc - 2 put: (distance >> 16 bitAnd: 16rFF);
+ byteAt: retpc - 3 put: (distance >> 8 bitAnd: 16rFF);
+ byteAt: retpc - 4 put: (distance bitAnd: 16rFF)]!
Item was added:
+ ----- Method: CogX64Compiler>>relocateMethodReferenceBeforeAddress:by: (in category 'inline cacheing') -----
+ relocateMethodReferenceBeforeAddress: pc by: delta
+ "We generate the method address using pc-relative addressing.
+ Simply check that rip-relative addressing is being used. c.f.
+ concretizeMoveCwR"
+ <inline: true>
+ self assert: ((objectMemory byteAt: pc - 6) = 16r8D
+ and: [((objectMemory byteAt: pc - 5) bitOr: (self mod: 0 RM: 0 RO: 7)) = (self mod: ModRegInd RM: 5 RO: 7)])!
Item was added:
+ ----- Method: CogX64CompilerTests>>testAddCqR (in category 'tests') -----
+ testAddCqR
+ "self new testAddCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: AddCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'addq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ self assert: (plainJane match: herIntended).
+ self assert: len = sz]]]!
Item was changed:
----- Method: CogX64CompilerTests>>testAndCqR (in category 'tests') -----
testAndCqR
"self new testAndCqR"
self concreteCompilerClass registersWithNamesDo:
[:reg :regname|
#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
[:const| | inst len|
inst := self gen: AndCqR operand: const operand: reg.
len := inst concretizeAt: 0.
self processor
disassembleInstructionAt: 0
In: inst machineCode object
into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
- "Convert e.g. '00000000: movl %rax, 0x2(%rax) : 48 89 40 02' to 'movl %rax, 0x2(%rax)'"
plainJane := self strip: str.
herIntended := 'andq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
self assert: (plainJane match: herIntended).
self assert: len = sz]]]!
Item was added:
+ ----- Method: CogX64CompilerTests>>testCmpCqR (in category 'tests') -----
+ testCmpCqR
+ "self new testCmpCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: CmpCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'cmpq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ self assert: (plainJane match: herIntended).
+ self assert: len = sz]]]!
Item was added:
+ ----- Method: CogX64CompilerTests>>testOrCqR (in category 'tests') -----
+ testOrCqR
+ "self new testOrCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: OrCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'orq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ self assert: (plainJane match: herIntended).
+ self assert: len = sz]]]!
Item was added:
+ ----- Method: CogX64CompilerTests>>testShiftCqR (in category 'tests') -----
+ testShiftCqR
+ "CogX64CompilerTests new testShiftCqR"
+ {LogicalShiftRightCqR. LogicalShiftLeftCqR. ArithmeticShiftRightCqR}
+ with: #('shrq' 'shlq' 'sarq')
+ do: [:op :opname|
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ 1 to: 63 do:
+ [:shift| | inst len |
+ inst := self gen: op operand: shift operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := opname ,' $', (shift > 1
+ ifTrue: ['0x', (shift printStringBase: 16 length: 2 padded: true)]
+ ifFalse: [shift asInteger]), ', ', regname.
+ self assert: herIntended equals: plainJane.
+ self assert: len = sz]]]]!
Item was added:
+ ----- Method: CogX64CompilerTests>>testSubCqR (in category 'tests') -----
+ testSubCqR
+ "self new testSubCqR"
+ self concreteCompilerClass registersWithNamesDo:
+ [:reg :regname|
+ #(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
+ [:const| | inst len|
+ inst := self gen: SubCqR operand: const operand: reg.
+ len := inst concretizeAt: 0.
+ self processor
+ disassembleInstructionAt: 0
+ In: inst machineCode object
+ into: [:str :sz| | plainJane herIntended |
+ "Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to 'movl %eax, 0x2(%eax)'"
+ plainJane := self strip: str.
+ herIntended := 'subq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ self assert: (plainJane match: herIntended).
+ self assert: len = sz]]]!
Item was changed:
----- Method: CurrentImageCoInterpreterFacade>>oopForObject: (in category 'object map') -----
oopForObject: o
+ ^(o isInteger and: [o between: objectMemory minSmallInteger and: objectMemory maxSmallInteger])
- ^o isInteger
ifTrue: [o << 1 bitOr: 1]
ifFalse: [objectMap at: o ifAbsentPut: [objectMap size * 8 + (1024 * 1024)]]!
Item was added:
+ ----- Method: CurrentImageCoInterpreterFacadeFor64BitSpurObjectRepresentation>>objectForOop: (in category 'private-cacheing') -----
+ objectForOop: anOop
+ "This is a keyAtValue: search and so needs speeding up either by a reverse map or a simple cache."
+ ^(anOop bitAnd: 3) caseOf: {
+ [0] -> [anOop = cachedOop
+ ifTrue: [cachedObject]
+ ifFalse: [cachedObject := objectMap keyAtValue: anOop. "may raise Error"
+ cachedOop := anOop. "Dom't assign until accessed without error"
+ cachedObject]].
+ [1] -> [anOop signedIntFromLong64 >> 3].
+ [2] -> [Character value: anOop >> 3].
+ [3] -> [objectMemory smallFloatValueOf: anOop] }!
Item was added:
+ ----- Method: CurrentImageCoInterpreterFacadeFor64BitSpurObjectRepresentation>>oopForObject: (in category 'object map') -----
+ oopForObject: o
+ o isNumber
+ ifTrue:
+ [o isInteger
+ ifTrue:
+ [(o between: objectMemory minSmallInteger and: objectMemory maxSmallInteger) ifTrue:
+ [^objectMemory integerObjectOf: o asInteger]]
+ ifFalse:
+ [o isFloat ifTrue:
+ [(objectMemory isSmallFloatValue: o) ifTrue:
+ [^objectMemory smallFloatValueOf: o]]]]
+ ifFalse:
+ [o isCharacter ifTrue:
+ [^objectMemory characterObjectOf: o asInteger]].
+ ^objectMap at: o ifAbsentPut: [objectMap size * 8 + (1024 * 1024)]!
Item was added:
+ ----- Method: CurrentImageCoInterpreterFacadeForSpurObjectRepresentation>>numSlotsFullShift (in category 'accessing') -----
+ numSlotsFullShift
+ ^objectMemory numSlotsFullShift!
Item was added:
+ ----- Method: CurrentImageCoInterpreterFacadeForSpurObjectRepresentation>>oopForObject: (in category 'object map') -----
+ oopForObject: o
+ ^(o isInteger and: [o between: objectMemory minSmallInteger and: objectMemory maxSmallInteger])
+ ifTrue: [o << 1 + 1]
+ ifFalse:
+ [o isCharacter
+ ifTrue: [o asInteger << 2 + 2]
+ ifFalse: [objectMap at: o ifAbsentPut: [objectMap size * 8 + (1024 * 1024)]]]!
Item was changed:
----- Method: Spur64BitMemoryManager>>smallFloatValueOf: (in category 'interpreter access') -----
smallFloatValueOf: oop
"Answer the C double precision floating point value of the argument, a SmallFloat.
See section 61-bit Immediate Floats in the SpurMemoryManager class comment.
msb lsb
Decode: [8expsubset][52mantissa][1s][3tags]
shift away tags: [ 000 ][8expsubset][52mantissa][1s]
add exponent offset: [ 11 exponent ][52mantissa][1s]
rot sign: [1s][ 11 exponent ][52mantissa]"
| bits |
<returnTypeC: #double>
bits := self smallFloatBitsOf: oop.
^self cCode: [(self cCoerce: (self addressOf: bits) to: #'double *') at: 0]
inSmalltalk:
[(Float new: 2)
at: 1 put: bits >> 32;
at: 2 put: (bits bitAnd: 16rFFFFFFFF);
+ * 1.0 "reduce to SmallFloat64 if possible"]!
- yourself]!
More information about the Vm-dev
mailing list