Skip to content

Commit

Permalink
8330851: C2: More efficient TypeFunc creation
Browse files Browse the repository at this point in the history
Reviewed-by: vlivanov, dlong
  • Loading branch information
offamitkumar committed Jan 17, 2025
1 parent a3eef6c commit f5573f5
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 256 deletions.
4 changes: 3 additions & 1 deletion src/hotspot/share/opto/arraycopynode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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
Expand Down Expand Up @@ -33,6 +33,8 @@
#include "utilities/macros.hpp"
#include "utilities/powerOfTwo.hpp"

const TypeFunc* ArrayCopyNode::_arraycopy_type_Type = nullptr;

ArrayCopyNode::ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard)
: CallNode(arraycopy_type(), nullptr, TypePtr::BOTTOM),
_kind(None),
Expand Down
14 changes: 12 additions & 2 deletions src/hotspot/share/opto/arraycopynode.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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
Expand Down Expand Up @@ -31,6 +31,7 @@
class GraphKit;

class ArrayCopyNode : public CallNode {
static const TypeFunc* _arraycopy_type_Type;
private:

// What kind of arraycopy variant is this?
Expand Down Expand Up @@ -65,7 +66,15 @@ class ArrayCopyNode : public CallNode {

bool _arguments_validated;

public:

static const TypeFunc* arraycopy_type() {
assert(_arraycopy_type_Type != nullptr, "should be initialized");
return _arraycopy_type_Type;
}

static void initialize_arraycopy_Type() {
assert(_arraycopy_type_Type == nullptr, "should be");
const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
fields[Src] = TypeInstPtr::BOTTOM;
fields[SrcPos] = TypeInt::INT;
Expand All @@ -83,9 +92,10 @@ class ArrayCopyNode : public CallNode {

const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);

return TypeFunc::make(domain, range);
_arraycopy_type_Type = TypeFunc::make(domain, range);
}

private:
ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard);

intptr_t get_length_if_constant(PhaseGVN *phase) const;
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/opto/callnode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
Expand Down Expand Up @@ -1666,6 +1666,8 @@ Node *AllocateArrayNode::make_ideal_length(const TypeOopPtr* oop_type, PhaseValu
}

//=============================================================================
const TypeFunc* LockNode::_lock_type_Type = nullptr;

uint LockNode::size_of() const { return sizeof(*this); }

// Redundant lock elimination
Expand Down
13 changes: 10 additions & 3 deletions src/hotspot/share/opto/callnode.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
Expand Down Expand Up @@ -1190,9 +1190,16 @@ class AbstractLockNode: public CallNode {
// 2 - a FastLockNode
//
class LockNode : public AbstractLockNode {
static const TypeFunc* _lock_type_Type;
public:

static const TypeFunc *lock_type() {
static inline const TypeFunc* lock_type() {
assert(_lock_type_Type != nullptr, "should be initialized");
return _lock_type_Type;
}

static void initialize_lock_Type() {
assert(_lock_type_Type == nullptr, "should be called once");
// create input type (domain)
const Type **fields = TypeTuple::fields(3);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
Expand All @@ -1205,7 +1212,7 @@ class LockNode : public AbstractLockNode {

const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);

return TypeFunc::make(domain,range);
_lock_type_Type = TypeFunc::make(domain,range);
}

virtual int Opcode() const;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/library_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5137,7 +5137,7 @@ bool LibraryCallKit::inline_unsafe_setMemory() {

// Call it. Note that the length argument is not scaled.
make_runtime_call(flags,
OptoRuntime::make_setmemory_Type(),
OptoRuntime::unsafe_setmemory_Type(),
StubRoutines::unsafe_setmemory(),
"unsafe_setmemory",
dst_type,
Expand Down
Loading

0 comments on commit f5573f5

Please sign in to comment.