src/hotspot/share/runtime/javaCalls.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46727 hotspot/src/share/vm/runtime/javaCalls.hpp@6e4a84748e2c
child 50152 b5023063346d
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
     2
 * Copyright (c) 1997, 2017, 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: 5419
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
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: 5419
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_JAVACALLS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_JAVACALLS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10565
diff changeset
    29
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/javaFrameAnchor.hpp"
37456
bf26e0f4235f 8153742: Move Thread::current() to thread.hpp
stefank
parents: 33593
diff changeset
    32
#include "runtime/thread.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/vmThread.hpp"
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 37456
diff changeset
    34
#include "utilities/macros.hpp"
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 37456
diff changeset
    35
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 37456
diff changeset
    36
#include CPU_HEADER(jniTypes)
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// A JavaCallWrapper is constructed before each JavaCall and destructed after the call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Its purpose is to allocate/deallocate a new handle block and to save/restore the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class JavaCallWrapper: StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  JavaThread*      _thread;                 // the thread to which this call belongs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  JNIHandleBlock*  _handles;                // the saved handle block
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10565
diff changeset
    47
  Method*          _callee_method;          // to be able to collect arguments if entry frame is top frame
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  oop              _receiver;               // the receiver of the call (if a non-static call)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  JavaFrameAnchor  _anchor;                 // last thread anchor state that we must restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  JavaValue*       _result;                 // result value
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Construction/destruction
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46369
diff changeset
    56
   JavaCallWrapper(const methodHandle& callee_method, Handle receiver, JavaValue* result, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  ~JavaCallWrapper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  JavaThread*      thread() const           { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  JNIHandleBlock*  handles() const          { return _handles; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  JavaFrameAnchor* anchor(void)             { return &_anchor; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  JavaValue*       result() const           { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // GC support
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10565
diff changeset
    67
  Method*          callee_method()          { return _callee_method; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  oop              receiver()               { return _receiver; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  void             oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
18938
ff8f8cec9434 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 14583
diff changeset
    71
  bool             is_first_frame() const   { return _anchor.last_Java_sp() == NULL; }
ff8f8cec9434 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 14583
diff changeset
    72
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
class JavaCallArguments : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  enum Constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
   _default_size = 8    // Must be at least # of arguments in JavaCalls methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
    83
  intptr_t    _value_buffer      [_default_size + 1];
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
    84
  u_char      _value_state_buffer[_default_size + 1];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  intptr_t*   _value;
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
    87
  u_char*     _value_state;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int         _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  int         _max_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  bool        _start_at_zero;      // Support late setting of receiver
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
    91
  JVMCI_ONLY(nmethod*    _alternative_target;) // Nmethod that should be called instead of normal target
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    // Starts at first element to support set_receiver.
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
    95
    _value       = &_value_buffer[1];
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
    96
    _value_state = &_value_state_buffer[1];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    _max_size = _default_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    _size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    _start_at_zero = false;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   101
    JVMCI_ONLY(_alternative_target = NULL;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   104
  // Helper for push_oop and the like.  The value argument is a
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   105
  // "handle" that refers to an oop.  We record the address of the
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   106
  // handle rather than the designated oop.  The handle is later
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   107
  // resolved to the oop by parameters().  This delays the exposure of
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   108
  // naked oops until it is GC-safe.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   109
  template<typename T>
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   110
  inline int push_oop_impl(T handle, int size) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   111
    // JNITypes::put_obj expects an oop value, so we play fast and
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   112
    // loose with the type system.  The cast from handle type to oop
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   113
    // *must* use a C-style cast.  In a product build it performs a
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   114
    // reinterpret_cast. In a debug build (more accurately, in a
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   115
    // CHECK_UNHANDLED_OOPS build) it performs a static_cast, invoking
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   116
    // the debug-only oop class's conversion from void* constructor.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   117
    JNITypes::put_obj((oop)handle, _value, size); // Updates size.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   118
    return size;                // Return the updated size.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   119
  }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   120
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  JavaCallArguments() { initialize(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  JavaCallArguments(Handle receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    push_oop(receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  JavaCallArguments(int max_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    if (max_size > _default_size) {
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   131
      _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   132
      _value_state = NEW_RESOURCE_ARRAY(u_char, max_size + 1);
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 1623
diff changeset
   133
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   134
      // Reserve room for potential receiver in value and state
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   135
      _value++;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   136
      _value_state++;
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 1623
diff changeset
   137
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      _max_size = max_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      _size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      _start_at_zero = false;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   141
      JVMCI_ONLY(_alternative_target = NULL;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   147
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   148
  void set_alternative_target(nmethod* target) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   149
    _alternative_target = target;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   150
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   151
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   152
  nmethod* alternative_target() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   153
    return _alternative_target;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   154
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   155
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   156
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   157
  // The possible values for _value_state elements.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   158
  enum {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   159
    value_state_primitive,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   160
    value_state_oop,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   161
    value_state_handle,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   162
    value_state_jobject,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   163
    value_state_limit
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   164
  };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   166
  inline void push_oop(Handle h) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   167
    _value_state[_size] = value_state_handle;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   168
    _size = push_oop_impl(h.raw_value(), _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   169
  }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   170
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   171
  inline void push_jobject(jobject h) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   172
    _value_state[_size] = value_state_jobject;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   173
    _size = push_oop_impl(h, _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   174
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   176
  inline void push_int(int i) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   177
    _value_state[_size] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   178
    JNITypes::put_int(i, _value, _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   179
  }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   180
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   181
  inline void push_double(double d) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   182
    _value_state[_size] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   183
    _value_state[_size + 1] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   184
    JNITypes::put_double(d, _value, _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   185
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   187
  inline void push_long(jlong l) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   188
    _value_state[_size] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   189
    _value_state[_size + 1] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   190
    JNITypes::put_long(l, _value, _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   191
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   193
  inline void push_float(float f) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   194
    _value_state[_size] = value_state_primitive;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   195
    JNITypes::put_float(f, _value, _size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   196
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  Handle receiver() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    assert(_size > 0, "must at least be one argument");
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   201
    assert(_value_state[0] == value_state_handle,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   202
           "first argument must be an oop");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    assert(_value[0] != 0, "receiver must be not-null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    return Handle((oop*)_value[0], false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  void set_receiver(Handle h) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    assert(_start_at_zero == false, "can only be called once");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    _start_at_zero = true;
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   210
    _value_state--;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    _value--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    _size++;
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   213
    _value_state[0] = value_state_handle;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   214
    push_oop_impl(h.raw_value(), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // Converts all Handles to oops, and returns a reference to parameter vector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  intptr_t* parameters() ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  int   size_of_parameters() const { return _size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Verify that pushed arguments fits a given method
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   222
  void verify(const methodHandle& method, BasicType return_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
// All calls to Java have to go via JavaCalls. Sets up the stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// and makes sure that the last_Java_frame pointers are chained correctly.
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 JavaCalls: AllStatic {
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33160
diff changeset
   230
  static void call_helper(JavaValue* result, const methodHandle& method, JavaCallArguments* args, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // call_special
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  // ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // The receiver must be first oop in argument list
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   235
  static void call_special(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   237
  static void call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, TRAPS); // No args
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   238
  static void call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   239
  static void call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // virtual call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // The receiver must be first oop in argument list
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   245
  static void call_virtual(JavaValue* result, Klass* spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   247
  static void call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, TRAPS); // No args
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   248
  static void call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   249
  static void call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Static call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // -----------
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   253
  static void call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   255
  static void call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, TRAPS);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   256
  static void call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   257
  static void call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43969
diff changeset
   258
  static void call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, Handle arg3, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // Low-level interface
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33160
diff changeset
   261
  static void call(JavaValue* result, const methodHandle& method, JavaCallArguments* args, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   263
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   264
#endif // SHARE_VM_RUNTIME_JAVACALLS_HPP