Skip to content

Commit 4125dbb

Browse files
committed
8302369: Reduce the stack size of the C1 compiler
1 parent 814cbd4 commit 4125dbb

14 files changed

+70
-146
lines changed

src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
6363
__ b(_continuation);
6464
}
6565

66-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
67-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
68-
assert(info != NULL, "must have info");
69-
_info = new CodeEmitInfo(info);
70-
}
71-
72-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
73-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
74-
assert(info != NULL, "must have info");
75-
_info = new CodeEmitInfo(info);
76-
}
77-
7866
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
7967
__ bind(_entry);
8068
if (_info->deoptimize_on_exception()) {
@@ -208,14 +196,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
208196
assert(_result->as_register() == r0, "result must in r0");
209197
__ b(_continuation);
210198
}
211-
// Implementation of MonitorAccessStubs
212-
213-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
214-
: MonitorAccessStub(obj_reg, lock_reg)
215-
{
216-
_info = new CodeEmitInfo(info);
217-
}
218-
219199

220200
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
221201
assert(__ rsp_offset() == 0, "frame size should be fixed");

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -2186,15 +2186,15 @@ void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr de
21862186
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
21872187
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
21882188
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2189-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
2189+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
21902190
__ str (r, Address(sp, offset_from_rsp_in_bytes));
21912191
}
21922192

21932193

21942194
void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
21952195
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
21962196
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2197-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
2197+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
21982198
__ mov (rscratch1, c);
21992199
__ str (rscratch1, Address(sp, offset_from_rsp_in_bytes));
22002200
}
@@ -2204,7 +2204,7 @@ void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
22042204
ShouldNotReachHere();
22052205
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
22062206
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2207-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
2207+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
22082208
__ lea(rscratch1, __ constant_oop_address(o));
22092209
__ str(rscratch1, Address(sp, offset_from_rsp_in_bytes));
22102210
}

src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
5353
__ b(_continuation);
5454
}
5555

56-
57-
// TODO: ARM - is it possible to inline these stubs into the main code stream?
58-
59-
60-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
61-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
62-
assert(info != NULL, "must have info");
63-
_info = new CodeEmitInfo(info);
64-
}
65-
66-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
67-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
68-
assert(info != NULL, "must have info");
69-
_info = new CodeEmitInfo(info);
70-
}
71-
7256
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
7357
__ bind(_entry);
7458

@@ -192,16 +176,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
192176
__ b(_continuation);
193177
}
194178

195-
196-
// Implementation of MonitorAccessStubs
197-
198-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
199-
: MonitorAccessStub(obj_reg, lock_reg)
200-
{
201-
_info = new CodeEmitInfo(info);
202-
}
203-
204-
205179
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
206180
__ bind(_entry);
207181
const Register obj_reg = _obj_reg->as_pointer_register();

src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
6464
}
6565
}
6666

67-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
68-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
69-
assert(info != NULL, "must have info");
70-
_info = new CodeEmitInfo(info);
71-
}
72-
73-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
74-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
75-
assert(info != NULL, "must have info");
76-
_info = new CodeEmitInfo(info);
77-
}
78-
7967
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
8068
__ bind(_entry);
8169

@@ -282,13 +270,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
282270
__ b(_continuation);
283271
}
284272

285-
286-
// Implementation of MonitorAccessStubs
287-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
288-
: MonitorAccessStub(obj_reg, lock_reg) {
289-
_info = new CodeEmitInfo(info);
290-
}
291-
292273
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
293274
__ bind(_entry);
294275
address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorenter_id : Runtime1::monitorenter_nofpu_id);

src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
6868
__ j(_continuation);
6969
}
7070

71-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
72-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
73-
assert(info != NULL, "must have info");
74-
_info = new CodeEmitInfo(info);
75-
}
76-
77-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
78-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
79-
assert(info != NULL, "must have info");
80-
_info = new CodeEmitInfo(info);
81-
}
82-
8371
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
8472
__ bind(_entry);
8573
if (_info->deoptimize_on_exception()) {
@@ -205,12 +193,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
205193
__ j(_continuation);
206194
}
207195

