Skip to content

Commit e41fd73

Browse files
committed
8266252: Streamline AbstractInterpreter::method_kind
Reviewed-by: iklam, coleenp
1 parent b823b3e commit e41fd73

File tree

4 files changed

+57
-62
lines changed

4 files changed

+57
-62
lines changed

src/hotspot/share/compiler/compilerOracle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "memory/oopFactory.hpp"
3333
#include "memory/resourceArea.hpp"
3434
#include "oops/klass.hpp"
35-
#include "oops/method.hpp"
35+
#include "oops/method.inline.hpp"
3636
#include "oops/symbol.hpp"
3737
#include "runtime/globals_extension.hpp"
3838
#include "runtime/handles.inline.hpp"

src/hotspot/share/interpreter/abstractInterpreter.cpp

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "oops/constantPool.hpp"
4040
#include "oops/cpCache.inline.hpp"
4141
#include "oops/methodData.hpp"
42-
#include "oops/method.hpp"
42+
#include "oops/method.inline.hpp"
4343
#include "oops/oop.inline.hpp"
4444
#include "prims/forte.hpp"
4545
#include "prims/jvmtiExport.hpp"
@@ -110,36 +110,61 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHan
110110
if (m->is_abstract()) return abstract;
111111

112112
// Method handle primitive?
113-
if (m->is_method_handle_intrinsic()) {
114-
vmIntrinsics::ID id = m->intrinsic_id();
115-
assert(MethodHandles::is_signature_polymorphic(id), "must match an intrinsic");
116-
MethodKind kind = (MethodKind)(method_handle_invoke_FIRST +
117-
vmIntrinsics::as_int(id) -
118-
static_cast<int>(vmIntrinsics::FIRST_MH_SIG_POLY));
119-
assert(kind <= method_handle_invoke_LAST, "parallel enum ranges");
120-
return kind;
121-
}
113+
vmIntrinsics::ID iid = m->intrinsic_id();
114+
if (iid != vmIntrinsics::_none) {
115+
if (m->is_method_handle_intrinsic()) {
116+
assert(MethodHandles::is_signature_polymorphic(iid), "must match an intrinsic");
117+
MethodKind kind = (MethodKind)(method_handle_invoke_FIRST +
118+
vmIntrinsics::as_int(iid) -
119+
static_cast<int>(vmIntrinsics::FIRST_MH_SIG_POLY));
120+
assert(kind <= method_handle_invoke_LAST, "parallel enum ranges");
121+
return kind;
122+
}
122123

124+
switch (iid) {
123125
#ifndef ZERO
124-
switch (m->intrinsic_id()) {
125-
// Use optimized stub code for CRC32 native methods.
126-
case vmIntrinsics::_updateCRC32 : return java_util_zip_CRC32_update;
127-
case vmIntrinsics::_updateBytesCRC32 : return java_util_zip_CRC32_updateBytes;
128-
case vmIntrinsics::_updateByteBufferCRC32 : return java_util_zip_CRC32_updateByteBuffer;
129-
// Use optimized stub code for CRC32C methods.
130-
case vmIntrinsics::_updateBytesCRC32C : return java_util_zip_CRC32C_updateBytes;
131-
case vmIntrinsics::_updateDirectByteBufferCRC32C : return java_util_zip_CRC32C_updateDirectByteBuffer;
132-
case vmIntrinsics::_intBitsToFloat: return java_lang_Float_intBitsToFloat;
133-
case vmIntrinsics::_floatToRawIntBits: return java_lang_Float_floatToRawIntBits;
134-
case vmIntrinsics::_longBitsToDouble: return java_lang_Double_longBitsToDouble;
135-
case vmIntrinsics::_doubleToRawLongBits: return java_lang_Double_doubleToRawLongBits;
136-
default: break;
137-
}
126+
// Use optimized stub code for CRC32 native methods.
127+
case vmIntrinsics::_updateCRC32: return java_util_zip_CRC32_update;
128+
case vmIntrinsics::_updateBytesCRC32: return java_util_zip_CRC32_updateBytes;
129+
case vmIntrinsics::_updateByteBufferCRC32: return java_util_zip_CRC32_updateByteBuffer;
130+
// Use optimized stub code for CRC32C methods.
131+
case vmIntrinsics::_updateBytesCRC32C: return java_util_zip_CRC32C_updateBytes;
132+
case vmIntrinsics::_updateDirectByteBufferCRC32C: return java_util_zip_CRC32C_updateDirectByteBuffer;
133+
case vmIntrinsics::_intBitsToFloat: return java_lang_Float_intBitsToFloat;
134+
case vmIntrinsics::_floatToRawIntBits: return java_lang_Float_floatToRawIntBits;
135+
case vmIntrinsics::_longBitsToDouble: return java_lang_Double_longBitsToDouble;
136+
case vmIntrinsics::_doubleToRawLongBits: return java_lang_Double_doubleToRawLongBits;
138137
#endif // ZERO
138+
case vmIntrinsics::_dsin: return java_lang_math_sin;
139+
case vmIntrinsics::_dcos: return java_lang_math_cos;
140+
case vmIntrinsics::_dtan: return java_lang_math_tan;
141+
case vmIntrinsics::_dabs: return java_lang_math_abs;
142+
case vmIntrinsics::_dlog: return java_lang_math_log;
143+
case vmIntrinsics::_dlog10: return java_lang_math_log10;
144+
case vmIntrinsics::_dpow: return java_lang_math_pow;
145+
case vmIntrinsics::_dexp: return java_lang_math_exp;
146+
case vmIntrinsics::_fmaD: return java_lang_math_fmaD;
147+
case vmIntrinsics::_fmaF: return java_lang_math_fmaF;
148+
case vmIntrinsics::_Reference_get: return java_lang_ref_reference_get;
149+
case vmIntrinsics::_dsqrt:
150+
// _dsqrt will be selected for both Math::sqrt and StrictMath::sqrt, but the latter
151+
// is native. Keep treating it like a native method in the interpreter
152+
assert(m->name() == vmSymbols::sqrt_name() &&
153+
(m->klass_name() == vmSymbols::java_lang_Math() ||
154+
m->klass_name() == vmSymbols::java_lang_StrictMath()), "must be");
155+
return m->is_native() ? native : java_lang_math_sqrt;
156+
case vmIntrinsics::_Object_init:
157+
if (RegisterFinalizersAtInit && m->code_size() == 1) {
158+
// We need to execute the special return bytecode to check for
159+
// finalizer registration so create a normal frame.
160+
return zerolocals;
161+
}
162+
break;
163+
default: break;
164+
}
165+
}
139166

