Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename verifier related value-types, rename JVM_SIGNATURE_VALUETYPE, … #83

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -469,7 +469,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
if (Signature::is_array(sym) &&
(sym->char_at(1) == JVM_SIGNATURE_ARRAY ||
sym->char_at(1) == JVM_SIGNATURE_CLASS ||
sym->char_at(1) == JVM_SIGNATURE_VALUETYPE )) {
sym->char_at(1) == JVM_SIGNATURE_INLINE_TYPE )) {
// We have an unloaded array.
// Build it on the fly if the element class exists.
SignatureStream ss(sym, false);
@@ -512,7 +512,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
while (sym->char_at(i) == JVM_SIGNATURE_ARRAY) {
i++;
}
if (i > 0 && sym->char_at(i) == JVM_SIGNATURE_VALUETYPE) {
if (i > 0 && sym->char_at(i) == JVM_SIGNATURE_INLINE_TYPE) {
// An unloaded array class of value types is an ObjArrayKlass, an
// unloaded value type class is an InstanceKlass. For consistency,
// make the signature of the unloaded array of value type use L
@@ -116,7 +116,7 @@ ciSymbol* ciObjArrayKlass::construct_array_name(ciSymbol* element_name,
name[pos] = JVM_SIGNATURE_ARRAY;
}
Symbol* base_name_sym = element_name->get_symbol();
assert(base_name_sym->char_at(0) != JVM_SIGNATURE_VALUETYPE, "unloaded array klass element should not have Q-type");
assert(base_name_sym->char_at(0) != JVM_SIGNATURE_INLINE_TYPE, "unloaded array klass element should not have Q-type");
if (Signature::is_array(base_name_sym) ||
Signature::has_envelope(base_name_sym)) {
strncpy(&name[pos], (char*)element_name->base(), element_len);
@@ -912,7 +912,7 @@ class CompileReplay : public StackObj {
Klass* kelem = resolve_klass(field_signature + 1, CHECK_(true));
value = oopFactory::new_objArray(kelem, length, CHECK_(true));
} else if (field_signature[0] == JVM_SIGNATURE_ARRAY &&
field_signature[1] == JVM_SIGNATURE_VALUETYPE) {
field_signature[1] == JVM_SIGNATURE_INLINE_TYPE) {
Klass* kelem = resolve_klass(field_signature + 1, CHECK_(true));
value = oopFactory::new_valueArray(kelem, length, CHECK_(true));
} else {
@@ -999,7 +999,7 @@ class CompileReplay : public StackObj {
const char* string_value = parse_escaped_string();
double value = atof(string_value);
java_mirror->double_field_put(fd.offset(), value);
} else if (field_signature[0] == JVM_SIGNATURE_VALUETYPE) {
} else if (field_signature[0] == JVM_SIGNATURE_INLINE_TYPE) {
Klass* kelem = resolve_klass(field_signature, CHECK);
ValueKlass* vk = ValueKlass::cast(kelem);
oop value = vk->allocate_instance(CHECK);
@@ -114,7 +114,7 @@ ciSymbol* ciValueArrayKlass::construct_array_name(ciSymbol* element_name,
for ( ; pos < dimension; pos++) {
name[pos] = JVM_SIGNATURE_ARRAY;
}
name[pos++] = JVM_SIGNATURE_VALUETYPE;
name[pos++] = JVM_SIGNATURE_INLINE_TYPE;
strncpy(name+pos, (char*)element_name->base(), element_len);
name[new_len-2] = JVM_SIGNATURE_ENDCLASS;
name[new_len-1] = '\0';
@@ -4523,7 +4523,7 @@ void ClassFileParser::layout_fields(ConstantPool* cp,
(_super_klass != NULL && _super_klass->has_nonstatic_fields());
const bool has_nonstatic_fields =
super_has_nonstatic_fields || (nonstatic_fields_count != 0);
const bool has_nonstatic_value_fields = nonstatic_inline_type_count > 0;
const bool has_nonstatic_inline_fields = nonstatic_inline_type_count > 0;

if (is_inline_type() && (!has_nonstatic_fields)) {
// There are a number of fixes required throughout the type system and JIT
@@ -4921,7 +4921,7 @@ void ClassFileParser::layout_fields(ConstantPool* cp,

#ifndef PRODUCT
if ((PrintFieldLayout && !is_inline_type()) ||
(PrintInlineLayout && (is_inline_type() || has_nonstatic_value_fields))) {
(PrintInlineLayout && (is_inline_type() || has_nonstatic_inline_fields))) {
print_field_layout(_class_name,
_fields,
cp,
@@ -5768,7 +5768,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature,
case JVM_SIGNATURE_LONG:
case JVM_SIGNATURE_DOUBLE:
return signature + 1;
case JVM_SIGNATURE_VALUETYPE:
case JVM_SIGNATURE_INLINE_TYPE:
// Can't enable this check until JDK upgrades the bytecode generators
// if (_major_version < CONSTANT_CLASS_DESCRIPTORS ) {
// classfile_parse_error("Class name contains illegal Q-signature "
@@ -7278,7 +7278,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st

for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
if (Signature::basic_type(fs.signature()) == T_VALUETYPE && !fs.access_flags().is_static()) {
// Pre-load value class
// Pre-load inline class
Klass* klass = SystemDictionary::resolve_inline_type_field_or_fail(&fs,
Handle(THREAD, _loader_data->class_loader()),
_protection_domain, true, CHECK);
@@ -202,7 +202,7 @@ Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class
// Set bad_class_name to true to indicate that the package name
// could not be obtained due to an error condition.
// In this situation, is_same_class_package returns false.
if (*start == JVM_SIGNATURE_CLASS || *start == JVM_SIGNATURE_VALUETYPE) {
if (*start == JVM_SIGNATURE_CLASS || *start == JVM_SIGNATURE_INLINE_TYPE) {
if (bad_class_name != NULL) {
*bad_class_name = true;
}
@@ -112,7 +112,7 @@ VerificationType StackMapFrame::set_locals_from_arg(
sig = sig_copy;
}
if (ss.type() == T_VALUETYPE) {
return VerificationType::valuetype_type(sig);
return VerificationType::inlinetype_type(sig);
}
return VerificationType::reference_type(sig);
}
@@ -194,7 +194,7 @@ VerificationType StackMapReader::parse_verification_type(u1* flags, TRAPS) {
_stream->stackmap_format_error("TBD something bad happened", THREAD);
return VerificationType::bogus_type();
}
return VerificationType::valuetype_type(fund_name);
return VerificationType::inlinetype_type(fund_name);
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VerificationType::inlinetype_type -> VerificationType::inline_type ?

} else {
return VerificationType::reference_type(klass_name);
}
@@ -125,11 +125,11 @@ bool VerificationType::is_reference_assignable_from(
VerificationType comp_from = from.get_component(context, CHECK_false);

/*
// This code implements non-covariance between value type arrays and both
// This code implements non-covariance between inline type arrays and both
// arrays of objects and arrays of interface types. If covariance is
// supported for value type arrays then this code should be removed.
if (comp_from.is_valuetype() && !comp_this.is_null() && comp_this.is_reference()) {
// An array of value types is not assignable to an array of java.lang.Objects.
// supported for inline type arrays then this code should be removed.
if (comp_from.is_inlinetype() && !comp_this.is_null() && comp_this.is_reference()) {
// An array of inline types is not assignable to an array of java.lang.Objects.
if (comp_this.name() == vmSymbols::java_lang_Object()) {
return false;
}
@@ -145,7 +145,7 @@ bool VerificationType::is_reference_assignable_from(
if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(comp_this_class, klass);
}
// An array of value types is not assignable to an array of interface types.
// An array of inline types is not assignable to an array of interface types.
if (comp_this_class->is_interface()) {
return false;
}
@@ -160,15 +160,15 @@ bool VerificationType::is_reference_assignable_from(
return false;
}

bool VerificationType::is_valuetype_assignable_from(const VerificationType& from) const {
// Check that 'from' is not null, is a value type, and is the same value type.
assert(is_valuetype(), "called with a non-valuetype type");
assert(!is_null(), "valuetype is not null");
return (!from.is_null() && from.is_valuetype() && name() == from.name());
bool VerificationType::is_inlinetype_assignable_from(const VerificationType& from) const {
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_inlinetype_assignable_from() -> is_inline_type_assignable_from()
to be more consistent with other names?

// Check that 'from' is not null, is an inline type, and is the same inline type.
assert(is_inlinetype(), "called with a non-inlinetype type");
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_inlinetype() -> is_inline_type() ?

assert(!is_null(), "inlinetype is not null");
return (!from.is_null() && from.is_inlinetype() && name() == from.name());
}

bool VerificationType::is_ref_assignable_from_value_type(const VerificationType& from, ClassVerifier* context, TRAPS) const {
assert(!from.is_null(), "Value type should not be null");
bool VerificationType::is_ref_assignable_from_inline_type(const VerificationType& from, ClassVerifier* context, TRAPS) const {
assert(!from.is_null(), "Inline type should not be null");
if (!is_null() && (name()->is_same_fundamental_type(from.name()) ||
name() == vmSymbols::java_lang_Object())) {
return true;
@@ -221,7 +221,7 @@ VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS)
Symbol* component_copy = context->create_temporary_symbol(component);
assert(component_copy == component, "symbols don't match");
return (ss.type() == T_VALUETYPE) ?
VerificationType::valuetype_type(component_copy) :
VerificationType::inlinetype_type(component_copy) :
VerificationType::reference_type(component_copy);
}
default:
@@ -248,7 +248,7 @@ void VerificationType::print_on(outputStream* st) const {
case Double_2nd: st->print("double_2nd"); break;
case Null: st->print("null"); break;
case ReferenceQuery: st->print("reference type"); break;
case ValueTypeQuery: st->print("inline type"); break;
case InlineTypeQuery: st->print("inline type"); break;
case NonScalarQuery: st->print("reference or inline type"); break;
case Category1Query: st->print("category1 type"); break;
case Category2Query: st->print("category2 type"); break;
@@ -258,7 +258,7 @@ void VerificationType::print_on(outputStream* st) const {
st->print("uninitializedThis");
} else if (is_uninitialized()) {
st->print("uninitialized %d", bci());
} else if (is_valuetype()) {
} else if (is_inlinetype()) {
name()->print_Qvalue_on(st);
} else {
if (name() != NULL) {
@@ -69,7 +69,7 @@ class VerificationType {

// Enum for the _data field
enum {
// Bottom three bits determine if the type is a reference, value type,
// Bottom three bits determine if the type is a reference, inline type,
// primitive, uninitialized or a query-type.
TypeMask = 0x00000007,

@@ -78,15 +78,15 @@ class VerificationType {
Primitive = 0x1, // see below for primitive list
Uninitialized = 0x2, // 0x00ffff00 contains bci
TypeQuery = 0x3, // Meta-types used for category testing
ValueType = 0x4, // _sym contains the name of a value type
InlineType = 0x4, // _sym contains the name of an inline type

// Utility flags
ReferenceFlag = 0x00, // For reference query types
Category1Flag = 0x01, // One-word values
Category2Flag = 0x02, // First word of a two-word value
Category2_2ndFlag = 0x04, // Second word of a two-word value
ValueTypeFlag = 0x08, // For value type query types
NonScalarFlag = 0x10, // For either value type or reference queries
InlineTypeFlag = 0x08, // For inline type query types
NonScalarFlag = 0x10, // For either inline type or reference queries

// special reference values
Null = 0x00000000, // A reference with a 0 sym is null
@@ -119,7 +119,7 @@ class VerificationType {
Category1Query = (Category1Flag << 1 * BitsPerByte) | TypeQuery,
Category2Query = (Category2Flag << 1 * BitsPerByte) | TypeQuery,
Category2_2ndQuery = (Category2_2ndFlag << 1 * BitsPerByte) | TypeQuery,
ValueTypeQuery = (ValueTypeFlag << 1 * BitsPerByte) | TypeQuery,
InlineTypeQuery = (InlineTypeFlag << 1 * BitsPerByte) | TypeQuery,
NonScalarQuery = (NonScalarFlag << 1 * BitsPerByte) | TypeQuery
};

@@ -153,8 +153,8 @@ class VerificationType {
// any reference is assignable to reference_check.
static VerificationType reference_check()
{ return VerificationType(ReferenceQuery); }
static VerificationType valuetype_check()
{ return VerificationType(ValueTypeQuery); }
static VerificationType inlinetype_check()
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlinetype_check() -> inline_type_check() ?

{ return VerificationType(InlineTypeQuery); }
static VerificationType category1_check()
{ return VerificationType(Category1Query); }
static VerificationType category2_check()
@@ -169,23 +169,23 @@ class VerificationType {
assert(((uintptr_t)sh & TypeMask) == 0, "Symbols must be aligned");
// If the above assert fails in the future because oop* isn't aligned,
// then this type encoding system will have to change to have a tag value
// to descriminate between oops and primitives.
// to discriminate between oops and primitives.
return VerificationType((uintptr_t)sh);
}
static VerificationType uninitialized_type(u2 bci)
{ return VerificationType(bci << 1 * BitsPerByte | Uninitialized); }
static VerificationType uninitialized_this_type()
{ return uninitialized_type(BciForThis); }

// For value types, store the actual Symbol* and set the 3rd bit.
// Provides a way for a value type to be distinguished from a reference type.
static VerificationType valuetype_type(Symbol* sh) {
// For inline types, store the actual Symbol* and set the 3rd bit.
// Provides a way for an inline type to be distinguished from a reference type.
static VerificationType inlinetype_type(Symbol* sh) {
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlinetype_type() -> inline_type() ?

assert(((uintptr_t)sh & TypeMask) == 0, "Symbols must be aligned");
assert((uintptr_t)sh != 0, "Null is not a valid value type");
assert((uintptr_t)sh != 0, "Null is not a valid inline type");
// If the above assert fails in the future because oop* isn't aligned,
// then this type encoding system will have to change to have a tag value
// to descriminate between oops and primitives.
return VerificationType((uintptr_t)sh | ValueType);
// to discriminate between oops and primitives.
return VerificationType((uintptr_t)sh | InlineType);
}

// Create based on u1 read from classfile
@@ -203,11 +203,11 @@ class VerificationType {
bool is_double() const { return (_u._data == Double); }
bool is_long2() const { return (_u._data == Long_2nd); }
bool is_double2() const { return (_u._data == Double_2nd); }
bool is_reference() const { return (((_u._data & TypeMask) == Reference) && !is_valuetype_check()); }
bool is_valuetype() const { return ((_u._data & TypeMask) == ValueType); }
bool is_reference() const { return (((_u._data & TypeMask) == Reference) && !is_inlinetype_check()); }
bool is_inlinetype() const { return ((_u._data & TypeMask) == InlineType); }
bool is_category1() const {
// This should return true for all one-word types, which are category1
// primitives, references (including uninitialized refs) and value types.
// primitives, references (including uninitialized refs) and inline types.
// Though the 'query' types should technically return 'false' here, if we
// allow this to return true, we can perform the test using only
// 2 operations rather than 8 (3 masks, 3 compares and 2 logical 'ands').
@@ -222,7 +222,7 @@ class VerificationType {
return ((_u._data & Category2_2nd) == Category2_2nd);
}
bool is_reference_check() const { return _u._data == ReferenceQuery; }
bool is_valuetype_check() const { return _u._data == ValueTypeQuery; }
bool is_inlinetype_check() const { return _u._data == InlineTypeQuery; }
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_inlinetype_check() -> is_inline_type_check() ?

bool is_nonscalar_check() const { return _u._data == NonScalarQuery; }
bool is_category1_check() const { return _u._data == Category1Query; }
bool is_category2_check() const { return _u._data == Category2Query; }
@@ -242,11 +242,11 @@ class VerificationType {
bool is_double_array() const { return is_x_array(JVM_SIGNATURE_DOUBLE); }
bool is_object_array() const { return is_x_array(JVM_SIGNATURE_CLASS); }
bool is_array_array() const { return is_x_array(JVM_SIGNATURE_ARRAY); }
bool is_value_array() const { return is_x_array(JVM_SIGNATURE_VALUETYPE); }
bool is_inline_array() const { return is_x_array(JVM_SIGNATURE_INLINE_TYPE); }
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term "inline" alone can be misleading (is it about the element being an inline type, is it about the elements of the array being inlined in the array, is it about the array being inlined in something else, etc).
Here, the check is about the kind of elements stored in the array, so I would suggest "is_inline_type_array()".

bool is_reference_array() const
{ return is_object_array() || is_array_array(); }
bool is_nonscalar_array() const
{ return is_object_array() || is_array_array() || is_value_array(); }
{ return is_object_array() || is_array_array() || is_inline_array(); }
bool is_object() const
{ return (is_reference() && !is_null() && name()->utf8_length() >= 1 &&
name()->char_at(0) != JVM_SIGNATURE_ARRAY); }
@@ -263,10 +263,10 @@ class VerificationType {
return VerificationType(is_long() ? Long_2nd : Double_2nd);
}

static VerificationType change_ref_to_valuetype(VerificationType ref) {
static VerificationType change_ref_to_inlinetype(VerificationType ref) {
Copy link
Collaborator

@fparain fparain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change_ref_to_inlinetype() -> change_ref_to_inline_type() ?

assert(ref.is_reference(), "Bad arg");
assert(!ref.is_null(), "Unexpected NULL");
return valuetype_type(ref.name());
return inlinetype_type(ref.name());
}

u2 bci() const {
@@ -275,14 +275,14 @@ class VerificationType {
}

Symbol* name() const {
assert(!is_null() && (is_reference() || is_valuetype()), "Must be a non-null reference or a value type");
return (is_reference() ? _u._sym : ((Symbol*)(_u._data & ~(uintptr_t)ValueType)));
assert(!is_null() && (is_reference() || is_inlinetype()), "Must be a non-null reference or an inline type");
return (is_reference() ? _u._sym : ((Symbol*)(_u._data & ~(uintptr_t)InlineType)));
}

bool equals(const VerificationType& t) const {
return (_u._data == t._u._data ||
(((is_reference() && t.is_reference()) ||
(is_valuetype() && t.is_valuetype())) &&
(is_inlinetype() && t.is_inlinetype())) &&
!is_null() && !t.is_null() && name() == t.name()));

}
@@ -315,20 +315,20 @@ class VerificationType {
return from.is_reference() || from.is_uninitialized();
case NonScalarQuery:
return from.is_reference() || from.is_uninitialized() ||
from.is_valuetype();
case ValueTypeQuery:
return from.is_valuetype();
from.is_inlinetype();
case InlineTypeQuery:
return from.is_inlinetype();
case Boolean:
case Byte:
case Char:
case Short:
// An int can be assigned to boolean, byte, char or short values.
return from.is_integer();
default:
if (is_valuetype()) {
return is_valuetype_assignable_from(from);
} else if (is_reference() && from.is_valuetype()) {
return is_ref_assignable_from_value_type(from, context, THREAD);
if (is_inlinetype()) {
return is_inlinetype_assignable_from(from);
} else if (is_reference() && from.is_inlinetype()) {
return is_ref_assignable_from_inline_type(from, context, THREAD);
} else if (is_reference() && from.is_reference()) {
return is_reference_assignable_from(from, context,
from_field_is_protected,
@@ -377,9 +377,9 @@ class VerificationType {
const VerificationType&, ClassVerifier*, bool from_field_is_protected,
TRAPS) const;

bool is_valuetype_assignable_from(const VerificationType& from) const;
bool is_inlinetype_assignable_from(const VerificationType& from) const;

bool is_ref_assignable_from_value_type(const VerificationType& from, ClassVerifier* context, TRAPS) const;
bool is_ref_assignable_from_inline_type(const VerificationType& from, ClassVerifier* context, TRAPS) const;


public: