From 9529d19daf495c9506b8d41edb1e963c33067cef Mon Sep 17 00:00:00 2001 From: loongson-jvm Date: Mon, 29 Jan 2024 17:03:24 +0800 Subject: [PATCH] Update (2024.01.29) 33504: LA port of 8322294: Cleanup NativePostCallNop 33503: Eliminate -Wparentheses warnings in LoongArch code 33502: LA port of 8237842: Separate definitions for default cache line and padding sizes --- src/hotspot/cpu/loongarch/frame_loongarch.hpp | 4 +--- .../cpu/loongarch/frame_loongarch.inline.hpp | 18 ++---------------- .../loongarch/globalDefinitions_loongarch.hpp | 6 +++++- .../cpu/loongarch/nativeInst_loongarch.cpp | 15 ++++++++++----- .../cpu/loongarch/nativeInst_loongarch.hpp | 14 ++++++++++---- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/hotspot/cpu/loongarch/frame_loongarch.hpp b/src/hotspot/cpu/loongarch/frame_loongarch.hpp index 36dd89ff08fb2..4e2c8cec35efd 100644 --- a/src/hotspot/cpu/loongarch/frame_loongarch.hpp +++ b/src/hotspot/cpu/loongarch/frame_loongarch.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2024, Loongson Technology. 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 @@ -155,8 +155,6 @@ static void verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp); #endif - const ImmutableOopMap* get_oop_map() const; - public: // Constructors diff --git a/src/hotspot/cpu/loongarch/frame_loongarch.inline.hpp b/src/hotspot/cpu/loongarch/frame_loongarch.inline.hpp index 8eac47d6ef994..d0f11d26f4b07 100644 --- a/src/hotspot/cpu/loongarch/frame_loongarch.inline.hpp +++ b/src/hotspot/cpu/loongarch/frame_loongarch.inline.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2024, Loongson Technology. 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 @@ -183,7 +183,7 @@ inline bool frame::equal(frame other) const { unextended_sp() == other.unextended_sp() && fp() == other.fp() && pc() == other.pc(); - assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); + assert(!ret || (cb() == other.cb() && _deopt_state == other._deopt_state), "inconsistent construction"); return ret; } @@ -342,20 +342,6 @@ inline int frame::sender_sp_ret_address_offset() { return frame::sender_sp_offset - frame::return_addr_offset; } -inline const ImmutableOopMap* frame::get_oop_map() const { - if (_cb == nullptr) return nullptr; - if (_cb->oop_maps() != nullptr) { - NativePostCallNop* nop = nativePostCallNop_at(_pc); - if (nop != nullptr && nop->displacement() != 0) { - int slot = ((nop->displacement() >> 24) & 0xff); - return _cb->oop_map_for_slot(slot, _pc); - } - const ImmutableOopMap* oop_map = OopMapSet::find_map(this); - return oop_map; - } - return nullptr; -} - //------------------------------------------------------------------------------ // frame::sender frame frame::sender(RegisterMap* map) const { diff --git a/src/hotspot/cpu/loongarch/globalDefinitions_loongarch.hpp b/src/hotspot/cpu/loongarch/globalDefinitions_loongarch.hpp index 2306c5bc6d165..65e81626fdc1b 100644 --- a/src/hotspot/cpu/loongarch/globalDefinitions_loongarch.hpp +++ b/src/hotspot/cpu/loongarch/globalDefinitions_loongarch.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2024, Loongson Technology. 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 @@ -53,6 +53,10 @@ const bool CCallingConventionRequiresIntsAsLongs = false; #define USE_POINTERS_TO_REGISTER_IMPL_ARRAY +// The expected size in bytes of a cache line. #define DEFAULT_CACHE_LINE_SIZE 64 +// The default padding size for data structures to avoid false sharing. +#define DEFAULT_PADDING_SIZE DEFAULT_CACHE_LINE_SIZE + #endif // CPU_LOONGARCH_GLOBALDEFINITIONS_LOONGARCH_HPP diff --git a/src/hotspot/cpu/loongarch/nativeInst_loongarch.cpp b/src/hotspot/cpu/loongarch/nativeInst_loongarch.cpp index c298cda5de73a..cc64142a1783a 100644 --- a/src/hotspot/cpu/loongarch/nativeInst_loongarch.cpp +++ b/src/hotspot/cpu/loongarch/nativeInst_loongarch.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2024, Loongson Technology. 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 @@ -511,12 +511,16 @@ void NativePostCallNop::make_deopt() { NativeDeoptInstruction::insert(addr_at(0)); } -void NativePostCallNop::patch(jint diff) { - assert(diff != 0, "must be"); +bool NativePostCallNop::patch(int32_t oopmap_slot, int32_t cb_offset) { + if (((oopmap_slot & 0xff) != oopmap_slot) || ((cb_offset & 0xffffff) != cb_offset)) { + return false; // cannot encode + } + uint32_t data = ((uint32_t)oopmap_slot << 24) | cb_offset; + assert(data != 0, "must be"); assert(check(), "must be"); - int lo = (diff & 0xffff); - int hi = ((diff >> 16) & 0xffff); + int lo = (data & 0xffff); + int hi = ((data >> 16) & 0xffff); uint32_t *code_pos_first = (uint32_t *) addr_at(4); uint32_t *code_pos_second = (uint32_t *) addr_at(8); @@ -525,6 +529,7 @@ void NativePostCallNop::patch(jint diff) { *((uint32_t *)(code_pos_first)) = (uint32_t) ((opcode | lo) << 5); *((uint32_t *)(code_pos_second)) = (uint32_t) ((opcode | hi) << 5); + return true; // successfully encoded } void NativeDeoptInstruction::verify() { diff --git a/src/hotspot/cpu/loongarch/nativeInst_loongarch.hpp b/src/hotspot/cpu/loongarch/nativeInst_loongarch.hpp index 3a322a218a35f..1246c7c0aa52e 100644 --- a/src/hotspot/cpu/loongarch/nativeInst_loongarch.hpp +++ b/src/hotspot/cpu/loongarch/nativeInst_loongarch.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2024, Loongson Technology. 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 @@ -536,15 +536,21 @@ class NativePostCallNop: public NativeInstruction { return is_nop() && ((uint_at(4) & 0xffc0001f) == 0x03800000); } - jint displacement() const { + bool decode(int32_t& oopmap_slot, int32_t& cb_offset) const { uint32_t first_ori = uint_at(4); uint32_t second_ori = uint_at(8); int lo = ((first_ori >> 5) & 0xffff); int hi = ((second_ori >> 5) & 0xffff); - return (jint) ((hi << 16) | lo); + uint32_t data = (hi << 16) | lo; + if (data == 0) { + return false; // no information encoded + } + cb_offset = (data & 0xffffff); + oopmap_slot = (data >> 24) & 0xff; + return true; // decoding succeeded } - void patch(jint diff); + bool patch(int32_t oopmap_slot, int32_t cb_offset); void make_deopt(); };