Skip to content

Commit 0df10bb

Browse files
committed
8339466: Enumerate shared stubs and define static fields and names via declarations
Reviewed-by: kvn, fyang
1 parent 9ebc2ec commit 0df10bb

File tree

11 files changed

+328
-138
lines changed

11 files changed

+328
-138
lines changed

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,8 @@ void SharedRuntime::generate_deopt_blob() {
21812181
pad += 512; // Increase the buffer size when compiling for JVMCI
21822182
}
21832183
#endif
2184-
CodeBuffer buffer("deopt_blob", 2048+pad, 1024);
2184+
const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id);
2185+
CodeBuffer buffer(name, 2048+pad, 1024);
21852186
MacroAssembler* masm = new MacroAssembler(&buffer);
21862187
int frame_size_in_words;
21872188
OopMap* map = nullptr;
@@ -2565,20 +2566,23 @@ uint SharedRuntime::out_preserve_stack_slots() {
25652566
// Generate a special Compile2Runtime blob that saves all registers,
25662567
// and setup oopmap.
25672568
//
2568-
SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
2569+
SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) {
2570+
assert(is_polling_page_id(id), "expected a polling page stub id");
2571+
25692572
ResourceMark rm;
25702573
OopMapSet *oop_maps = new OopMapSet();
25712574
OopMap* map;
25722575

25732576
// Allocate space for the code. Setup code generation tools.
2574-
CodeBuffer buffer("handler_blob", 2048, 1024);
2577+
const char* name = SharedRuntime::stub_name(id);
2578+
CodeBuffer buffer(name, 2048, 1024);
25752579
MacroAssembler* masm = new MacroAssembler(&buffer);
25762580

25772581
address start = __ pc();
25782582
address call_pc = nullptr;
25792583
int frame_size_in_words;
2580-
bool cause_return = (poll_type == POLL_AT_RETURN);
2581-
RegisterSaver reg_save(poll_type == POLL_AT_VECTOR_LOOP /* save_vectors */);
2584+
bool cause_return = (id == SharedStubId::polling_page_return_handler_id);
2585+
RegisterSaver reg_save(id == SharedStubId::polling_page_vectors_safepoint_handler_id /* save_vectors */);
25822586

25832587
// When the signal occurred, the LR was either signed and stored on the stack (in which
25842588
// case it will be restored from the stack before being used) or unsigned and not stored
@@ -2690,12 +2694,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
26902694
// but since this is generic code we don't know what they are and the caller
26912695
// must do any gc of the args.
26922696
//
2693-
RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) {
2697+
RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) {
26942698
assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
2699+
assert(is_resolve_id(id), "expected a resolve stub id");
26952700

26962701
// allocate space for the code
26972702
ResourceMark rm;
26982703

2704+
const char* name = SharedRuntime::stub_name(id);
26992705
CodeBuffer buffer(name, 1000, 512);
27002706
MacroAssembler* masm = new MacroAssembler(&buffer);
27012707

@@ -2787,7 +2793,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
27872793
// otherwise assume that stack unwinding will be initiated, so
27882794
// caller saved registers were assumed volatile in the compiler.
27892795

2790-
RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) {
2796+
RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) {
2797+
assert(is_throw_id(id), "expected a throw stub id");
2798+
2799+
const char* name = SharedRuntime::stub_name(id);
2800+
27912801
// Information about frame layout at time of blocking runtime call.
27922802
// Note that we only have to preserve callee-saved registers since
27932803
// the compilers are responsible for supplying a continuation point
@@ -2896,7 +2906,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
28962906

28972907
int insts_size = 1024;
28982908
int locs_size = 64;
2899-
CodeBuffer code("jfr_write_checkpoint", insts_size, locs_size);
2909+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id);
2910+
CodeBuffer code(name, insts_size, locs_size);
29002911
OopMapSet* oop_maps = new OopMapSet();
29012912
MacroAssembler* masm = new MacroAssembler(&code);
29022913

@@ -2915,7 +2926,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
29152926
oop_maps->add_gc_map(the_pc - start, map);
29162927

29172928
RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
2918-
RuntimeStub::new_runtime_stub("jfr_write_checkpoint", &code, frame_complete,
2929+
RuntimeStub::new_runtime_stub(name, &code, frame_complete,
29192930
(framesize >> (LogBytesPerWord - LogBytesPerInt)),
29202931
oop_maps, false);
29212932
return stub;
@@ -2934,7 +2945,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
29342945
int insts_size = 1024;
29352946
int locs_size = 64;
29362947

2937-
CodeBuffer code("jfr_return_lease", insts_size, locs_size);
2948+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id);
2949+
CodeBuffer code(name, insts_size, locs_size);
29382950
OopMapSet* oop_maps = new OopMapSet();
29392951
MacroAssembler* masm = new MacroAssembler(&code);
29402952

@@ -2953,7 +2965,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
29532965
oop_maps->add_gc_map(the_pc - start, map);
29542966

