Skip to content

Commit 0b17e00

Browse files
Harshit470250dean-long
authored andcommitted
8347396: Efficient TypeFunc creations
Reviewed-by: dlong, vlivanov, adinn
1 parent 3a109f4 commit 0b17e00

5 files changed

Lines changed: 67 additions & 8 deletions

File tree

src/hotspot/share/gc/shared/c2/barrierSetC2.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,10 @@ Node* BarrierSetC2::obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobi
813813
return old_tlab_top;
814814
}
815815

816-
static const TypeFunc* clone_type() {
816+
const TypeFunc* BarrierSetC2::_clone_type_Type = nullptr;
817+
818+
void BarrierSetC2::make_clone_type() {
819+
assert(BarrierSetC2::_clone_type_Type == nullptr, "should be");
817820
// Create input type (domain)
818821
int argcnt = NOT_LP64(3) LP64_ONLY(4);
819822
const Type** const domain_fields = TypeTuple::fields(argcnt);
@@ -829,7 +832,12 @@ static const TypeFunc* clone_type() {
829832
const Type** const range_fields = TypeTuple::fields(0);
830833
const TypeTuple* const range = TypeTuple::make(TypeFunc::Parms + 0, range_fields);
831834

832-
return TypeFunc::make(domain, range);
835+
BarrierSetC2::_clone_type_Type = TypeFunc::make(domain, range);
836+
}
837+
838+
inline const TypeFunc* BarrierSetC2::clone_type() {
839+
assert(BarrierSetC2::_clone_type_Type != nullptr, "should be initialized");
840+
return BarrierSetC2::_clone_type_Type;
833841
}
834842

835843
#define XTOP LP64_ONLY(COMMA phase->top())

src/hotspot/share/gc/shared/c2/barrierSetC2.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ class BarrierStubC2 : public ArenaObj {
270270
// various GC barrier sets inherit from the BarrierSetC2 class to sprinkle
271271
// barriers into the accesses.
272272
class BarrierSetC2: public CHeapObj<mtGC> {
273+
private:
274+
static const TypeFunc* _clone_type_Type;
275+
273276
protected:
274277
virtual void resolve_address(C2Access& access) const;
275278
virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;
@@ -379,6 +382,9 @@ class BarrierSetC2: public CHeapObj<mtGC> {
379382

380383
static int arraycopy_payload_base_offset(bool is_array);
381384

385+
static void make_clone_type();
386+
static const TypeFunc* clone_type();
387+
382388
#ifndef PRODUCT
383389
virtual void dump_barrier_data(const MachNode* mach, outputStream* st) const {
384390
st->print("%x", mach->barrier_data());

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,33 @@ void ShenandoahBarrierSetC2::post_barrier(GraphKit* kit,
519519

520520
#undef __
521521

522-
const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() {
522+
const TypeFunc* ShenandoahBarrierSetC2::_write_barrier_pre_Type = nullptr;
523+
const TypeFunc* ShenandoahBarrierSetC2::_clone_barrier_Type = nullptr;
524+
const TypeFunc* ShenandoahBarrierSetC2::_load_reference_barrier_Type = nullptr;
525+
526+
inline const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() {
527+
assert(ShenandoahBarrierSetC2::_write_barrier_pre_Type != nullptr, "should be initialized");
528+
return ShenandoahBarrierSetC2::_write_barrier_pre_Type;
529+
}
530+
531+
inline const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() {
532+
assert(ShenandoahBarrierSetC2::_clone_barrier_Type != nullptr, "should be initialized");
533+
return ShenandoahBarrierSetC2::_clone_barrier_Type;
534+
}
535+
536+
const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() {
537+
assert(ShenandoahBarrierSetC2::_load_reference_barrier_Type != nullptr, "should be initialized");
538+
return ShenandoahBarrierSetC2::_load_reference_barrier_Type;
539+
}
540+
541+
void ShenandoahBarrierSetC2::init() {
542+
ShenandoahBarrierSetC2::make_write_barrier_pre_Type();
543+
ShenandoahBarrierSetC2::make_clone_barrier_Type();
544+
ShenandoahBarrierSetC2::make_load_reference_barrier_Type();
545+
}
546+
547+
void ShenandoahBarrierSetC2::make_write_barrier_pre_Type() {
548+
assert(ShenandoahBarrierSetC2::_write_barrier_pre_Type == nullptr, "should be");
523549
const Type **fields = TypeTuple::fields(1);
524550
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value
525551
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
@@ -528,10 +554,11 @@ const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() {
528554
fields = TypeTuple::fields(0);
529555
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
530556

531-
return TypeFunc::make(domain, range);
557+
ShenandoahBarrierSetC2::_write_barrier_pre_Type = TypeFunc::make(domain, range);
532558
}
533559

534-
const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() {
560+
void ShenandoahBarrierSetC2::make_clone_barrier_Type() {
561+
assert(ShenandoahBarrierSetC2::_clone_barrier_Type == nullptr, "should be");
535562
const Type **fields = TypeTuple::fields(1);
536563
fields[TypeFunc::Parms+0] = TypeOopPtr::NOTNULL; // src oop
537564
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
@@ -540,10 +567,11 @@ const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() {
540567
fields = TypeTuple::fields(0);
541568
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
542569

543-
return TypeFunc::make(domain, range);
570+
ShenandoahBarrierSetC2::_clone_barrier_Type = TypeFunc::make(domain, range);
544571
}
545572

546-
const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() {
573+
void ShenandoahBarrierSetC2::make_load_reference_barrier_Type() {
574+
assert(ShenandoahBarrierSetC2::_load_reference_barrier_Type == nullptr, "should be");
547575
const Type **fields = TypeTuple::fields(2);
548576
fields[TypeFunc::Parms+0] = TypeOopPtr::BOTTOM; // original field value
549577
fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address
@@ -555,7 +583,7 @@ const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() {
555583
fields[TypeFunc::Parms+0] = TypeOopPtr::BOTTOM;
556584
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
557585

558-
return TypeFunc::make(domain, range);
586+
ShenandoahBarrierSetC2::_load_reference_barrier_Type = TypeFunc::make(domain, range);
559587
}
560588

561589
Node* ShenandoahBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const {

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ class ShenandoahBarrierSetC2 : public BarrierSetC2 {
8282

8383
static bool clone_needs_barrier(Node* src, PhaseGVN& gvn);
8484

85+
static const TypeFunc* _write_barrier_pre_Type;
86+
static const TypeFunc* _clone_barrier_Type;
87+
static const TypeFunc* _load_reference_barrier_Type;
88+
static void make_write_barrier_pre_Type();
89+
static void make_clone_barrier_Type();
90+
static void make_load_reference_barrier_Type();
91+
8592
protected:
8693
virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;
8794
virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;
@@ -106,6 +113,8 @@ class ShenandoahBarrierSetC2 : public BarrierSetC2 {
106113
static const TypeFunc* write_barrier_pre_Type();
107114
static const TypeFunc* clone_barrier_Type();
108115
static const TypeFunc* load_reference_barrier_Type();
116+
static void init();
117+
109118
virtual bool has_load_barrier_nodes() const { return true; }
110119

111120
// This is the entry-point for the backend to perform accesses through the Access API.

src/hotspot/share/opto/type.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#include "utilities/ostream.hpp"
5050
#include "utilities/powerOfTwo.hpp"
5151
#include "utilities/stringUtils.hpp"
52+
#if INCLUDE_SHENANDOAHGC
53+
#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
54+
#endif // INCLUDE_SHENANDOAHGC
5255

5356
// Portions of code courtesy of Clifford Click
5457

@@ -732,6 +735,11 @@ void Type::Initialize_shared(Compile* current) {
732735
mreg2type[Op_VecY] = TypeVect::VECTY;
733736
mreg2type[Op_VecZ] = TypeVect::VECTZ;
734737

738+
#if INCLUDE_SHENANDOAHGC
739+
ShenandoahBarrierSetC2::init();
740+
#endif //INCLUDE_SHENANDOAHGC
741+
742+
BarrierSetC2::make_clone_type();
735743
LockNode::initialize_lock_Type();
736744
ArrayCopyNode::initialize_arraycopy_Type();
737745
OptoRuntime::initialize_types();

0 commit comments

Comments
 (0)