8163589: Add back class id intrinsic method for event based tracing
Reviewed-by: kvn, mgronlun
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp Thu Sep 01 08:30:17 2016 +0200
@@ -221,6 +221,9 @@
case vmIntrinsics::_putCharStringU:
#ifdef TRACE_HAVE_INTRINSICS
case vmIntrinsics::_counterTime:
+#if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT)
+ case vmIntrinsics::_getClassId:
+#endif
#endif
break;
default:
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Thu Sep 01 08:30:17 2016 +0200
@@ -3083,6 +3083,37 @@
__ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
}
+#ifdef TRACE_HAVE_INTRINSICS
+void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
+ CodeEmitInfo* info = state_for(x);
+ CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
+
+ assert(info != NULL, "must have info");
+ LIRItem arg(x->argument_at(0), this);
+
+ arg.load_item();
+ LIR_Opr klass = new_register(T_METADATA);
+ __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info);
+ LIR_Opr id = new_register(T_LONG);
+ ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET;
+ LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
+
+ __ move(trace_id_addr, id);
+ __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
+ __ store(id, trace_id_addr);
+
+#ifdef TRACE_ID_META_BITS
+ __ logical_and(id, LIR_OprFact::longConst(~TRACE_ID_META_BITS), id);
+#endif
+#ifdef TRACE_ID_CLASS_SHIFT
+ __ unsigned_shift_right(id, TRACE_ID_CLASS_SHIFT, id);
+#endif
+
+ __ move(id, rlock_result(x));
+}
+#endif
+
+
void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) {
assert(x->number_of_arguments() == 0, "wrong type");
// Enforce computation of _reserved_argument_area_size which is required on some platforms.
@@ -3108,6 +3139,9 @@
}
#ifdef TRACE_HAVE_INTRINSICS
+ case vmIntrinsics::_getClassId:
+ do_ClassIDIntrinsic(x);
+ break;
case vmIntrinsics::_counterTime:
do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), x);
break;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Thu Sep 01 08:30:17 2016 +0200
@@ -438,6 +438,10 @@
SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
+#ifdef TRACE_HAVE_INTRINSICS
+ void do_ClassIDIntrinsic(Intrinsic* x);
+#endif
+
void do_RuntimeCall(address routine, Intrinsic* x);
ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k,
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp Thu Sep 01 08:30:17 2016 +0200
@@ -366,6 +366,7 @@
switch(id) {
#ifdef TRACE_HAVE_INTRINSICS
case vmIntrinsics::_counterTime:
+ case vmIntrinsics::_getClassId:
#endif
case vmIntrinsics::_currentTimeMillis:
case vmIntrinsics::_nanoTime:
--- a/hotspot/src/share/vm/opto/c2compiler.cpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp Thu Sep 01 08:30:17 2016 +0200
@@ -530,6 +530,7 @@
case vmIntrinsics::_isInterrupted:
#ifdef TRACE_HAVE_INTRINSICS
case vmIntrinsics::_counterTime:
+ case vmIntrinsics::_getClassId:
#endif
case vmIntrinsics::_currentTimeMillis:
case vmIntrinsics::_nanoTime:
--- a/hotspot/src/share/vm/opto/library_call.cpp Wed Aug 31 19:41:57 2016 -0400
+++ b/hotspot/src/share/vm/opto/library_call.cpp Thu Sep 01 08:30:17 2016 +0200
@@ -254,6 +254,9 @@
bool inline_native_currentThread();
bool inline_native_time_funcs(address method, const char* funcName);
+#ifdef TRACE_HAVE_INTRINSICS
+ bool inline_native_classID();
+#endif
bool inline_native_isInterrupted();
bool inline_native_Class_query(vmIntrinsics::ID id);
bool inline_native_subtype_check();
@@ -708,6 +711,7 @@
#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();
#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");
@@ -3132,6 +3136,43 @@
return true;
}
+#ifdef TRACE_HAVE_INTRINSICS
+
+/*
+* oop -> myklass
+* myklass->trace_id |= USED
+* return myklass->trace_id & ~0x3
+*/
+bool LibraryCallKit::inline_native_classID() {
+ Node* cls = null_check(argument(0), T_OBJECT);
+ Node* kls = load_klass_from_mirror(cls, false, NULL, 0);
+ kls = null_check(kls, T_OBJECT);
+
+ ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET;
+ Node* insp = basic_plus_adr(kls, in_bytes(offset));
+ Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered);
+
+ Node* clsused = longcon(0x01l); // set the class bit
+ Node* orl = _gvn.transform(new OrLNode(tvalue, clsused));
+ const TypePtr *adr_type = _gvn.type(insp)->isa_ptr();
+ store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered);
+
+#ifdef TRACE_ID_META_BITS
+ Node* mbits = longcon(~TRACE_ID_META_BITS);
+ tvalue = _gvn.transform(new AndLNode(tvalue, mbits));
+#endif
+#ifdef TRACE_ID_CLASS_SHIFT
+ Node* cbits = intcon(TRACE_ID_CLASS_SHIFT);
+ tvalue = _gvn.transform(new URShiftLNode(tvalue, cbits));
+#endif
+
+ set_result(tvalue);
+ return true;
+
+}
+
+#endif
+
//------------------------inline_native_currentThread------------------
bool LibraryCallKit::inline_native_currentThread() {
Node* junk = NULL;