Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into JDK-8263358
Browse files Browse the repository at this point in the history
  • Loading branch information
pconcannon committed Mar 11, 2021
2 parents 1ec4990 + 273f8bd commit d5bcd25
Show file tree
Hide file tree
Showing 124 changed files with 2,007 additions and 1,136 deletions.
2 changes: 2 additions & 0 deletions src/hotspot/share/ci/ciEnv.cpp
Expand Up @@ -658,6 +658,8 @@ ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,
assert (constant->is_instance(), "must be an instance, or not? ");
return ciConstant(T_OBJECT, constant);
}
} else if (tag.is_unresolved_klass_in_error()) {
return ciConstant();
} else if (tag.is_klass() || tag.is_unresolved_klass()) {
// 4881222: allow ldc to take a class type
ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor);
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/ci/ciStreams.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -233,6 +233,11 @@ class ciBytecodeStream : StackObj {
return tag.is_unresolved_klass();
}

bool is_unresolved_klass_in_error() const {
constantTag tag = get_constant_pool_tag(get_klass_index());
return tag.is_unresolved_klass_in_error();
}

// If this bytecode is one of get_field, get_static, put_field,
// or put_static, get the referenced field.
ciField* get_field(bool& will_link);
Expand Down
37 changes: 22 additions & 15 deletions src/hotspot/share/ci/ciTypeFlow.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -721,23 +721,28 @@ void ciTypeFlow::StateVector::do_jsr(ciBytecodeStream* str) {
// ciTypeFlow::StateVector::do_ldc
void ciTypeFlow::StateVector::do_ldc(ciBytecodeStream* str) {
ciConstant con = str->get_constant();
BasicType basic_type = con.basic_type();
if (basic_type == T_ILLEGAL) {
// OutOfMemoryError in the CI while loading constant
push_null();
outer()->record_failure("ldc did not link");
return;
}
if (is_reference_type(basic_type)) {
ciObject* obj = con.as_object();
if (obj->is_null_object()) {
push_null();
if (con.is_valid()) {
BasicType basic_type = con.basic_type();
if (is_reference_type(basic_type)) {
ciObject* obj = con.as_object();
if (obj->is_null_object()) {
push_null();
} else {
assert(obj->is_instance() || obj->is_array(), "must be java_mirror of klass");
push_object(obj->klass());
}
} else {
assert(obj->is_instance() || obj->is_array(), "must be java_mirror of klass");
push_object(obj->klass());
push_translate(ciType::make(basic_type));
}
} else {
push_translate(ciType::make(basic_type));
if (str->is_unresolved_klass_in_error()) {
trap(str, NULL, Deoptimization::make_trap_request(Deoptimization::Reason_unhandled,
Deoptimization::Action_none));
} else {
// OutOfMemoryError in the CI while loading constant
push_null();
outer()->record_failure("ldc did not link");
}
}
}

Expand Down Expand Up @@ -2168,6 +2173,8 @@ bool ciTypeFlow::can_trap(ciBytecodeStream& str) {
case Bytecodes::_ldc:
case Bytecodes::_ldc_w:
case Bytecodes::_ldc2_w:
return str.is_unresolved_klass_in_error();

case Bytecodes::_aload_0:
// These bytecodes can trap for rewriting. We need to assume that
// they do not throw exceptions to make the monitor analysis work.
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/classfile/classFileStream.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -45,7 +45,9 @@ ClassFileStream::ClassFileStream(const u1* buffer,
_current(buffer),
_source(source),
_need_verify(verify_stream),
_from_boot_loader_modules_image(from_boot_loader_modules_image) {}
_from_boot_loader_modules_image(from_boot_loader_modules_image) {
assert(buffer != NULL, "caller should throw NPE");
}

const u1* ClassFileStream::clone_buffer() const {
u1* const new_buffer_start = NEW_RESOURCE_ARRAY(u1, length());
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/classfile/javaClasses.cpp
Expand Up @@ -1958,13 +1958,15 @@ int java_lang_Throwable::_backtrace_offset;
int java_lang_Throwable::_detailMessage_offset;
int java_lang_Throwable::_stackTrace_offset;
int java_lang_Throwable::_depth_offset;
int java_lang_Throwable::_cause_offset;
int java_lang_Throwable::_static_unassigned_stacktrace_offset;

#define THROWABLE_FIELDS_DO(macro) \
macro(_backtrace_offset, k, "backtrace", object_signature, false); \
macro(_detailMessage_offset, k, "detailMessage", string_signature, false); \
macro(_stackTrace_offset, k, "stackTrace", java_lang_StackTraceElement_array, false); \
macro(_depth_offset, k, "depth", int_signature, false); \
macro(_cause_offset, k, "cause", throwable_signature, false); \
macro(_static_unassigned_stacktrace_offset, k, "UNASSIGNED_STACK", java_lang_StackTraceElement_array, true)

void java_lang_Throwable::compute_offsets() {
Expand Down Expand Up @@ -2005,6 +2007,9 @@ oop java_lang_Throwable::message(oop throwable) {
return throwable->obj_field(_detailMessage_offset);
}

oop java_lang_Throwable::cause(oop throwable) {
return throwable->obj_field(_cause_offset);
}

// Return Symbol for detailed_message or NULL
Symbol* java_lang_Throwable::detail_message(oop throwable) {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/classfile/javaClasses.hpp
Expand Up @@ -499,6 +499,7 @@ class java_lang_Throwable: AllStatic {
static int _detailMessage_offset;
static int _stackTrace_offset;
static int _depth_offset;
static int _cause_offset;
static int _static_unassigned_stacktrace_offset;

// StackTrace (programmatic access, new since 1.4)
Expand All @@ -516,6 +517,7 @@ class java_lang_Throwable: AllStatic {
static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
// Message
static oop message(oop throwable);
static oop cause(oop throwable);
static void set_message(oop throwable, oop value);
static Symbol* detail_message(oop throwable);
static void print_stack_element(outputStream *st, Method* method, int bci);
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/classfile/klassFactory.cpp
Expand Up @@ -205,10 +205,7 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,

const ClassInstanceInfo* cl_inst_info = cl_info.class_hidden_info_ptr();
InstanceKlass* result = parser.create_instance_klass(old_stream != stream, *cl_inst_info, CHECK_NULL);

if (result == NULL) {
return NULL;
}
assert(result != NULL, "result cannot be null with no pending exception");

if (cached_class_file != NULL) {
// JVMTI: we have an InstanceKlass now, tell it about the cached bytes
Expand Down
68 changes: 38 additions & 30 deletions src/hotspot/share/classfile/resolutionErrors.cpp
Expand Up @@ -33,27 +33,42 @@
#include "runtime/safepoint.hpp"
#include "utilities/hashtable.inline.hpp"

// add new entry to the table
// create new error entry
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index,
Symbol* error, Symbol* message)
Symbol* error, Symbol* message,
Symbol* cause, Symbol* cause_msg)
{
assert_locked_or_safepoint(SystemDictionary_lock);
assert(!pool.is_null() && error != NULL, "adding NULL obj");

ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error, message);
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool());
entry->set_cp_index(cp_index);
entry->set_error(error);
entry->set_message(message);
entry->set_nest_host_error(NULL);
entry->set_cause(cause);
entry->set_cause_msg(cause_msg);

add_entry(index, entry);
}

// add new entry to the table
// create new nest host error entry
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index,
const char* message)
{
assert_locked_or_safepoint(SystemDictionary_lock);
assert(!pool.is_null() && message != NULL, "adding NULL obj");

ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, message);
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool());
entry->set_cp_index(cp_index);
entry->set_nest_host_error(message);
entry->set_error(NULL);
entry->set_message(NULL);
entry->set_cause(NULL);
entry->set_cause_msg(NULL);

add_entry(index, entry);
}

Expand Down Expand Up @@ -87,35 +102,22 @@ void ResolutionErrorEntry::set_message(Symbol* c) {
}
}

void ResolutionErrorEntry::set_nest_host_error(const char* message) {
_nest_host_error = message;
void ResolutionErrorEntry::set_cause(Symbol* c) {
_cause = c;
if (_cause != NULL) {
_cause->increment_refcount();
}
}

// create new error entry
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
int cp_index, Symbol* error,
Symbol* message)
{
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
entry->set_cp_index(cp_index);
entry->set_error(error);
entry->set_message(message);
entry->set_nest_host_error(NULL);

return entry;
void ResolutionErrorEntry::set_cause_msg(Symbol* c) {
_cause_msg = c;
if (_cause_msg != NULL) {
_cause_msg->increment_refcount();
}
}

// create new nest host error entry
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
int cp_index, const char* message)
{
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
entry->set_cp_index(cp_index);
entry->set_nest_host_error(message);
entry->set_error(NULL);
entry->set_message(NULL);

return entry;
void ResolutionErrorEntry::set_nest_host_error(const char* message) {
_nest_host_error = message;
}

void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
Expand All @@ -126,6 +128,12 @@ void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
if (entry->message() != NULL) {
entry->message()->decrement_refcount();
}
if (entry->cause() != NULL) {
entry->cause()->decrement_refcount();
}
if (entry->cause_msg() != NULL) {
entry->cause_msg()->decrement_refcount();
}
if (entry->nest_host_error() != NULL) {
FREE_C_HEAP_ARRAY(char, entry->nest_host_error());
}
Expand Down
22 changes: 14 additions & 8 deletions src/hotspot/share/classfile/resolutionErrors.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -41,15 +41,12 @@ const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;

class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {

private:
void free_entry(ResolutionErrorEntry *entry);

public:
ResolutionErrorTable(int table_size);

ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
Symbol* error, Symbol* message);
ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
const char* message);
void free_entry(ResolutionErrorEntry *entry);

ResolutionErrorEntry* bucket(int i) {
return (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::bucket(i);
}
Expand All @@ -64,7 +61,8 @@ class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
}

void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int which, Symbol* error, Symbol* message);
const constantPoolHandle& pool, int which, Symbol* error, Symbol* message,
Symbol* cause, Symbol* cause_msg);

void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int which, const char* message);
Expand Down Expand Up @@ -99,6 +97,8 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
int _cp_index;
Symbol* _error;
Symbol* _message;
Symbol* _cause;
Symbol* _cause_msg;
const char* _nest_host_error;

public:
Expand All @@ -113,6 +113,12 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
Symbol* message() const { return _message; }
void set_message(Symbol* c);

Symbol* cause() const { return _cause; }
void set_cause(Symbol* c);

Symbol* cause_msg() const { return _cause_msg; }
void set_cause_msg(Symbol* c);

const char* nest_host_error() const { return _nest_host_error; }
void set_nest_host_error(const char* message);

Expand Down

0 comments on commit d5bcd25

Please sign in to comment.