hotspot/src/os_cpu/linux_aarch64/vm/assembler_linux_aarch64.cpp
author vadim
Tue, 07 Apr 2015 13:37:30 +0300
changeset 31699 7bc1eec6ce3b
parent 29182 78af2a4d1ec3
child 34633 2a6c7c7b30a7
permissions -rw-r--r--
8074871: Adjust device table handling Reviewed-by: prr, srl, mschoene
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29182
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     1
/*
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     3
 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     5
 *
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     8
 * published by the Free Software Foundation.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
     9
 *
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    14
 * accompanied this code).
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    15
 *
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    19
 *
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    22
 * questions.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    23
 *
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    24
 */
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    25
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    26
#include "precompiled.hpp"
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    27
#include "asm/macroAssembler.hpp"
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    29
#include "runtime/os.hpp"
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    30
#include "runtime/threadLocalStorage.hpp"
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    31
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    32
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    33
// get_thread can be called anywhere inside generated code so we need
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    34
// to save whatever non-callee save context might get clobbered by the
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    35
// call to the C thread_local lookup call or, indeed, the call setup
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    36
// code. x86 appears to save C arg registers.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    37
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    38
void MacroAssembler::get_thread(Register dst) {
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    39
  // call pthread_getspecific
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    40
  // void * pthread_getspecific(pthread_key_t key);
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    41
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    42
  // Save all call-clobbered regs except dst, plus r19 and r20.
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    43
  RegSet saved_regs = RegSet::range(r0, r20) + lr - dst;
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    44
  push(saved_regs, sp);
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    45
  mov(c_rarg0, ThreadLocalStorage::thread_index());
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    46
  mov(r19, CAST_FROM_FN_PTR(address, pthread_getspecific));
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    47
  blrt(r19, 1, 0, 1);
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    48
  if (dst != c_rarg0) {
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    49
    mov(dst, c_rarg0);
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    50
  }
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    51
  // restore pushed registers
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    52
  pop(saved_regs, sp);
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    53
}
78af2a4d1ec3 8068055: AARCH64: os_cpu
aph
parents:
diff changeset
    54