< prev index next >

src/os_cpu/solaris_x86/vm/assembler_solaris_x86.cpp

Print this page


   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  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "runtime/os.hpp"
  29 #include "runtime/threadLocalStorage.hpp"

  30 
  31 
  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 }
  41 
  42 #define __  _masm->
  43 #ifndef _LP64
  44 static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) {
  45 
  46   // slow call to of thr_getspecific
  47   // int thr_getspecific(thread_key_t key, void **value);
  48   // Consider using pthread_getspecific instead.
  49 
  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);
  67 
  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.
  74 








  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);
  92 
  93 __  movl(rdi, ThreadLocalStorage::thread_index());
  94 __  call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific)));
  95 
  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
 111 
 112 void MacroAssembler::get_thread(Register thread) {
 113 
 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_int8 (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_int8 (segment);
 129      AddressLiteral tls_off((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none);
 130      movptr (thread, tls_off);
 131      return ;
 132   }
 133 
 134   slow_call_thr_specific(this, thread);
 135 
 136 }
   1 /*
   2  * Copyright (c) 1999, 2015, 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  */
  24 
  25 #include "precompiled.hpp"

  26 #include "asm/macroAssembler.inline.hpp"
  27 #include "runtime/os.hpp"
  28 #include "runtime/threadLocalStorage.hpp"
  29 #include "runtime/thread.inline.hpp"
  30 

  31 void MacroAssembler::int3() {
  32   push(rax);
  33   push(rdx);
  34   push(rcx);
  35   call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
  36   pop(rcx);
  37   pop(rdx);
  38   pop(rax);
  39 }
  40 
  41 // This is simply a call to ThreadLocalStorage::thread()
  42 void MacroAssembler::get_thread(Register thread) {










  43   if (thread != rax) {
  44     push(rax);


  45   }
  46   push(rdi);
  47   push(rsi);
  48   push(rdx);
  49   push(rcx);
  50   push(r8);
  51   push(r9);
  52   push(r10);
  53   push(r11);
  54 
  55   call(RuntimeAddress(CAST_FROM_FN_PTR(address, ThreadLocalStorage::thread)));





  56   
  57   pop(r11);
  58   pop(r10);
  59   pop(r9);
  60   pop(r8);
  61   pop(rcx);
  62   pop(rdx);
  63   pop(rsi);
  64   pop(rdi);
  65   if (thread != rax) {
  66     movl(thread, rax);
  67     pop(rax);
  68   } 


























































  69 }
< prev index next >