Skip to content

Commit 3859faf

Browse files
author
Vladimir Kozlov
committed
8231349: Move intrinsic stubs generation to compiler runtime initialization code
Reviewed-by: redestad, vlivanov
1 parent f37674a commit 3859faf

38 files changed

+595
-352
lines changed

src/hotspot/cpu/aarch64/globals_aarch64.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
// (see globals.hpp)
3434

3535
define_pd_global(bool, ImplicitNullChecks, true); // Generate code for implicit null checks
36-
define_pd_global(bool, TrapBasedNullChecks, false);
36+
define_pd_global(bool, TrapBasedNullChecks, false);
3737
define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap NULLs past to check cast
3838

39+
define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI);
40+
3941
define_pd_global(uintx, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment.
4042
define_pd_global(intx, CodeEntryAlignment, 64);
4143
define_pd_global(intx, OptoLoopAlignment, 16);

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,26 +570,31 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
570570
// caller, but with an uncorrected stack, causing delayed havoc.
571571

572572
if (VerifyAdapterCalls &&
573-
(Interpreter::code() != NULL || StubRoutines::code1() != NULL)) {
573+
(Interpreter::code() != NULL || StubRoutines::final_stubs_code() != NULL)) {
574574
#if 0
575575
// So, let's test for cascading c2i/i2c adapters right now.
576576
// assert(Interpreter::contains($return_addr) ||
577577
// StubRoutines::contains($return_addr),
578578
// "i2c adapter must return to an interpreter frame");
579579
__ block_comment("verify_i2c { ");
580580
Label L_ok;
581-
if (Interpreter::code() != NULL)
581+
if (Interpreter::code() != NULL) {
582582
range_check(masm, rax, r11,
583583
Interpreter::code()->code_start(), Interpreter::code()->code_end(),
584584
L_ok);
585-
if (StubRoutines::code1() != NULL)
585+
}
586+
if (StubRoutines::initial_stubs_code() != NULL) {
586587
range_check(masm, rax, r11,
587-
StubRoutines::code1()->code_begin(), StubRoutines::code1()->code_end(),
588+
StubRoutines::initial_stubs_code()->code_begin(),
589+
StubRoutines::initial_stubs_code()->code_end(),
588590
L_ok);
589-
if (StubRoutines::code2() != NULL)
591+
}
592+
if (StubRoutines::final_stubs_code() != NULL) {
590593
range_check(masm, rax, r11,
591-
StubRoutines::code2()->code_begin(), StubRoutines::code2()->code_end(),
594+
StubRoutines::final_stubs_code()->code_begin(),
595+
StubRoutines::final_stubs_code()->code_end(),
592596
L_ok);
597+
}
593598
const char* msg = "i2c adapter must return to an interpreter frame";
594599
__ block_comment(msg);
595600
__ stop(msg);

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7997,7 +7997,7 @@ class StubGenerator: public StubCodeGenerator {
79977997

79987998

79997999
// Initialization
8000-
void generate_initial() {
8000+
void generate_initial_stubs() {
80018001
// Generate initial stubs and initializes the entry points
80028002

80038003
// entry points that exist in all platforms Note: This is code
@@ -8023,6 +8023,12 @@ class StubGenerator: public StubCodeGenerator {
80238023
generate_throw_exception("delayed StackOverflowError throw_exception",
80248024
CAST_FROM_FN_PTR(address,
80258025
SharedRuntime::throw_delayed_StackOverflowError));
8026+
8027+
// Initialize table for copy memory (arraycopy) check.
8028+
if (UnsafeCopyMemory::_table == nullptr) {
8029+
UnsafeCopyMemory::create_table(8);
8030+
}
8031+
80268032
if (UseCRC32Intrinsics) {
80278033
// set table address before stub generation which use it
80288034
StubRoutines::_crc_table_adr = (address)StubRoutines::aarch64::_crc_table;
@@ -8047,7 +8053,7 @@ class StubGenerator: public StubCodeGenerator {
80478053
}
80488054
}
80498055

8050-
void generate_phase1() {
8056+
void generate_continuation_stubs() {
80518057
// Continuation stubs:
80528058
StubRoutines::_cont_thaw = generate_cont_thaw();
80538059
StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
@@ -8057,7 +8063,7 @@ class StubGenerator: public StubCodeGenerator {
80578063
JFR_ONLY(StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();)
80588064
}
80598065

8060-
void generate_all() {
8066+
void generate_final_stubs() {
80618067
// support for verify_oop (must happen after universe_init)
80628068
if (VerifyOops) {
80638069
StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
@@ -8080,32 +8086,47 @@ class StubGenerator: public StubCodeGenerator {
80808086
SharedRuntime::
80818087
throw_NullPointerException_at_call));
80828088

8083-
if (UseSVE == 0) {
8084-
StubRoutines::aarch64::_vector_iota_indices = generate_iota_indices("iota_indices");
8085-
}
8086-
80878089
// arraycopy stubs used by compilers
80888090
generate_arraycopy_stubs();
80898091

8090-
// countPositives stub for large arrays.
8091-
StubRoutines::aarch64::_count_positives = generate_count_positives(StubRoutines::aarch64::_count_positives_long);
8092+
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
8093+
if (bs_nm != NULL) {
8094+
StubRoutines::aarch64::_method_entry_barrier = generate_method_entry_barrier();
8095+
}
8096+
8097+
StubRoutines::aarch64::_spin_wait = generate_spin_wait();
8098+
8099+
#if defined (LINUX) && !defined (__ARM_FEATURE_ATOMICS)
8100+
8101+
generate_atomic_entry_points();
8102+
8103+
#endif // LINUX
8104+
8105+
StubRoutines::aarch64::set_completed(); // Inidicate that arraycopy and zero_blocks stubs are generated
8106+
}
8107+
8108+
void generate_compiler_stubs() {
8109+
#if COMPILER2_OR_JVMCI
8110+
8111+
if (UseSVE == 0) {
8112+
StubRoutines::aarch64::_vector_iota_indices = generate_iota_indices("iota_indices");
8113+
}
80928114

80938115
// array equals stub for large arrays.
80948116
if (!UseSimpleArrayEquals) {
80958117
StubRoutines::aarch64::_large_array_equals = generate_large_array_equals();
80968118
}
80978119

8120+
// byte_array_inflate stub for large arrays.
8121+
StubRoutines::aarch64::_large_byte_array_inflate = generate_large_byte_array_inflate();
8122+
8123+
// countPositives stub for large arrays.
8124+
StubRoutines::aarch64::_count_positives = generate_count_positives(StubRoutines::aarch64::_count_positives_long);
8125+
80988126
generate_compare_long_strings();
80998127

81008128
generate_string_indexof_stubs();
81018129

8102-
// byte_array_inflate stub for large arrays.
8103-
StubRoutines::aarch64::_large_byte_array_inflate = generate_large_byte_array_inflate();
8104-
8105-
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
8106-
if (bs_nm != NULL) {
8107-
StubRoutines::aarch64::_method_entry_barrier = generate_method_entry_barrier();
8108-
}
81098130
#ifdef COMPILER2
81108131
if (UseMultiplyToLenIntrinsic) {
81118132
StubRoutines::_multiplyToLen = generate_multiplyToLen();
@@ -8192,36 +8213,33 @@ class StubGenerator: public StubCodeGenerator {
81928213
if (UseAdler32Intrinsics) {
81938214
StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32();
81948215
}
8195-
8196-
StubRoutines::aarch64::_spin_wait = generate_spin_wait();
8197-
8198-
#if defined (LINUX) && !defined (__ARM_FEATURE_ATOMICS)
8199-
8200-
generate_atomic_entry_points();
8201-
8202-
#endif // LINUX
8203-
8204-
StubRoutines::aarch64::set_completed();
8216+
#endif // COMPILER2_OR_JVMCI
82058217
}
82068218

82078219
public:
8208-
StubGenerator(CodeBuffer* code, int phase) : StubCodeGenerator(code) {
8209-
if (phase == 0) {
8210-
generate_initial();
8211-
} else if (phase == 1) {
8212-
generate_phase1(); // stubs that must be available for the interpreter
8213-
} else {
8214-
generate_all();
8215-
}
8220+
StubGenerator(CodeBuffer* code, StubsKind kind) : StubCodeGenerator(code) {
8221+
switch(kind) {
8222+
case Initial_stubs:
8223+
generate_initial_stubs();
8224+
break;
8225+
case Continuation_stubs:
8226+
generate_continuation_stubs();
8227+
break;
8228+
case Compiler_stubs:
8229+
generate_compiler_stubs();
8230+
break;
8231+
case Final_stubs:
8232+
generate_final_stubs();
8233+
break;
8234+
default:
8235+
fatal("unexpected stubs kind: %d", kind);
8236+
break;
8237+
};
82168238
}
82178239
}; // end class declaration
82188240

8219-
#define UCM_TABLE_MAX_ENTRIES 8
8220-
void StubGenerator_generate(CodeBuffer* code, int phase) {
8221-
if (UnsafeCopyMemory::_table == NULL) {
8222-
UnsafeCopyMemory::create_table(UCM_TABLE_MAX_ENTRIES);
8223-
}
8224-
StubGenerator g(code, phase);
8241+
void StubGenerator_generate(CodeBuffer* code, StubCodeGenerator::StubsKind kind) {
8242+
StubGenerator g(code, kind);
82258243
}
82268244

82278245

src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -35,8 +35,11 @@ static bool returns_to_call_stub(address return_pc) {
3535
}
3636

3737
enum platform_dependent_constants {
38-
code_size1 = 19000, // simply increase if too small (assembler will crash if too small)
39-
code_size2 = 45000 // simply increase if too small (assembler will crash if too small)
38+
// simply increase sizes if too small (assembler will crash if too small)
39+
_initial_stubs_code_size = 10000,
40+
_continuation_stubs_code_size = 2000,
41+
_compiler_stubs_code_size = 30000,
42+
_final_stubs_code_size = 20000
4043
};
4144

4245
class aarch64 {

src/hotspot/cpu/arm/globals_arm.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for i
3434
define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls past to check cast
3535
define_pd_global(bool, TrapBasedNullChecks, false); // Not needed
3636

37+
define_pd_global(bool, DelayCompilerStubsGeneration, false); // No need - only few compiler's stubs
38+
3739
define_pd_global(uintx, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment.
3840
define_pd_global(intx, CodeEntryAlignment, 16);
3941
define_pd_global(intx, OptoLoopAlignment, 16);

src/hotspot/cpu/arm/stubGenerator_arm.cpp

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,7 +3077,7 @@ class StubGenerator: public StubCodeGenerator {
30773077
//---------------------------------------------------------------------------
30783078
// Initialization
30793079

3080-
void generate_initial() {
3080+
void generate_initial_stubs() {
30813081
// Generates all stubs and initializes the entry points
30823082

30833083
//------------------------------------------------------------------------------------------------------------------------
@@ -3094,6 +3094,10 @@ class StubGenerator: public StubCodeGenerator {
30943094
// stub for throwing stack overflow error used both by interpreter and compiler
30953095
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
30963096

3097+
if (UnsafeCopyMemory::_table == nullptr) {
3098+
UnsafeCopyMemory::create_table(32);
3099+
}
3100+
30973101
// integer division used both by interpreter and compiler
30983102
StubRoutines::Arm::_idiv_irem_entry = generate_idiv_irem();
30993103

@@ -3106,7 +3110,7 @@ class StubGenerator: public StubCodeGenerator {
31063110

31073111
}
31083112

3109-
void generate_phase1() {
3113+
void generate_continuation_stubs() {
31103114
// Continuation stubs:
31113115
StubRoutines::_cont_thaw = generate_cont_thaw();
31123116
StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
@@ -3116,14 +3120,9 @@ class StubGenerator: public StubCodeGenerator {
31163120
JFR_ONLY(StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();)
31173121
}
31183122

3119-
void generate_all() {
3123+
void generate_final_stubs() {
31203124
// Generates all stubs and initializes the entry points
31213125

3122-
#ifdef COMPILER2
3123-
// Generate partial_subtype_check first here since its code depends on
3124-
// UseZeroBaseCompressedOops which is defined after heap initialization.
3125-
StubRoutines::Arm::_partial_subtype_check = generate_partial_subtype_check();
3126-
#endif
31273126
// These entry points require SharedInfo::stack0 to be set up in non-core builds
31283127
// and need to be relocatable, so they each fabricate a RuntimeStub internally.
31293128
StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
@@ -3144,6 +3143,14 @@ class StubGenerator: public StubCodeGenerator {
31443143
StubRoutines::Arm::_method_entry_barrier = generate_method_entry_barrier();
31453144
}
31463145

3146+
}
3147+
3148+
void generate_compiler_stubs() {
3149+
#ifdef COMPILER2
3150+
// Generate partial_subtype_check first here since its code depends on
3151+
// UseZeroBaseCompressedOops which is defined after heap initialization.
3152+
StubRoutines::Arm::_partial_subtype_check = generate_partial_subtype_check();
3153+
31473154
#ifdef COMPILE_CRYPTO
31483155
// generate AES intrinsics code
31493156
if (UseAESIntrinsics) {
@@ -3154,25 +3161,31 @@ class StubGenerator: public StubCodeGenerator {
31543161
StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt();
31553162
}
31563163
#endif // COMPILE_CRYPTO
3164+
#endif // COMPILER2
31573165
}
31583166

3159-
31603167
public:
3161-
StubGenerator(CodeBuffer* code, int phase) : StubCodeGenerator(code) {
3162-
if (phase == 0) {
3163-
generate_initial();
3164-
} else if (phase == 1) {
3165-
generate_phase1();
3166-
} else {
3167-
generate_all();
3168-
}
3168+
StubGenerator(CodeBuffer* code, StubsKind kind) : StubCodeGenerator(code) {
3169+
switch(kind) {
3170+
case Initial_stubs:
3171+
generate_initial_stubs();
3172+
break;
3173+
case Continuation_stubs:
3174+
generate_continuation_stubs();
3175+
break;
3176+
case Compiler_stubs:
3177+
generate_compiler_stubs();
3178+
break;
3179+
case Final_stubs:
3180+
generate_final_stubs();
3181+
break;
3182+
default:
3183+
fatal("unexpected stubs kind: %d", kind);
3184+
break;
3185+
};
31693186
}
31703187
}; // end class declaration
31713188

3172-
#define UCM_TABLE_MAX_ENTRIES 32
3173-
void StubGenerator_generate(CodeBuffer* code, int phase) {
3174-
if (UnsafeCopyMemory::_table == nullptr) {
3175-
UnsafeCopyMemory::create_table(UCM_TABLE_MAX_ENTRIES);
3176-
}
3177-
StubGenerator g(code, phase);
3189+
void StubGenerator_generate(CodeBuffer* code, StubCodeGenerator::StubsKind kind) {
3190+
StubGenerator g(code, kind);
31783191
}

src/hotspot/cpu/arm/stubRoutines_arm.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -30,8 +30,11 @@
3030
// extend it.
3131

3232
enum platform_dependent_constants {
33-
code_size1 = 9000, // simply increase if too small (assembler will crash if too small)
34-
code_size2 = 22000 // simply increase if too small (assembler will crash if too small)
33+
// simply increase sizes if too small (assembler will crash if too small)
34+
_initial_stubs_code_size = 9000,
35+
_continuation_stubs_code_size = 2000,
36+
_compiler_stubs_code_size = 22000,
37+
_final_stubs_code_size = 22000
3538
};
3639

3740
class Arm {

src/hotspot/cpu/ppc/globals_ppc.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -36,6 +36,8 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for impli
3636
define_pd_global(bool, TrapBasedNullChecks, true);
3737
define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap NULLs passed to check cast.
3838

39+
define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI);
40+
3941
#define DEFAULT_STACK_YELLOW_PAGES (2)
4042
#define DEFAULT_STACK_RED_PAGES (1)
4143
// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the

0 commit comments

Comments
 (0)