29552967
RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
2956-
RuntimeStub::new_runtime_stub("jfr_return_lease", &code, frame_complete,
2968+
RuntimeStub::new_runtime_stub(name, &code, frame_complete,
29572969
(framesize >> (LogBytesPerWord - LogBytesPerInt)),
29582970
oop_maps, false);
29592971
return stub;

src/hotspot/cpu/arm/sharedRuntime_arm.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ uint SharedRuntime::out_preserve_stack_slots() {
13601360
//------------------------------generate_deopt_blob----------------------------
13611361
void SharedRuntime::generate_deopt_blob() {
13621362
ResourceMark rm;
1363-
CodeBuffer buffer("deopt_blob", 1024, 1024);
1363+
const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id);
1364+
CodeBuffer buffer(name, 1024, 1024);
13641365
int frame_size_in_words;
13651366
OopMapSet* oop_maps;
13661367
int reexecute_offset;
@@ -1601,15 +1602,17 @@ void SharedRuntime::generate_deopt_blob() {
16011602
// setup oopmap, and calls safepoint code to stop the compiled code for
16021603
// a safepoint.
16031604
//
1604-
SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
1605+
SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) {
16051606
assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
1607+
assert(is_polling_page_id(id), "expected a polling page stub id");
16061608

16071609
ResourceMark rm;
1608-
CodeBuffer buffer("handler_blob", 256, 256);
1610+
const char* name = SharedRuntime::stub_name(id);
1611+
CodeBuffer buffer(name, 256, 256);
16091612
int frame_size_words;
16101613
OopMapSet* oop_maps;
16111614

1612-
bool cause_return = (poll_type == POLL_AT_RETURN);
1615+
bool cause_return = (id == SharedStubId::polling_page_return_handler_id);
16131616

16141617
MacroAssembler* masm = new MacroAssembler(&buffer);
16151618
address start = __ pc();
@@ -1671,10 +1674,12 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
16711674
return SafepointBlob::create(&buffer, oop_maps, frame_size_words);
16721675
}
16731676

1674-
RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) {
1677+
RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) {
16751678
assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
1679+
assert(is_resolve_id(id), "expected a resolve stub id");
16761680

16771681
ResourceMark rm;
1682+
const char* name = SharedRuntime::stub_name(id);
16781683
CodeBuffer buffer(name, 1000, 512);
16791684
int frame_size_words;
16801685
OopMapSet *oop_maps;
@@ -1733,7 +1738,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
17331738
// Continuation point for throwing of implicit exceptions that are not handled in
17341739
// the current activation. Fabricates an exception oop and initiates normal
17351740
// exception dispatching in this frame.
1736-
RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) {
1741+
RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) {
1742+
assert(is_throw_id(id), "expected a throw stub id");
1743+
1744+
const char* name = SharedRuntime::stub_name(id);
1745+
17371746
int insts_size = 128;
17381747
int locs_size = 32;
17391748

@@ -1793,7 +1802,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
17931802
framesize // inclusive of return address
17941803
};
17951804

1796-
CodeBuffer code("jfr_write_checkpoint", 512, 64);
1805+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id);
1806+
CodeBuffer code(name, 512, 64);
17971807
MacroAssembler* masm = new MacroAssembler(&code);
17981808

17991809
address start = __ pc();
@@ -1818,7 +1828,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
18181828
oop_maps->add_gc_map(frame_complete, map);
18191829

18201830
RuntimeStub* stub =
1821-
RuntimeStub::new_runtime_stub(code.name(),
1831+
RuntimeStub::new_runtime_stub(name,
18221832
&code,
18231833
frame_complete,
18241834
(framesize >> (LogBytesPerWord - LogBytesPerInt)),
@@ -1836,7 +1846,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
18361846
framesize // inclusive of return address
18371847
};
18381848

1839-
CodeBuffer code("jfr_return_lease", 512, 64);
1849+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id);
1850+
CodeBuffer code(name, 512, 64);
18401851
MacroAssembler* masm = new MacroAssembler(&code);
18411852

18421853
address start = __ pc();
@@ -1858,7 +1869,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
18581869
oop_maps->add_gc_map(frame_complete, map);
18591870

