mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8166806: Add intrinsic support for writer used in event based tracing
Reviewed-by: kvn, egahlin
This commit is contained in:
parent
2069d6b6b3
commit
1175b7f1c8
6 changed files with 64 additions and 0 deletions
|
@ -223,6 +223,7 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
|
|||
case vmIntrinsics::_putCharStringU:
|
||||
#ifdef TRACE_HAVE_INTRINSICS
|
||||
case vmIntrinsics::_counterTime:
|
||||
case vmIntrinsics::_getBufferWriter:
|
||||
#if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT)
|
||||
case vmIntrinsics::_getClassId:
|
||||
#endif
|
||||
|
|
|
@ -3120,6 +3120,22 @@ void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
|
|||
|
||||
__ move(id, rlock_result(x));
|
||||
}
|
||||
|
||||
void LIRGenerator::do_getBufferWriter(Intrinsic* x) {
|
||||
LabelObj* L_end = new LabelObj();
|
||||
|
||||
LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
|
||||
in_bytes(TRACE_THREAD_DATA_WRITER_OFFSET),
|
||||
T_OBJECT);
|
||||
LIR_Opr result = rlock_result(x);
|
||||
__ move_wide(jobj_addr, result);
|
||||
__ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
|
||||
__ branch(lir_cond_equal, T_OBJECT, L_end->label());
|
||||
__ move_wide(new LIR_Address(result, T_OBJECT), result);
|
||||
|
||||
__ branch_destination(L_end->label());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -3151,6 +3167,9 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) {
|
|||
case vmIntrinsics::_getClassId:
|
||||
do_ClassIDIntrinsic(x);
|
||||
break;
|
||||
case vmIntrinsics::_getBufferWriter:
|
||||
do_getBufferWriter(x);
|
||||
break;
|
||||
case vmIntrinsics::_counterTime:
|
||||
do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), x);
|
||||
break;
|
||||
|
|
|
@ -441,6 +441,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
|
|||
|
||||
#ifdef TRACE_HAVE_INTRINSICS
|
||||
void do_ClassIDIntrinsic(Intrinsic* x);
|
||||
void do_getBufferWriter(Intrinsic* x);
|
||||
#endif
|
||||
|
||||
void do_RuntimeCall(address routine, Intrinsic* x);
|
||||
|
|
|
@ -537,6 +537,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
|
|||
#ifdef TRACE_HAVE_INTRINSICS
|
||||
case vmIntrinsics::_counterTime:
|
||||
case vmIntrinsics::_getClassId:
|
||||
case vmIntrinsics::_getBufferWriter:
|
||||
#endif
|
||||
case vmIntrinsics::_currentTimeMillis:
|
||||
case vmIntrinsics::_nanoTime:
|
||||
|
|
|
@ -256,6 +256,7 @@ class LibraryCallKit : public GraphKit {
|
|||
bool inline_native_time_funcs(address method, const char* funcName);
|
||||
#ifdef TRACE_HAVE_INTRINSICS
|
||||
bool inline_native_classID();
|
||||
bool inline_native_getBufferWriter();
|
||||
#endif
|
||||
bool inline_native_isInterrupted();
|
||||
bool inline_native_Class_query(vmIntrinsics::ID id);
|
||||
|
@ -713,6 +714,7 @@ bool LibraryCallKit::try_to_inline(int predicate) {
|
|||
#ifdef TRACE_HAVE_INTRINSICS
|
||||
case vmIntrinsics::_counterTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime");
|
||||
case vmIntrinsics::_getClassId: return inline_native_classID();
|
||||
case vmIntrinsics::_getBufferWriter: return inline_native_getBufferWriter();
|
||||
#endif
|
||||
case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
|
||||
case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
|
||||
|
@ -3198,6 +3200,44 @@ bool LibraryCallKit::inline_native_classID() {
|
|||
|
||||
}
|
||||
|
||||
bool LibraryCallKit::inline_native_getBufferWriter() {
|
||||
Node* tls_ptr = _gvn.transform(new ThreadLocalNode());
|
||||
|
||||
Node* jobj_ptr = basic_plus_adr(top(), tls_ptr,
|
||||
in_bytes(TRACE_THREAD_DATA_WRITER_OFFSET)
|
||||
);
|
||||
|
||||
Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
|
||||
|
||||
Node* jobj_cmp_null = _gvn.transform( new CmpPNode(jobj, null()) );
|
||||
Node* test_jobj_eq_null = _gvn.transform( new BoolNode(jobj_cmp_null, BoolTest::eq) );
|
||||
|
||||
IfNode* iff_jobj_null =
|
||||
create_and_map_if(control(), test_jobj_eq_null, PROB_NEVER, COUNT_UNKNOWN);
|
||||
|
||||
enum { _normal_path = 1,
|
||||
_null_path = 2,
|
||||
PATH_LIMIT };
|
||||
|
||||
RegionNode* result_rgn = new RegionNode(PATH_LIMIT);
|
||||
PhiNode* result_val = new PhiNode(result_rgn, TypePtr::BOTTOM);
|
||||
record_for_igvn(result_rgn);
|
||||
|
||||
Node* jobj_is_null = _gvn.transform( new IfTrueNode(iff_jobj_null) );
|
||||
result_rgn->init_req(_null_path, jobj_is_null);
|
||||
result_val->init_req(_null_path, null());
|
||||
|
||||
Node* jobj_is_not_null = _gvn.transform( new IfFalseNode(iff_jobj_null) );
|
||||
result_rgn->init_req(_normal_path, jobj_is_not_null);
|
||||
|
||||
Node* res = make_load(NULL, jobj, TypeInstPtr::BOTTOM, T_OBJECT, MemNode::unordered);
|
||||
result_val->init_req(_normal_path, res);
|
||||
|
||||
set_result(result_rgn, result_val);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------inline_native_currentThread------------------
|
||||
|
|
|
@ -57,6 +57,8 @@ extern "C" void JNICALL trace_register_natives(JNIEnv*, jclass);
|
|||
#define TRACE_DEFINE_THREAD_TRACE_ID_OFFSET typedef int ___IGNORED_hs_trace_type5
|
||||
#define TRACE_THREAD_TRACE_ID_OFFSET in_ByteSize(0); ShouldNotReachHere()
|
||||
#define TRACE_DEFINE_THREAD_ID_SIZE typedef int ___IGNORED_hs_trace_type6
|
||||
#define TRACE_DEFINE_THREAD_DATA_WRITER_OFFSET typedef int ___IGNORED_hs_trace_type7
|
||||
#define TRACE_THREAD_DATA_WRITER_OFFSET in_ByteSize(0); ShouldNotReachHere()
|
||||
#define TRACE_TEMPLATES(template)
|
||||
#define TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue