< prev index next >

src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp

Print this page

  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  * 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.

102   address a = Runtime1::entry_for(StubId::c1_predicate_failed_trap_id);
103   __ far_call(RuntimeAddress(a));
104   ce->add_call_info_here(_info);
105   ce->verify_oop_map(_info);
106   DEBUG_ONLY(__ should_not_reach_here());
107 }
108 
109 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
110   if (_offset != -1) {
111     ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
112   }
113   __ bind(_entry);
114   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_throw_div0_exception_id)));
115   ce->add_call_info_here(_info);
116   ce->verify_oop_map(_info);
117 #ifdef ASSERT
118   __ should_not_reach_here();
119 #endif
120 }
121 


































































122 
123 
124 // Implementation of NewInstanceStub
125 
126 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, StubId stub_id) {
127   _result = result;
128   _klass = klass;
129   _klass_reg = klass_reg;
130   _info = new CodeEmitInfo(info);
131   assert(stub_id == StubId::c1_new_instance_id                 ||
132          stub_id == StubId::c1_fast_new_instance_id            ||
133          stub_id == StubId::c1_fast_new_instance_init_check_id,
134          "need new_instance id");
135   _stub_id   = stub_id;
136 }
137 
138 
139 
140 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
141   assert(__ rsp_offset() == 0, "frame size should be fixed");

159   _result = result;
160   _info = new CodeEmitInfo(info);
161 }
162 
163 
164 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
165   assert(__ rsp_offset() == 0, "frame size should be fixed");
166   __ bind(_entry);
167   assert(_length->as_register() == r19, "length must in r19,");
168   assert(_klass_reg->as_register() == r3, "klass_reg must in r3");
169   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_type_array_id)));
170   ce->add_call_info_here(_info);
171   ce->verify_oop_map(_info);
172   assert(_result->as_register() == r0, "result must in r0");
173   __ b(_continuation);
174 }
175 
176 
177 // Implementation of NewObjectArrayStub
178 
179 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {

180   _klass_reg = klass_reg;
181   _result = result;
182   _length = length;
183   _info = new CodeEmitInfo(info);

184 }
185 
186 
187 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
188   assert(__ rsp_offset() == 0, "frame size should be fixed");
189   __ bind(_entry);
190   assert(_length->as_register() == r19, "length must in r19,");
191   assert(_klass_reg->as_register() == r3, "klass_reg must in r3");
192   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_object_array_id)));






193   ce->add_call_info_here(_info);
194   ce->verify_oop_map(_info);
195   assert(_result->as_register() == r0, "result must in r0");
196   __ b(_continuation);
197 }
198 
199 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
200   assert(__ rsp_offset() == 0, "frame size should be fixed");
201   __ bind(_entry);










202   ce->store_parameter(_obj_reg->as_register(),  1);
203   ce->store_parameter(_lock_reg->as_register(), 0);
204   StubId enter_id;
205   if (ce->compilation()->has_fpu_code()) {
206     enter_id = StubId::c1_monitorenter_id;
207   } else {
208     enter_id = StubId::c1_monitorenter_nofpu_id;
209   }
210   __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id)));
211   ce->add_call_info_here(_info);
212   ce->verify_oop_map(_info);
213   __ b(_continuation);
214 }
215 
216 
217 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
218   __ bind(_entry);
219 
220   // lock_reg was destroyed by fast unlocking attempt => recompute it
221   ce->monitor_address(_monitor_ix, _lock_reg);

  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  * 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.