18601871
RuntimeStub* stub =
1861-
RuntimeStub::new_runtime_stub(code.name(),
1872+
RuntimeStub::new_runtime_stub(name,
18621873
&code,
18631874
frame_complete,
18641875
(framesize >> (LogBytesPerWord - LogBytesPerInt)),

src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,7 +2856,8 @@ void SharedRuntime::generate_deopt_blob() {
28562856
// Allocate space for the code
28572857
ResourceMark rm;
28582858
// Setup code generation tools
2859-
CodeBuffer buffer("deopt_blob", 2048, 1024);
2859+
const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id);
2860+
CodeBuffer buffer(name, 2048, 1024);
28602861
InterpreterMacroAssembler* masm = new InterpreterMacroAssembler(&buffer);
28612862
Label exec_mode_initialized;
28622863
int frame_size_in_words;
@@ -3206,23 +3207,25 @@ void OptoRuntime::generate_uncommon_trap_blob() {
32063207
#endif // COMPILER2
32073208

32083209
// Generate a special Compile2Runtime blob that saves all registers, and setup oopmap.
3209-
SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
3210+
SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) {
32103211
assert(StubRoutines::forward_exception_entry() != nullptr,
32113212
"must be generated before");
3213+
assert(is_polling_page_id(id), "expected a polling page stub id");
32123214

32133215
ResourceMark rm;
32143216
OopMapSet *oop_maps = new OopMapSet();
32153217
OopMap* map;
32163218

32173219
// Allocate space for the code. Setup code generation tools.
3218-
CodeBuffer buffer("handler_blob", 2048, 1024);
3220+
const char* name = SharedRuntime::stub_name(id);
3221+
CodeBuffer buffer(name, 2048, 1024);
32193222
MacroAssembler* masm = new MacroAssembler(&buffer);
32203223

32213224
address start = __ pc();
32223225
int frame_size_in_bytes = 0;
32233226

32243227
RegisterSaver::ReturnPCLocation return_pc_location;
3225-
bool cause_return = (poll_type == POLL_AT_RETURN);
3228+
bool cause_return = (id == SharedStubId::polling_page_return_handler_id);
32263229
if (cause_return) {
32273230
// Nothing to do here. The frame has already been popped in MachEpilogNode.
32283231
// Register LR already contains the return pc.
@@ -3232,7 +3235,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
32323235
return_pc_location = RegisterSaver::return_pc_is_thread_saved_exception_pc;
32333236
}
32343237

3235-
bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);
3238+
bool save_vectors = (id == SharedStubId::polling_page_vectors_safepoint_handler_id);
32363239

32373240
// Save registers, fpu state, and flags. Set R31 = return pc.
32383241
map = RegisterSaver::push_frame_reg_args_and_save_live_registers(masm,
@@ -3319,11 +3322,13 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
33193322
// but since this is generic code we don't know what they are and the caller
33203323
// must do any gc of the args.
33213324
//
3322-
RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) {
3325+
RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) {
3326+
assert(is_resolve_id(id), "expected a resolve stub id");
33233327

33243328
// allocate space for the code
33253329
ResourceMark rm;
33263330

3331+
const char* name = SharedRuntime::stub_name(id);
33273332
CodeBuffer buffer(name, 1000, 512);
33283333
MacroAssembler* masm = new MacroAssembler(&buffer);
33293334

@@ -3421,7 +3426,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
34213426
// Note: the routine set_pc_not_at_call_for_caller in
34223427
// SharedRuntime.cpp requires that this code be generated into a
34233428
// RuntimeStub.
3424-
RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) {
3429+
RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) {
3430+
assert(is_throw_id(id), "expected a throw stub id");
3431+
3432+
const char* name = SharedRuntime::stub_name(id);
3433+
34253434
ResourceMark rm;
34263435
const char* timer_msg = "SharedRuntime generate_throw_exception";
34273436
TraceTime timer(timer_msg, TRACETIME_LOG(Info, startuptime));
@@ -3740,7 +3749,8 @@ void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints,
37403749
// It returns a jobject handle to the event writer.
37413750
// The handle is dereferenced and the return value is the event writer oop.
37423751
RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
3743-
CodeBuffer code("jfr_write_checkpoint", 512, 64);
3752+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id);
3753+
CodeBuffer code(name, 512, 64);
37443754
MacroAssembler* masm = new MacroAssembler(&code);
37453755

37463756
Register tmp1 = R10_ARG8;
@@ -3768,16 +3778,16 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
37683778
oop_maps->add_gc_map(calls_return_pc - start, map);
37693779

37703780
RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
3771-
RuntimeStub::new_runtime_stub(code.name(),
3772-
&code, frame_complete,
3781+
RuntimeStub::new_runtime_stub(name, &code, frame_complete,
37733782
(framesize >> (LogBytesPerWord - LogBytesPerInt)),
37743783
oop_maps, false);
37753784
return stub;
37763785
}
37773786

37783787
// For c2: call to return a leased buffer.
37793788
RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
3780-
CodeBuffer code("jfr_return_lease", 512, 64);
3789+
const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id);
3790+
CodeBuffer code(name, 512, 64);
37813791
MacroAssembler* masm = new MacroAssembler(&code);
37823792

37833793
Register tmp1 = R10_ARG8;
@@ -3803,8 +3813,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
38033813
oop_maps->add_gc_map(calls_return_pc - start, map);
38043814

38053815
RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
3806-
RuntimeStub::new_runtime_stub(code.name(),
3807-
&code, frame_complete,
3816+
RuntimeStub::new_runtime_stub(name, &code, frame_complete,
38083817
(framesize >> (LogBytesPerWord - LogBytesPerInt)),
38093818
oop_maps, false);
38103819
return stub;

0 commit comments

Comments
 (0)