src/os_cpu/solaris_x86/vm/assembler_solaris_x86.cpp

Thu, 16 Feb 2012 17:12:49 -0800

author
kvn
date
Thu, 16 Feb 2012 17:12:49 -0800
changeset 3577
9b8ce46870df
parent 2314
f95d63e2154a
child 4318
cd3d6a6b95d9
permissions
-rw-r--r--

7145346: VerifyStackAtCalls is broken
Summary: Replace call_epilog() encoding with macroassembler use. Moved duplicated code to x86.ad. Fixed return_addr() definition.
Reviewed-by: never

     1 /*
     2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "asm/assembler.hpp"
    27 #include "assembler_x86.inline.hpp"
    28 #include "runtime/os.hpp"
    29 #include "runtime/threadLocalStorage.hpp"
    32 void MacroAssembler::int3() {
    33   push(rax);
    34   push(rdx);
    35   push(rcx);
    36   call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
    37   pop(rcx);
    38   pop(rdx);
    39   pop(rax);
    40 }
    42 #define __  _masm->
    43 #ifndef _LP64
    44 static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) {
    46   // slow call to of thr_getspecific
    47   // int thr_getspecific(thread_key_t key, void **value);
    48   // Consider using pthread_getspecific instead.
    50 __  push(0);                                                            // allocate space for return value
    51   if (thread != rax) __ push(rax);                                      // save rax, if caller still wants it
    52 __  push(rcx);                                                          // save caller save
    53 __  push(rdx);                                                          // save caller save
    54   if (thread != rax) {
    55 __    lea(thread, Address(rsp, 3 * sizeof(int)));                       // address of return value
    56   } else {
    57 __    lea(thread, Address(rsp, 2 * sizeof(int)));                       // address of return value
    58   }
    59 __  push(thread);                                                       // and pass the address
    60 __  push(ThreadLocalStorage::thread_index());                           // the key
    61 __  call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific)));
    62 __  increment(rsp, 2 * wordSize);
    63 __  pop(rdx);
    64 __  pop(rcx);
    65   if (thread != rax) __ pop(rax);
    66 __  pop(thread);
    68 }
    69 #else
    70 static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) {
    71   // slow call to of thr_getspecific
    72   // int thr_getspecific(thread_key_t key, void **value);
    73   // Consider using pthread_getspecific instead.
    75   if (thread != rax) {
    76 __    push(rax);
    77   }
    78 __  push(0); // space for return value
    79 __  push(rdi);
    80 __  push(rsi);
    81 __  lea(rsi, Address(rsp, 16)); // pass return value address
    82 __  push(rdx);
    83 __  push(rcx);
    84 __  push(r8);
    85 __  push(r9);
    86 __  push(r10);
    87   // XXX
    88 __  mov(r10, rsp);
    89 __  andptr(rsp, -16);
    90 __  push(r10);
    91 __  push(r11);
    93 __  movl(rdi, ThreadLocalStorage::thread_index());
    94 __  call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific)));
    96 __  pop(r11);
    97 __  pop(rsp);
    98 __  pop(r10);
    99 __  pop(r9);
   100 __  pop(r8);
   101 __  pop(rcx);
   102 __  pop(rdx);
   103 __  pop(rsi);
   104 __  pop(rdi);
   105 __  pop(thread); // load return value
   106   if (thread != rax) {
   107 __    pop(rax);
   108   }
   109 }
   110 #endif //LP64
   112 void MacroAssembler::get_thread(Register thread) {
   114   int segment = NOT_LP64(Assembler::GS_segment) LP64_ONLY(Assembler::FS_segment);
   115   // Try to emit a Solaris-specific fast TSD/TLS accessor.
   116   ThreadLocalStorage::pd_tlsAccessMode tlsMode = ThreadLocalStorage::pd_getTlsAccessMode ();
   117   if (tlsMode == ThreadLocalStorage::pd_tlsAccessIndirect) {            // T1
   118      // Use thread as a temporary: mov r, gs:[0]; mov r, [r+tlsOffset]
   119      emit_byte (segment);
   120      // ExternalAddress doesn't work because it can't take NULL
   121      AddressLiteral null(0, relocInfo::none);
   122      movptr (thread, null);
   123      movptr(thread, Address(thread, ThreadLocalStorage::pd_getTlsOffset())) ;
   124      return ;
   125   } else
   126   if (tlsMode == ThreadLocalStorage::pd_tlsAccessDirect) {              // T2
   127      // mov r, gs:[tlsOffset]
   128      emit_byte (segment);
   129      AddressLiteral tls_off((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none);
   130      movptr (thread, tls_off);
   131      return ;
   132   }
   134   slow_call_thr_specific(this, thread);
   136 }

mercurial