208-
// Implementation of MonitorAccessStubs
209-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
210-
: MonitorAccessStub(obj_reg, lock_reg) {
211-
_info = new CodeEmitInfo(info);
212-
}
213-
214196
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
215197
assert(__ rsp_offset() == 0, "frame size should be fixed");
216198
__ bind(_entry);

src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
44
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -2241,14 +2241,14 @@ void LIR_Assembler::logic_op_imm(Register dst, Register left, int right, LIR_Cod
22412241
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
22422242
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
22432243
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2244-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
2244+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
22452245
__ sd(r, Address(sp, offset_from_rsp_in_bytes));
22462246
}
22472247

22482248
void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
22492249
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
22502250
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2251-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
2251+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
22522252
__ mv(t0, c);
22532253
__ sd(t0, Address(sp, offset_from_rsp_in_bytes));
22542254
}

src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
4545
ShouldNotReachHere();
4646
}
4747

48-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
49-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
50-
assert(info != NULL, "must have info");
51-
_info = new CodeEmitInfo(info);
52-
}
53-
54-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
55-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
56-
assert(info != NULL, "must have info");
57-
_info = new CodeEmitInfo(info);
58-
}
59-
6048
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
6149
__ bind(_entry);
6250
if (_info->deoptimize_on_exception()) {
@@ -227,11 +215,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
227215
__ z_brul(_continuation);
228216
}
229217

230-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
231-
: MonitorAccessStub(obj_reg, lock_reg) {
232-
_info = new CodeEmitInfo(info);
233-
}
234-
235218
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
236219
__ bind(_entry);
237220
Runtime1::StubID enter_id;

src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,6 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
116116
__ jmp(_continuation);
117117
}
118118

119-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
120-
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
121-
assert(info != NULL, "must have info");
122-
_info = new CodeEmitInfo(info);
123-
}
124-
125-
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
126-
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
127-
assert(info != NULL, "must have info");
128-
_info = new CodeEmitInfo(info);
129-
}
130-
131119
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
132120
__ bind(_entry);
133121
if (_info->deoptimize_on_exception()) {
@@ -254,16 +242,6 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
254242
__ jmp(_continuation);
255243
}
256244

257-
258-
// Implementation of MonitorAccessStubs
259-
260-
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
261-
: MonitorAccessStub(obj_reg, lock_reg)
262-
{
263-
_info = new CodeEmitInfo(info);
264-
}
265-
266-
267245
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
268246
assert(__ rsp_offset() == 0, "frame size should be fixed");
269247
__ bind(_entry);

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -3025,31 +3025,31 @@ void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr de
30253025
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
30263026
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
30273027
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3028-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
3028+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
30293029
__ movptr (Address(rsp, offset_from_rsp_in_bytes), r);
30303030
}
30313031

30323032

30333033
void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
30343034
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
30353035
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3036-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
3036+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
30373037
__ movptr (Address(rsp, offset_from_rsp_in_bytes), c);
30383038
}
30393039

30403040

30413041
void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
30423042
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
30433043
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3044-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
3044+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
30453045
__ movoop(Address(rsp, offset_from_rsp_in_bytes), o, rscratch1);
30463046
}
30473047

30483048

30493049
void LIR_Assembler::store_parameter(Metadata* m, int offset_from_rsp_in_words) {
30503050
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
30513051
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3052-
assert(offset_from_rsp_in_bytes <= frame_map()->reserved_argument_area_size(), "invalid offset");
3052+
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
30533053
__ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m, rscratch1);
30543054
}
30553055

