8172169: Re-examine String field optionality

Reviewed-by: kvn, thartmann
This commit is contained in:
Claes Redestad 2017-01-03 21:36:05 +01:00
parent 2e0248d2fc
commit 450472a24a
4 changed files with 19 additions and 42 deletions

View File

@ -163,8 +163,8 @@ void java_lang_String::compute_offsets() {
Klass* k = SystemDictionary::String_klass();
compute_offset(value_offset, k, vmSymbols::value_name(), vmSymbols::byte_array_signature());
compute_optional_offset(hash_offset, k, vmSymbols::hash_name(), vmSymbols::int_signature());
compute_optional_offset(coder_offset, k, vmSymbols::coder_name(), vmSymbols::byte_signature());
compute_offset(hash_offset, k, vmSymbols::hash_name(), vmSymbols::int_signature());
compute_offset(coder_offset, k, vmSymbols::coder_name(), vmSymbols::byte_signature());
initialized = true;
}
@ -3977,12 +3977,8 @@ void JavaClasses::check_offsets() {
// java.lang.String
CHECK_OFFSET("java/lang/String", java_lang_String, value, "[B");
if (java_lang_String::has_hash_field()) {
CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I");
}
if (java_lang_String::has_coder_field()) {
CHECK_OFFSET("java/lang/String", java_lang_String, coder, "B");
}
CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I");
CHECK_OFFSET("java/lang/String", java_lang_String, coder, "B");
// java.lang.Class

View File

@ -81,15 +81,6 @@ class java_lang_String : AllStatic {
static Handle create_from_platform_dependent_str(const char* str, TRAPS);
static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
static bool has_hash_field() {
assert(initialized, "Must be initialized");
return (hash_offset > 0);
}
static bool has_coder_field() {
assert(initialized, "Must be initialized");
return (coder_offset > 0);
}
static void set_compact_strings(bool value);
static int value_offset_in_bytes() {

View File

@ -30,10 +30,8 @@
#include "oops/oopsHierarchy.hpp"
void java_lang_String::set_coder(oop string, jbyte coder) {
assert(initialized, "Must be initialized");
if (coder_offset > 0) {
string->byte_field_put(coder_offset, coder);
}
assert(initialized && (coder_offset > 0), "Must be initialized");
string->byte_field_put(coder_offset, coder);
}
void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
@ -61,15 +59,11 @@ unsigned int java_lang_String::hash(oop java_string) {
return java_string->int_field(hash_offset);
}
bool java_lang_String::is_latin1(oop java_string) {
assert(initialized, "Must be initialized");
assert(initialized && (coder_offset > 0), "Must be initialized");
assert(is_instance(java_string), "must be java_string");
if (coder_offset > 0) {
jbyte coder = java_string->byte_field(coder_offset);
assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
return coder == CODER_LATIN1;
} else {
return false;
}
jbyte coder = java_string->byte_field(coder_offset);
assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
return coder == CODER_LATIN1;
}
int java_lang_String::length(oop java_string) {
assert(initialized, "Must be initialized");

View File

@ -4348,20 +4348,16 @@ Node* GraphKit::load_String_value(Node* ctrl, Node* str) {
}
Node* GraphKit::load_String_coder(Node* ctrl, Node* str) {
if (java_lang_String::has_coder_field()) {
if (!CompactStrings) {
return intcon(java_lang_String::CODER_UTF16);
}
int coder_offset = java_lang_String::coder_offset_in_bytes();
const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
false, NULL, 0);
const TypePtr* coder_field_type = string_type->add_offset(coder_offset);
int coder_field_idx = C->get_alias_index(coder_field_type);
return make_load(ctrl, basic_plus_adr(str, str, coder_offset),
TypeInt::BYTE, T_BYTE, coder_field_idx, MemNode::unordered);
} else {
return intcon(0); // false
if (!CompactStrings) {
return intcon(java_lang_String::CODER_UTF16);
}
int coder_offset = java_lang_String::coder_offset_in_bytes();
const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
false, NULL, 0);
const TypePtr* coder_field_type = string_type->add_offset(coder_offset);
int coder_field_idx = C->get_alias_index(coder_field_type);
return make_load(ctrl, basic_plus_adr(str, str, coder_offset),
TypeInt::BYTE, T_BYTE, coder_field_idx, MemNode::unordered);
}
void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) {