author | herrick |
Thu, 17 Oct 2019 07:55:35 -0400 | |
branch | JDK-8200758-branch |
changeset 58670 | 6fb9e12d5595 |
parent 54786 | ebf733a324d4 |
permissions | -rw-r--r-- |
42065 | 1 |
/* |
54523
5df03f58d25b
8222297: IRT_ENTRY/IRT_LEAF etc are the same as JRT
coleenp
parents:
49480
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
42065 | 3 |
* Copyright (c) 2016 SAP SE. All rights reserved. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
#include "precompiled.hpp" |
|
27 |
#include "asm/macroAssembler.inline.hpp" |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
28 |
#include "interpreter/interp_masm.hpp" |
42065 | 29 |
#include "interpreter/interpreter.hpp" |
30 |
#include "interpreter/interpreterRuntime.hpp" |
|
31 |
#include "memory/allocation.inline.hpp" |
|
32 |
#include "oops/oop.inline.hpp" |
|
33 |
#include "runtime/handles.inline.hpp" |
|
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" |
42065 | 36 |
#include "runtime/signature.hpp" |
37 |
||
38 |
// Access macros for Java and C arguments. |
|
39 |
// First Java argument is at index-1. |
|
40 |
#define locals_j_arg_at(index) Address(Z_R1/*locals*/, in_ByteSize((-(index)*wordSize))) |
|
41 |
||
42 |
#define __ _masm-> |
|
43 |
||
44 |
static int sp_c_int_arg_offset(int arg_nr, int fp_arg_nr) { |
|
45 |
int int_arg_nr = arg_nr-fp_arg_nr; |
|
46 |
||
47 |
// arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 0 |
|
48 |
if (int_arg_nr < 5) { |
|
49 |
return int_arg_nr * wordSize + _z_abi(carg_1); |
|
50 |
} |
|
51 |
int offset = int_arg_nr - 5 + (fp_arg_nr > 4 ? fp_arg_nr - 4 : 0); |
|
52 |
return offset * wordSize + _z_abi(remaining_cargs); |
|
53 |
} |
|
54 |
||
55 |
static int sp_c_fp_arg_offset(int arg_nr, int fp_arg_nr) { |
|
56 |
int int_arg_nr = arg_nr-fp_arg_nr; |
|
57 |
||
58 |
// Arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 0. |
|
59 |
if (fp_arg_nr < 5) { |
|
60 |
return (fp_arg_nr - 1 ) * wordSize + _z_abi(cfarg_1); |
|
61 |
} |
|
62 |
int offset = fp_arg_nr - 5 + (int_arg_nr > 4 ? int_arg_nr - 4 : 0); |
|
63 |
return offset * wordSize + _z_abi(remaining_cargs); |
|
64 |
} |
|
65 |
||
66 |
// Implementation of SignatureHandlerGenerator |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
67 |
InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator( |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
68 |
const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) { |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
69 |
_masm = new MacroAssembler(buffer); |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
70 |
_fp_arg_nr = 0; |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
71 |
} |
42065 | 72 |
|
73 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_int() { |
|
74 |
int int_arg_nr = jni_offset() - _fp_arg_nr; |
|
75 |
Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ? |
|
76 |
as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0; |
|
77 |
||
78 |
__ z_lgf(r, locals_j_arg_at(offset())); |
|
79 |
if (DEBUG_ONLY(true ||) int_arg_nr >= 5) { |
|
80 |
__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_long() { |
|
85 |
int int_arg_nr = jni_offset() - _fp_arg_nr; |
|
86 |
Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ? |
|
87 |
as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0; |
|
88 |
||
89 |
__ z_lg(r, locals_j_arg_at(offset() + 1)); // Long resides in upper slot. |
|
90 |
if (DEBUG_ONLY(true ||) int_arg_nr >= 5) { |
|
91 |
__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() { |
|
96 |
FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ? |
|
97 |
as_FloatRegister((_fp_arg_nr * 2) + Z_FARG1->encoding()) : Z_F1; |
|
98 |
_fp_arg_nr++; |
|
99 |
__ z_ley(fp_reg, locals_j_arg_at(offset())); |
|
100 |
if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) { |
|
101 |
__ z_ste(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr) + 4, Z_SP); |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() { |
|
106 |
FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ? |
|
107 |
as_FloatRegister((_fp_arg_nr*2) + Z_FARG1->encoding()) : Z_F1; |
|
108 |
_fp_arg_nr++; |
|
109 |
__ z_ldy(fp_reg, locals_j_arg_at(offset()+1)); |
|
110 |
if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) { |
|
111 |
__ z_std(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr), Z_SP); |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { |
|
116 |
int int_arg_nr = jni_offset() - _fp_arg_nr; |
|
117 |
Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ? |
|
118 |
as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0; |
|
119 |
||
120 |
// The handle for a receiver will never be null. |
|
121 |
bool do_NULL_check = offset() != 0 || is_static(); |
|
122 |
||
123 |
Label do_null; |
|
124 |
if (do_NULL_check) { |
|
125 |
__ clear_reg(r, true, false); |
|
126 |
__ load_and_test_long(Z_R0, locals_j_arg_at(offset())); |
|
127 |
__ z_bre(do_null); |
|
128 |
} |
|
129 |
__ add2reg(r, -offset() * wordSize, Z_R1 /* locals */); |
|
130 |
__ bind(do_null); |
|
131 |
if (DEBUG_ONLY(true ||) int_arg_nr >= 5) { |
|
132 |
__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP); |
|
133 |
} |
|
134 |
} |
|
135 |
||
136 |
||
137 |
void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) { |
|
138 |
__ z_lgr(Z_R1, Z_ARG1); // Z_R1 is used in locals_j_arg_at(index) macro. |
|
139 |
||
140 |
// Generate code to handle arguments. |
|
141 |
iterate(fingerprint); |
|
142 |
__ load_const_optimized(Z_RET, AbstractInterpreter::result_handler(method()->result_type())); |
|
143 |
__ z_br(Z_R14); |
|
144 |
__ flush(); |
|
145 |
} |
|
146 |
||
147 |
#undef __ |
|
148 |
||
149 |
// Implementation of SignatureHandlerLibrary |
|
150 |
||
151 |
void SignatureHandlerLibrary::pd_set_handler(address handler) {} |
|
152 |
||
54523
5df03f58d25b
8222297: IRT_ENTRY/IRT_LEAF etc are the same as JRT
coleenp
parents:
49480
diff
changeset
|
153 |
JRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method)) |
42065 | 154 |
methodHandle m(thread, method); |
155 |
assert(m->is_native(), "sanity check"); |
|
156 |
Symbol *s = m->signature(); |
|
157 |
return (address) s->base(); |
|
54523
5df03f58d25b
8222297: IRT_ENTRY/IRT_LEAF etc are the same as JRT
coleenp
parents:
49480
diff
changeset
|
158 |
JRT_END |
42065 | 159 |
|
54523
5df03f58d25b
8222297: IRT_ENTRY/IRT_LEAF etc are the same as JRT
coleenp
parents:
49480
diff
changeset
|
160 |
JRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method)) |
42065 | 161 |
methodHandle m(thread, method); |
162 |
assert(m->is_native(), "sanity check"); |
|
163 |
return AbstractInterpreter::result_handler(m->result_type()); |
|
54523
5df03f58d25b
8222297: IRT_ENTRY/IRT_LEAF etc are the same as JRT
coleenp
parents:
49480
diff
changeset
|
164 |
JRT_END |