asm/AJStackAlignmentTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 15 Jun 2016 23:46:29 +0100
changeset 23 d2d9a2d4d6bf
parent 10 588414eaacff
child 24 5aace704e3c8
permissions -rw-r--r--
Added README, licenses and copyright notices.

"{ Package: 'jv:dragonfly/asm' }"

"{ NameSpace: Smalltalk }"

TestCase subclass:#AJStackAlignmentTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:'AJx86Registers'
	category:'AsmJit-Tests'
!

!AJStackAlignmentTests methodsFor:'tests'!

testJumps

    | asm callInfo |
    
    asm := self newAssembler.
    asm noStackFrame.
    
    asm jmp: #foo;
        nop;
        nop;
        nop;
        nop;
        nop;
        nop;
        nop;
        nop;
    label: #foo.
    
    ^ asm generatedCode.
!

testNewProtocolForAlignedCalls

    | asm callInfo |
    
    asm := self newAssembler.
    
    
    asm cdeclCall:  [:call |

        call 
            push: EAX;
            push: EAX;
            push: 4.

        asm call: EAX.
        callInfo := call.
    ] alignment: 32.
    
    
    asm generatedCode. "to analyze instructions"
    self assert: callInfo stackSize = 12.
    self assert: callInfo needsAlignment

    "Modified (format): / 15-12-2015 / 23:20:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!AJStackAlignmentTests methodsFor:'utility'!

newAssembler 
    ^ AJx86Assembler new
! !