hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86.cpp
author sundar
Tue, 25 Jun 2013 17:31:19 +0530
changeset 18615 3f6e6adcbc1a
parent 14837 a75c3082d106
child 32181 dee472a9b4db
permissions -rw-r--r--
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223 Reviewed-by: hannesw, jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1066
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1066
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1066
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 7397
diff changeset
    26
#include "asm/macroAssembler.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 7397
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/threadLocalStorage.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
void MacroAssembler::int3() {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    33
  push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    34
  push(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    35
  push(rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    37
  pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    38
  pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    39
  pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    42
#define __  _masm->
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    43
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    44
static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // slow call to of thr_getspecific
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // int thr_getspecific(thread_key_t key, void **value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Consider using pthread_getspecific instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    50
__  push(0);                                                            // allocate space for return value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    51
  if (thread != rax) __ push(rax);                                      // save rax, if caller still wants it
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    52
__  push(rcx);                                                          // save caller save
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    53
__  push(rdx);                                                          // save caller save
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  if (thread != rax) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    55
__    lea(thread, Address(rsp, 3 * sizeof(int)));                       // address of return value
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    57
__    lea(thread, Address(rsp, 2 * sizeof(int)));                       // address of return value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    58
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    59
__  push(thread);                                                       // and pass the address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    60
__  push(ThreadLocalStorage::thread_index());                           // the key
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    61
__  call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    62
__  increment(rsp, 2 * wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    63
__  pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    64
__  pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    65
  if (thread != rax) __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    66
__  pop(thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    67
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    68
}
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    69
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    70
static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    71
  // slow call to of thr_getspecific
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    72
  // int thr_getspecific(thread_key_t key, void **value);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    73
  // Consider using pthread_getspecific instead.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    74
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    75
  if (thread != rax) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    76
__    push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    78
__  push(0); // space for return value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    79
__  push(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    80
__  push(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    81
__  lea(rsi, Address(rsp, 16)); // pass return value address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    82
__  push(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    83
__  push(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    84
__  push(r8);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    85
__  push(r9);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    86
__  push(r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    87
  // XXX
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    88
__  mov(r10, rsp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    89
__  andptr(rsp, -16);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    90
__  push(r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    91
__  push(r11);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    92
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    93
__  movl(rdi, ThreadLocalStorage::thread_index());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    94
__  call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    95
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    96
__  pop(r11);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    97
__  pop(rsp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    98
__  pop(r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
    99
__  pop(r9);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   100
__  pop(r8);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   101
__  pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   102
__  pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   103
__  pop(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   104
__  pop(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   105
__  pop(thread); // load return value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   106
  if (thread != rax) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   107
__    pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   108
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   110
#endif //LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   111
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   112
void MacroAssembler::get_thread(Register thread) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   113
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   114
  int segment = NOT_LP64(Assembler::GS_segment) LP64_ONLY(Assembler::FS_segment);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   115
  // Try to emit a Solaris-specific fast TSD/TLS accessor.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   116
  ThreadLocalStorage::pd_tlsAccessMode tlsMode = ThreadLocalStorage::pd_getTlsAccessMode ();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   117
  if (tlsMode == ThreadLocalStorage::pd_tlsAccessIndirect) {            // T1
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   118
     // Use thread as a temporary: mov r, gs:[0]; mov r, [r+tlsOffset]
14837
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 14626
diff changeset
   119
     emit_int8 (segment);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   120
     // ExternalAddress doesn't work because it can't take NULL
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   121
     AddressLiteral null(0, relocInfo::none);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   122
     movptr (thread, null);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   123
     movptr(thread, Address(thread, ThreadLocalStorage::pd_getTlsOffset())) ;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   124
     return ;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   125
  } else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   126
  if (tlsMode == ThreadLocalStorage::pd_tlsAccessDirect) {              // T2
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   127
     // mov r, gs:[tlsOffset]
14837
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 14626
diff changeset
   128
     emit_int8 (segment);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   129
     AddressLiteral tls_off((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   130
     movptr (thread, tls_off);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   131
     return ;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   132
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   133
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   134
  slow_call_thr_specific(this, thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   135
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 823
diff changeset
   136
}