hotspot/src/share/vm/runtime/interfaceSupport.hpp
author david
Thu, 14 Jan 2016 13:26:19 +0100
changeset 35492 c8c0273e6b91
parent 34633 2a6c7c7b30a7
child 36086 f70e100d3195
permissions -rw-r--r--
8146690: Make all classes in GC follow the naming convention. Reviewed-by: dholmes, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
29070
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
     2
 * Copyright (c) 1997, 2015, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
#ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29070
diff changeset
    28
#include "gc/shared/gcLocker.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/orderAccess.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/safepoint.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 13963
diff changeset
    34
#include "runtime/thread.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "runtime/vmThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "utilities/preserveException.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "utilities/top.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Wrapper for all entry points to the virtual machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// The HandleMarkCleaner is a faster version of HandleMark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// It relies on the fact that there is a HandleMark further
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// down the stack (in JavaCalls::call_helper), and just resets
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// to the saved values in that HandleMark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class HandleMarkCleaner: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  Thread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  HandleMarkCleaner(Thread* thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    _thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    _thread->last_handle_mark()->push();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  ~HandleMarkCleaner() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _thread->last_handle_mark()->pop_and_restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
 private:
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 14583
diff changeset
    59
  inline void* operator new(size_t size, void* ptr) throw() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    return ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
    64
// InterfaceSupport provides functionality used by the VM_LEAF_BASE and
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
    65
// VM_ENTRY_BASE macros. These macros are used to guard entry points into
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
    66
