< prev index next >

src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp

Print this page

159 // Note that this offset is invariant of PreserveFramePointer.
160 static const int entry_barrier_offset(nmethod* nm) {
161 #ifdef _LP64
162   if (nm->is_compiled_by_c2()) {
163     return -14;
164   } else {
165     return -15;
166   }
167 #else
168   return -18;
169 #endif
170 }
171 
172 static NativeNMethodCmpBarrier* native_nmethod_barrier(nmethod* nm) {
173   address barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm);
174   NativeNMethodCmpBarrier* barrier = reinterpret_cast<NativeNMethodCmpBarrier*>(barrier_address);
175   debug_only(barrier->verify());
176   return barrier;
177 }
178 

























179 void BarrierSetNMethod::disarm(nmethod* nm) {
180   if (!supports_entry_barrier(nm)) {
181     return;
182   }
183 
184   NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
185   cmp->set_immediate(disarmed_value());
186 }
187 
188 void BarrierSetNMethod::arm(nmethod* nm, int arm_value) {
189   if (!supports_entry_barrier(nm)) {
190     return;
191   }
192 
193   NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
194   cmp->set_immediate(arm_value);
195 }
196 
197 bool BarrierSetNMethod::is_armed(nmethod* nm) {
198   if (!supports_entry_barrier(nm)) {
199     return false;
200   }
201 
202   NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
203   return (disarmed_value() != cmp->get_immedate());
204 }

159 // Note that this offset is invariant of PreserveFramePointer.
160 static const int entry_barrier_offset(nmethod* nm) {
161 #ifdef _LP64
162   if (nm->is_compiled_by_c2()) {
163     return -14;
164   } else {
165     return -15;
166   }
167 #else
168   return -18;
169 #endif
170 }
171 
172 static NativeNMethodCmpBarrier* native_nmethod_barrier(nmethod* nm) {
173   address barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm);
174   NativeNMethodCmpBarrier* barrier = reinterpret_cast<NativeNMethodCmpBarrier*>(barrier_address);
175   debug_only(barrier->verify());
176   return barrier;
177 }
178 
179 static void set_immediate(nmethod* nm, jint val) {
180   NativeNMethodCmpBarrier* cmp1 = native_nmethod_barrier(nm);
181   cmp1->set_immediate(val);
182 
183   if (!nm->is_osr_method() && nm->method()->has_scalarized_args()) {
184     // nmethods with scalarized arguments have multiple entry points that each have an own nmethod entry barrier
185     assert(nm->verified_entry_point() != nm->verified_inline_entry_point(), "scalarized entry point not found");
186     address method_body = nm->is_compiled_by_c1() ? nm->verified_inline_entry_point() : nm->verified_entry_point();
187     address entry_point2 = nm->is_compiled_by_c1() ? nm->verified_entry_point() : nm->verified_inline_entry_point();
188 
189     int barrier_offset = reinterpret_cast<address>(cmp1) - method_body;
190     NativeNMethodCmpBarrier* cmp2 = reinterpret_cast<NativeNMethodCmpBarrier*>(entry_point2 + barrier_offset);
191     assert(cmp1 != cmp2, "sanity");
192     debug_only(cmp2->verify());
193     cmp2->set_immediate(val);
194 
195     if (method_body != nm->verified_inline_ro_entry_point() && entry_point2 != nm->verified_inline_ro_entry_point()) {
196       NativeNMethodCmpBarrier* cmp3 = reinterpret_cast<NativeNMethodCmpBarrier*>(nm->verified_inline_ro_entry_point() + barrier_offset);
197       assert(cmp1 != cmp3 && cmp2 != cmp3, "sanity");
198       debug_only(cmp3->verify());
199       cmp3->set_immediate(val);
200     }
201   }
202 }
203 
204 void BarrierSetNMethod::disarm(nmethod* nm) {
205   if (!supports_entry_barrier(nm)) {
206     return;
207   }
208 
209   set_immediate(nm, disarmed_value());

210 }
211 
212 void BarrierSetNMethod::arm(nmethod* nm, int arm_value) {
213   if (!supports_entry_barrier(nm)) {
214     return;
215   }
216 
217   set_immediate(nm, arm_value);

218 }
219 
220 bool BarrierSetNMethod::is_armed(nmethod* nm) {
221   if (!supports_entry_barrier(nm)) {
222     return false;
223   }
224 
225   NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm);
226   return (disarmed_value() != cmp->get_immedate());
227 }
< prev index next >