src/hotspot/share/c1/c1_CodeStubs.hpp

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class CounterOverflowStub: public CodeStub {
110110

111111
public:
112112
CounterOverflowStub(CodeEmitInfo* info, int bci, LIR_Opr method) : _info(info), _bci(bci), _method(method) {
113+
FrameMap* f = Compilation::current()->frame_map();
114+
f->update_reserved_argument_area_size(2 * BytesPerWord);
113115
}
114116

115117
virtual void emit_code(LIR_Assembler* e);
@@ -166,9 +168,21 @@ class RangeCheckStub: public CodeStub {
166168

167169
public:
168170
// For ArrayIndexOutOfBoundsException.
169-
RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array);
171+
RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
172+
: _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
173+
assert(info != NULL, "must have info");
174+
_info = new CodeEmitInfo(info);
175+
FrameMap* f = Compilation::current()->frame_map();
176+
f->update_reserved_argument_area_size(2 * BytesPerWord);
177+
}
170178
// For IndexOutOfBoundsException.
171-
RangeCheckStub(CodeEmitInfo* info, LIR_Opr index);
179+
RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
180+
: _index(index), _array(), _throw_index_out_of_bounds_exception(true) {
181+
assert(info != NULL, "must have info");
182+
_info = new CodeEmitInfo(info);
183+
FrameMap* f = Compilation::current()->frame_map();
184+
f->update_reserved_argument_area_size(2 * BytesPerWord);
185+
}
172186
virtual void emit_code(LIR_Assembler* e);
173187
virtual CodeEmitInfo* info() const { return _info; }
174188
virtual bool is_exception_throw_stub() const { return true; }
@@ -335,7 +349,12 @@ class MonitorEnterStub: public MonitorAccessStub {
335349
CodeEmitInfo* _info;
336350

337351
public:
338-
MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info);
352+
MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
353+
: MonitorAccessStub(obj_reg, lock_reg) {
354+
_info = new CodeEmitInfo(info);
355+
FrameMap* f = Compilation::current()->frame_map();
356+
f->update_reserved_argument_area_size(2 * BytesPerWord);
357+
}
339358

340359
virtual void emit_code(LIR_Assembler* e);
341360
virtual CodeEmitInfo* info() const { return _info; }
@@ -476,7 +495,10 @@ class DeoptimizeStub : public CodeStub {
476495

477496
public:
478497
DeoptimizeStub(CodeEmitInfo* info, Deoptimization::DeoptReason reason, Deoptimization::DeoptAction action) :
479-
_info(new CodeEmitInfo(info)), _trap_request(Deoptimization::make_trap_request(reason, action)) {}
498+
_info(new CodeEmitInfo(info)), _trap_request(Deoptimization::make_trap_request(reason, action)) {
499+
FrameMap* f = Compilation::current()->frame_map();
500+
f->update_reserved_argument_area_size(2 * BytesPerWord);
501+
}
480502

481503
virtual void emit_code(LIR_Assembler* e);
482504
virtual CodeEmitInfo* info() const { return _info; }
@@ -499,6 +521,8 @@ class SimpleExceptionStub: public CodeStub {
499521
public:
500522
SimpleExceptionStub(Runtime1::StubID stub, LIR_Opr obj, CodeEmitInfo* info):
501523
_obj(obj), _stub(stub), _info(info) {
524+
FrameMap* f = Compilation::current()->frame_map();
525+
f->update_reserved_argument_area_size(2 * BytesPerWord);
502526
}
503527

504528
void set_obj(LIR_Opr obj) {
@@ -534,7 +558,14 @@ class ArrayCopyStub: public CodeStub {
534558
LIR_OpArrayCopy* _op;
535559

536560
public:
537-
ArrayCopyStub(LIR_OpArrayCopy* op): _op(op) { }
561+
ArrayCopyStub(LIR_OpArrayCopy* op): _op(op) {
562+
FrameMap* f = Compilation::current()->frame_map();
563+
#if defined(X86)
564+
f->update_reserved_argument_area_size(5 * BytesPerWord);
565+
#else
566+
f->update_reserved_argument_area_size(2 * BytesPerWord);
567+
#endif
568+
}
538569

539570
LIR_Opr src() const { return _op->src(); }
540571
LIR_Opr src_pos() const { return _op->src_pos(); }

0 commit comments

Comments
 (0)