180 return -18;
181 #endif
182 }
183
184 static NativeNMethodCmpBarrier* native_nmethod_barrier(nmethod* nm) {
185 address barrier_address;
186 #if INCLUDE_JVMCI
187 if (nm->is_compiled_by_jvmci()) {
188 barrier_address = nm->code_begin() + nm->jvmci_nmethod_data()->nmethod_entry_patch_offset();
189 } else
190 #endif
191 {
192 barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm);
193 }
194
195 NativeNMethodCmpBarrier* barrier = reinterpret_cast<NativeNMethodCmpBarrier*>(barrier_address);
196 barrier->verify();
197 return barrier;
198 }
199
200 void BarrierSetNMethod::set_guard_value(nmethod* nm, int value) {
201 if (!supports_entry_barrier(nm)) {
202 return;
203 }
204
205 NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
206 cmp->set_immediate(value);
207 }
208
209 int BarrierSetNMethod::guard_value(nmethod* nm) {
210 if (!supports_entry_barrier(nm)) {
211 return disarmed_guard_value();
212 }
213
214 NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
215 return cmp->get_immediate();
216 }
217
218
219 #if INCLUDE_JVMCI
220 bool BarrierSetNMethod::verify_barrier(nmethod* nm, err_msg& msg) {
221 NativeNMethodCmpBarrier* barrier = native_nmethod_barrier(nm);
222 return barrier->check_barrier(msg);
223 }
224 #endif
|
180 return -18;
181 #endif
182 }
183
184 static NativeNMethodCmpBarrier* native_nmethod_barrier(nmethod* nm) {
185 address barrier_address;
186 #if INCLUDE_JVMCI
187 if (nm->is_compiled_by_jvmci()) {
188 barrier_address = nm->code_begin() + nm->jvmci_nmethod_data()->nmethod_entry_patch_offset();
189 } else
190 #endif
191 {
192 barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm);
193 }
194
195 NativeNMethodCmpBarrier* barrier = reinterpret_cast<NativeNMethodCmpBarrier*>(barrier_address);
196 barrier->verify();
197 return barrier;
198 }
199
200 static void set_immediate(nmethod* nm, jint val) {
201 NativeNMethodCmpBarrier* cmp1 = native_nmethod_barrier(nm);
202 cmp1->set_immediate(val);
203
204 if (!nm->is_osr_method() && nm->method()->has_scalarized_args()) {
205 // nmethods with scalarized arguments have multiple entry points that each have an own nmethod entry barrier
206 assert(nm->verified_entry_point() != nm->verified_inline_entry_point(), "scalarized entry point not found");
207 address method_body = nm->is_compiled_by_c1() ? nm->verified_inline_entry_point() : nm->verified_entry_point();
208 address entry_point2 = nm->is_compiled_by_c1() ? nm->verified_entry_point() : nm->verified_inline_entry_point();
209
210 int barrier_offset = reinterpret_cast<address>(cmp1) - method_body;
211 NativeNMethodCmpBarrier* cmp2 = reinterpret_cast<NativeNMethodCmpBarrier*>(entry_point2 + barrier_offset);
212 assert(cmp1 != cmp2, "sanity");
213 debug_only(cmp2->verify());
214 cmp2->set_immediate(val);
215
216 if (method_body != nm->verified_inline_ro_entry_point() && entry_point2 != nm->verified_inline_ro_entry_point()) {
217 NativeNMethodCmpBarrier* cmp3 = reinterpret_cast<NativeNMethodCmpBarrier*>(nm->verified_inline_ro_entry_point() + barrier_offset);
218 assert(cmp1 != cmp3 && cmp2 != cmp3, "sanity");
219 debug_only(cmp3->verify());
220 cmp3->set_immediate(val);
221 }
222 }
223 }
224
225 void BarrierSetNMethod::set_guard_value(nmethod* nm, int value) {
226 if (!supports_entry_barrier(nm)) {
227 return;
228 }
229
230 set_immediate(nm, value);
231 }
232
233 int BarrierSetNMethod::guard_value(nmethod* nm) {
234 if (!supports_entry_barrier(nm)) {
235 return disarmed_guard_value();
236 }
237
238 NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
239 return cmp->get_immediate();
240 }
241
242
243 #if INCLUDE_JVMCI
244 bool BarrierSetNMethod::verify_barrier(nmethod* nm, err_msg& msg) {
245 NativeNMethodCmpBarrier* barrier = native_nmethod_barrier(nm);
246 return barrier->check_barrier(msg);
247 }
248 #endif
|