From ae9ad862ee54e119553efec919f1061dca36b954 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 21 May 2024 12:01:48 +0000 Subject: [PATCH] 8331934: [s390x] Add support for primitive array C1 clone intrinsic Reviewed-by: mdoerr, sjayagond --- src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp | 7 +++-- src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp | 24 ++++++++++++++--- .../cpu/s390/c1_MacroAssembler_s390.cpp | 27 ++++++++++--------- .../cpu/s390/c1_MacroAssembler_s390.hpp | 5 ++-- src/hotspot/share/c1/c1_Compiler.cpp | 2 +- src/hotspot/share/c1/c1_LIR.cpp | 2 +- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 503440a5fcc..a5e62169a93 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -2274,7 +2274,9 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false); __ call_VM_leaf(entry); - __ bind(*stub->continuation()); + if (stub != nullptr) { + __ bind(*stub->continuation()); + } } void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) { @@ -2385,7 +2387,8 @@ void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) { arrayOopDesc::base_offset_in_bytes(op->type()), type2aelembytes(op->type()), op->klass()->as_register(), - *op->stub()->entry()); + *op->stub()->entry(), + op->zero_array()); } __ bind(*op->stub()->continuation()); } diff --git a/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp b/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp index 8df13597425..619f0f7174f 100644 --- a/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2017 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 @@ -710,7 +710,13 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) { frame_map()->c_calling_convention(&sig); // Make all state_for calls early since they can emit code. - CodeEmitInfo* info = state_for (x, x->state()); + CodeEmitInfo* info = nullptr; + if (x->state_before() != nullptr && x->state_before()->force_reexecute()) { + info = state_for(x, x->state_before()); + info->set_force_reexecute(); + } else { + info = state_for(x, x->state()); + } LIRItem src(x->argument_at(0), this); LIRItem src_pos(x->argument_at(1), this); @@ -735,6 +741,9 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) { int flags; ciArrayKlass* expected_type; arraycopy_helper(x, &flags, &expected_type); + if (x->check_flag(Instruction::OmitChecksFlag)) { + flags = 0; + } __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, expected_type, flags, info); // does add_safepoint @@ -769,7 +778,13 @@ void LIRGenerator::do_NewInstance(NewInstance* x) { } void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { - CodeEmitInfo* info = state_for (x, x->state()); + CodeEmitInfo* info = nullptr; + if (x->state_before() != nullptr && x->state_before()->force_reexecute()) { + info = state_for(x, x->state_before()); + info->set_force_reexecute(); + } else { + info = state_for(x, x->state()); + } LIRItem length(x->length(), this); length.load_item(); @@ -786,7 +801,8 @@ void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); - __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); + __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, + klass_reg, slow_path, x->zero_array()); LIR_Opr result = rlock_result(x); __ move(reg, result); diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index 58bdcee5d5f..604a8336ff9 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 @@ -191,7 +191,6 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register } void C1_MacroAssembler::initialize_body(Register objectFields, Register len_in_bytes, Register Rzero) { - Label done; assert_different_registers(objectFields, len_in_bytes, Rzero); // Initialize object fields. @@ -203,7 +202,6 @@ void C1_MacroAssembler::initialize_body(Register objectFields, Register len_in_b // Use Rzero as src length, then mvcle will copy nothing // and fill the object with the padding value 0. move_long_ext(objectFields, as_Register(Rzero->encoding()-1), 0); - bind(done); } void C1_MacroAssembler::allocate_object( @@ -274,7 +272,8 @@ void C1_MacroAssembler::allocate_array( int base_offset_in_bytes, // elements offset in bytes int elt_size, // element size in bytes Register klass, // object klass - Label& slow_case // Continuation point if fast allocation fails. + Label& slow_case, // Continuation point if fast allocation fails. + bool zero_array // zero the allocated array or not ) { assert_different_registers(obj, len, t1, t2, klass); @@ -305,15 +304,17 @@ void C1_MacroAssembler::allocate_array( initialize_header(obj, klass, len, noreg, t1); // Clear rest of allocated space. - Label done; - Register object_fields = t1; - Register Rzero = Z_R1_scratch; - z_aghi(arr_size, -base_offset_in_bytes); - z_bre(done); // Jump if size of fields is zero. - z_la(object_fields, base_offset_in_bytes, obj); - z_xgr(Rzero, Rzero); - initialize_body(object_fields, arr_size, Rzero); - bind(done); + if (zero_array) { + Label done; + Register object_fields = t1; + Register Rzero = Z_R1_scratch; + z_aghi(arr_size, -base_offset_in_bytes); + z_bre(done); // Jump if size of fields is zero. + z_la(object_fields, base_offset_in_bytes, obj); + z_xgr(Rzero, Rzero); + initialize_body(object_fields, arr_size, Rzero); + bind(done); + } // Dtrace support is unimplemented. // if (CURRENT_ENV->dtrace_alloc_probes()) { diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.hpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.hpp index c77258509e1..e93eff43bd4 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 @@ -89,7 +89,8 @@ int base_offset_in_bytes, // elements offset in bytes int elt_size, // element size in bytes Register klass, // object klass - Label& slow_case // Continuation point if fast allocation fails. + Label& slow_case, // Continuation point if fast allocation fails. + bool zero_array // zero the allocated array or not ); // Invalidates registers in this window. diff --git a/src/hotspot/share/c1/c1_Compiler.cpp b/src/hotspot/share/c1/c1_Compiler.cpp index 6e518b0213b..3a902bb4230 100644 --- a/src/hotspot/share/c1/c1_Compiler.cpp +++ b/src/hotspot/share/c1/c1_Compiler.cpp @@ -235,7 +235,7 @@ bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_counterTime: #endif case vmIntrinsics::_getObjectSize: -#if defined(X86) || defined(AARCH64) +#if defined(X86) || defined(AARCH64) || defined(S390) case vmIntrinsics::_clone: #endif break; diff --git a/src/hotspot/share/c1/c1_LIR.cpp b/src/hotspot/share/c1/c1_LIR.cpp index 4017a5324b5..bbf802aca13 100644 --- a/src/hotspot/share/c1/c1_LIR.cpp +++ b/src/hotspot/share/c1/c1_LIR.cpp @@ -353,7 +353,7 @@ LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_ , _tmp(tmp) , _expected_type(expected_type) , _flags(flags) { -#if defined(X86) || defined(AARCH64) +#if defined(X86) || defined(AARCH64) || defined(S390) if (expected_type != nullptr && flags == 0) { _stub = nullptr; } else {