src/hotspot/cpu/s390/jniTypes_s390.hpp
author vlivanov
Wed, 24 Jul 2019 10:50:40 +0300
changeset 57574 6a159c6c23cc
parent 53244 9807daeb47c4
permissions -rw-r--r--
8227260: JNI upcalls should bypass class initialization barrier in c2i adapter Reviewed-by: eosterlund, dholmes, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47659
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2016 SAP SE. All rights reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47659
diff changeset
    26
#ifndef CPU_S390_JNITYPES_S390_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47659
diff changeset
    27
#define CPU_S390_JNITYPES_S390_HPP
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
// This file holds platform-dependent routines used to write primitive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
// jni types to the array of arguments passed into JavaCalls::call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
47659
a8e9aff89f7b 8189608: Remove duplicated jni.h
ihse
parents: 47216
diff changeset
    32
#include "jni.h"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "memory/allocation.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "oops/oop.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
class JNITypes : AllStatic {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
  // These functions write a java primitive type (in native format) to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
  // a java stack slot array to be passed as an argument to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
  // JavaCalls:calls. I.e., they are functionally 'push' operations
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
  // if they have a 'pos' formal parameter. Note that jlongs and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
  // jdoubles are written _in reverse_ of the order in which they
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
  // appear in the interpreter stack. This is because call stubs (see
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
  // stubGenerator_s390.cpp) reverse the argument list constructed by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
  // JavaCallArguments (see javaCalls.hpp).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
 public:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
  // Ints are stored in native format in one JavaCallArgument slot at *to.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
  static inline void put_int(jint  from, intptr_t *to) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
    *(jint*) to = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
  static inline void put_int(jint  from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
    *(jint*) (to + pos++) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
  static inline void put_int(jint *from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
    *(jint*) (to + pos++) = *from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
  // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  static inline void put_long(jlong  from, intptr_t *to) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
    *(jlong*) (to + 1) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
  static inline void put_long(jlong  from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
    *(jlong*) (to + 1 + pos) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
    pos += 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
  static inline void put_long(jlong *from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
    *(jlong*) (to + 1 + pos) = *from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
    pos += 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
  // Oops are stored in native format in one JavaCallArgument slot at *to.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
  static inline void put_obj(oop  from, intptr_t *to) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
    *(oop*) to = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
  static inline void put_obj(oop  from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
    *(oop*) (to + pos++) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
  static inline void put_obj(oop *from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
    *(oop*) (to + pos++) = *from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
  // Floats are stored in native format in one JavaCallArgument slot at *to.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
  static inline void put_float(jfloat  from, intptr_t *to) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
    *(jfloat*) to = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  static inline void put_float(jfloat  from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
    *(jfloat*) (to + pos++) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  static inline void put_float(jfloat *from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
    *(jfloat*) (to + pos++) = *from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
  // Doubles are stored in native word format in one JavaCallArgument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
  // slot at *(to+1).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
  static inline void put_double(jdouble  from, intptr_t *to) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
    *(jdouble*) (to + 1) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  static inline void put_double(jdouble  from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
    *(jdouble*) (to + 1 + pos) = from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
    pos += 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
  static inline void put_double(jdouble *from, intptr_t *to, int& pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
    *(jdouble*) (to + 1 + pos) = *from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
    pos += 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  // The get_xxx routines, on the other hand, actually _do_ fetch
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  // java primitive types from the interpreter stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  // No need to worry about alignment on z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
  static inline jint get_int(intptr_t *from) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
    return *(jint*) from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
  static inline jlong get_long(intptr_t *from) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
    return *(jlong*) (from + 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
  static inline oop get_obj(intptr_t *from) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
    return *(oop*) from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  static inline jfloat get_float(intptr_t *from) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
    return *(jfloat*) from;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  static inline jdouble get_double(intptr_t *from) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
    return *(jdouble*) (from + 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
};
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47659
diff changeset
   141
#endif // CPU_S390_JNITYPES_S390_HPP