hotspot/src/os_cpu/bsd_x86/vm/assembler_bsd_x86.cpp
author katleman
Thu, 06 Jun 2013 09:54:40 -0700
changeset 17989 7a038718c2b1
parent 14626 0cf4eccf130f
child 34633 2a6c7c7b30a7
permissions -rw-r--r--
Added tag jdk8-b93 for changeset 3ea33579af2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 10565
diff changeset
    26
#include "asm/macroAssembler.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 10565
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
#include "runtime/os.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
#include "runtime/threadLocalStorage.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
#ifndef _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
void MacroAssembler::int3() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    33
  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    34
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    36
void MacroAssembler::get_thread(Register thread) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    37
  movl(thread, rsp);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    38
  shrl(thread, PAGE_SHIFT);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    39
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    40
  ExternalAddress tls_base((address)ThreadLocalStorage::sp_map_addr());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    41
  Address index(noreg, thread, Address::times_4);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    42
  ArrayAddress tls(tls_base, index);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    43
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
  movptr(thread, tls);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    47
void MacroAssembler::int3() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    48
  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    49
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    50
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
void MacroAssembler::get_thread(Register thread) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    52
  // call pthread_getspecific
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    53
  // void * pthread_getspecific(pthread_key_t key);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    54
   if (thread != rax) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    55
     push(rax);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    56
   }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    57
   push(rdi);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
   push(rsi);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    59
   push(rdx);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
   push(rcx);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    61
   push(r8);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
   push(r9);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    63
   push(r10);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
   // XXX
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
   mov(r10, rsp);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    66
   andq(rsp, -16);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    67
   push(r10);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
   push(r11);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    69
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    70
   movl(rdi, ThreadLocalStorage::thread_index());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    71
   call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific)));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    72
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    73
   pop(r11);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    74
   pop(rsp);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    75
   pop(r10);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    76
   pop(r9);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
   pop(r8);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
   pop(rcx);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
   pop(rdx);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
   pop(rsi);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
   pop(rdi);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    82
   if (thread != rax) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    83
       mov(thread, rax);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
       pop(rax);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    85
   }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    86
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    87
#endif