hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp
author duke
Wed, 05 Jul 2017 20:10:48 +0200
changeset 27963 88d7c7c376e9
parent 26576 a9429d24d429
child 29573 2d800e5d575f
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 19336
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 * questions.
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
14286
ec9e76cd402f 8001619: Remove usage of _ALLBSD_SOURCE in bsd files
sla
parents: 13963
diff changeset
    26
#if !defined(__APPLE__) && !defined(__NetBSD__)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
#include <pthread.h>
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
# include <pthread_np.h> /* For pthread_attr_get_np */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
#endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
// no precompiled headers
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
#include "assembler_zero.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    33
#include "classfile/classLoader.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    34
#include "classfile/systemDictionary.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
#include "classfile/vmSymbols.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    36
#include "code/icBuffer.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    37
#include "code/vtableStubs.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    38
#include "interpreter/interpreter.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    39
#include "jvm_bsd.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    40
#include "memory/allocation.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    41
#include "mutex_bsd.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    42
#include "nativeInst_zero.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    43
#include "os_share_bsd.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
#include "prims/jniFastGetField.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
#include "prims/jvm.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
#include "prims/jvm_misc.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    47
#include "runtime/arguments.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    48
#include "runtime/extendedPC.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    49
#include "runtime/frame.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    50
#include "runtime/interfaceSupport.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
#include "runtime/java.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    52
#include "runtime/javaCalls.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    53
#include "runtime/mutexLocker.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    54
#include "runtime/osThread.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    55
#include "runtime/sharedRuntime.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    56
#include "runtime/stubRoutines.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 14286
diff changeset
    57
#include "runtime/thread.inline.hpp"
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
#include "runtime/timer.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    59
#include "utilities/events.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
#include "utilities/vmError.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    61
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
address os::current_stack_pointer() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    63
  address dummy = (address) &dummy;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
  return dummy;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    66
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    67
frame os::get_sender_for_C_frame(frame* fr) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
  ShouldNotCallThis();
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
    69
  return frame();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    70
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    71
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    72
frame os::current_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    73
  // The only thing that calls this is the stack printing code in
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    74
  // VMError::report:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    75
  //   - Step 110 (printing stack bounds) uses the sp in the frame
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    76
  //     to determine the amount of free space on the stack.  We
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
  //     set the sp to a close approximation of the real value in
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
  //     order to allow this step to complete.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
  //   - Step 120 (printing native stack) tries to walk the stack.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
  //     The frame we create has a NULL pc, which is ignored as an
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
  //     invalid frame.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    82
  frame dummy = frame();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    83
  dummy.set_sp((intptr_t *) current_stack_pointer());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
  return dummy;
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
char* os::non_memory_address_word() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    88
  // Must never look like an address returned by reserve_memory,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    89
  // even in its subfields (as defined by the CPU immediate fields,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
  // if the CPU splits constants across multiple instructions).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
#ifdef SPARC
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    92
  // On SPARC, 0 != %hi(any real address), because there is no
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    93
  // allocation in the first 1Kb of the virtual address space.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    94
  return (char *) 0;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
  // This is the value for x86; works pretty well for PPC too.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    97
  return (char *) -1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    98
#endif // SPARC
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    99
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
13859
7fe4578493fc 7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents: 11961
diff changeset
   101
