aoqi@0: // aoqi@0: // Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: // aoqi@0: // This code is free software; you can redistribute it and/or modify it aoqi@0: // under the terms of the GNU General Public License version 2 only, as aoqi@0: // published by the Free Software Foundation. aoqi@0: // aoqi@0: // This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: // version 2 for more details (a copy is included in the LICENSE file that aoqi@0: // accompanied this code). aoqi@0: // aoqi@0: // You should have received a copy of the GNU General Public License version aoqi@0: // 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: // aoqi@0: // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: // or visit www.oracle.com if you need additional information or have any aoqi@0: // questions. aoqi@0: // aoqi@0: // aoqi@0: aoqi@0: // Get the raw thread ID from %g7 aoqi@0: aoqi@0: .inline _raw_thread_id, 0 aoqi@0: .register %g7,#scratch aoqi@0: .volatile aoqi@0: mov %g7, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Clear SPARC fprs.FEF DU and DL bits -- aoqi@0: // allows the kernel to avoid saving FPU state at context-switch time. aoqi@0: // Use for state-transition points (into _thread_blocked) or when aoqi@0: // parking. aoqi@0: aoqi@0: .inline _mark_fpu_nosave, 0 aoqi@0: .volatile aoqi@0: wr %g0, 0, %fprs aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: // Support for jint Atomic::xchg(jint exchange_value, volatile jint* dest). aoqi@0: // aoqi@0: // Arguments: aoqi@0: // exchange_value: O0 aoqi@0: // dest: O1 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the value previously stored in dest aoqi@0: aoqi@0: .inline _Atomic_swap32, 2 aoqi@0: .volatile aoqi@0: swap [%o1],%o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t * dest). aoqi@0: // aoqi@0: // 64-bit aoqi@0: // aoqi@0: // Arguments: aoqi@0: // exchange_value: O0 aoqi@0: // dest: O1 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the value previously stored in dest aoqi@0: aoqi@0: .inline _Atomic_swap64, 2 aoqi@0: .volatile aoqi@0: 1: aoqi@0: mov %o0, %o3 aoqi@0: ldx [%o1], %o2 aoqi@0: casx [%o1], %o2, %o3 aoqi@0: cmp %o2, %o3 aoqi@0: bne %xcc, 1b aoqi@0: nop aoqi@0: mov %o2, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for jint Atomic::cmpxchg(jint exchange_value, aoqi@0: // volatile jint* dest, aoqi@0: // jint compare_value) aoqi@0: // aoqi@0: // Arguments: aoqi@0: // exchange_value: O0 aoqi@0: // dest: O1 aoqi@0: // compare_value: O2 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the value previously stored in dest aoqi@0: aoqi@0: .inline _Atomic_cas32, 3 aoqi@0: .volatile aoqi@0: cas [%o1], %o2, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, aoqi@0: // volatile intptr_t* dest, aoqi@0: // intptr_t compare_value) aoqi@0: // aoqi@0: // 64-bit aoqi@0: // aoqi@0: // Arguments: aoqi@0: // exchange_value: O0 aoqi@0: // dest: O1 aoqi@0: // compare_value: O2 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the value previously stored in dest aoqi@0: aoqi@0: .inline _Atomic_cas64, 3 aoqi@0: .volatile aoqi@0: casx [%o1], %o2, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for jlong Atomic::cmpxchg(jlong exchange_value, aoqi@0: // volatile jlong* dest, aoqi@0: // jlong compare_value) aoqi@0: // aoqi@0: // 32-bit calling conventions aoqi@0: // aoqi@0: // Arguments: aoqi@0: // exchange_value: O1:O0 aoqi@0: // dest: O2 aoqi@0: // compare_value: O4:O3 aoqi@0: // aoqi@0: // Results: aoqi@0: // O1:O0: the value previously stored in dest aoqi@0: aoqi@0: .inline _Atomic_casl, 3 aoqi@0: .volatile aoqi@0: sllx %o0, 32, %o0 aoqi@0: srl %o1, 0, %o1 aoqi@0: or %o0,%o1,%o0 aoqi@0: sllx %o3, 32, %o3 aoqi@0: srl %o4, 0, %o4 aoqi@0: or %o3,%o4,%o3 aoqi@0: casx [%o2], %o3, %o0 aoqi@0: srl %o0, 0, %o1 aoqi@0: srlx %o0, 32, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: // Support for jlong Atomic::load and Atomic::store on v9. aoqi@0: // aoqi@0: // void _Atomic_move_long_v9(volatile jlong* src, volatile jlong* dst) aoqi@0: // aoqi@0: // Arguments: aoqi@0: // src: O0 aoqi@0: // dest: O1 aoqi@0: // aoqi@0: // Overwrites O2 aoqi@0: aoqi@0: .inline _Atomic_move_long_v9,2 aoqi@0: .volatile aoqi@0: ldx [%o0], %o2 aoqi@0: stx %o2, [%o1] aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: // Support for jint Atomic::add(jint add_value, volatile jint* dest). aoqi@0: // aoqi@0: // Arguments: aoqi@0: // add_value: O0 (e.g., +1 or -1) aoqi@0: // dest: O1 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the new value stored in dest aoqi@0: // aoqi@0: // Overwrites O3 aoqi@0: aoqi@0: .inline _Atomic_add32, 2 aoqi@0: .volatile aoqi@0: 2: aoqi@0: ld [%o1], %o2 aoqi@0: add %o0, %o2, %o3 aoqi@0: cas [%o1], %o2, %o3 aoqi@0: cmp %o2, %o3 aoqi@0: bne 2b aoqi@0: nop aoqi@0: add %o0, %o2, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) aoqi@0: // aoqi@0: // 64-bit aoqi@0: // aoqi@0: // Arguments: aoqi@0: // add_value: O0 (e.g., +1 or -1) aoqi@0: // dest: O1 aoqi@0: // aoqi@0: // Results: aoqi@0: // O0: the new value stored in dest aoqi@0: // aoqi@0: // Overwrites O3 aoqi@0: aoqi@0: .inline _Atomic_add64, 2 aoqi@0: .volatile aoqi@0: 3: aoqi@0: ldx [%o1], %o2 aoqi@0: add %o0, %o2, %o3 aoqi@0: casx [%o1], %o2, %o3 aoqi@0: cmp %o2, %o3 aoqi@0: bne %xcc, 3b aoqi@0: nop aoqi@0: add %o0, %o2, %o0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for void OrderAccess::acquire() aoqi@0: // The method is intentionally empty. aoqi@0: // It exists for the sole purpose of generating aoqi@0: // a C/C++ sequence point over which the compiler won't aoqi@0: // reorder code. aoqi@0: aoqi@0: .inline _OrderAccess_acquire,0 aoqi@0: .volatile aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for void OrderAccess::fence() aoqi@0: aoqi@0: .inline _OrderAccess_fence,0 aoqi@0: .volatile aoqi@0: membar #StoreLoad aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for void Prefetch::read(void *loc, intx interval) aoqi@0: // aoqi@0: // Prefetch for several reads. aoqi@0: aoqi@0: .inline _Prefetch_read, 2 aoqi@0: .volatile aoqi@0: prefetch [%o0+%o1], 0 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for void Prefetch::write(void *loc, intx interval) aoqi@0: // aoqi@0: // Prefetch for several writes. aoqi@0: aoqi@0: .inline _Prefetch_write, 2 aoqi@0: .volatile aoqi@0: prefetch [%o0+%o1], 2 aoqi@0: .nonvolatile aoqi@0: .end aoqi@0: aoqi@0: aoqi@0: // Support for void Copy::conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) aoqi@0: // aoqi@0: // 32-bit aoqi@0: // aoqi@0: // Arguments: aoqi@0: // from: O0 aoqi@0: // to: O1 aoqi@0: // count: O2 treated as signed aoqi@0: // aoqi@0: // Clobbers: aoqi@0: // long_value: O2, O3 aoqi@0: // count: O4 aoqi@0: // aoqi@0: // if (from > to) { aoqi@0: // while (--count >= 0) { aoqi@0: // *to++ = *from++; aoqi@0: // } aoqi@0: // } else { aoqi@0: // while (--count >= 0) { aoqi@0: // to[count] = from[count]; aoqi@0: // } aoqi@0: // } aoqi@0: .inline _Copy_conjoint_jlongs_atomic, 3 aoqi@0: .volatile aoqi@0: cmp %o0, %o1 aoqi@0: bleu 4f aoqi@0: sll %o2, 3, %o4 aoqi@0: ba 2f aoqi@0: 1: aoqi@0: subcc %o4, 8, %o4 aoqi@0: std %o2, [%o1] aoqi@0: add %o0, 8, %o0 aoqi@0: add %o1, 8, %o1 aoqi@0: 2: aoqi@0: bge,a 1b aoqi@0: ldd [%o0], %o2 aoqi@0: ba 5f aoqi@0: nop aoqi@0: 3: aoqi@0: std %o2, [%o1+%o4] aoqi@0: 4: aoqi@0: subcc %o4, 8, %o4 aoqi@0: bge,a 3b aoqi@0: ldd [%o0+%o4], %o2 aoqi@0: 5: aoqi@0: .nonvolatile aoqi@0: .end