Skip to content

Commit

Permalink
8264940: java/lang/invoke/6998541/Test6998541.java failed "guarantee(…
Browse files Browse the repository at this point in the history
…ik->is_initialized()) failed: java/lang/Byte$ByteCache must be initialized"

Co-authored-by: Wu Yan <wuyan34@huawei.com>
Reviewed-by: dholmes, kvn, dcubed
  • Loading branch information
2 people authored and Daniel D. Daugherty committed Apr 13, 2021
1 parent 943503e commit c797511
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/hotspot/share/ci/ciInstanceKlass.cpp
Expand Up @@ -28,6 +28,7 @@
#include "ci/ciInstanceKlass.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmClasses.hpp"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
Expand Down Expand Up @@ -282,6 +283,31 @@ bool ciInstanceKlass::is_boxed_value_offset(int offset) const {
(offset == java_lang_boxing_object::value_offset(bt));
}

static bool is_klass_initialized(Symbol* klass_name) {
VM_ENTRY_MARK;
InstanceKlass* ik = SystemDictionary::find_instance_klass(klass_name, Handle(), Handle());
return ik != nullptr && ik->is_initialized();
}

bool ciInstanceKlass::is_box_cache_valid() const {
BasicType box_type = box_klass_type();

if (box_type != T_OBJECT) {
switch(box_type) {
case T_INT: return is_klass_initialized(java_lang_Integer_IntegerCache::symbol());
case T_CHAR: return is_klass_initialized(java_lang_Character_CharacterCache::symbol());
case T_SHORT: return is_klass_initialized(java_lang_Short_ShortCache::symbol());
case T_BYTE: return is_klass_initialized(java_lang_Byte_ByteCache::symbol());
case T_LONG: return is_klass_initialized(java_lang_Long_LongCache::symbol());
case T_BOOLEAN:
case T_FLOAT:
case T_DOUBLE: return true;
default:;
}
}
return false;
}

// ------------------------------------------------------------------
// ciInstanceKlass::is_in_package
//
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/ci/ciInstanceKlass.hpp
Expand Up @@ -271,6 +271,7 @@ class ciInstanceKlass : public ciKlass {
BasicType box_klass_type() const;
bool is_box_klass() const;
bool is_boxed_value_offset(int offset) const;
bool is_box_cache_valid() const;

// Is this klass in the given package?
bool is_in_package(const char* packagename) {
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/opto/callGenerator.cpp
Expand Up @@ -565,6 +565,11 @@ static bool has_non_debug_usages(Node* n) {
return false;
}

static bool is_box_cache_valid(CallNode* call) {
ciInstanceKlass* klass = call->as_CallStaticJava()->method()->holder();
return klass->is_box_cache_valid();
}

// delay box in runtime, treat box as a scalarized object
static void scalarize_debug_usages(CallNode* call, Node* resproj) {
GraphKit kit(call->jvms());
Expand Down Expand Up @@ -660,7 +665,7 @@ void CallGenerator::do_late_inline_helper() {
if (is_boxing_late_inline() && callprojs.resproj != nullptr) {
// replace box node to scalar node only in case it is directly referenced by debug info
assert(call->as_CallStaticJava()->is_boxing_method(), "sanity");
if (!has_non_debug_usages(callprojs.resproj)) {
if (!has_non_debug_usages(callprojs.resproj) && is_box_cache_valid(call)) {
scalarize_debug_usages(call, callprojs.resproj);
}
}
Expand Down

1 comment on commit c797511

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.