diff --git a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp index 4a60b88a5c015..59d721eb4bfb6 100644 --- a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp @@ -63,18 +63,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ b(_continuation); } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { @@ -208,14 +196,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { assert(_result->as_register() == r0, "result must in r0"); __ b(_continuation); } -// Implementation of MonitorAccessStubs - -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) -: MonitorAccessStub(obj_reg, lock_reg) -{ - _info = new CodeEmitInfo(info); -} - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { assert(__ rsp_offset() == 0, "frame size should be fixed"); diff --git a/src/hotspot/cpu/aarch64/c1_Defs_aarch64.hpp b/src/hotspot/cpu/aarch64/c1_Defs_aarch64.hpp index e92c538637f08..9470caae9fe5a 100644 --- a/src/hotspot/cpu/aarch64/c1_Defs_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c1_Defs_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -82,4 +82,9 @@ enum { pd_two_operand_lir_form = false }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 2 +}; + #endif // CPU_AARCH64_C1_DEFS_AARCH64_HPP diff --git a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp index f776129d4fce0..3d8dbc38071ed 100644 --- a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp +++ b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp @@ -53,22 +53,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ b(_continuation); } - -// TODO: ARM - is it possible to inline these stubs into the main code stream? - - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != nullptr, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != nullptr, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); @@ -192,16 +176,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ b(_continuation); } - -// Implementation of MonitorAccessStubs - -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) -: MonitorAccessStub(obj_reg, lock_reg) -{ - _info = new CodeEmitInfo(info); -} - - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); const Register obj_reg = _obj_reg->as_pointer_register(); diff --git a/src/hotspot/cpu/arm/c1_Defs_arm.hpp b/src/hotspot/cpu/arm/c1_Defs_arm.hpp index 68b5449cd5838..32e0b02964879 100644 --- a/src/hotspot/cpu/arm/c1_Defs_arm.hpp +++ b/src/hotspot/cpu/arm/c1_Defs_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023, 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 @@ -78,6 +78,11 @@ enum { pd_two_operand_lir_form = false }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 2 +}; + #define PATCHED_ADDR (204) #define CARDTABLEBARRIERSET_POST_BARRIER_HELPER diff --git a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp index 109372bb1a4b1..36d47e5a1d086 100644 --- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp @@ -64,18 +64,6 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) { } } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); @@ -282,13 +270,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ b(_continuation); } - -// Implementation of MonitorAccessStubs -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) - : MonitorAccessStub(obj_reg, lock_reg) { - _info = new CodeEmitInfo(info); -} - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorenter_id : Runtime1::monitorenter_nofpu_id); diff --git a/src/hotspot/cpu/ppc/c1_Defs_ppc.hpp b/src/hotspot/cpu/ppc/c1_Defs_ppc.hpp index 0d18d889da153..9044b9edd2653 100644 --- a/src/hotspot/cpu/ppc/c1_Defs_ppc.hpp +++ b/src/hotspot/cpu/ppc/c1_Defs_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -77,4 +77,9 @@ enum { pd_two_operand_lir_form = false }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 2 +}; + #endif // CPU_PPC_C1_DEFS_PPC_HPP diff --git a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp index 197216d6eca94..83dab175a61dc 100644 --- a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp @@ -68,18 +68,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ j(_continuation); } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { @@ -205,12 +193,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ j(_continuation); } -// Implementation of MonitorAccessStubs -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) -: MonitorAccessStub(obj_reg, lock_reg) { - _info = new CodeEmitInfo(info); -} - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { assert(__ rsp_offset() == 0, "frame size should be fixed"); __ bind(_entry); diff --git a/src/hotspot/cpu/riscv/c1_Defs_riscv.hpp b/src/hotspot/cpu/riscv/c1_Defs_riscv.hpp index 967bfc9d53909..bce243802980b 100644 --- a/src/hotspot/cpu/riscv/c1_Defs_riscv.hpp +++ b/src/hotspot/cpu/riscv/c1_Defs_riscv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -85,4 +85,9 @@ enum { pd_two_operand_lir_form = false }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 2 +}; + #endif // CPU_RISCV_C1_DEFS_RISCV_HPP diff --git a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp index eb62ee9f10230..b99027f09d5c7 100644 --- a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp +++ b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp @@ -45,18 +45,6 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) { ShouldNotReachHere(); } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { @@ -227,11 +215,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ z_brul(_continuation); } -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) - : MonitorAccessStub(obj_reg, lock_reg) { - _info = new CodeEmitInfo(info); -} - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); Runtime1::StubID enter_id; diff --git a/src/hotspot/cpu/s390/c1_Defs_s390.hpp b/src/hotspot/cpu/s390/c1_Defs_s390.hpp index 3fc3ee2772c04..6343a40bb06c7 100644 --- a/src/hotspot/cpu/s390/c1_Defs_s390.hpp +++ b/src/hotspot/cpu/s390/c1_Defs_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -72,4 +72,9 @@ enum { pd_two_operand_lir_form = true }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 2 +}; + #endif // CPU_S390_C1_DEFS_S390_HPP diff --git a/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp b/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp index edbad4147039f..2665c5da4aaa6 100644 --- a/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp +++ b/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp @@ -116,18 +116,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ jmp(_continuation); } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) - : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { - assert(info != NULL, "must have info"); - _info = new CodeEmitInfo(info); -} - void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { @@ -254,16 +242,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ jmp(_continuation); } - -// Implementation of MonitorAccessStubs - -MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) -: MonitorAccessStub(obj_reg, lock_reg) -{ - _info = new CodeEmitInfo(info); -} - - void MonitorEnterStub::emit_code(LIR_Assembler* ce) { assert(__ rsp_offset() == 0, "frame size should be fixed"); __ bind(_entry); diff --git a/src/hotspot/cpu/x86/c1_Defs_x86.hpp b/src/hotspot/cpu/x86/c1_Defs_x86.hpp index 40a486225715b..28da99cdf2764 100644 --- a/src/hotspot/cpu/x86/c1_Defs_x86.hpp +++ b/src/hotspot/cpu/x86/c1_Defs_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, 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 @@ -79,4 +79,9 @@ enum { pd_two_operand_lir_form = true }; +// the number of stack required by ArrayCopyStub +enum { + pd_arraycopystub_reserved_argument_area_size = 5 +}; + #endif // CPU_X86_C1_DEFS_X86_HPP diff --git a/src/hotspot/share/c1/c1_CodeStubs.hpp b/src/hotspot/share/c1/c1_CodeStubs.hpp index 20603fc5cc183..89c897972547a 100644 --- a/src/hotspot/share/c1/c1_CodeStubs.hpp +++ b/src/hotspot/share/c1/c1_CodeStubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2023, 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 @@ -110,6 +110,8 @@ class CounterOverflowStub: public CodeStub { public: CounterOverflowStub(CodeEmitInfo* info, int bci, LIR_Opr method) : _info(info), _bci(bci), _method(method) { + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } virtual void emit_code(LIR_Assembler* e); @@ -166,9 +168,21 @@ class RangeCheckStub: public CodeStub { public: // For ArrayIndexOutOfBoundsException. - RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array); + RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) + : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); + } // For IndexOutOfBoundsException. - RangeCheckStub(CodeEmitInfo* info, LIR_Opr index); + RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _index(index), _array(), _throw_index_out_of_bounds_exception(true) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); + } virtual void emit_code(LIR_Assembler* e); virtual CodeEmitInfo* info() const { return _info; } virtual bool is_exception_throw_stub() const { return true; } @@ -335,7 +349,12 @@ class MonitorEnterStub: public MonitorAccessStub { CodeEmitInfo* _info; public: - MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info); + MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) + : MonitorAccessStub(obj_reg, lock_reg) { + _info = new CodeEmitInfo(info); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); + } virtual void emit_code(LIR_Assembler* e); virtual CodeEmitInfo* info() const { return _info; } @@ -476,7 +495,10 @@ class DeoptimizeStub : public CodeStub { public: DeoptimizeStub(CodeEmitInfo* info, Deoptimization::DeoptReason reason, Deoptimization::DeoptAction action) : - _info(new CodeEmitInfo(info)), _trap_request(Deoptimization::make_trap_request(reason, action)) {} + _info(new CodeEmitInfo(info)), _trap_request(Deoptimization::make_trap_request(reason, action)) { + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); + } virtual void emit_code(LIR_Assembler* e); virtual CodeEmitInfo* info() const { return _info; } @@ -499,6 +521,8 @@ class SimpleExceptionStub: public CodeStub { public: SimpleExceptionStub(Runtime1::StubID stub, LIR_Opr obj, CodeEmitInfo* info): _obj(obj), _stub(stub), _info(info) { + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } void set_obj(LIR_Opr obj) { @@ -534,7 +558,10 @@ class ArrayCopyStub: public CodeStub { LIR_OpArrayCopy* _op; public: - ArrayCopyStub(LIR_OpArrayCopy* op): _op(op) { } + ArrayCopyStub(LIR_OpArrayCopy* op): _op(op) { + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(arraycopystub_reserved_argument_area_size * BytesPerWord); + } LIR_Opr src() const { return _op->src(); } LIR_Opr src_pos() const { return _op->src_pos(); } diff --git a/src/hotspot/share/c1/c1_Compilation.cpp b/src/hotspot/share/c1/c1_Compilation.cpp index 155e297abbe8f..4d5331a46aa11 100644 --- a/src/hotspot/share/c1/c1_Compilation.cpp +++ b/src/hotspot/share/c1/c1_Compilation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2023, 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 @@ -398,7 +398,7 @@ int Compilation::compile_java_method() { { PhaseTraceTime timeit(_t_emit_lir); - _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack())); + _frame_map = new FrameMap(method(), hir()->number_of_locks(), hir()->max_stack()); emit_lir(); } CHECK_BAILOUT_(no_frame_size); diff --git a/src/hotspot/share/c1/c1_Defs.hpp b/src/hotspot/share/c1/c1_Defs.hpp index 4d3763e07ba3f..0e7b120ef8d6a 100644 --- a/src/hotspot/share/c1/c1_Defs.hpp +++ b/src/hotspot/share/c1/c1_Defs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, 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 @@ -61,4 +61,9 @@ enum { two_operand_lir_form = pd_two_operand_lir_form }; +// the number of stack required by ArrayCopyStub +enum { + arraycopystub_reserved_argument_area_size = pd_arraycopystub_reserved_argument_area_size +}; + #endif // SHARE_C1_C1_DEFS_HPP diff --git a/src/hotspot/share/c1/c1_FrameMap.cpp b/src/hotspot/share/c1/c1_FrameMap.cpp index fe934d54146f7..4157b42535f7d 100644 --- a/src/hotspot/share/c1/c1_FrameMap.cpp +++ b/src/hotspot/share/c1/c1_FrameMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2023, 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 @@ -162,7 +162,11 @@ FrameMap::FrameMap(ciMethod* method, int monitors, int reserved_argument_area_si assert(monitors >= 0, "not set"); _num_monitors = monitors; assert(reserved_argument_area_size >= 0, "not set"); - _reserved_argument_area_size = MAX2(4, reserved_argument_area_size) * BytesPerWord; + + // reserved_argument_area_size does not include stack space that needs to be occupied in the stub + // and the stub will modify the value through update_reserved_argument_area_size(int size) if needed. + // see the constructor of class CounterOverflowStub for example. + _reserved_argument_area_size = reserved_argument_area_size * BytesPerWord; _argcount = method->arg_size(); _argument_locations = new intArray(_argcount, _argcount, -1); diff --git a/src/hotspot/share/c1/c1_FrameMap.hpp b/src/hotspot/share/c1/c1_FrameMap.hpp index a0e2562bfca08..b133032038351 100644 --- a/src/hotspot/share/c1/c1_FrameMap.hpp +++ b/src/hotspot/share/c1/c1_FrameMap.hpp @@ -77,6 +77,11 @@ class FrameMap : public CompilationResourceObj { spill_slot_size_in_bytes = 4 }; + void update_reserved_argument_area_size (int size) { + assert(size >= 0, "check"); + _reserved_argument_area_size = MAX2(_reserved_argument_area_size, size); + } + #include CPU_HEADER(c1_FrameMap) friend class LIR_Opr; @@ -122,18 +127,12 @@ class FrameMap : public CompilationResourceObj { _cpu_reg2rnr[reg->encoding()] = rnr; } - void update_reserved_argument_area_size (int size) { - assert(size >= 0, "check"); - _reserved_argument_area_size = MAX2(_reserved_argument_area_size, size); - } - protected: #ifndef PRODUCT static void cpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_cpu_regs, "cpu register number is too big"); } static void fpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_fpu_regs, "fpu register number is too big"); } #endif - ByteSize sp_offset_for_monitor_base(const int idx) const; Address make_new_address(ByteSize sp_offset) const; diff --git a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.hpp b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.hpp index f6d3c2ab79f9b..b6620a22dc491 100644 --- a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.hpp +++ b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_C1_G1BARRIERSETC1_HPP #include "c1/c1_CodeStubs.hpp" +#include "c1/c1_Compilation.hpp" #include "gc/shared/c1/modRefBarrierSetC1.hpp" class G1PreBarrierStub: public CodeStub { @@ -47,6 +48,8 @@ class G1PreBarrierStub: public CodeStub { { assert(_pre_val->is_register(), "should be temporary register"); assert(_addr->is_address(), "should be the address of the field"); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } // Version that _does not_ generate load of the previous value; the @@ -56,6 +59,8 @@ class G1PreBarrierStub: public CodeStub { _patch_code(lir_patch_none), _info(NULL) { assert(_pre_val->is_register(), "should be a register"); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } LIR_Opr addr() const { return _addr; } @@ -94,7 +99,10 @@ class G1PostBarrierStub: public CodeStub { public: // addr (the address of the object head) and new_val must be registers. - G1PostBarrierStub(LIR_Opr addr, LIR_Opr new_val): _addr(addr), _new_val(new_val) { } + G1PostBarrierStub(LIR_Opr addr, LIR_Opr new_val): _addr(addr), _new_val(new_val) { + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); + } LIR_Opr addr() const { return _addr; } LIR_Opr new_val() const { return _new_val; } diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp index 2a965f608f1dc..71093300e8296 100644 --- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp +++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp @@ -47,6 +47,8 @@ class ShenandoahPreBarrierStub: public CodeStub { { assert(_pre_val->is_register(), "should be temporary register"); assert(_addr->is_address(), "should be the address of the field"); + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } // Version that _does not_ generate load of the previous value; the @@ -104,6 +106,9 @@ class ShenandoahLoadReferenceBarrierStub: public CodeStub { assert(_result->is_register(), "should be register"); assert(_tmp1->is_register(), "should be register"); assert(_tmp2->is_register(), "should be register"); + + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } LIR_Opr obj() const { return _obj; } diff --git a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp index 705d498399a94..93001511f88f1 100644 --- a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp +++ b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp @@ -47,6 +47,9 @@ ZLoadBarrierStubC1::ZLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address r // Has index or displacement, need tmp register to load address into _tmp = access.gen()->new_pointer_register(); } + + FrameMap* f = Compilation::current()->frame_map(); + f->update_reserved_argument_area_size(2 * BytesPerWord); } DecoratorSet ZLoadBarrierStubC1::decorators() const {