377 PatchID _id;
378 address _pc_start;
379 int _bytes_to_copy;
380 Label _patched_code_entry;
381 Label _patch_site_entry;
382 Label _patch_site_continuation;
383 Register _obj;
384 CodeEmitInfo* _info;
385 int _index; // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
386 static int _patch_info_offset;
387
388 void align_patch_site(MacroAssembler* masm);
389
390 public:
391 static int patch_info_offset() { return _patch_info_offset; }
392
393 PatchingStub(MacroAssembler* masm, PatchID id, int index = -1):
394 _id(id)
395 , _info(NULL)
396 , _index(index) {
397 if (os::is_MP()) {
398 // force alignment of patch sites on MP hardware so we
399 // can guarantee atomic writes to the patch site.
400 align_patch_site(masm);
401 }
402 _pc_start = masm->pc();
403 masm->bind(_patch_site_entry);
404 }
405
406 void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
407 _info = info;
408 _obj = obj;
409 masm->bind(_patch_site_continuation);
410 _bytes_to_copy = masm->pc() - pc_start();
411 if (_id == PatchingStub::access_field_id) {
412 // embed a fixed offset to handle long patches which need to be offset by a word.
413 // the patching code will just add the field offset field to this offset so
414 // that we can refernce either the high or low word of a double word field.
415 int field_offset = 0;
416 switch (patch_code) {
417 case lir_patch_low: field_offset = lo_word_offset_in_bytes; break;
418 case lir_patch_high: field_offset = hi_word_offset_in_bytes; break;
419 case lir_patch_normal: field_offset = 0; break;
420 default: ShouldNotReachHere();
421 }
|
377 PatchID _id;
378 address _pc_start;
379 int _bytes_to_copy;
380 Label _patched_code_entry;
381 Label _patch_site_entry;
382 Label _patch_site_continuation;
383 Register _obj;
384 CodeEmitInfo* _info;
385 int _index; // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
386 static int _patch_info_offset;
387
388 void align_patch_site(MacroAssembler* masm);
389
390 public:
391 static int patch_info_offset() { return _patch_info_offset; }
392
393 PatchingStub(MacroAssembler* masm, PatchID id, int index = -1):
394 _id(id)
395 , _info(NULL)
396 , _index(index) {
397 // force alignment of patch sites so we
398 // can guarantee atomic writes to the patch site.
399 align_patch_site(masm);
400 _pc_start = masm->pc();
401 masm->bind(_patch_site_entry);
402 }
403
404 void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
405 _info = info;
406 _obj = obj;
407 masm->bind(_patch_site_continuation);
408 _bytes_to_copy = masm->pc() - pc_start();
409 if (_id == PatchingStub::access_field_id) {
410 // embed a fixed offset to handle long patches which need to be offset by a word.
411 // the patching code will just add the field offset field to this offset so
412 // that we can refernce either the high or low word of a double word field.
413 int field_offset = 0;
414 switch (patch_code) {
415 case lir_patch_low: field_offset = lo_word_offset_in_bytes; break;
416 case lir_patch_high: field_offset = hi_word_offset_in_bytes; break;
417 case lir_patch_normal: field_offset = 0; break;
418 default: ShouldNotReachHere();
419 }
|