< prev index next >

src/share/vm/ci/ciReplay.cpp

Print this page




 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(THREAD, holder->class_loader()),
 807                                Handle(THREAD, holder->protection_domain()),
 808                                SignatureStream::ReturnNull, THREAD);
 809         assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 810         ValueKlass* vk = ValueKlass::cast(k);
 811         int field_offset = fd->offset() - vk->first_field_offset();
 812         oop obj = (oop)((address)_vt + field_offset);
 813         ValueTypeFieldInitializer init_fields(obj, _replay);
 814         vk->do_nonstatic_fields(&init_fields);
 815         break;
 816       }
 817       }
 818     }
 819   };
 820 
 821   // Initialize a class and fill in the value for a static field.
 822   // This is useful when the compile was dependent on the value of
 823   // static fields but it's impossible to properly rerun the static
 824   // initiailizer.
 825   void process_staticfield(TRAPS) {
 826     InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
 827 
 828     if (ReplaySuppressInitializers == 0 ||
 829         ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
 830       return;
 831     }
 832 
 833     assert(k->is_initialized(), "must be");
 834 
 835     const char* field_name = parse_escaped_string();
 836     const char* field_signature = parse_string();
 837     fieldDescriptor fd;
 838     Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
 839     Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 840     if (!k->find_local_field(name, sig, &fd) ||
 841         !fd.is_static() ||
 842         fd.has_initial_value()) {
 843       report_error(field_name);
 844       return;
 845     }
 846 
 847     oop java_mirror = k->java_mirror();
 848     if (field_signature[0] == '[') {
 849       int length = parse_int("array length");
 850       oop value = NULL;
 851 
 852       if (field_signature[1] == '[') {
 853         // multi dimensional array
 854         ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);

 855         int rank = 0;
 856         while (field_signature[rank] == '[') {
 857           rank++;
 858         }
 859         int* dims = NEW_RESOURCE_ARRAY(int, rank);
 860         dims[0] = length;
 861         for (int i = 1; i < rank; i++) {
 862           dims[i] = 1; // These aren't relevant to the compiler
 863         }
 864         value = kelem->multi_allocate(rank, dims, CHECK);
 865       } else {
 866         if (strcmp(field_signature, "[B") == 0) {
 867           value = oopFactory::new_byteArray(length, CHECK);
 868         } else if (strcmp(field_signature, "[Z") == 0) {
 869           value = oopFactory::new_boolArray(length, CHECK);
 870         } else if (strcmp(field_signature, "[C") == 0) {
 871           value = oopFactory::new_charArray(length, CHECK);
 872         } else if (strcmp(field_signature, "[S") == 0) {
 873           value = oopFactory::new_shortArray(length, CHECK);
 874         } else if (strcmp(field_signature, "[F") == 0) {
 875           value = oopFactory::new_singleArray(length, CHECK);
 876         } else if (strcmp(field_signature, "[D") == 0) {
 877           value = oopFactory::new_doubleArray(length, CHECK);
 878         } else if (strcmp(field_signature, "[I") == 0) {
 879           value = oopFactory::new_intArray(length, CHECK);
 880         } else if (strcmp(field_signature, "[J") == 0) {
 881           value = oopFactory::new_longArray(length, CHECK);
 882         } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
 883           Klass* kelem = resolve_klass(field_signature + 1, CHECK);
 884           value = oopFactory::new_objArray(kelem, length, CHECK);
 885         } else {
 886           report_error("unhandled array staticfield");
 887         }
 888       }
 889       java_mirror->obj_field_put(fd.offset(), value);
 890     } else {
 891       const char* string_value = field_signature[0] != 'Q' ? parse_escaped_string() : NULL;








































 892       if (strcmp(field_signature, "I") == 0) {

 893         int value = atoi(string_value);
 894         java_mirror->int_field_put(fd.offset(), value);
 895       } else if (strcmp(field_signature, "B") == 0) {

 896         int value = atoi(string_value);
 897         java_mirror->byte_field_put(fd.offset(), value);
 898       } else if (strcmp(field_signature, "C") == 0) {

 899         int value = atoi(string_value);
 900         java_mirror->char_field_put(fd.offset(), value);
 901       } else if (strcmp(field_signature, "S") == 0) {

 902         int value = atoi(string_value);
 903         java_mirror->short_field_put(fd.offset(), value);
 904       } else if (strcmp(field_signature, "Z") == 0) {

 905         int value = atoi(string_value);
 906         java_mirror->bool_field_put(fd.offset(), value);
 907       } else if (strcmp(field_signature, "J") == 0) {

 908         jlong value;
 909         if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
 910           fprintf(stderr, "Error parsing long: %s\n", string_value);
 911           return;
 912         }
 913         java_mirror->long_field_put(fd.offset(), value);
 914       } else if (strcmp(field_signature, "F") == 0) {

 915         float value = atof(string_value);
 916         java_mirror->float_field_put(fd.offset(), value);
 917       } else if (strcmp(field_signature, "D") == 0) {

 918         double value = atof(string_value);
 919         java_mirror->double_field_put(fd.offset(), value);
 920       } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
 921         Handle value = java_lang_String::create_from_str(string_value, CHECK);
 922         java_mirror->obj_field_put(fd.offset(), value());
 923       } else if (field_signature[0] == 'L') {
 924         Klass* k = resolve_klass(string_value, CHECK);
 925         oop value = InstanceKlass::cast(k)->allocate_instance(CHECK);
 926         java_mirror->obj_field_put(fd.offset(), value);
 927       } else if (field_signature[0] == 'Q') {
 928         Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 929         Klass* kelem = resolve_klass(field_signature, CHECK);
 930         ValueKlass* vk = ValueKlass::cast(kelem);
 931         oop value = vk->allocate_instance(CHECK);
 932         ValueTypeFieldInitializer init_fields(value, this);
 933         vk->do_nonstatic_fields(&init_fields);
 934         java_mirror->obj_field_put(fd.offset(), value);
 935       } else if (field_signature[0] == 'Q') {
 936         Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 937         Klass* kelem = resolve_klass(field_signature, CHECK);
 938         ValueKlass* vk = ValueKlass::cast(kelem);
 939         oop value = vk->allocate_instance(CHECK);
 940         ValueTypeFieldInitializer init_fields(value, this);
 941         vk->do_nonstatic_fields(&init_fields);



 942         java_mirror->obj_field_put(fd.offset(), value);
 943       } else {


 944         report_error("unhandled staticfield");
 945       }
 946     }
 947   }
 948 
 949 #if INCLUDE_JVMTI
 950   void process_JvmtiExport(TRAPS) {
 951     const char* field = parse_string();
 952     bool value = parse_int("JvmtiExport flag") != 0;
 953     if (strcmp(field, "can_access_local_variables") == 0) {
 954       JvmtiExport::set_can_access_local_variables(value);
 955     } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
 956       JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
 957     } else if (strcmp(field, "can_post_on_exceptions") == 0) {
 958       JvmtiExport::set_can_post_on_exceptions(value);
 959     } else {
 960       report_error("Unrecognized JvmtiExport directive");
 961     }
 962   }
 963 #endif // INCLUDE_JVMTI




 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       case T_OBJECT: {
 798         Thread* THREAD = Thread::current();
 799         bool res = _replay->process_staticfield_reference(string_value, _vt, fd, THREAD);
 800         assert(res, "should succeed for arrays & objects");
 801         break;
 802       }
 803       case T_VALUETYPE: {
 804         Thread* THREAD = Thread::current();
 805         SignatureStream ss(fd->signature(), false);
 806         InstanceKlass* holder = fd->field_holder();
 807         Klass* k = ss.as_klass(Handle(THREAD, holder->class_loader()),
 808                                Handle(THREAD, holder->protection_domain()),
 809                                SignatureStream::ReturnNull, THREAD);
 810         assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 811         ValueKlass* vk = ValueKlass::cast(k);
 812         int field_offset = fd->offset() - vk->first_field_offset();
 813         oop obj = (oop)((address)_vt + field_offset);
 814         ValueTypeFieldInitializer init_fields(obj, _replay);
 815         vk->do_nonstatic_fields(&init_fields);
 816         break;
 817       }
 818       }
 819     }
 820   };
 821 
 822   bool process_staticfield_reference(const char* field_signature, oop java_mirror, fieldDescriptor* fd, TRAPS) {


























 823     if (field_signature[0] == '[') {
 824       int length = parse_int("array length");
 825       oop value = NULL;
 826 
 827       if (field_signature[1] == '[') {
 828         // multi dimensional array
 829         Klass* k = resolve_klass(field_signature, CHECK_(true));
 830         ArrayKlass* kelem = (ArrayKlass *)k;
 831         int rank = 0;
 832         while (field_signature[rank] == '[') {
 833           rank++;
 834         }
 835         int* dims = NEW_RESOURCE_ARRAY(int, rank);
 836         dims[0] = length;
 837         for (int i = 1; i < rank; i++) {
 838           dims[i] = 1; // These aren't relevant to the compiler
 839         }
 840         value = kelem->multi_allocate(rank, dims, CHECK_(true));
 841       } else {
 842         if (strcmp(field_signature, "[B") == 0) {
 843           value = oopFactory::new_byteArray(length, CHECK_(true));
 844         } else if (strcmp(field_signature, "[Z") == 0) {
 845           value = oopFactory::new_boolArray(length, CHECK_(true));
 846         } else if (strcmp(field_signature, "[C") == 0) {
 847           value = oopFactory::new_charArray(length, CHECK_(true));
 848         } else if (strcmp(field_signature, "[S") == 0) {
 849           value = oopFactory::new_shortArray(length, CHECK_(true));
 850         } else if (strcmp(field_signature, "[F") == 0) {
 851           value = oopFactory::new_singleArray(length, CHECK_(true));
 852         } else if (strcmp(field_signature, "[D") == 0) {
 853           value = oopFactory::new_doubleArray(length, CHECK_(true));
 854         } else if (strcmp(field_signature, "[I") == 0) {
 855           value = oopFactory::new_intArray(length, CHECK_(true));
 856         } else if (strcmp(field_signature, "[J") == 0) {
 857           value = oopFactory::new_longArray(length, CHECK_(true));
 858         } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
 859           Klass* kelem = resolve_klass(field_signature + 1, CHECK_(true));
 860           value = oopFactory::new_objArray(kelem, length, CHECK_(true));
 861         } else {
 862           report_error("unhandled array staticfield");
 863         }
 864       }
 865       java_mirror->obj_field_put(fd->offset(), value);
 866       return true;
 867     } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
 868       const char* string_value = parse_escaped_string();
 869       Handle value = java_lang_String::create_from_str(string_value, CHECK_(true));
 870       java_mirror->obj_field_put(fd->offset(), value());
 871       return true;
 872     } else if (field_signature[0] == 'L') {
 873       Klass* k = resolve_klass(field_signature, CHECK_(true));
 874       oop value = InstanceKlass::cast(k)->allocate_instance(CHECK_(true));
 875       java_mirror->obj_field_put(fd->offset(), value);
 876       return true;
 877     } 
 878     return false;
 879   }
 880 
 881   // Initialize a class and fill in the value for a static field.
 882   // This is useful when the compile was dependent on the value of
 883   // static fields but it's impossible to properly rerun the static
 884   // initiailizer.
 885   void process_staticfield(TRAPS) {
 886     InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
 887 
 888     if (ReplaySuppressInitializers == 0 ||
 889         ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
 890       return;
 891     }
 892 
 893     assert(k->is_initialized(), "must be");
 894 
 895     const char* field_name = parse_escaped_string();
 896     const char* field_signature = parse_string();
 897     fieldDescriptor fd;
 898     Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
 899     Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 900     if (!k->find_local_field(name, sig, &fd) ||
 901         !fd.is_static() ||
 902         fd.has_initial_value()) {
 903       report_error(field_name);
 904       return;
 905     }
 906 
 907     oop java_mirror = k->java_mirror();
 908     if (strcmp(field_signature, "I") == 0) {
 909       const char* string_value = parse_escaped_string();
 910       int value = atoi(string_value);
 911       java_mirror->int_field_put(fd.offset(), value);
 912     } else if (strcmp(field_signature, "B") == 0) {
 913       const char* string_value = parse_escaped_string();
 914       int value = atoi(string_value);
 915       java_mirror->byte_field_put(fd.offset(), value);
 916     } else if (strcmp(field_signature, "C") == 0) {
 917       const char* string_value = parse_escaped_string();
 918       int value = atoi(string_value);
 919       java_mirror->char_field_put(fd.offset(), value);
 920     } else if (strcmp(field_signature, "S") == 0) {
 921       const char* string_value = parse_escaped_string();
 922       int value = atoi(string_value);
 923       java_mirror->short_field_put(fd.offset(), value);
 924     } else if (strcmp(field_signature, "Z") == 0) {
 925       const char* string_value = parse_escaped_string();
 926       int value = atoi(string_value);
 927       java_mirror->bool_field_put(fd.offset(), value);
 928     } else if (strcmp(field_signature, "J") == 0) {
 929       const char* string_value = parse_escaped_string();
 930       jlong value;
 931       if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
 932         fprintf(stderr, "Error parsing long: %s\n", string_value);
 933         return;
 934       }
 935       java_mirror->long_field_put(fd.offset(), value);
 936     } else if (strcmp(field_signature, "F") == 0) {
 937       const char* string_value = parse_escaped_string();
 938       float value = atof(string_value);
 939       java_mirror->float_field_put(fd.offset(), value);
 940     } else if (strcmp(field_signature, "D") == 0) {
 941       const char* string_value = parse_escaped_string();
 942       double value = atof(string_value);
 943       java_mirror->double_field_put(fd.offset(), value);















 944     } else if (field_signature[0] == 'Q') {
 945       Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
 946       Klass* kelem = resolve_klass(field_signature, CHECK);
 947       ValueKlass* vk = ValueKlass::cast(kelem);
 948       oop value = vk->allocate_instance(CHECK);
 949       ValueTypeFieldInitializer init_fields(value, this);
 950       vk->do_nonstatic_fields(&init_fields);
 951       if (HAS_PENDING_EXCEPTION) {
 952         return;
 953       }
 954       java_mirror->obj_field_put(fd.offset(), value);
 955     } else {
 956       bool res = process_staticfield_reference(field_signature, java_mirror, &fd, CHECK);
 957       if (!res)  {
 958         report_error("unhandled staticfield");
 959       }
 960     }
 961   }
 962 
 963 #if INCLUDE_JVMTI
 964   void process_JvmtiExport(TRAPS) {
 965     const char* field = parse_string();
 966     bool value = parse_int("JvmtiExport flag") != 0;
 967     if (strcmp(field, "can_access_local_variables") == 0) {
 968       JvmtiExport::set_can_access_local_variables(value);
 969     } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
 970       JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
 971     } else if (strcmp(field, "can_post_on_exceptions") == 0) {
 972       JvmtiExport::set_can_post_on_exceptions(value);
 973     } else {
 974       report_error("Unrecognized JvmtiExport directive");
 975     }
 976   }
 977 #endif // INCLUDE_JVMTI


< prev index next >