// the VM and perform checks upon leave of the VM.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class InterfaceSupport: AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
# ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  static long _scavenge_alot_counter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  static long _fullgc_alot_counter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  static long _number_of_calls;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  static long _fullgc_alot_invocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Helper methods used to implement +ScavengeALot and +FullGCALot
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  static void gc_alot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static void walk_stack_from(vframe* start_vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static void walk_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static void zombieAll();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    85
  static void unlinkSymbols();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static void deoptimizeAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  static void stress_derived_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  static void verify_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  static void verify_last_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
# endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // OS dependent stuff
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    94
#ifdef TARGET_OS_FAMILY_linux
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    95
# include "interfaceSupport_linux.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    96
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    97
#ifdef TARGET_OS_FAMILY_solaris
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    98
# include "interfaceSupport_solaris.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    99
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   100
#ifdef TARGET_OS_FAMILY_windows
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   101
# include "interfaceSupport_windows.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   102
#endif
22827
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
   103
#ifdef TARGET_OS_FAMILY_aix
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
   104
# include "interfaceSupport_aix.hpp"
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
   105
#endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
   106
#ifdef TARGET_OS_FAMILY_bsd
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
   107
# include "interfaceSupport_bsd.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8921
diff changeset
   108
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   109
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// Basic class for all thread transition classes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
class ThreadStateTransition : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  JavaThread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  ThreadStateTransition(JavaThread *thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    _thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    assert(thread != NULL && thread->is_Java_thread(), "must be Java thread");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Change threadstate in a manner, so safepoint can detect changes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // Time-critical: called on exit from every runtime routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    assert(from != _thread_in_Java, "use transition_from_java");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    assert(from != _thread_in_native, "use transition_from_native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    assert(thread->thread_state() == from, "coming from wrong thread state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    // Change to transition state (assumes total store ordering!  -Urs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    thread->set_thread_state((JavaThreadState)(from + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // Make sure new state is seen by VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      if (UseMembar) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        // Force a fence between the write above and read below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        OrderAccess::fence();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        // store to serialize page so VM thread can do pseudo remote membar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        os::write_memory_serialize_page(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    if (SafepointSynchronize::do_call_back()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      SafepointSynchronize::block(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    thread->set_thread_state(to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // transition_and_fence must be used on any thread state transition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // where there might not be a Java call stub on the stack, in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // particular on Windows where the Structured Exception Handler is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // set up in the call stub. os::write_memory_serialize_page() can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // fault and we can't recover from it on Windows without a SEH in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  static inline void transition_and_fence(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    assert(thread->thread_state() == from, "coming from wrong thread state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    // Change to transition state (assumes total store ordering!  -Urs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    thread->set_thread_state((JavaThreadState)(from + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    // Make sure new state is seen by VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      if (UseMembar) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        // Force a fence between the write above and read below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        OrderAccess::fence();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
        // Must use this rather than serialization page in particular on Windows
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
        InterfaceSupport::serialize_memory(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    if (SafepointSynchronize::do_call_back()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      SafepointSynchronize::block(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    thread->set_thread_state(to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // Same as above, but assumes from = _thread_in_Java. This is simpler, since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // never block on entry to the VM. This will break the code, since e.g. preserve arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // have not been setup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  static inline void transition_from_java(JavaThread *thread, JavaThreadState to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    thread->set_thread_state(to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    assert((to & 1) == 0, "odd numbers are transitions states");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    // Change to transition state (assumes total store ordering!  -Urs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    thread->set_thread_state(_thread_in_native_trans);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    // Make sure new state is seen by GC thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      if (UseMembar) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        // Force a fence between the write above and read below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        OrderAccess::fence();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
        // Must use this rather than serialization page in particular on Windows
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        InterfaceSupport::serialize_memory(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    // We never install asynchronous exceptions when coming (back) in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    // to the runtime from native code because the runtime is not set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    // up to handle exceptions floating around at arbitrary points.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    if (SafepointSynchronize::do_call_back() || thread->is_suspend_after_native()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      // Clear unhandled oops anywhere where we could block, even if we don't.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    thread->set_thread_state(to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
   void trans(JavaThreadState from, JavaThreadState to)  { transition(_thread, from, to); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
   void trans_from_java(JavaThreadState to)              { transition_from_java(_thread, to); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
   void trans_from_native(JavaThreadState to)            { transition_from_native(_thread, to); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
   void trans_and_fence(JavaThreadState from, JavaThreadState to) { transition_and_fence(_thread, from, to); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
class ThreadInVMfromJava : public ThreadStateTransition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  ThreadInVMfromJava(JavaThread* thread) : ThreadStateTransition(thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    trans_from_java(_thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  ~ThreadInVMfromJava()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    trans(_thread_in_vm, _thread_in_Java);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    // Check for pending. async. exceptions or suspends.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
class ThreadInVMfromUnknown {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  JavaThread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  ThreadInVMfromUnknown() : _thread(NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    Thread* t = Thread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    if (t->is_Java_thread()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
      JavaThread* t2 = (JavaThread*) t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      if (t2->thread_state() == _thread_in_native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        _thread = t2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
        ThreadStateTransition::transition_from_native(t2, _thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        // Used to have a HandleMarkCleaner but that is dangerous as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        // it could free a handle in our (indirect, nested) caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
        // We expect any handles will be short lived and figure we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        // don't need an actual HandleMark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  ~ThreadInVMfromUnknown()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    if (_thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
      ThreadStateTransition::transition_and_fence(_thread, _thread_in_vm, _thread_in_native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
class ThreadInVMfromNative : public ThreadStateTransition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  ThreadInVMfromNative(JavaThread* thread) : ThreadStateTransition(thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    trans_from_native(_thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  ~ThreadInVMfromNative() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    trans_and_fence(_thread_in_vm, _thread_in_native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
class ThreadToNativeFromVM : public ThreadStateTransition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  ThreadToNativeFromVM(JavaThread *thread) : ThreadStateTransition(thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    // We are leaving the VM at this point and going directly to native code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    // Block, if we are in the middle of a safepoint synchronization.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    assert(!thread->owns_locks(), "must release all locks when leaving VM");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    thread->frame_anchor()->make_walkable(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    trans_and_fence(_thread_in_vm, _thread_in_native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    // Check for pending. async. exceptions or suspends.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  ~ThreadToNativeFromVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    trans_from_native(_thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    // We don't need to clear_walkable because it will happen automagically when we return to java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
class ThreadBlockInVM : public ThreadStateTransition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  ThreadBlockInVM(JavaThread *thread)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  : ThreadStateTransition(thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    // Once we are blocked vm expects stack to be walkable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    thread->frame_anchor()->make_walkable(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    trans_and_fence(_thread_in_vm, _thread_blocked);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  ~ThreadBlockInVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    trans_and_fence(_thread_blocked, _thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    // We don't need to clear_walkable because it will happen automagically when we return to java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// This special transition class is only used to prevent asynchronous exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
// from being installed on vm exit in situations where we can't tolerate them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
// See bugs: 4324348, 4854693, 4998314, 5040492, 5050705.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  ThreadInVMfromJavaNoAsyncException(JavaThread* thread) : ThreadStateTransition(thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    trans_from_java(_thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  ~ThreadInVMfromJavaNoAsyncException()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    trans(_thread_in_vm, _thread_in_Java);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    // NOTE: We do not check for pending. async. exceptions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    // If we did and moved the pending async exception over into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    // pending exception field, we would need to deopt (currently C2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    // only). However, to do so would require that we transition back
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    // to the _thread_in_vm state. Instead we postpone the handling of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    // the async exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    // Check for pending. suspends only.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    if (_thread->has_special_runtime_exit_condition())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      _thread->handle_special_runtime_exit_condition(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
// Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
// Can be used to verify properties on enter/exit of the VM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
class VMEntryWrapper {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  VMEntryWrapper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    if (VerifyLastFrame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      InterfaceSupport::verify_last_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  ~VMEntryWrapper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    InterfaceSupport::check_gc_alot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    if (WalkStackALot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      InterfaceSupport::walk_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    // This option is not used by Compiler 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    if (StressDerivedPointers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
      InterfaceSupport::stress_derived_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    if (DeoptimizeALot || DeoptimizeRandom) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      InterfaceSupport::deoptimizeAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    if (ZombieALot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
      InterfaceSupport::zombieAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   365
    if (UnlinkSymbolsALot) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   366
      InterfaceSupport::unlinkSymbols();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   367
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    // do verification AFTER potential deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    if (VerifyStack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      InterfaceSupport::verify_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
class VMNativeEntryWrapper {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  VMNativeEntryWrapper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  ~VMNativeEntryWrapper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
// VM-internal runtime interface support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
class RuntimeHistogramElement : public HistogramElement {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
   RuntimeHistogramElement(const char* name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
#define TRACE_CALL(result_type, header)                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  InterfaceSupport::_number_of_calls++;                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  if (CountRuntimeCalls) {                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    if (e != NULL) e->increment_count();                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
#define TRACE_CALL(result_type, header)                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  /* do nothing */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
// LEAF routines do not lock, GC or throw exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   414
#define VM_LEAF_BASE(result_type, header)                            \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  TRACE_CALL(result_type, header)                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  debug_only(NoHandleMark __hm;)                                     \
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10969
diff changeset
   417
  os::verify_stack_alignment();                                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  /* begin of body */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
// ENTRY routines may lock, GC and throw exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   423
#define VM_ENTRY_BASE(result_type, header, thread)                   \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  TRACE_CALL(result_type, header)                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  HandleMarkCleaner __hm(thread);                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  Thread* THREAD = thread;                                           \
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10969
diff changeset
   427
  os::verify_stack_alignment();                                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  /* begin of body */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
// QUICK_ENTRY routines behave like ENTRY but without a handle mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   433
#define VM_QUICK_ENTRY_BASE(result_type, header, thread)             \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  TRACE_CALL(result_type, header)                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  debug_only(NoHandleMark __hm;)                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  Thread* THREAD = thread;                                           \
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 10969
diff changeset
   437
  os::verify_stack_alignment();                                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  /* begin of body */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
// Definitions for IRT (Interpreter Runtime)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
// (thread is an argument passed in to all these routines)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
#define IRT_ENTRY(result_type, header)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  result_type header {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    ThreadInVMfromJava __tiv(thread);                                \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   447
    VM_ENTRY_BASE(result_type, header, thread)                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    debug_only(VMEntryWrapper __vew;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
#define IRT_LEAF(result_type, header)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  result_type header {                                               \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   453
    VM_LEAF_BASE(result_type, header)                                \
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 34633
diff changeset
   454
    debug_only(NoSafepointVerifier __nspv(true);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
#define IRT_ENTRY_NO_ASYNC(result_type, header)                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  result_type header {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    ThreadInVMfromJavaNoAsyncException __tiv(thread);                \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   460
    VM_ENTRY_BASE(result_type, header, thread)                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    debug_only(VMEntryWrapper __vew;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
#define IRT_END }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
// Definitions for JRT (Java (Compiler/Shared) Runtime)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
#define JRT_ENTRY(result_type, header)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  result_type header {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    ThreadInVMfromJava __tiv(thread);                                \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   471
    VM_ENTRY_BASE(result_type, header, thread)                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    debug_only(VMEntryWrapper __vew;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
#define JRT_LEAF(result_type, header)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  result_type header {                                               \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   477
  VM_LEAF_BASE(result_type, header)                                  \
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 34633
diff changeset
   478
  debug_only(JRTLeafVerifier __jlv;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
#define JRT_ENTRY_NO_ASYNC(result_type, header)                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  result_type header {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    ThreadInVMfromJavaNoAsyncException __tiv(thread);                \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   484
    VM_ENTRY_BASE(result_type, header, thread)                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    debug_only(VMEntryWrapper __vew;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
// Same as JRT Entry but allows for return value after the safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
// to get back into Java from the VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
#define JRT_BLOCK_ENTRY(result_type, header)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  result_type header {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    TRACE_CALL(result_type, header)                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    HandleMarkCleaner __hm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
#define JRT_BLOCK                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    {                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    ThreadInVMfromJava __tiv(thread);                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    Thread* THREAD = thread;                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    debug_only(VMEntryWrapper __vew;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
29070
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   500
#define JRT_BLOCK_NO_ASYNC                                           \
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   501
    {                                                                \
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   502
    ThreadInVMfromJavaNoAsyncException __tiv(thread);                \
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   503
    Thread* THREAD = thread;                                         \
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   504
    debug_only(VMEntryWrapper __vew;)
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 22838
diff changeset
   505
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
#define JRT_BLOCK_END }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
#define JRT_END }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
// Definitions for JNI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
#define JNI_ENTRY(result_type, header)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    JNI_ENTRY_NO_PRESERVE(result_type, header)                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    WeakPreserveExceptionMark __wem(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
#define JNI_ENTRY_NO_PRESERVE(result_type, header)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  result_type JNICALL header {                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    ThreadInVMfromNative __tiv(thread);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    debug_only(VMNativeEntryWrapper __vew;)                          \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   523
    VM_ENTRY_BASE(result_type, header, thread)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
// Ensure that the VMNativeEntryWrapper constructor, which can cause
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   527
// a GC, is called outside the NoHandleMark (set via VM_QUICK_ENTRY_BASE).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
#define JNI_QUICK_ENTRY(result_type, header)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  result_type JNICALL header {                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    ThreadInVMfromNative __tiv(thread);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    debug_only(VMNativeEntryWrapper __vew;)                          \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   535
    VM_QUICK_ENTRY_BASE(result_type, header, thread)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
#define JNI_LEAF(result_type, header)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  result_type JNICALL header {                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   543
    VM_LEAF_BASE(result_type, header)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
// Close the routine and the extern "C"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
#define JNI_END } }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
// Definitions for JVM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
#define JVM_ENTRY(result_type, header)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  result_type JNICALL header {                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    ThreadInVMfromNative __tiv(thread);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    debug_only(VMNativeEntryWrapper __vew;)                          \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   559
    VM_ENTRY_BASE(result_type, header, thread)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
#define JVM_ENTRY_NO_ENV(result_type, header)                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  result_type JNICALL header {                                       \
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 34285
diff changeset
   565
    JavaThread* thread = JavaThread::current();                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    ThreadInVMfromNative __tiv(thread);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    debug_only(VMNativeEntryWrapper __vew;)                          \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   568
    VM_ENTRY_BASE(result_type, header, thread)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
#define JVM_QUICK_ENTRY(result_type, header)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  result_type JNICALL header {                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    ThreadInVMfromNative __tiv(thread);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    debug_only(VMNativeEntryWrapper __vew;)                          \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   577
    VM_QUICK_ENTRY_BASE(result_type, header, thread)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
#define JVM_LEAF(result_type, header)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
extern "C" {                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  result_type JNICALL header {                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    VM_Exit::block_if_vm_exited();                                   \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 10565
diff changeset
   584
    VM_LEAF_BASE(result_type, header)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
#define JVM_END } }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   588
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   589
#endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP