1 /*
2 * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
104 address a = Runtime1::entry_for(StubId::c1_predicate_failed_trap_id);
105 __ far_call(RuntimeAddress(a));
106 ce->add_call_info_here(_info);
107 ce->verify_oop_map(_info);
108 DEBUG_ONLY(__ should_not_reach_here());
109 }
110
111 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
112 if (_offset != -1) {
113 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
114 }
115 __ bind(_entry);
116 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_throw_div0_exception_id)));
117 ce->add_call_info_here(_info);
118 ce->verify_oop_map(_info);
119 #ifdef ASSERT
120 __ should_not_reach_here();
121 #endif
122 }
123
124 // Implementation of NewInstanceStub
125 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, StubId stub_id) {
126 _result = result;
127 _klass = klass;
128 _klass_reg = klass_reg;
129 _info = new CodeEmitInfo(info);
130 assert(stub_id == StubId::c1_new_instance_id ||
131 stub_id == StubId::c1_fast_new_instance_id ||
132 stub_id == StubId::c1_fast_new_instance_init_check_id,
133 "need new_instance id");
134 _stub_id = stub_id;
135 }
136
137 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
138 assert(__ rsp_offset() == 0, "frame size should be fixed");
139 __ bind(_entry);
140 __ mv(x13, _klass_reg->as_register());
141 __ far_call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
142 ce->add_call_info_here(_info);
143 ce->verify_oop_map(_info);
149 NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
150 _klass_reg = klass_reg;
151 _length = length;
152 _result = result;
153 _info = new CodeEmitInfo(info);
154 }
155
156 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
157 assert(__ rsp_offset() == 0, "frame size should be fixed");
158 __ bind(_entry);
159 assert(_length->as_register() == x9, "length must in x9");
160 assert(_klass_reg->as_register() == x13, "klass_reg must in x13");
161 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_type_array_id)));
162 ce->add_call_info_here(_info);
163 ce->verify_oop_map(_info);
164 assert(_result->as_register() == x10, "result must in x10");
165 __ j(_continuation);
166 }
167
168 // Implementation of NewObjectArrayStub
169 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
170 _klass_reg = klass_reg;
171 _result = result;
172 _length = length;
173 _info = new CodeEmitInfo(info);
174 }
175
176 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
177 assert(__ rsp_offset() == 0, "frame size should be fixed");
178 __ bind(_entry);
179 assert(_length->as_register() == x9, "length must in x9");
180 assert(_klass_reg->as_register() == x13, "klass_reg must in x13");
181 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_object_array_id)));
182 ce->add_call_info_here(_info);
183 ce->verify_oop_map(_info);
184 assert(_result->as_register() == x10, "result must in x10");
185 __ j(_continuation);
186 }
187
188 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
189 assert(__ rsp_offset() == 0, "frame size should be fixed");
190 __ bind(_entry);
191 ce->store_parameter(_obj_reg->as_register(), 1);
192 ce->store_parameter(_lock_reg->as_register(), 0);
193 StubId enter_id;
194 if (ce->compilation()->has_fpu_code()) {
195 enter_id = StubId::c1_monitorenter_id;
196 } else {
197 enter_id = StubId::c1_monitorenter_nofpu_id;
198 }
199 __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id)));
200 ce->add_call_info_here(_info);
201 ce->verify_oop_map(_info);
202 __ j(_continuation);
203 }
204
205 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
206 __ bind(_entry);
207
208 // lock_reg was destroyed by fast unlocking attempt => recompute it
209 ce->monitor_address(_monitor_ix, _lock_reg);
210
|
1 /*
2 * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
104 address a = Runtime1::entry_for(StubId::c1_predicate_failed_trap_id);
105 __ far_call(RuntimeAddress(a));
106 ce->add_call_info_here(_info);
107 ce->verify_oop_map(_info);
108 DEBUG_ONLY(__ should_not_reach_here());
109 }
110
111 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
112 if (_offset != -1) {
113 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
114 }
115 __ bind(_entry);
116 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_throw_div0_exception_id)));
117 ce->add_call_info_here(_info);
118 ce->verify_oop_map(_info);
119 #ifdef ASSERT
120 __ should_not_reach_here();
121 #endif
122 }
123
124 // Implementation of LoadFlattenedArrayStub
125
126 LoadFlattenedArrayStub::LoadFlattenedArrayStub(LIR_Opr array, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
127 _array = array;
128 _index = index;
129 _result = result;
130 _scratch_reg = FrameMap::r10_oop_opr;
131 _info = new CodeEmitInfo(info);
132 }
133
134 void LoadFlattenedArrayStub::emit_code(LIR_Assembler* ce) {
135 assert(__ rsp_offset() == 0, "frame size should be fixed");
136 __ bind(_entry);
137 ce->store_parameter(_array->as_register(), 1);
138 ce->store_parameter(_index->as_register(), 0);
139 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_load_flat_array_id)));
140 ce->add_call_info_here(_info);
141 ce->verify_oop_map(_info);
142 if (_result->as_register() != x10) {
143 __ mv(_result->as_register(), x10);
144 }
145 __ j(_continuation);
146 }
147
148 // Implementation of StoreFlattenedArrayStub
149
150 StoreFlattenedArrayStub::StoreFlattenedArrayStub(LIR_Opr array, LIR_Opr index, LIR_Opr value, CodeEmitInfo* info) {
151 _array = array;
152 _index = index;
153 _value = value;
154 _scratch_reg = FrameMap::r10_oop_opr;
155 _info = new CodeEmitInfo(info);
156 }
157
158 void StoreFlattenedArrayStub::emit_code(LIR_Assembler* ce) {
159 assert(__ rsp_offset() == 0, "frame size should be fixed");
160 __ bind(_entry);
161 ce->store_parameter(_array->as_register(), 2);
162 ce->store_parameter(_index->as_register(), 1);
163 ce->store_parameter(_value->as_register(), 0);
164 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_store_flat_array_id)));
165 ce->add_call_info_here(_info);
166 ce->verify_oop_map(_info);
167 __ j(_continuation);
168 }
169
170 // Implementation of SubstitutabilityCheckStub
171
172 SubstitutabilityCheckStub::SubstitutabilityCheckStub(LIR_Opr left, LIR_Opr right, CodeEmitInfo* info) {
173 _left = left;
174 _right = right;
175 _scratch_reg = FrameMap::r10_oop_opr;
176 _info = new CodeEmitInfo(info);
177 }
178
179 void SubstitutabilityCheckStub::emit_code(LIR_Assembler* ce) {
180 assert(__ rsp_offset() == 0, "frame size should be fixed");
181 __ bind(_entry);
182 ce->store_parameter(_left->as_register(), 1);
183 ce->store_parameter(_right->as_register(), 0);
184 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_substitutability_check_id)));
185 ce->add_call_info_here(_info);
186 ce->verify_oop_map(_info);
187 __ j(_continuation);
188 }
189
190 // Implementation of NewInstanceStub
191 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, StubId stub_id) {
192 _result = result;
193 _klass = klass;
194 _klass_reg = klass_reg;
195 _info = new CodeEmitInfo(info);
196 assert(stub_id == StubId::c1_new_instance_id ||
197 stub_id == StubId::c1_fast_new_instance_id ||
198 stub_id == StubId::c1_fast_new_instance_init_check_id,
199 "need new_instance id");
200 _stub_id = stub_id;
201 }
202
203 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
204 assert(__ rsp_offset() == 0, "frame size should be fixed");
205 __ bind(_entry);
206 __ mv(x13, _klass_reg->as_register());
207 __ far_call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
208 ce->add_call_info_here(_info);
209 ce->verify_oop_map(_info);
215 NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
216 _klass_reg = klass_reg;
217 _length = length;
218 _result = result;
219 _info = new CodeEmitInfo(info);
220 }
221
222 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
223 assert(__ rsp_offset() == 0, "frame size should be fixed");
224 __ bind(_entry);
225 assert(_length->as_register() == x9, "length must in x9");
226 assert(_klass_reg->as_register() == x13, "klass_reg must in x13");
227 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_type_array_id)));
228 ce->add_call_info_here(_info);
229 ce->verify_oop_map(_info);
230 assert(_result->as_register() == x10, "result must in x10");
231 __ j(_continuation);
232 }
233
234 // Implementation of NewObjectArrayStub
235 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result,
236 CodeEmitInfo* info, bool is_null_free) {
237 _klass_reg = klass_reg;
238 _result = result;
239 _length = length;
240 _info = new CodeEmitInfo(info);
241 _is_null_free = is_null_free;
242 }
243
244 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
245 assert(__ rsp_offset() == 0, "frame size should be fixed");
246 __ bind(_entry);
247 assert(_length->as_register() == x9, "length must in x9");
248 assert(_klass_reg->as_register() == x13, "klass_reg must in x13");
249
250 if (_is_null_free) {
251 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_null_free_array_id)));
252 } else {
253 __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_object_array_id)));
254 }
255
256 ce->add_call_info_here(_info);
257 ce->verify_oop_map(_info);
258 assert(_result->as_register() == x10, "result must in x10");
259 __ j(_continuation);
260 }
261
262 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
263 assert(__ rsp_offset() == 0, "frame size should be fixed");
264 __ bind(_entry);
265 if (_throw_ie_stub != nullptr) {
266 // When we come here, _obj_reg has already been checked to be non-null.
267 __ ld(t0, Address(_obj_reg->as_register(), oopDesc::mark_offset_in_bytes()));
268 __ mv(t1, markWord::inline_type_pattern);
269 __ andr(t0, t0, t1);
270 __ beq(t0, t1, *_throw_ie_stub->entry(), /* is_far */ true);
271 }
272 ce->store_parameter(_obj_reg->as_register(), 1);
273 ce->store_parameter(_lock_reg->as_register(), 0);
274 StubId enter_id;
275 if (ce->compilation()->has_fpu_code()) {
276 enter_id = StubId::c1_monitorenter_id;
277 } else {
278 enter_id = StubId::c1_monitorenter_nofpu_id;
279 }
280 __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id)));
281 ce->add_call_info_here(_info);
282 ce->verify_oop_map(_info);
283 __ j(_continuation);
284 }
285
286 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
287 __ bind(_entry);
288
289 // lock_reg was destroyed by fast unlocking attempt => recompute it
290 ce->monitor_address(_monitor_ix, _lock_reg);
291
|