diff --git a/hotspot/src/share/vm/cr/codeReviveOptRecords.cpp b/hotspot/src/share/vm/cr/codeReviveOptRecords.cpp index f4a9eba13b..ca0c7af734 100644 --- a/hotspot/src/share/vm/cr/codeReviveOptRecords.cpp +++ b/hotspot/src/share/vm/cr/codeReviveOptRecords.cpp @@ -647,8 +647,7 @@ size_t OptConstantReplace::estimate_size_in_bytes() { return 1 + 2 + 4 + 2 + 8; } -jlong OptConstantReplace::get_field_val(ciConstant field_const) { - jlong field_val = 0; +bool OptConstantReplace::get_field_val(ciConstant field_const, jlong &field_val) { jfloat f_val = 0; jint i_val = 0; jdouble d_val = 0; @@ -672,14 +671,10 @@ jlong OptConstantReplace::get_field_val(ciConstant field_const) { d_val = field_const.as_double(); field_val = *(jlong*)&d_val; break; - case T_OBJECT: - case T_ARRAY: - ShouldNotReachHere(); - break; default: - fatal("illegal"); + return false; } - return field_val; + return true; } int OptConstantReplace::calc_opt_score() { @@ -689,10 +684,15 @@ int OptConstantReplace::calc_opt_score() { ciField* expected_fld = expected_kls->get_field_by_offset(_field_offset, true); guarantee(expected_fld != NULL, "should be"); ciConstant expected_const = expected_fld->constant_value(); - - jlong field_val = get_field_val(expected_const); jshort field_type = (jshort)expected_const.basic_type(); + jlong field_val = 0; + bool field_status = get_field_val(expected_const, field_val); + if (field_status == false) { + CR_LOG(cr_restore, cr_fail, "Fail for get_field_val, illegal field_type: %d\n", field_type); + return max_jint; + } + int result = 0; if (field_type == _field_type && field_val == _field_val) { result = -1; diff --git a/hotspot/src/share/vm/cr/codeReviveOptRecords.hpp b/hotspot/src/share/vm/cr/codeReviveOptRecords.hpp index c5505a56a4..9a501f9beb 100644 --- a/hotspot/src/share/vm/cr/codeReviveOptRecords.hpp +++ b/hotspot/src/share/vm/cr/codeReviveOptRecords.hpp @@ -219,7 +219,7 @@ class OptConstantReplace : public OptRecord { virtual size_t estimate_size_in_bytes(); virtual void write_to_stream(CompressedWriteStream* out); virtual void read_from_stream(CompressedReadStream* in); - static jlong get_field_val(ciConstant field_const); + static bool get_field_val(ciConstant field_const, jlong &field_val); virtual int calc_opt_score(); virtual bool equal(OptRecord* other); virtual int compare_by_type_name(OptRecord* other); diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp index 65c0d62026..9343e1f2a8 100644 --- a/hotspot/src/share/vm/opto/parse3.cpp +++ b/hotspot/src/share/vm/opto/parse3.cpp @@ -186,7 +186,13 @@ void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) { // save for aot ciKlass* klass = field->holder(); ciConstant field_const = field->constant_value(); - env()->opt_records()->add_ConstantReplaceRecord(klass, field->offset(), (jshort)field_const.basic_type(), OptConstantReplace::get_field_val(field_const)); + jlong field_val = 0; + bool field_status = OptConstantReplace::get_field_val(field_const, field_val); + if (field_status == false) { + CR_LOG(cr_save, cr_fail, "Fail for save klass %p, because of illegal field_type: %d\n", klass, (jshort)field_const.basic_type()); + return; + } + env()->opt_records()->add_ConstantReplaceRecord(klass, field->offset(), (jshort)field_const.basic_type(), field_val); return; } }