102   address a = Runtime1::entry_for(StubId::c1_predicate_failed_trap_id);
103   __ far_call(RuntimeAddress(a));
104   ce->add_call_info_here(_info);
105   ce->verify_oop_map(_info);
106   DEBUG_ONLY(__ should_not_reach_here());
107 }
108 
109 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
110   if (_offset != -1) {
111     ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
112   }
113   __ bind(_entry);
114   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_throw_div0_exception_id)));
115   ce->add_call_info_here(_info);
116   ce->verify_oop_map(_info);
117 #ifdef ASSERT
118   __ should_not_reach_here();
119 #endif
120 }
121 
122 // Implementation of LoadFlattenedArrayStub
123 
124 LoadFlattenedArrayStub::LoadFlattenedArrayStub(LIR_Opr array, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
125   _array = array;
126   _index = index;
127   _result = result;
128   _scratch_reg = FrameMap::r0_oop_opr;
129   _info = new CodeEmitInfo(info);
130 }
131 
132 void LoadFlattenedArrayStub::emit_code(LIR_Assembler* ce) {
133   assert(__ rsp_offset() == 0, "frame size should be fixed");
134   __ bind(_entry);
135   ce->store_parameter(_array->as_register(), 1);
136   ce->store_parameter(_index->as_register(), 0);
137   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_load_flat_array_id)));
138   ce->add_call_info_here(_info);
139   ce->verify_oop_map(_info);
140   if (_result->as_register() != r0) {
141     __ mov(_result->as_register(), r0);
142   }
143   __ b(_continuation);
144 }
145 
146 
147 // Implementation of StoreFlattenedArrayStub
148 
149 StoreFlattenedArrayStub::StoreFlattenedArrayStub(LIR_Opr array, LIR_Opr index, LIR_Opr value, CodeEmitInfo* info) {
150   _array = array;
151   _index = index;
152   _value = value;
153   _scratch_reg = FrameMap::r0_oop_opr;
154   _info = new CodeEmitInfo(info);
155 }
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   __ b(_continuation);
168 }
169 
170 // Implementation of SubstitutabilityCheckStub
171 SubstitutabilityCheckStub::SubstitutabilityCheckStub(LIR_Opr left, LIR_Opr right, CodeEmitInfo* info) {
172   _left = left;
173   _right = right;
174   _scratch_reg = FrameMap::r0_oop_opr;
175   _info = new CodeEmitInfo(info);
176 }
177 
178 void SubstitutabilityCheckStub::emit_code(LIR_Assembler* ce) {
179   assert(__ rsp_offset() == 0, "frame size should be fixed");
180   __ bind(_entry);
181   ce->store_parameter(_left->as_register(), 1);
182   ce->store_parameter(_right->as_register(), 0);
183   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_substitutability_check_id)));
184   ce->add_call_info_here(_info);
185   ce->verify_oop_map(_info);
186   __ b(_continuation);
187 }
188 
189 
190 // Implementation of NewInstanceStub
191 
192 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, StubId stub_id) {
193   _result = result;
194   _klass = klass;
195   _klass_reg = klass_reg;
196   _info = new CodeEmitInfo(info);
197   assert(stub_id == StubId::c1_new_instance_id                 ||
198          stub_id == StubId::c1_fast_new_instance_id            ||
199          stub_id == StubId::c1_fast_new_instance_init_check_id,
200          "need new_instance id");
201   _stub_id   = stub_id;
202 }
203 
204 
205 
206 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
207   assert(__ rsp_offset() == 0, "frame size should be fixed");

225   _result = result;
226   _info = new CodeEmitInfo(info);
227 }
228 
229 
230 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
231   assert(__ rsp_offset() == 0, "frame size should be fixed");
232   __ bind(_entry);
233   assert(_length->as_register() == r19, "length must in r19,");
234   assert(_klass_reg->as_register() == r3, "klass_reg must in r3");
235   __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_type_array_id)));
236   ce->add_call_info_here(_info);
237   ce->verify_oop_map(_info);
238   assert(_result->as_register() == r0, "result must in r0");
239   __ b(_continuation);
240 }
241 
242 
243 // Implementation of NewObjectArrayStub
244 
245 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result,
246                                        CodeEmitInfo* info, bool is_null_free) {
247   _klass_reg = klass_reg;
248   _result = result;
249   _length = length;
250   _info = new CodeEmitInfo(info);
251   _is_null_free = is_null_free;
252 }
253 
254 
255 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
256   assert(__ rsp_offset() == 0, "frame size should be fixed");
257   __ bind(_entry);
258   assert(_length->as_register() == r19, "length must in r19,");
259   assert(_klass_reg->as_register() == r3, "klass_reg must in r3");
260 
261   if (_is_null_free) {
262     __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_null_free_array_id)));
263   } else {
264     __ far_call(RuntimeAddress(Runtime1::entry_for(StubId::c1_new_object_array_id)));
265   }
266 
267   ce->add_call_info_here(_info);
268   ce->verify_oop_map(_info);
269   assert(_result->as_register() == r0, "result must in r0");
270   __ b(_continuation);
271 }
272 
273 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
274   assert(__ rsp_offset() == 0, "frame size should be fixed");
275   __ bind(_entry);
276   if (_throw_ie_stub != nullptr) {
277     // When we come here, _obj_reg has already been checked to be non-null.
278     __ ldr(rscratch1, Address(_obj_reg->as_register(), oopDesc::mark_offset_in_bytes()));
279     __ mov(rscratch2, markWord::inline_type_pattern);
280     __ andr(rscratch1, rscratch1, rscratch2);
281 
282     __ cmp(rscratch1, rscratch2);
283     __ br(Assembler::EQ, *_throw_ie_stub->entry());
284   }
285 
286   ce->store_parameter(_obj_reg->as_register(),  1);
287   ce->store_parameter(_lock_reg->as_register(), 0);
288   StubId enter_id;
289   if (ce->compilation()->has_fpu_code()) {
290     enter_id = StubId::c1_monitorenter_id;
291   } else {
292     enter_id = StubId::c1_monitorenter_nofpu_id;
293   }
294   __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id)));
295   ce->add_call_info_here(_info);
296   ce->verify_oop_map(_info);
297   __ b(_continuation);
298 }
299 
300 
301 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
302   __ bind(_entry);
303 
304   // lock_reg was destroyed by fast unlocking attempt => recompute it
305   ce->monitor_address(_monitor_ix, _lock_reg);
< prev index next >