src/hotspot/cpu/sparc/interpreterRT_sparc.cpp
author coleenp
Fri, 16 Mar 2018 09:12:13 -0400
changeset 49449 ef5d5d343e2a
parent 49359 59f6547e151f
child 49480 d7df2dd501ce
permissions -rw-r--r--
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files Summary: interfaceSupport.hpp is an inline file so moved to interfaceSupport.inline.hpp and stopped including it in .hpp files Reviewed-by: stefank, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
     2
 * Copyright (c) 1998, 2018, 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: 6176
diff changeset
    25
#include "precompiled.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 13728
diff changeset
    26
#include "asm/macroAssembler.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    27
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    28
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    29
#include "memory/allocation.inline.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
    30
#include "memory/universe.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    31
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    32
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    33
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    34
#include "runtime/icache.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49359
diff changeset
    35
#include "runtime/interfaceSupport.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    36
#include "runtime/signature.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// Implementation of SignatureHandlerGenerator
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
void InterpreterRuntime::SignatureHandlerGenerator::pass_word(int size_of_arg, int offset_in_arg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  Argument  jni_arg(jni_offset() + offset_in_arg, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  Register     Rtmp = O0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  __ store_argument(Rtmp, jni_arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  Argument  jni_arg(jni_offset(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  Register  Rtmp = O0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  __ ldx(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  __ store_long_argument(Rtmp, jni_arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  Argument  jni_arg(jni_offset(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  FloatRegister  Rtmp = F0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  __ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  __ store_float_argument(Rtmp, jni_arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  Argument  jni_arg(jni_offset(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  FloatRegister  Rtmp = F0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  __ ldf(FloatRegisterImpl::D, Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  __ store_double_argument(Rtmp, jni_arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  Argument  jni_arg(jni_offset(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  Argument java_arg(    offset(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  Register    Rtmp1 = O0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  Register    Rtmp2 =  jni_arg.is_register() ?  jni_arg.as_register() : O0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  Register    Rtmp3 =  G3_scratch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // the handle for a receiver will never be null
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool do_NULL_check = offset() != 0 || is_static();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
    86
  Address     h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  __ ld_ptr(h_arg, Rtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  if (!do_NULL_check) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
    89
    __ add(h_arg.base(), h_arg.disp(), Rtmp2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    if (Rtmp1 == Rtmp2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
          __ tst(Rtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    else  __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    __ brx(Assembler::notZero, true, Assembler::pt, L);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
    96
    __ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  __ store_ptr_argument(Rtmp2, jni_arg);    // this is often a no-op
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // generate code to handle arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  iterate(fingerprint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // return result handler
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   109
  AddressLiteral result_handler(Interpreter::result_handler(method()->result_type()));
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   110
  __ sethi(result_handler, Lscratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  __ retl();
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   112
  __ delayed()->add(Lscratch, result_handler.low10(), Lscratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  __ flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// Implementation of SignatureHandlerLibrary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
void SignatureHandlerLibrary::pd_set_handler(address handler) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
class SlowSignatureHandler: public NativeSignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  address   _from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  intptr_t* _to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  intptr_t* _RegArgSignature;                   // Signature of first Arguments to be passed in Registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  uint      _argcount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  enum {                                        // We need to differenciate float from non floats in reg args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    non_float  = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    float_sig  = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    double_sig = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    long_sig   = 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  virtual void pass_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2571
diff changeset
   139
    _from -= Interpreter::stackElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    add_signature( non_float );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  virtual void pass_object() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    // pass address of from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    intptr_t *from_addr = (intptr_t*)(_from + Interpreter::local_offset_in_bytes(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    *_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr;
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2571
diff changeset
   147
    _from -= Interpreter::stackElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    add_signature( non_float );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  virtual void pass_float()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2571
diff changeset
   153
    _from -= Interpreter::stackElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    add_signature( float_sig );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  virtual void pass_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    *_to++ = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2571
diff changeset
   159
    _from -= 2*Interpreter::stackElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
   add_signature( double_sig );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  virtual void pass_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    _to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    _to += 1;
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2571
diff changeset
   166
    _from -= 2*Interpreter::stackElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    add_signature( long_sig );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  virtual void add_signature( intptr_t sig_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    if ( _argcount < (sizeof (intptr_t))*4 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      *_RegArgSignature |= (sig_type << (_argcount*2) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      _argcount++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
 public:
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46381
diff changeset
   179
  SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    _from = from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    _to   = to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    _RegArgSignature = RegArgSig;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    *_RegArgSignature = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    _argcount = method->is_static() ? 2 : 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
                                                    JavaThread* thread,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   191
                                                    Method* method,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
                                                    intptr_t* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
                                                    intptr_t* to ))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  methodHandle m(thread, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  assert(m->is_native(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // handle arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // Warning: We use reg arg slot 00 temporarily to return the RegArgSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // back to the code that pops the arguments into the CPU registers
27471
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 25715
diff changeset
   199
  SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate((uint64_t)CONST64(-1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // return result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  return Interpreter::result_handler(m->result_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
IRT_END