comparison src/share/vm/code/relocInfo.cpp @ 11041:7875ea94bea5

8017308: Remove unused breakpoint relocation type Summary: remove unused breakpoint relocation type Reviewed-by: kvn
author goetz
date Mon, 24 Jun 2013 11:53:54 -0700
parents cd3d6a6b95d9
children 8085ce95b6f5 de6a9e811145 53fa76359eb1
comparison
equal deleted inserted replaced
11025:fc8a1a5de78e 11041:7875ea94bea5
336 address code_end = (address)code() + code()->size(); 336 address code_end = (address)code() + code()->size();
337 assert(limit == NULL || limit <= code_end, "in bounds"); 337 assert(limit == NULL || limit <= code_end, "in bounds");
338 _limit = limit; 338 _limit = limit;
339 } 339 }
340 340
341
342 void PatchingRelocIterator:: prepass() {
343 // turn breakpoints off during patching
344 _init_state = (*this); // save cursor
345 while (next()) {
346 if (type() == relocInfo::breakpoint_type) {
347 breakpoint_reloc()->set_active(false);
348 }
349 }
350 (RelocIterator&)(*this) = _init_state; // reset cursor for client
351 }
352
353
354 void PatchingRelocIterator:: postpass() {
355 // turn breakpoints back on after patching
356 (RelocIterator&)(*this) = _init_state; // reset cursor again
357 while (next()) {
358 if (type() == relocInfo::breakpoint_type) {
359 breakpoint_Relocation* bpt = breakpoint_reloc();
360 bpt->set_active(bpt->enabled());
361 }
362 }
363 }
364
365
366 // All the strange bit-encodings are in here. 341 // All the strange bit-encodings are in here.
367 // The idea is to encode relocation data which are small integers 342 // The idea is to encode relocation data which are small integers
368 // very efficiently (a single extra halfword). Larger chunks of 343 // very efficiently (a single extra halfword). Larger chunks of
369 // relocation data need a halfword header to hold their size. 344 // relocation data need a halfword header to hold their size.
370 void RelocIterator::advance_over_prefix() { 345 void RelocIterator::advance_over_prefix() {
702 677
703 _section = sindex; 678 _section = sindex;
704 _target = address_from_scaled_offset(offset, base); 679 _target = address_from_scaled_offset(offset, base);
705 } 680 }
706 681
707
708 void breakpoint_Relocation::pack_data_to(CodeSection* dest) {
709 short* p = (short*) dest->locs_end();
710 address point = dest->locs_point();
711
712 *p++ = _bits;
713
714 assert(_target != NULL, "sanity");
715
716 if (internal()) normalize_address(_target, dest);
717
718 jint target_bits =
719 (jint)( internal() ? scaled_offset (_target, point)
720 : runtime_address_to_index(_target) );
721 if (settable()) {
722 // save space for set_target later
723 p = add_jint(p, target_bits);
724 } else {
725 p = add_var_int(p, target_bits);
726 }
727
728 for (int i = 0; i < instrlen(); i++) {
729 // put placeholder words until bytes can be saved
730 p = add_short(p, (short)0x7777);
731 }
732
733 dest->set_locs_end((relocInfo*) p);
734 }
735
736
737 void breakpoint_Relocation::unpack_data() {
738 _bits = live_bits();
739
740 int targetlen = datalen() - 1 - instrlen();
741 jint target_bits = 0;
742 if (targetlen == 0) target_bits = 0;
743 else if (targetlen == 1) target_bits = *(data()+1);
744 else if (targetlen == 2) target_bits = relocInfo::jint_from_data(data()+1);
745 else { ShouldNotReachHere(); }
746
747 _target = internal() ? address_from_scaled_offset(target_bits, addr())
748 : index_to_runtime_address (target_bits);
749 }
750
751
752 //// miscellaneous methods 682 //// miscellaneous methods
753 oop* oop_Relocation::oop_addr() { 683 oop* oop_Relocation::oop_addr() {
754 int n = _oop_index; 684 int n = _oop_index;
755 if (n == 0) { 685 if (n == 0) {
756 // oop is stored in the code stream 686 // oop is stored in the code stream
930 if (target == NULL) { 860 if (target == NULL) {
931 target = pd_get_address_from_code(); 861 target = pd_get_address_from_code();
932 } 862 }
933 return target; 863 return target;
934 } 864 }
935
936
937 breakpoint_Relocation::breakpoint_Relocation(int kind, address target, bool internal) {
938 bool active = false;
939 bool enabled = (kind == initialization);
940 bool removable = (kind != safepoint);
941 bool settable = (target == NULL);
942
943 int bits = kind;
944 if (enabled) bits |= enabled_state;
945 if (internal) bits |= internal_attr;
946 if (removable) bits |= removable_attr;
947 if (settable) bits |= settable_attr;
948
949 _bits = bits | high_bit;
950 _target = target;
951
952 assert(this->kind() == kind, "kind encoded");
953 assert(this->enabled() == enabled, "enabled encoded");
954 assert(this->active() == active, "active encoded");
955 assert(this->internal() == internal, "internal encoded");
956 assert(this->removable() == removable, "removable encoded");
957 assert(this->settable() == settable, "settable encoded");
958 }
959
960
961 address breakpoint_Relocation::target() const {
962 return _target;
963 }
964
965
966 void breakpoint_Relocation::set_target(address x) {
967 assert(settable(), "must be settable");
968 jint target_bits =
969 (jint)(internal() ? scaled_offset (x, addr())
970 : runtime_address_to_index(x));
971 short* p = &live_bits() + 1;
972 p = add_jint(p, target_bits);
973 assert(p == instrs(), "new target must fit");
974 _target = x;
975 }
976
977
978 void breakpoint_Relocation::set_enabled(bool b) {
979 if (enabled() == b) return;
980
981 if (b) {
982 set_bits(bits() | enabled_state);
983 } else {
984 set_active(false); // remove the actual breakpoint insn, if any
985 set_bits(bits() & ~enabled_state);
986 }
987 }
988
989
990 void breakpoint_Relocation::set_active(bool b) {
991 assert(!b || enabled(), "cannot activate a disabled breakpoint");
992
993 if (active() == b) return;
994
995 // %%% should probably seize a lock here (might not be the right lock)
996 //MutexLockerEx ml_patch(Patching_lock, true);
997 //if (active() == b) return; // recheck state after locking
998
999 if (b) {
1000 set_bits(bits() | active_state);
1001 if (instrlen() == 0)
1002 fatal("breakpoints in original code must be undoable");
1003 pd_swap_in_breakpoint (addr(), instrs(), instrlen());
1004 } else {
1005 set_bits(bits() & ~active_state);
1006 pd_swap_out_breakpoint(addr(), instrs(), instrlen());
1007 }
1008 }
1009
1010 865
1011 //--------------------------------------------------------------------------------- 866 //---------------------------------------------------------------------------------
1012 // Non-product code 867 // Non-product code
1013 868
1014 #ifndef PRODUCT 869 #ifndef PRODUCT