void os::initialize_thread(Thread* thr) {
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   102
  // Nothing to do.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   103
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   104
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   105
address os::Bsd::ucontext_get_pc(ucontext_t* uc) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   106
  ShouldNotCallThis();
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
   107
  return NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   108
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   109
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   110
ExtendedPC os::fetch_frame_from_context(void* ucVoid,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   111
                                        intptr_t** ret_sp,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   112
                                        intptr_t** ret_fp) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   113
  ShouldNotCallThis();
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
   114
  return ExtendedPC();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   115
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   116
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   117
frame os::fetch_frame_from_context(void* ucVoid) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   118
  ShouldNotCallThis();
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
   119
  return frame();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   120
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   121
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   122
extern "C" JNIEXPORT int
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   123
JVM_handle_bsd_signal(int sig,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   124
                        siginfo_t* info,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   125
                        void* ucVoid,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   126
                        int abort_if_unrecognized) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   127
  ucontext_t* uc = (ucontext_t*) ucVoid;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   128
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   129
  Thread* t = ThreadLocalStorage::get_thread_slow();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   130
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   131
  SignalHandlerMark shm(t);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   132
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   133
  // Note: it's not uncommon that JNI code uses signal/sigset to
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   134
  // install then restore certain signal handler (e.g. to temporarily
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   135
  // block SIGPIPE, or have a SIGILL handler when detecting CPU
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   136
  // type). When that happens, JVM_handle_bsd_signal() might be
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   137
  // invoked with junk info/ucVoid. To avoid unnecessary crash when
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   138
  // libjsig is not preloaded, try handle signals that do not require
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   139
  // siginfo/ucontext first.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   140
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   141
  if (sig == SIGPIPE || sig == SIGXFSZ) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   142
    // allow chained handler to go first
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   143
    if (os::Bsd::chained_handler(sig, info, ucVoid)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   144
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   145
    } else {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   146
      if (PrintMiscellaneous && (WizardMode || Verbose)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   147
        char buf[64];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   148
        warning("Ignoring %s - see bugs 4229104 or 646499219",
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   149
                os::exception_name(sig, buf, sizeof(buf)));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   150
      }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   151
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   152
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   153
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   154
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   155
  JavaThread* thread = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   156
  VMThread* vmthread = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   157
  if (os::Bsd::signal_handlers_are_installed) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   158
    if (t != NULL ){
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   159
      if(t->is_Java_thread()) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   160
        thread = (JavaThread*)t;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   161
      }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   162
      else if(t->is_VM_thread()){
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   163
        vmthread = (VMThread *)t;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   164
      }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   165
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
  if (info != NULL && thread != NULL) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
    // Handle ALL stack overflow variations here
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   170
    if (sig == SIGSEGV || sig == SIGBUS) {
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   171
      address addr = (address) info->si_addr;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
      // check if fault address is within thread stack
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
      if (addr < thread->stack_base() &&
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   175
          addr >= thread->stack_base() - thread->stack_size()) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   176
        // stack overflow
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   177
        if (thread->in_stack_yellow_zone(addr)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   178
          thread->disable_stack_yellow_zone();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   179
          ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   180
        }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   181
        else if (thread->in_stack_red_zone(addr)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   182
          thread->disable_stack_red_zone();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   183
          ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   184
        }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   185
      }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   186
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   187
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   188
    /*if (thread->thread_state() == _thread_in_Java) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   189
      ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   190
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   191
    else*/ if (thread->thread_state() == _thread_in_vm &&
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   192
               sig == SIGBUS && thread->doing_unsafe_access()) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   193
      ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   194
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   195
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   196
    // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   197
    // kicks in and the heap gets shrunk before the field access.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   198
    /*if (sig == SIGSEGV || sig == SIGBUS) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   199
      address addr = JNI_FastGetField::find_slowcase_pc(pc);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   200
      if (addr != (address)-1) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   201
        stub = addr;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   202
      }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   203
    }*/
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   204
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   205
    // Check to see if we caught the safepoint code in the process
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   206
    // of write protecting the memory serialization page.  It write
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   207
    // enables the page immediately after protecting it so we can
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   208
    // just return to retry the write.
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   209
    if ((sig == SIGSEGV || sig == SIGBUS) &&
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   210
        os::is_memory_serialize_page(thread, (address) info->si_addr)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   211
      // Block current thread until permission is restored.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   212
      os::block_on_serialize_page_trap();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   213
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   214
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   215
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   216
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   217
  // signal-chaining
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   218
  if (os::Bsd::chained_handler(sig, info, ucVoid)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   219
     return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   220
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   221
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   222
  if (!abort_if_unrecognized) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   223
    // caller wants another chance, so give it to him
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   224
    return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   225
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   226
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   227
#ifndef PRODUCT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   228
  if (sig == SIGSEGV) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   229
    fatal("\n#"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   230
          "\n#    /--------------------\\"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   231
          "\n#    | segmentation fault |"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   232
          "\n#    \\---\\ /--------------/"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   233
          "\n#        /"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   234
          "\n#    [-]        |\\_/|    "
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   235
          "\n#    (+)=C      |o o|__  "
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   236
          "\n#    | |        =-*-=__\\ "
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   237
          "\n#    OOO        c_c_(___)");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   238
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   239
#endif // !PRODUCT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   240
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   241
  const char *fmt =
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   242
      "caught unhandled signal " INT32_FORMAT " at address " PTR_FORMAT;
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   243
  char buf[128];
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   244
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   245
  sprintf(buf, fmt, sig, info->si_addr);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   246
  fatal(buf);
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
   247
  return false;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   248
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   249
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   250
void os::Bsd::init_thread_fpu_state(void) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   251
  // Nothing to do
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   252
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   253
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   254
bool os::is_allocatable(size_t bytes) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   255
#ifdef _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   256
  return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   257
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   258
  if (bytes < 2 * G) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   259
    return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   260
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   261
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   262
  char* addr = reserve_memory(bytes, NULL);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   263
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   264
  if (addr != NULL) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   265
    release_memory(addr, bytes);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   266
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   267
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   268
  return addr != NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   269
#endif // _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   270
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   271
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   272
///////////////////////////////////////////////////////////////////////////////
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   273
// thread stack
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   274
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   275
size_t os::Bsd::min_stack_allowed = 64 * K;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   276
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   277
bool os::Bsd::supports_variable_stack_size() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   278
  return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   279
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   280
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   281
size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   282
#ifdef _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   283
  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   284
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   285
  size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   286
#endif // _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   287
  return s;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   288
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   289
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   290
size_t os::Bsd::default_guard_size(os::ThreadType thr_type) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   291
  // Only enable glibc guard pages for non-Java threads
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   292
  // (Java threads have HotSpot guard pages)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   293
  return (thr_type == java_thread ? 0 : page_size());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   294
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   295
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   296
static void current_stack_region(address *bottom, size_t *size) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   297
  address stack_bottom;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   298
  address stack_top;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   299
  size_t stack_bytes;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   300
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   301
#ifdef __APPLE__
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   302
  pthread_t self = pthread_self();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   303
  stack_top = (address) pthread_get_stackaddr_np(self);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   304
  stack_bytes = pthread_get_stacksize_np(self);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   305
  stack_bottom = stack_top - stack_bytes;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   306
#elif defined(__OpenBSD__)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   307
  stack_t ss;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   308
  int rslt = pthread_stackseg_np(pthread_self(), &ss);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   309
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   310
  if (rslt != 0)
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   311
    fatal(err_msg("pthread_stackseg_np failed with err = " INT32_FORMAT,
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   312
          rslt));
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   313
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   314
  stack_top = (address) ss.ss_sp;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   315
  stack_bytes  = ss.ss_size;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   316
  stack_bottom = stack_top - stack_bytes;
14286
ec9e76cd402f 8001619: Remove usage of _ALLBSD_SOURCE in bsd files
sla
parents: 13963
diff changeset
   317
#else
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   318
  pthread_attr_t attr;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   319
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   320
  int rslt = pthread_attr_init(&attr);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   321
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   322
  // JVM needs to know exact stack location, abort if it fails
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   323
  if (rslt != 0)
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   324
    fatal(err_msg("pthread_attr_init failed with err = " INT32_FORMAT, rslt));
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   325
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   326
  rslt = pthread_attr_get_np(pthread_self(), &attr);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   327
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   328
  if (rslt != 0)
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   329
    fatal(err_msg("pthread_attr_get_np failed with err = " INT32_FORMAT,
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   330
          rslt));
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   331
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   332
  if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   333
      pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   334
    fatal("Can not locate current stack attributes!");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   335
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   336
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   337
  pthread_attr_destroy(&attr);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   338
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   339
  stack_top = stack_bottom + stack_bytes;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   340
#endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   341
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   342
  assert(os::current_stack_pointer() >= stack_bottom, "should do");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   343
  assert(os::current_stack_pointer() < stack_top, "should do");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   344
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   345
  *bottom = stack_bottom;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   346
  *size = stack_top - stack_bottom;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   347
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   348
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   349
address os::current_stack_base() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   350
  address bottom;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   351
  size_t size;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   352
  current_stack_region(&bottom, &size);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   353
  return bottom + size;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   354
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   355
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   356
size_t os::current_stack_size() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   357
  // stack size includes normal stack and HotSpot guard pages
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   358
  address bottom;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   359
  size_t size;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   360
  current_stack_region(&bottom, &size);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   361
  return size;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   362
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   363
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   364
/////////////////////////////////////////////////////////////////////////////
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   365
// helper functions for fatal error handler
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   366
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   367
void os::print_context(outputStream* st, void* context) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   368
  ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   369
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   370
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   371
void os::print_register_info(outputStream *st, void *context) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   372
  ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   373
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   374
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   375
/////////////////////////////////////////////////////////////////////////////
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   376
// Stubs for things that would be in bsd_zero.s if it existed.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   377
// You probably want to disassemble these monkeys to check they're ok.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   378
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   379
extern "C" {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   380
  int SpinPause() {
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 14583
diff changeset
   381
    return 1;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   382
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   383
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   384
  void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   385
    if (from > to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   386
      jshort *end = from + count;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   387
      while (from < end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   388
        *(to++) = *(from++);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   389
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   390
    else if (from < to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   391
      jshort *end = from;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   392
      from += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   393
      to   += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   394
      while (from >= end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   395
        *(to--) = *(from--);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   396
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   397
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   398
  void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   399
    if (from > to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   400
      jint *end = from + count;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   401
      while (from < end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   402
        *(to++) = *(from++);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   403
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   404
    else if (from < to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   405
      jint *end = from;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   406
      from += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   407
      to   += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   408
      while (from >= end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   409
        *(to--) = *(from--);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   410
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   411
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   412
  void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   413
    if (from > to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   414
      jlong *end = from + count;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   415
      while (from < end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   416
        os::atomic_copy64(from++, to++);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   417
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   418
    else if (from < to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   419
      jlong *end = from;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   420
      from += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   421
      to   += count - 1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   422
      while (from >= end)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   423
        os::atomic_copy64(from--, to--);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   424
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   425
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   426
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   427
  void _Copy_arrayof_conjoint_bytes(HeapWord* from,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   428
                                    HeapWord* to,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   429
                                    size_t    count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   430
    memmove(to, from, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   431
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   432
  void _Copy_arrayof_conjoint_jshorts(HeapWord* from,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   433
                                      HeapWord* to,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   434
                                      size_t    count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   435
    memmove(to, from, count * 2);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   436
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   437
  void _Copy_arrayof_conjoint_jints(HeapWord* from,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   438
                                    HeapWord* to,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   439
                                    size_t    count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   440
    memmove(to, from, count * 4);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   441
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   442
  void _Copy_arrayof_conjoint_jlongs(HeapWord* from,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   443
                                     HeapWord* to,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   444
                                     size_t    count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   445
    memmove(to, from, count * 8);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   446
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   447
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   448
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   449
/////////////////////////////////////////////////////////////////////////////
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   450
// Implementations of atomic operations not supported by processors.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   451
//  -- http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Atomic-Builtins.html
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   452
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   453
#ifndef _LP64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   454
extern "C" {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   455
  long long unsigned int __sync_val_compare_and_swap_8(
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   456
    volatile void *ptr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   457
    long long unsigned int oldval,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   458
    long long unsigned int newval) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   459
    ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   460
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   461
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   462
#endif // !_LP64
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10739
diff changeset
   463
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10739
diff changeset
   464
#ifndef PRODUCT
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10739
diff changeset
   465
void os::verify_stack_alignment() {
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10739
diff changeset
   466
}
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10739
diff changeset
   467
#endif
26576
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 22234
diff changeset
   468
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 22234
diff changeset
   469
int os::extra_bang_size_in_bytes() {
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 22234
diff changeset
   470
  // Zero does not require an additional stack bang.
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 22234
diff changeset
   471
  return 0;
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 22234
diff changeset
   472
}