Path: blob/master/src/hotspot/os_cpu/bsd_x86/bsd_x86_32.S
40930 views
#1# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#222324#ifdef __APPLE__25# Darwin uses _ prefixed global symbols26#define SYMBOL(s) _ ## s27#define ELF_TYPE(name, description)28#else29#define SYMBOL(s) s30#define ELF_TYPE(name, description) .type name,description31#endif3233.globl SYMBOL(fixcw)3435# NOTE WELL! The _Copy functions are called directly36# from server-compiler-generated code via CallLeafNoFP,37# which means that they *must* either not use floating38# point or use it in the same manner as does the server39# compiler.4041.globl SYMBOL(_Copy_conjoint_bytes)42.globl SYMBOL(_Copy_arrayof_conjoint_bytes)43.globl SYMBOL(_Copy_conjoint_jshorts_atomic)44.globl SYMBOL(_Copy_arrayof_conjoint_jshorts)45.globl SYMBOL(_Copy_conjoint_jints_atomic)46.globl SYMBOL(_Copy_arrayof_conjoint_jints)47.globl SYMBOL(_Copy_conjoint_jlongs_atomic)48.globl SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts)4950.globl SYMBOL(_Atomic_cmpxchg_long)51.globl SYMBOL(_Atomic_move_long)5253.text5455# Support for void os::Solaris::init_thread_fpu_state() in os_solaris_i486.cpp56# Set fpu to 53 bit precision. This happens too early to use a stub.57# ported from solaris_x86_32.s58.p2align 4,,1559SYMBOL(fixcw):60pushl $0x27f61fldcw 0(%esp)62popl %eax63ret6465.globl SYMBOL(SpinPause)66ELF_TYPE(SpinPause,@function)67.p2align 4,,1568SYMBOL(SpinPause):69rep70nop71movl $1, %eax72ret7374# Support for void Copy::conjoint_bytes(void* from,75# void* to,76# size_t count)77.p2align 4,,1578ELF_TYPE(_Copy_conjoint_bytes,@function)79SYMBOL(_Copy_conjoint_bytes):80pushl %esi81movl 4+12(%esp),%ecx # count82pushl %edi83movl 8+ 4(%esp),%esi # from84movl 8+ 8(%esp),%edi # to85cmpl %esi,%edi86leal -1(%esi,%ecx),%eax # from + count - 187jbe cb_CopyRight88cmpl %eax,%edi89jbe cb_CopyLeft90# copy from low to high91cb_CopyRight:92cmpl $3,%ecx93jbe 5f # <= 3 bytes94# align source address at dword address boundary95movl %ecx,%eax # original count96movl $4,%ecx97subl %esi,%ecx98andl $3,%ecx # prefix byte count99jz 1f # no prefix100subl %ecx,%eax # byte count less prefix101# copy prefix102subl %esi,%edi1030: movb (%esi),%dl104movb %dl,(%edi,%esi,1)105addl $1,%esi106subl $1,%ecx107jnz 0b108addl %esi,%edi1091: movl %eax,%ecx # byte count less prefix110shrl $2,%ecx # dword count111jz 4f # no dwords to move112cmpl $32,%ecx113jbe 2f # <= 32 dwords114# copy aligned dwords115rep; smovl116jmp 4f117# copy aligned dwords1182: subl %esi,%edi119.p2align 4,,151203: movl (%esi),%edx121movl %edx,(%edi,%esi,1)122addl $4,%esi123subl $1,%ecx124jnz 3b125addl %esi,%edi1264: movl %eax,%ecx # byte count less prefix1275: andl $3,%ecx # suffix byte count128jz 7f # no suffix129# copy suffix130xorl %eax,%eax1316: movb (%esi,%eax,1),%dl132movb %dl,(%edi,%eax,1)133addl $1,%eax134subl $1,%ecx135jnz 6b1367: popl %edi137popl %esi138ret139# copy from high to low140cb_CopyLeft:141std142leal -4(%edi,%ecx),%edi # to + count - 4143movl %eax,%esi # from + count - 1144movl %ecx,%eax145subl $3,%esi # from + count - 4146cmpl $3,%ecx147jbe 5f # <= 3 bytes1481: shrl $2,%ecx # dword count149jz 4f # no dwords to move150cmpl $32,%ecx151ja 3f # > 32 dwords152# copy dwords, aligned or not153subl %esi,%edi154.p2align 4,,151552: movl (%esi),%edx156movl %edx,(%edi,%esi,1)157subl $4,%esi158subl $1,%ecx159jnz 2b160addl %esi,%edi161jmp 4f162# copy dwords, aligned or not1633: rep; smovl1644: movl %eax,%ecx # byte count1655: andl $3,%ecx # suffix byte count166jz 7f # no suffix167# copy suffix168subl %esi,%edi169addl $3,%esi1706: movb (%esi),%dl171movb %dl,(%edi,%esi,1)172subl $1,%esi173subl $1,%ecx174jnz 6b1757: cld176popl %edi177popl %esi178ret179180# Support for void Copy::arrayof_conjoint_bytes(void* from,181# void* to,182# size_t count)183#184# Same as _Copy_conjoint_bytes, except no source alignment check.185.p2align 4,,15186ELF_TYPE(_Copy_arrayof_conjoint_bytes,@function)187SYMBOL(_Copy_arrayof_conjoint_bytes):188pushl %esi189movl 4+12(%esp),%ecx # count190pushl %edi191movl 8+ 4(%esp),%esi # from192movl 8+ 8(%esp),%edi # to193cmpl %esi,%edi194leal -1(%esi,%ecx),%eax # from + count - 1195jbe acb_CopyRight196cmpl %eax,%edi197jbe acb_CopyLeft198# copy from low to high199acb_CopyRight:200cmpl $3,%ecx201jbe 5f2021: movl %ecx,%eax203shrl $2,%ecx204jz 4f205cmpl $32,%ecx206ja 3f207# copy aligned dwords208subl %esi,%edi209.p2align 4,,152102: movl (%esi),%edx211movl %edx,(%edi,%esi,1)212addl $4,%esi213subl $1,%ecx214jnz 2b215addl %esi,%edi216jmp 4f217# copy aligned dwords2183: rep; smovl2194: movl %eax,%ecx2205: andl $3,%ecx221jz 7f222# copy suffix223xorl %eax,%eax2246: movb (%esi,%eax,1),%dl225movb %dl,(%edi,%eax,1)226addl $1,%eax227subl $1,%ecx228jnz 6b2297: popl %edi230popl %esi231ret232acb_CopyLeft:233std234leal -4(%edi,%ecx),%edi # to + count - 4235movl %eax,%esi # from + count - 1236movl %ecx,%eax237subl $3,%esi # from + count - 4238cmpl $3,%ecx239jbe 5f2401: shrl $2,%ecx241jz 4f242cmpl $32,%ecx243jbe 2f # <= 32 dwords244rep; smovl245jmp 4f246.space 82472: subl %esi,%edi248.p2align 4,,152493: movl (%esi),%edx250movl %edx,(%edi,%esi,1)251subl $4,%esi252subl $1,%ecx253jnz 3b254addl %esi,%edi2554: movl %eax,%ecx2565: andl $3,%ecx257jz 7f258subl %esi,%edi259addl $3,%esi2606: movb (%esi),%dl261movb %dl,(%edi,%esi,1)262subl $1,%esi263subl $1,%ecx264jnz 6b2657: cld266popl %edi267popl %esi268ret269270# Support for void Copy::conjoint_jshorts_atomic(void* from,271# void* to,272# size_t count)273.p2align 4,,15274ELF_TYPE(_Copy_conjoint_jshorts_atomic,@function)275SYMBOL(_Copy_conjoint_jshorts_atomic):276pushl %esi277movl 4+12(%esp),%ecx # count278pushl %edi279movl 8+ 4(%esp),%esi # from280movl 8+ 8(%esp),%edi # to281cmpl %esi,%edi282leal -2(%esi,%ecx,2),%eax # from + count*2 - 2283jbe cs_CopyRight284cmpl %eax,%edi285jbe cs_CopyLeft286# copy from low to high287cs_CopyRight:288# align source address at dword address boundary289movl %esi,%eax # original from290andl $3,%eax # either 0 or 2291jz 1f # no prefix292# copy prefix293subl $1,%ecx294jl 5f # zero count295movw (%esi),%dx296movw %dx,(%edi)297addl %eax,%esi # %eax == 2298addl %eax,%edi2991: movl %ecx,%eax # word count less prefix300sarl %ecx # dword count301jz 4f # no dwords to move302cmpl $32,%ecx303jbe 2f # <= 32 dwords304# copy aligned dwords305rep; smovl306jmp 4f307# copy aligned dwords3082: subl %esi,%edi309.p2align 4,,153103: movl (%esi),%edx311movl %edx,(%edi,%esi,1)312addl $4,%esi313subl $1,%ecx314jnz 3b315addl %esi,%edi3164: andl $1,%eax # suffix count317jz 5f # no suffix318# copy suffix319movw (%esi),%dx320movw %dx,(%edi)3215: popl %edi322popl %esi323ret324# copy from high to low325cs_CopyLeft:326std327leal -4(%edi,%ecx,2),%edi # to + count*2 - 4328movl %eax,%esi # from + count*2 - 2329movl %ecx,%eax330subl $2,%esi # from + count*2 - 43311: sarl %ecx # dword count332jz 4f # no dwords to move333cmpl $32,%ecx334ja 3f # > 32 dwords335subl %esi,%edi336.p2align 4,,153372: movl (%esi),%edx338movl %edx,(%edi,%esi,1)339subl $4,%esi340subl $1,%ecx341jnz 2b342addl %esi,%edi343jmp 4f3443: rep; smovl3454: andl $1,%eax # suffix count346jz 5f # no suffix347# copy suffix348addl $2,%esi349addl $2,%edi350movw (%esi),%dx351movw %dx,(%edi)3525: cld353popl %edi354popl %esi355ret356357# Support for void Copy::arrayof_conjoint_jshorts(void* from,358# void* to,359# size_t count)360.p2align 4,,15361ELF_TYPE(_Copy_arrayof_conjoint_jshorts,@function)362SYMBOL(_Copy_arrayof_conjoint_jshorts):363pushl %esi364movl 4+12(%esp),%ecx # count365pushl %edi366movl 8+ 4(%esp),%esi # from367movl 8+ 8(%esp),%edi # to368cmpl %esi,%edi369leal -2(%esi,%ecx,2),%eax # from + count*2 - 2370jbe acs_CopyRight371cmpl %eax,%edi372jbe acs_CopyLeft373acs_CopyRight:374movl %ecx,%eax # word count375sarl %ecx # dword count376jz 4f # no dwords to move377cmpl $32,%ecx378jbe 2f # <= 32 dwords379# copy aligned dwords380rep; smovl381jmp 4f382# copy aligned dwords383.space 53842: subl %esi,%edi385.p2align 4,,153863: movl (%esi),%edx387movl %edx,(%edi,%esi,1)388addl $4,%esi389subl $1,%ecx390jnz 3b391addl %esi,%edi3924: andl $1,%eax # suffix count393jz 5f # no suffix394# copy suffix395movw (%esi),%dx396movw %dx,(%edi)3975: popl %edi398popl %esi399ret400acs_CopyLeft:401std402leal -4(%edi,%ecx,2),%edi # to + count*2 - 4403movl %eax,%esi # from + count*2 - 2404movl %ecx,%eax405subl $2,%esi # from + count*2 - 4406sarl %ecx # dword count407jz 4f # no dwords to move408cmpl $32,%ecx409ja 3f # > 32 dwords410subl %esi,%edi411.p2align 4,,154122: movl (%esi),%edx413movl %edx,(%edi,%esi,1)414subl $4,%esi415subl $1,%ecx416jnz 2b417addl %esi,%edi418jmp 4f4193: rep; smovl4204: andl $1,%eax # suffix count421jz 5f # no suffix422# copy suffix423addl $2,%esi424addl $2,%edi425movw (%esi),%dx426movw %dx,(%edi)4275: cld428popl %edi429popl %esi430ret431432# Support for void Copy::conjoint_jints_atomic(void* from,433# void* to,434# size_t count)435# Equivalent to436# arrayof_conjoint_jints437.p2align 4,,15438ELF_TYPE(_Copy_conjoint_jints_atomic,@function)439ELF_TYPE(_Copy_arrayof_conjoint_jints,@function)440SYMBOL(_Copy_conjoint_jints_atomic):441SYMBOL(_Copy_arrayof_conjoint_jints):442pushl %esi443movl 4+12(%esp),%ecx # count444pushl %edi445movl 8+ 4(%esp),%esi # from446movl 8+ 8(%esp),%edi # to447cmpl %esi,%edi448leal -4(%esi,%ecx,4),%eax # from + count*4 - 4449jbe ci_CopyRight450cmpl %eax,%edi451jbe ci_CopyLeft452ci_CopyRight:453cmpl $32,%ecx454jbe 2f # <= 32 dwords455rep; smovl456popl %edi457popl %esi458ret459.space 104602: subl %esi,%edi461jmp 4f462.p2align 4,,154633: movl (%esi),%edx464movl %edx,(%edi,%esi,1)465addl $4,%esi4664: subl $1,%ecx467jge 3b468popl %edi469popl %esi470ret471ci_CopyLeft:472std473leal -4(%edi,%ecx,4),%edi # to + count*4 - 4474cmpl $32,%ecx475ja 4f # > 32 dwords476subl %eax,%edi # eax == from + count*4 - 4477jmp 3f478.p2align 4,,154792: movl (%eax),%edx480movl %edx,(%edi,%eax,1)481subl $4,%eax4823: subl $1,%ecx483jge 2b484cld485popl %edi486popl %esi487ret4884: movl %eax,%esi # from + count*4 - 4489rep; smovl490cld491popl %edi492popl %esi493ret494495# Support for void Copy::conjoint_jlongs_atomic(jlong* from,496# jlong* to,497# size_t count)498#499# 32-bit500#501# count treated as signed502#503# // if (from > to) {504# while (--count >= 0) {505# *to++ = *from++;506# }507# } else {508# while (--count >= 0) {509# to[count] = from[count];510# }511# }512.p2align 4,,15513ELF_TYPE(_Copy_conjoint_jlongs_atomic,@function)514SYMBOL(_Copy_conjoint_jlongs_atomic):515movl 4+8(%esp),%ecx # count516movl 4+0(%esp),%eax # from517movl 4+4(%esp),%edx # to518cmpl %eax,%edx519jae cla_CopyLeft520cla_CopyRight:521subl %eax,%edx522jmp 2f523.p2align 4,,155241: fildll (%eax)525fistpll (%edx,%eax,1)526addl $8,%eax5272: subl $1,%ecx528jge 1b529ret530.p2align 4,,155313: fildll (%eax,%ecx,8)532fistpll (%edx,%ecx,8)533cla_CopyLeft:534subl $1,%ecx535jge 3b536ret537538# Support for void Copy::arrayof_conjoint_jshorts(void* from,539# void* to,540# size_t count)541.p2align 4,,15542ELF_TYPE(_mmx_Copy_arrayof_conjoint_jshorts,@function)543SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts):544pushl %esi545movl 4+12(%esp),%ecx546pushl %edi547movl 8+ 4(%esp),%esi548movl 8+ 8(%esp),%edi549cmpl %esi,%edi550leal -2(%esi,%ecx,2),%eax551jbe mmx_acs_CopyRight552cmpl %eax,%edi553jbe mmx_acs_CopyLeft554mmx_acs_CopyRight:555movl %ecx,%eax556sarl %ecx557je 5f558cmpl $33,%ecx559jae 3f5601: subl %esi,%edi561.p2align 4,,155622: movl (%esi),%edx563movl %edx,(%edi,%esi,1)564addl $4,%esi565subl $1,%ecx566jnz 2b567addl %esi,%edi568jmp 5f5693: smovl # align to 8 bytes, we know we are 4 byte aligned to start570subl $1,%ecx5714: .p2align 4,,15572movq 0(%esi),%mm0573addl $64,%edi574movq 8(%esi),%mm1575subl $16,%ecx576movq 16(%esi),%mm2577movq %mm0,-64(%edi)578movq 24(%esi),%mm0579movq %mm1,-56(%edi)580movq 32(%esi),%mm1581movq %mm2,-48(%edi)582movq 40(%esi),%mm2583movq %mm0,-40(%edi)584movq 48(%esi),%mm0585movq %mm1,-32(%edi)586movq 56(%esi),%mm1587movq %mm2,-24(%edi)588movq %mm0,-16(%edi)589addl $64,%esi590movq %mm1,-8(%edi)591cmpl $16,%ecx592jge 4b593emms594testl %ecx,%ecx595ja 1b5965: andl $1,%eax597je 7f5986: movw (%esi),%dx599movw %dx,(%edi)6007: popl %edi601popl %esi602ret603mmx_acs_CopyLeft:604std605leal -4(%edi,%ecx,2),%edi606movl %eax,%esi607movl %ecx,%eax608subl $2,%esi609sarl %ecx610je 4f611cmpl $32,%ecx612ja 3f613subl %esi,%edi614.p2align 4,,156152: movl (%esi),%edx616movl %edx,(%edi,%esi,1)617subl $4,%esi618subl $1,%ecx619jnz 2b620addl %esi,%edi621jmp 4f6223: rep; smovl6234: andl $1,%eax624je 6f625addl $2,%esi626addl $2,%edi6275: movw (%esi),%dx628movw %dx,(%edi)6296: cld630popl %edi631popl %esi632ret633634635# Support for int64_t Atomic::cmpxchg(int64_t compare_value,636# volatile int64_t* dest,637# int64_t exchange_value)638#639.p2align 4,,15640ELF_TYPE(_Atomic_cmpxchg_long,@function)641SYMBOL(_Atomic_cmpxchg_long):642# 8(%esp) : return PC643pushl %ebx # 4(%esp) : old %ebx644pushl %edi # 0(%esp) : old %edi645movl 12(%esp), %ebx # 12(%esp) : exchange_value (low)646movl 16(%esp), %ecx # 16(%esp) : exchange_value (high)647movl 24(%esp), %eax # 24(%esp) : compare_value (low)648movl 28(%esp), %edx # 28(%esp) : compare_value (high)649movl 20(%esp), %edi # 20(%esp) : dest650lock651cmpxchg8b (%edi)652popl %edi653popl %ebx654ret655656657# Support for int64_t Atomic::load and Atomic::store.658# void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst)659.p2align 4,,15660ELF_TYPE(_Atomic_move_long,@function)661SYMBOL(_Atomic_move_long):662movl 4(%esp), %eax # src663fildll (%eax)664movl 8(%esp), %eax # dest665fistpll (%eax)666ret667668669