140167
// Native method?
141-
// Note: This test must come _before_ the test for intrinsic
142-
// methods. See also comments below.
143168
if (m->is_native()) {
144169
assert(!m->is_method_handle_intrinsic(), "overlapping bits here, watch out");
145170
return m->is_synchronized() ? native_synchronized : native;
@@ -150,41 +175,11 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHan
150175
return zerolocals_synchronized;
151176
}
152177

153-
if (RegisterFinalizersAtInit && m->code_size() == 1 &&
154-
m->intrinsic_id() == vmIntrinsics::_Object_init) {
155-
// We need to execute the special return bytecode to check for
156-
// finalizer registration so create a normal frame.
157-
return zerolocals;
158-
}
159-
160178
// Empty method?
161179
if (m->is_empty_method()) {
162180
return empty;
163181
}
164182

165-
// Special intrinsic method?
166-
// Note: This test must come _after_ the test for native methods,
167-
// otherwise we will run into problems with JDK 1.2, see also
168-
// TemplateInterpreterGenerator::generate_method_entry() for
169-
// for details.
170-
switch (m->intrinsic_id()) {
171-
case vmIntrinsics::_dsin : return java_lang_math_sin ;
172-
case vmIntrinsics::_dcos : return java_lang_math_cos ;
173-
case vmIntrinsics::_dtan : return java_lang_math_tan ;
174-
case vmIntrinsics::_dabs : return java_lang_math_abs ;
175-
case vmIntrinsics::_dsqrt : return java_lang_math_sqrt ;
176-
case vmIntrinsics::_dlog : return java_lang_math_log ;
177-
case vmIntrinsics::_dlog10: return java_lang_math_log10;
178-
case vmIntrinsics::_dpow : return java_lang_math_pow ;
179-
case vmIntrinsics::_dexp : return java_lang_math_exp ;
180-
case vmIntrinsics::_fmaD : return java_lang_math_fmaD ;
181-
case vmIntrinsics::_fmaF : return java_lang_math_fmaF ;
182-
183-
case vmIntrinsics::_Reference_get
184-
: return java_lang_ref_reference_get;
185-
default : break;
186-
}
187-
188183
// Getter method?
189184
if (m->is_getter()) {
190185
return getter;

src/hotspot/share/oops/method.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,6 @@ void Method::compute_from_signature(Symbol* sig) {
620620
constMethod()->set_fingerprint(fp.fingerprint());
621621
}
622622

623-
bool Method::is_empty_method() const {
624-
return code_size() == 1
625-
&& *code_base() == Bytecodes::_return;
626-
}
627-
628623
bool Method::is_vanilla_constructor() const {
629624
// Returns true if this method is a vanilla constructor, i.e. an "<init>" "()V" method
630625
// which only calls the superclass vanilla constructor and possibly does stores of

src/hotspot/share/oops/method.inline.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ inline void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
8383

8484
inline bool Method::has_compiled_code() const { return code() != NULL; }
8585

86+
inline bool Method::is_empty_method() const {
87+
return code_size() == 1
88+
&& *code_base() == Bytecodes::_return;
89+
}
90+
8691
#endif // SHARE_OOPS_METHOD_INLINE_HPP

0 commit comments

Comments
 (0)