Skip to content

Commit

Permalink
Merge lworld
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-arm committed Jul 21, 2021
2 parents 287c838 + 31d3bb0 commit aa8ff76
Show file tree
Hide file tree
Showing 84 changed files with 4,682 additions and 4,535 deletions.
12 changes: 7 additions & 5 deletions src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Expand Up @@ -961,7 +961,7 @@ static void gen_inline_cache_check(MacroAssembler *masm, Label& skip_fixup) {


// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler* masm,
int comp_args_on_stack,
const GrowableArray<SigEntry>* sig,
const VMRegPair* regs,
Expand All @@ -970,7 +970,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
const GrowableArray<SigEntry>* sig_cc_ro,
const VMRegPair* regs_cc_ro,
AdapterFingerPrint* fingerprint,
AdapterBlob*& new_adapter) {
AdapterBlob*& new_adapter,
bool allocate_code_blob) {

address i2c_entry = __ pc();
gen_i2c_adapter(masm, comp_args_on_stack, sig, regs);
Expand Down Expand Up @@ -1035,9 +1036,10 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

// The c2i adapter might safepoint and trigger a GC. The caller must make sure that
// the GC knows about the location of oop argument locations passed to the c2i adapter.

bool caller_must_gc_arguments = (regs != regs_cc);
new_adapter = AdapterBlob::create(masm->code(), frame_complete, frame_size_in_words, oop_maps, caller_must_gc_arguments);
if (allocate_code_blob) {
bool caller_must_gc_arguments = (regs != regs_cc);
new_adapter = AdapterBlob::create(masm->code(), frame_complete, frame_size_in_words, oop_maps, caller_must_gc_arguments);
}

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_inline_entry, c2i_inline_ro_entry, c2i_unverified_entry, c2i_unverified_inline_entry, c2i_no_clinit_check_entry);
}
Expand Down
11 changes: 7 additions & 4 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Expand Up @@ -1196,7 +1196,7 @@ static void gen_inline_cache_check(MacroAssembler *masm, Label& skip_fixup) {
}

// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler* masm,
int comp_args_on_stack,
const GrowableArray<SigEntry>* sig,
const VMRegPair* regs,
Expand All @@ -1205,7 +1205,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
const GrowableArray<SigEntry>* sig_cc_ro,
const VMRegPair* regs_cc_ro,
AdapterFingerPrint* fingerprint,
AdapterBlob*& new_adapter) {
AdapterBlob*& new_adapter,
bool allocate_code_blob) {
address i2c_entry = __ pc();
gen_i2c_adapter(masm, comp_args_on_stack, sig, regs);

Expand Down Expand Up @@ -1282,8 +1283,10 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

// The c2i adapters might safepoint and trigger a GC. The caller must make sure that
// the GC knows about the location of oop argument locations passed to the c2i adapter.
bool caller_must_gc_arguments = (regs != regs_cc);
new_adapter = AdapterBlob::create(masm->code(), frame_complete, frame_size_in_words, oop_maps, caller_must_gc_arguments);
if (allocate_code_blob) {
bool caller_must_gc_arguments = (regs != regs_cc);
new_adapter = AdapterBlob::create(masm->code(), frame_complete, frame_size_in_words, oop_maps, caller_must_gc_arguments);
}

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_inline_entry, c2i_inline_ro_entry, c2i_unverified_entry, c2i_unverified_inline_entry, c2i_no_clinit_check_entry);
}
Expand Down
9 changes: 8 additions & 1 deletion src/hotspot/cpu/x86/templateTable_x86.cpp
Expand Up @@ -3181,7 +3181,14 @@ void TemplateTable::withfield() {

resolve_cache_and_index(f2_byte, cache, index, sizeof(u2));

call_VM(rbx, CAST_FROM_FN_PTR(address, InterpreterRuntime::withfield), cache);
Register cpentry = rbx;

ByteSize cp_base_offset = ConstantPoolCache::base_offset();

__ lea(cpentry, Address(cache, index, Address::times_ptr,
in_bytes(cp_base_offset)));
__ lea(rax, at_tos());
__ call_VM(rbx, CAST_FROM_FN_PTR(address, InterpreterRuntime::withfield2), cpentry, rax);
// new value type is returned in rbx
// stack adjustement is returned in rax
__ verify_oop(rbx);
Expand Down
23 changes: 13 additions & 10 deletions src/hotspot/cpu/zero/sharedRuntime_zero.cpp
Expand Up @@ -66,17 +66,20 @@ BufferedInlineTypeBlob* SharedRuntime::generate_buffered_inline_type_adapter(con
return NULL;
}

AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler* masm,
int comp_args_on_stack,
const GrowableArray <SigEntry> *sig,
const VMRegPair *regs,
const GrowableArray <SigEntry> *sig_cc,
const VMRegPair *regs_cc,
const GrowableArray <SigEntry> *sig_cc_ro,
const VMRegPair *regs_cc_ro,
AdapterFingerPrint *fingerprint,
AdapterBlob *&new_adapter) {
new_adapter = AdapterBlob::create(masm->code(), 0, 0, NULL);
const GrowableArray <SigEntry>* sig,
const VMRegPair* regs,
const GrowableArray <SigEntry>* sig_cc,
const VMRegPair* regs_cc,
const GrowableArray <SigEntry>* sig_cc_ro,
const VMRegPair* regs_cc_ro,
AdapterFingerPrint* fingerprint,
AdapterBlob*& new_adapter,
bool allocate_code_blob) {
if (allocate_code_blob) {
new_adapter = AdapterBlob::create(masm->code(), 0, 0, NULL);
}
return AdapterHandlerLibrary::new_entry(
fingerprint,
CAST_FROM_FN_PTR(address,zero_null_code_stub),
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/classfile/classFileParser.cpp
Expand Up @@ -5177,7 +5177,8 @@ void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const {
p = skip_over_field_name(bytes, true, length);
legal = (p != NULL) && ((p - bytes) == (int)length);
}
} else if (_major_version >= CONSTANT_CLASS_DESCRIPTORS && bytes[length - 1] == ';' ) {
} else if ((_major_version >= CONSTANT_CLASS_DESCRIPTORS || _class_name->starts_with("jdk/internal/reflect/"))
&& bytes[length - 1] == ';' ) {
// Support for L...; and Q...; descriptors
legal = verify_unqualified_name(bytes + 1, length - 2, LegalClass);
} else {
Expand Down
15 changes: 5 additions & 10 deletions src/hotspot/share/gc/shared/c2/barrierSetC2.cpp
Expand Up @@ -682,18 +682,13 @@ int BarrierSetC2::arraycopy_payload_base_offset(bool is_array) {
return base_off;
}

void BarrierSetC2::clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* countx, bool is_array) const {
#ifdef ASSERT
intptr_t src_offset;
Node* src = AddPNode::Ideal_base_and_offset(src_base, &kit->gvn(), src_offset);
intptr_t dst_offset;
Node* dst = AddPNode::Ideal_base_and_offset(dst_base, &kit->gvn(), dst_offset);
assert(src == NULL || (src_offset % BytesPerLong == 0), "expect 8 bytes alignment");
assert(dst == NULL || (dst_offset % BytesPerLong == 0), "expect 8 bytes alignment");
#endif
void BarrierSetC2::clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* size, bool is_array) const {
int base_off = arraycopy_payload_base_offset(is_array);
Node* payload_size = size;
Node* offset = kit->MakeConX(base_off);
ArrayCopyNode* ac = ArrayCopyNode::make(kit, false, src_base, offset, dst_base, offset, countx, true, false);
payload_size = kit->gvn().transform(new SubXNode(payload_size, offset));
payload_size = kit->gvn().transform(new URShiftXNode(payload_size, kit->intcon(LogBytesPerLong)));
ArrayCopyNode* ac = ArrayCopyNode::make(kit, false, src_base, offset, dst_base, offset, payload_size, true, false);
if (is_array) {
ac->set_clone_array();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
Expand Up @@ -242,7 +242,7 @@ class BarrierSetC2: public CHeapObj<mtGC> {
virtual Node* atomic_xchg_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;
virtual Node* atomic_add_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;

virtual void clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* countx, bool is_array) const;
virtual void clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* size, bool is_array) const;

virtual Node* obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobig_false, Node* size_in_bytes,
Node*& i_o, Node*& needgc_ctrl,
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp
Expand Up @@ -125,8 +125,8 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
kit->final_sync(ideal);
}

void CardTableBarrierSetC2::clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* countx, bool is_array) const {
BarrierSetC2::clone(kit, src_base, dst_base, countx, is_array);
void CardTableBarrierSetC2::clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const {
BarrierSetC2::clone(kit, src, dst, size, is_array);
const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;

// If necessary, emit some card marks afterwards. (Non-arrays only.)
Expand All @@ -141,7 +141,7 @@ void CardTableBarrierSetC2::clone(GraphKit* kit, Node* src_base, Node* dst_base,
int raw_adr_idx = Compile::AliasIdxRaw;
post_barrier(kit, kit->control(),
kit->memory(raw_adr_type),
dst_base,
dst,
no_particular_field,
raw_adr_idx,
no_particular_value,
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp
Expand Up @@ -42,7 +42,7 @@ class CardTableBarrierSetC2: public ModRefBarrierSetC2 {
Node* byte_map_base_node(GraphKit* kit) const;

public:
virtual void clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* countx, bool is_array) const;
virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const;
virtual bool is_gc_barrier_node(Node* node) const;
virtual void eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const;
virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const;
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/interpreter/bytecodeUtils.cpp
Expand Up @@ -980,6 +980,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) {
break;
}

case Bytecodes::_withfield:
case Bytecodes::_putstatic:
case Bytecodes::_putfield: {
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
Expand Down Expand Up @@ -1133,6 +1134,7 @@ int ExceptionMessageBuilder::get_NPE_null_slot(int bci) {
case Bytecodes::_lastore:
case Bytecodes::_dastore:
return 3;
case Bytecodes::_withfield:
case Bytecodes::_putfield: {
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
ConstantPool* cp = _method->constants();
Expand Down Expand Up @@ -1429,6 +1431,7 @@ void ExceptionMessageBuilder::print_NPE_failed_action(outputStream *os, int bci)
Symbol* name = cp->symbol_at(name_index);
os->print("Cannot read field \"%s\"", name->as_C_string());
} break;
case Bytecodes::_withfield:
case Bytecodes::_putfield: {
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
os->print("Cannot assign field \"%s\"", get_field_name(_method, cp_index));
Expand Down
80 changes: 79 additions & 1 deletion src/hotspot/share/interpreter/interpreterRuntime.cpp
Expand Up @@ -306,6 +306,7 @@ JRT_ENTRY(void, InterpreterRuntime::defaultvalue(JavaThread* current, ConstantPo
current->set_vm_result(res);
JRT_END

// withfield support used by aarch64 but not x86 (see withfield2 below)
JRT_ENTRY(int, InterpreterRuntime::withfield(JavaThread* current, ConstantPoolCache* cp_cache))
LastFrameAccessor last_frame(current);
// Getting the InlineKlass
Expand All @@ -329,7 +330,11 @@ JRT_ENTRY(int, InterpreterRuntime::withfield(JavaThread* current, ConstantPoolCa
jint tos_idx = f.interpreter_frame_expression_stack_size() - 1;
int vt_offset = type2size[field_type];
oop old_value = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx - vt_offset);
assert(old_value != NULL && oopDesc::is_oop(old_value) && old_value->is_inline_type(),"Verifying receiver");
if (old_value == NULL) {
THROW_(vmSymbols::java_lang_NullPointerException(), return_offset);
}
assert(oopDesc::is_oop(old_value), "Verifying receiver");
assert(old_value->klass()->is_inline_klass(), "Must have been checked during resolution");
Handle old_value_h(THREAD, old_value);

// Creating new value by copying the one passed in argument
Expand Down Expand Up @@ -368,6 +373,79 @@ JRT_ENTRY(int, InterpreterRuntime::withfield(JavaThread* current, ConstantPoolCa
return return_offset;
JRT_END

// withfield support for x86, avoiding costly calls to retrieve last Java frame
JRT_ENTRY(int, InterpreterRuntime::withfield2(JavaThread* current, ConstantPoolCacheEntry* cpe, uintptr_t ptr))
oop obj = NULL;
int recv_offset = type2size[as_BasicType(cpe->flag_state())];
assert(frame::interpreter_frame_expression_stack_direction() == -1, "currently is -1 on all platforms");
int ret_adj = (recv_offset + type2size[T_OBJECT] )* AbstractInterpreter::stackElementSize;
obj = (oopDesc*)(((uintptr_t*)ptr)[recv_offset * Interpreter::stackElementWords]);
if (obj == NULL) {
THROW_(vmSymbols::java_lang_NullPointerException(), ret_adj);
}
assert(oopDesc::is_oop(obj), "Verifying receiver");
assert(obj->klass()->is_inline_klass(), "Must have been checked during resolution");
instanceHandle old_value_h(THREAD, (instanceOop)obj);
oop ref = NULL;
if (cpe->flag_state() == atos) {
ref = *(oopDesc**)ptr;
}
Handle ref_h(THREAD, ref);
InlineKlass* ik = InlineKlass::cast(old_value_h()->klass());
instanceOop new_value = ik->allocate_instance_buffer(CHECK_(ret_adj));
Handle new_value_h = Handle(THREAD, new_value);
ik->inline_copy_oop_to_new_oop(old_value_h(), new_value_h());
int offset = cpe->f2_as_offset();
switch(cpe->flag_state()) {
case ztos:
new_value_h()->bool_field_put(offset, (jboolean)(*(jint*)ptr));
break;
case btos:
new_value_h()->byte_field_put(offset, (jbyte)(*(jint*)ptr));
break;
case ctos:
new_value_h()->char_field_put(offset, (jchar)(*(jint*)ptr));
break;
case stos:
new_value_h()->short_field_put(offset, (jshort)(*(jint*)ptr));
break;
case itos:
new_value_h()->int_field_put(offset, (*(jint*)ptr));
break;
case ltos:
new_value_h()->long_field_put(offset, *(jlong*)ptr);
break;
case ftos:
new_value_h()->float_field_put(offset, *(jfloat*)ptr);
break;
case dtos:
new_value_h()->double_field_put(offset, *(jdouble*)ptr);
break;
case atos:
{
if (cpe->is_null_free_inline_type()) {
if (!cpe->is_inlined()) {
if (ref_h() == NULL) {
THROW_(vmSymbols::java_lang_NullPointerException(), ret_adj);
}
new_value_h()->obj_field_put(offset, ref_h());
} else {
int field_index = cpe->field_index();
InlineKlass* field_ik = InlineKlass::cast(ik->get_inline_type_field_klass(field_index));
field_ik->write_inlined_field(new_value_h(), offset, ref_h(), CHECK_(ret_adj));
}
} else {
new_value_h()->obj_field_put(offset, ref_h());
}
}
break;
default:
ShouldNotReachHere();
}
current->set_vm_result(new_value_h());
return ret_adj;
JRT_END

JRT_ENTRY(void, InterpreterRuntime::uninitialized_static_inline_type_field(JavaThread* current, oopDesc* mirror, int index))
// The interpreter tries to access an inline static field that has not been initialized.
// This situation can happen in different scenarios:
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/interpreter/interpreterRuntime.hpp
Expand Up @@ -66,6 +66,7 @@ class InterpreterRuntime: AllStatic {
static void register_finalizer(JavaThread* current, oopDesc* obj);
static void defaultvalue (JavaThread* current, ConstantPool* pool, int index);
static int withfield (JavaThread* current, ConstantPoolCache* cp_cache);
static int withfield2 (JavaThread* current, ConstantPoolCacheEntry* cpe, uintptr_t ptr);
static void uninitialized_static_inline_type_field(JavaThread* current, oopDesc* mirror, int offset);
static void write_heap_copy (JavaThread* current, oopDesc* value, int offset, oopDesc* rcv);
static void read_inlined_field(JavaThread* current, oopDesc* value, int index, Klass* field_holder);
Expand Down
14 changes: 14 additions & 0 deletions src/hotspot/share/interpreter/linkResolver.cpp
Expand Up @@ -970,6 +970,20 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
}

if (byte == Bytecodes::_withfield && !resolved_klass->is_inline_klass()) {
ResourceMark rm(THREAD);
char msg[200];
jio_snprintf(msg, sizeof(msg), "Bytecode withfield cannot be used on identity class %s", resolved_klass->external_name());
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
}

if (is_put && !is_static && byte != Bytecodes::_withfield && resolved_klass->is_inline_klass()) {
ResourceMark rm(THREAD);
char msg[200];
jio_snprintf(msg, sizeof(msg), "Bytecode putfield cannot be used on primitive class %s", resolved_klass->external_name());
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
}

// Resolve instance field
Klass* sel_klass = resolved_klass->find_field(field, sig, &fd);
// check if field exists; i.e., if a klass containing the field def has been selected
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/graphKit.cpp
Expand Up @@ -1763,8 +1763,8 @@ Node* GraphKit::access_atomic_add_at(Node* obj,
}
}

void GraphKit::access_clone(Node* src_base, Node* dst_base, Node* countx, bool is_array) {
return _barrier_set->clone(this, src_base, dst_base, countx, is_array);
void GraphKit::access_clone(Node* src, Node* dst, Node* size, bool is_array) {
return _barrier_set->clone(this, src, dst, size, is_array);
}

//-------------------------array_element_address-------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/graphKit.hpp
Expand Up @@ -657,7 +657,7 @@ class GraphKit : public Phase {
BasicType bt,
DecoratorSet decorators);

void access_clone(Node* src_base, Node* dst_base, Node* countx, bool is_array);
void access_clone(Node* src, Node* dst, Node* size, bool is_array);

// Return addressing for an array element.
Node* array_element_address(Node* ary, Node* idx, BasicType elembt,
Expand Down

0 comments on commit aa8ff76

Please sign in to comment.