< prev index next >

src/share/vm/ci/ciReplay.cpp

Print this page
rev 10535 : incremental inlining fixes


  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "ci/ciMethodData.hpp"
  26 #include "ci/ciReplay.hpp"
  27 #include "ci/ciSymbol.hpp"
  28 #include "ci/ciKlass.hpp"
  29 #include "ci/ciUtilities.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "memory/allocation.inline.hpp"
  32 #include "memory/oopFactory.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/oop.inline.hpp"

  35 #include "utilities/copy.hpp"
  36 #include "utilities/macros.hpp"
  37 
  38 #ifndef PRODUCT
  39 
  40 // ciReplay
  41 
  42 typedef struct _ciMethodDataRecord {
  43   const char* _klass_name;
  44   const char* _method_name;
  45   const char* _signature;
  46 
  47   int _state;
  48   int _current_mileage;
  49 
  50   intptr_t* _data;
  51   char*     _orig_data;
  52   Klass**   _classes;
  53   Method**  _methods;
  54   int*      _classes_offsets;


 720           if (tag == JVM_CONSTANT_Class) {
 721           } else if (tag == JVM_CONSTANT_UnresolvedClass) {
 722             tty->print_cr("Warning: entry was unresolved in the replay data");
 723           } else {
 724             report_error("Unexpected tag");
 725             return;
 726           }
 727           break;
 728 
 729         case 0:
 730           if (parsed_two_word == i) continue;
 731 
 732         default:
 733           fatal("Unexpected tag: %d", cp->tag_at(i).value());
 734           break;
 735       }
 736 
 737     }
 738   }
 739 














































































 740   // Initialize a class and fill in the value for a static field.
 741   // This is useful when the compile was dependent on the value of
 742   // static fields but it's impossible to properly rerun the static
 743   // initiailizer.
 744   void process_staticfield(TRAPS) {
 745     InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
 746 
 747     if (ReplaySuppressInitializers == 0 ||
 748         ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
 749       return;
 750     }
 751 
 752     assert(k->is_initialized(), "must be");
 753 
 754     const char* field_name = parse_escaped_string();;
 755     const char* field_signature = parse_string();
 756     fieldDescriptor fd;
 757     Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
 758     Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 759     if (!k->find_local_field(name, sig, &fd) ||
 760         !fd.is_static() ||
 761         fd.has_initial_value()) {
 762       report_error(field_name);
 763       return;
 764     }
 765 
 766     oop java_mirror = k->java_mirror();
 767     if (field_signature[0] == '[') {
 768       int length = parse_int("array length");
 769       oop value = NULL;
 770 
 771       if (field_signature[1] == '[') {
 772         // multi dimensional array
 773         ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
 774         int rank = 0;


 790           value = oopFactory::new_charArray(length, CHECK);
 791         } else if (strcmp(field_signature, "[S") == 0) {
 792           value = oopFactory::new_shortArray(length, CHECK);
 793         } else if (strcmp(field_signature, "[F") == 0) {
 794           value = oopFactory::new_singleArray(length, CHECK);
 795         } else if (strcmp(field_signature, "[D") == 0) {
 796           value = oopFactory::new_doubleArray(length, CHECK);
 797         } else if (strcmp(field_signature, "[I") == 0) {
 798           value = oopFactory::new_intArray(length, CHECK);
 799         } else if (strcmp(field_signature, "[J") == 0) {
 800           value = oopFactory::new_longArray(length, CHECK);
 801         } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
 802           KlassHandle kelem = resolve_klass(field_signature + 1, CHECK);
 803           value = oopFactory::new_objArray(kelem(), length, CHECK);
 804         } else {
 805           report_error("unhandled array staticfield");
 806         }
 807       }
 808       java_mirror->obj_field_put(fd.offset(), value);
 809     } else {
 810       const char* string_value = parse_escaped_string();
 811       if (strcmp(field_signature, "I") == 0) {
 812         int value = atoi(string_value);
 813         java_mirror->int_field_put(fd.offset(), value);
 814       } else if (strcmp(field_signature, "B") == 0) {
 815         int value = atoi(string_value);
 816         java_mirror->byte_field_put(fd.offset(), value);
 817       } else if (strcmp(field_signature, "C") == 0) {
 818         int value = atoi(string_value);
 819         java_mirror->char_field_put(fd.offset(), value);
 820       } else if (strcmp(field_signature, "S") == 0) {
 821         int value = atoi(string_value);
 822         java_mirror->short_field_put(fd.offset(), value);
 823       } else if (strcmp(field_signature, "Z") == 0) {
 824         int value = atol(string_value);
 825         java_mirror->bool_field_put(fd.offset(), value);
 826       } else if (strcmp(field_signature, "J") == 0) {
 827         jlong value;
 828         if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
 829           fprintf(stderr, "Error parsing long: %s\n", string_value);
 830           return;
 831         }
 832         java_mirror->long_field_put(fd.offset(), value);
 833       } else if (strcmp(field_signature, "F") == 0) {
 834         float value = atof(string_value);
 835         java_mirror->float_field_put(fd.offset(), value);
 836       } else if (strcmp(field_signature, "D") == 0) {
 837         double value = atof(string_value);
 838         java_mirror->double_field_put(fd.offset(), value);
 839       } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
 840         Handle value = java_lang_String::create_from_str(string_value, CHECK);
 841         java_mirror->obj_field_put(fd.offset(), value());
 842       } else if (field_signature[0] == 'L') {
 843         Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 844         KlassHandle kelem = resolve_klass(field_signature, CHECK);
 845         oop value = InstanceKlass::cast(kelem())->allocate_instance(CHECK);








 846         java_mirror->obj_field_put(fd.offset(), value);
 847       } else {
 848         report_error("unhandled staticfield");
 849       }
 850     }
 851   }
 852 
 853 #if INCLUDE_JVMTI
 854   void process_JvmtiExport(TRAPS) {
 855     const char* field = parse_string();
 856     bool value = parse_int("JvmtiExport flag") != 0;
 857     if (strcmp(field, "can_access_local_variables") == 0) {
 858       JvmtiExport::set_can_access_local_variables(value);
 859     } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
 860       JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
 861     } else if (strcmp(field, "can_post_on_exceptions") == 0) {
 862       JvmtiExport::set_can_post_on_exceptions(value);
 863     } else {
 864       report_error("Unrecognized JvmtiExport directive");
 865     }




  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "ci/ciMethodData.hpp"
  26 #include "ci/ciReplay.hpp"
  27 #include "ci/ciSymbol.hpp"
  28 #include "ci/ciKlass.hpp"
  29 #include "ci/ciUtilities.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "memory/allocation.inline.hpp"
  32 #include "memory/oopFactory.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/valueKlass.hpp"
  36 #include "utilities/copy.hpp"
  37 #include "utilities/macros.hpp"
  38 
  39 #ifndef PRODUCT
  40 
  41 // ciReplay
  42 
  43 typedef struct _ciMethodDataRecord {
  44   const char* _klass_name;
  45   const char* _method_name;
  46   const char* _signature;
  47 
  48   int _state;
  49   int _current_mileage;
  50 
  51   intptr_t* _data;
  52   char*     _orig_data;
  53   Klass**   _classes;
  54   Method**  _methods;
  55   int*      _classes_offsets;


 721           if (tag == JVM_CONSTANT_Class) {
 722           } else if (tag == JVM_CONSTANT_UnresolvedClass) {
 723             tty->print_cr("Warning: entry was unresolved in the replay data");
 724           } else {
 725             report_error("Unexpected tag");
 726             return;
 727           }
 728           break;
 729 
 730         case 0:
 731           if (parsed_two_word == i) continue;
 732 
 733         default:
 734           fatal("Unexpected tag: %d", cp->tag_at(i).value());
 735           break;
 736       }
 737 
 738     }
 739   }
 740 
 741   class ValueTypeFieldInitializer : public FieldClosure {
 742     oop _vt;
 743     CompileReplay* _replay;
 744   public:
 745     ValueTypeFieldInitializer(oop vt, CompileReplay* replay)
 746       : _vt(vt), _replay(replay) {}
 747 
 748     void do_field(fieldDescriptor* fd) {
 749       BasicType bt = fd->field_type();
 750       const char* string_value = bt != T_VALUETYPE ? _replay->parse_escaped_string() : NULL;
 751       switch (bt) {
 752         case T_BYTE: {
 753           int value = atoi(string_value);
 754           _vt->byte_field_put(fd->offset(), value);
 755           break;
 756         }
 757         case T_BOOLEAN: {
 758           int value = atoi(string_value);
 759           _vt->bool_field_put(fd->offset(), value);
 760           break;
 761         }
 762         case T_SHORT: {
 763           int value = atoi(string_value);
 764           _vt->short_field_put(fd->offset(), value);
 765           break;
 766         }
 767         case T_CHAR: {
 768           int value = atoi(string_value);
 769           _vt->char_field_put(fd->offset(), value);
 770           break;
 771         }
 772         case T_INT: {
 773           int value = atoi(string_value);
 774           _vt->int_field_put(fd->offset(), value);
 775           break;
 776         }
 777         case T_LONG: {
 778           jlong value;
 779           if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
 780             fprintf(stderr, "Error parsing long: %s\n", string_value);
 781             break;
 782           }
 783           _vt->long_field_put(fd->offset(), value);
 784           break;
 785         }
 786         case T_FLOAT: {
 787           float value = atof(string_value);
 788           _vt->float_field_put(fd->offset(), value);
 789           break;
 790         }
 791         case T_DOUBLE: {
 792           double value = atof(string_value);
 793           _vt->double_field_put(fd->offset(), value);
 794           break;
 795         }
 796         case T_ARRAY:
 797           _replay->report_error("Array in value type unsupported");
 798           break;
 799         case T_OBJECT:
 800           _replay->report_error("Object in value type unsupported");
 801           break;
 802         case T_VALUETYPE: {
 803           Thread* THREAD = Thread::current();
 804           SignatureStream ss(fd->signature(), false);
 805           InstanceKlass* holder = fd->field_holder();
 806           Klass* k = ss.as_klass(Handle(holder->class_loader()), Handle(holder->protection_domain()), SignatureStream::ReturnNull, THREAD);
 807           assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 808           ValueKlass* vk = ValueKlass::cast(k);
 809           int field_offset = fd->offset() - vk->first_field_offset();
 810           oop obj = (oop)((address)_vt + field_offset);
 811           ValueTypeFieldInitializer init_fields(obj, _replay);
 812           vk->do_nonstatic_fields(&init_fields);
 813           break;
 814         }
 815       }
 816     }
 817   };
 818 
 819   // Initialize a class and fill in the value for a static field.
 820   // This is useful when the compile was dependent on the value of
 821   // static fields but it's impossible to properly rerun the static
 822   // initiailizer.
 823   void process_staticfield(TRAPS) {
 824     InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
 825 
 826     if (ReplaySuppressInitializers == 0 ||
 827         ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
 828       return;
 829     }
 830 
 831     assert(k->is_initialized(), "must be");
 832 
 833     const char* field_name = parse_escaped_string();
 834     const char* field_signature = parse_string();
 835     fieldDescriptor fd;
 836     Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
 837     Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 838     if (!k->find_local_field(name, sig, &fd) ||
 839         !fd.is_static() ||
 840         fd.has_initial_value()) {
 841       report_error(field_name);
 842       return;
 843     }
 844 
 845     oop java_mirror = k->java_mirror();
 846     if (field_signature[0] == '[') {
 847       int length = parse_int("array length");
 848       oop value = NULL;
 849 
 850       if (field_signature[1] == '[') {
 851         // multi dimensional array
 852         ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
 853         int rank = 0;


 869           value = oopFactory::new_charArray(length, CHECK);
 870         } else if (strcmp(field_signature, "[S") == 0) {
 871           value = oopFactory::new_shortArray(length, CHECK);
 872         } else if (strcmp(field_signature, "[F") == 0) {
 873           value = oopFactory::new_singleArray(length, CHECK);
 874         } else if (strcmp(field_signature, "[D") == 0) {
 875           value = oopFactory::new_doubleArray(length, CHECK);
 876         } else if (strcmp(field_signature, "[I") == 0) {
 877           value = oopFactory::new_intArray(length, CHECK);
 878         } else if (strcmp(field_signature, "[J") == 0) {
 879           value = oopFactory::new_longArray(length, CHECK);
 880         } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
 881           KlassHandle kelem = resolve_klass(field_signature + 1, CHECK);
 882           value = oopFactory::new_objArray(kelem(), length, CHECK);
 883         } else {
 884           report_error("unhandled array staticfield");
 885         }
 886       }
 887       java_mirror->obj_field_put(fd.offset(), value);
 888     } else {
 889       const char* string_value = field_signature[0] != 'Q' ? parse_escaped_string() : NULL;
 890       if (strcmp(field_signature, "I") == 0) {
 891         int value = atoi(string_value);
 892         java_mirror->int_field_put(fd.offset(), value);
 893       } else if (strcmp(field_signature, "B") == 0) {
 894         int value = atoi(string_value);
 895         java_mirror->byte_field_put(fd.offset(), value);
 896       } else if (strcmp(field_signature, "C") == 0) {
 897         int value = atoi(string_value);
 898         java_mirror->char_field_put(fd.offset(), value);
 899       } else if (strcmp(field_signature, "S") == 0) {
 900         int value = atoi(string_value);
 901         java_mirror->short_field_put(fd.offset(), value);
 902       } else if (strcmp(field_signature, "Z") == 0) {
 903         int value = atol(string_value);
 904         java_mirror->bool_field_put(fd.offset(), value);
 905       } else if (strcmp(field_signature, "J") == 0) {
 906         jlong value;
 907         if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
 908           fprintf(stderr, "Error parsing long: %s\n", string_value);
 909           return;
 910         }
 911         java_mirror->long_field_put(fd.offset(), value);
 912       } else if (strcmp(field_signature, "F") == 0) {
 913         float value = atof(string_value);
 914         java_mirror->float_field_put(fd.offset(), value);
 915       } else if (strcmp(field_signature, "D") == 0) {
 916         double value = atof(string_value);
 917         java_mirror->double_field_put(fd.offset(), value);
 918       } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
 919         Handle value = java_lang_String::create_from_str(string_value, CHECK);
 920         java_mirror->obj_field_put(fd.offset(), value());
 921       } else if (field_signature[0] == 'L') {
 922         Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 923         KlassHandle kelem = resolve_klass(field_signature, CHECK);
 924         oop value = InstanceKlass::cast(kelem())->allocate_instance(CHECK);
 925         java_mirror->obj_field_put(fd.offset(), value);
 926       } else if (field_signature[0] == 'Q') {
 927         Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 928         KlassHandle kelem = resolve_klass(field_signature, CHECK);
 929         ValueKlass* vk = ValueKlass::cast(kelem());
 930         oop value = vk->allocate_instance(CHECK);
 931         ValueTypeFieldInitializer init_fields(value, this);
 932         vk->do_nonstatic_fields(&init_fields);
 933         java_mirror->obj_field_put(fd.offset(), value);
 934       } else {
 935         report_error("unhandled staticfield");
 936       }
 937     }
 938   }
 939 
 940 #if INCLUDE_JVMTI
 941   void process_JvmtiExport(TRAPS) {
 942     const char* field = parse_string();
 943     bool value = parse_int("JvmtiExport flag") != 0;
 944     if (strcmp(field, "can_access_local_variables") == 0) {
 945       JvmtiExport::set_can_access_local_variables(value);
 946     } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
 947       JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
 948     } else if (strcmp(field, "can_post_on_exceptions") == 0) {
 949       JvmtiExport::set_can_post_on_exceptions(value);
 950     } else {
 951       report_error("Unrecognized JvmtiExport directive");
 952     }


< prev index next >