Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/hotspot/share/classfile/vmIntrinsics.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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 @@ -36,31 +36,31 @@
#include "utilities/tribool.hpp"

// These are flag-matching functions:
inline bool match_F_R(jshort flags) {
inline bool match_F_R(u2 flags) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish more code could be size-agnostic. So instead of using u2 here, there could be a typedef in accessFlags.hpp that we could use that hides the size. However, it's not a big deal, because it seems unlikely this type will change much in the future without a JVM spec change. I'm tempted to suggesting using AccessFlags here, but it's a class. Since this is an end-point "consumer" of the type that doesn't store it or pass it along, we could even use something like uint here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good idea if this weren't so limited. I did chat with DanH. to see if access flags will ever grow in size from u2 and he was doubtful that would ever happen. uint would work here too, but this small use might prevent some future -Wconversion warnings and doesn't hurt anything.
Thank you for reviewing.

const int req = 0;
const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED | JVM_ACC_NATIVE;
return (flags & (req | neg)) == req;
}

inline bool match_F_Y(jshort flags) {
inline bool match_F_Y(u2 flags) {
const int req = JVM_ACC_SYNCHRONIZED;
const int neg = JVM_ACC_STATIC | JVM_ACC_NATIVE;
return (flags & (req | neg)) == req;
}

inline bool match_F_RN(jshort flags) {
inline bool match_F_RN(u2 flags) {
const int req = JVM_ACC_NATIVE;
const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED;
return (flags & (req | neg)) == req;
}

inline bool match_F_S(jshort flags) {
inline bool match_F_S(u2 flags) {
const int req = JVM_ACC_STATIC;
const int neg = JVM_ACC_SYNCHRONIZED | JVM_ACC_NATIVE;
return (flags & (req | neg)) == req;
}

inline bool match_F_SN(jshort flags) {
inline bool match_F_SN(u2 flags) {
const int req = JVM_ACC_STATIC | JVM_ACC_NATIVE;
const int neg = JVM_ACC_SYNCHRONIZED;
return (flags & (req | neg)) == req;
Expand Down Expand Up @@ -711,7 +711,7 @@ bool vmIntrinsics::is_disabled_by_flags(vmIntrinsics::ID id) {
vmIntrinsics::ID vmIntrinsics::find_id_impl(vmSymbolID holder,
vmSymbolID name,
vmSymbolID sig,
jshort flags) {
u2 flags) {
assert((int)vmSymbolID::SID_LIMIT <= (1<<vmSymbols::log2_SID_LIMIT), "must fit");

// Let the C compiler build the decision tree.
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/vmIntrinsics.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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 @@ -1494,7 +1494,7 @@ class vmIntrinsics : AllStatic {
static ID find_id_impl(vmSymbolID holder,
vmSymbolID name,
vmSymbolID sig,
jshort flags);
u2 flags);

// check if the intrinsic is disabled by course-grained flags.
static bool disabled_by_jvm_flags(vmIntrinsics::ID id);
Expand All @@ -1505,7 +1505,7 @@ class vmIntrinsics : AllStatic {
static ID find_id(vmSymbolID holder,
vmSymbolID name,
vmSymbolID sig,
jshort flags) {
u2 flags) {
ID id = find_id_impl(holder, name, sig, flags);
#ifdef ASSERT
// ID _none does not hold the following asserts.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/method.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 @@ -1652,8 +1652,8 @@ void Method::init_intrinsic_id(vmSymbolID klass_id) {
&& sig_id == vmSymbolID::NO_SID) {
return;
}
jshort flags = checked_cast<jshort>(access_flags().as_unsigned_short());

u2 flags = access_flags().as_unsigned_short();
vmIntrinsics::ID id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
if (id != vmIntrinsics::_none) {
set_intrinsic_id(id);
Expand Down