src/hotspot/share/opto/library_call.cpp
changeset 50113 caf115bb98ad
parent 50083 07015dd8157f
child 50180 ffa644980dff
equal deleted inserted replaced
50112:7a2a740815b7 50113:caf115bb98ad
    28 #include "classfile/systemDictionary.hpp"
    28 #include "classfile/systemDictionary.hpp"
    29 #include "classfile/vmSymbols.hpp"
    29 #include "classfile/vmSymbols.hpp"
    30 #include "compiler/compileBroker.hpp"
    30 #include "compiler/compileBroker.hpp"
    31 #include "compiler/compileLog.hpp"
    31 #include "compiler/compileLog.hpp"
    32 #include "memory/resourceArea.hpp"
    32 #include "memory/resourceArea.hpp"
       
    33 #include "jfr/support/jfrIntrinsics.hpp"
    33 #include "oops/objArrayKlass.hpp"
    34 #include "oops/objArrayKlass.hpp"
    34 #include "opto/addnode.hpp"
    35 #include "opto/addnode.hpp"
    35 #include "opto/arraycopynode.hpp"
    36 #include "opto/arraycopynode.hpp"
    36 #include "opto/c2compiler.hpp"
    37 #include "opto/c2compiler.hpp"
    37 #include "opto/callGenerator.hpp"
    38 #include "opto/callGenerator.hpp"
    52 #include "opto/subnode.hpp"
    53 #include "opto/subnode.hpp"
    53 #include "prims/nativeLookup.hpp"
    54 #include "prims/nativeLookup.hpp"
    54 #include "prims/unsafe.hpp"
    55 #include "prims/unsafe.hpp"
    55 #include "runtime/objectMonitor.hpp"
    56 #include "runtime/objectMonitor.hpp"
    56 #include "runtime/sharedRuntime.hpp"
    57 #include "runtime/sharedRuntime.hpp"
    57 #ifdef TRACE_HAVE_INTRINSICS
    58 #include "utilities/macros.hpp"
    58 #include "trace/traceMacros.hpp"
    59 
    59 #endif
       
    60 
    60 
    61 class LibraryIntrinsic : public InlineCallGenerator {
    61 class LibraryIntrinsic : public InlineCallGenerator {
    62   // Extend the set of intrinsics known to the runtime:
    62   // Extend the set of intrinsics known to the runtime:
    63  public:
    63  public:
    64  private:
    64  private:
   256   bool inline_unsafe_newArray(bool uninitialized);
   256   bool inline_unsafe_newArray(bool uninitialized);
   257   bool inline_unsafe_copyMemory();
   257   bool inline_unsafe_copyMemory();
   258   bool inline_native_currentThread();
   258   bool inline_native_currentThread();
   259 
   259 
   260   bool inline_native_time_funcs(address method, const char* funcName);
   260   bool inline_native_time_funcs(address method, const char* funcName);
   261 #ifdef TRACE_HAVE_INTRINSICS
   261 #ifdef JFR_HAVE_INTRINSICS
   262   bool inline_native_classID();
   262   bool inline_native_classID();
   263   bool inline_native_getBufferWriter();
   263   bool inline_native_getEventWriter();
   264 #endif
   264 #endif
   265   bool inline_native_isInterrupted();
   265   bool inline_native_isInterrupted();
   266   bool inline_native_Class_query(vmIntrinsics::ID id);
   266   bool inline_native_Class_query(vmIntrinsics::ID id);
   267   bool inline_native_subtype_check();
   267   bool inline_native_subtype_check();
   268   bool inline_native_getLength();
   268   bool inline_native_getLength();
   744   case vmIntrinsics::_onSpinWait:               return inline_onspinwait();
   744   case vmIntrinsics::_onSpinWait:               return inline_onspinwait();
   745 
   745 
   746   case vmIntrinsics::_currentThread:            return inline_native_currentThread();
   746   case vmIntrinsics::_currentThread:            return inline_native_currentThread();
   747   case vmIntrinsics::_isInterrupted:            return inline_native_isInterrupted();
   747   case vmIntrinsics::_isInterrupted:            return inline_native_isInterrupted();
   748 
   748 
   749 #ifdef TRACE_HAVE_INTRINSICS
   749 #ifdef JFR_HAVE_INTRINSICS
   750   case vmIntrinsics::_counterTime:              return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime");
   750   case vmIntrinsics::_counterTime:              return inline_native_time_funcs(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), "counterTime");
   751   case vmIntrinsics::_getClassId:               return inline_native_classID();
   751   case vmIntrinsics::_getClassId:               return inline_native_classID();
   752   case vmIntrinsics::_getBufferWriter:          return inline_native_getBufferWriter();
   752   case vmIntrinsics::_getEventWriter:           return inline_native_getEventWriter();
   753 #endif
   753 #endif
   754   case vmIntrinsics::_currentTimeMillis:        return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
   754   case vmIntrinsics::_currentTimeMillis:        return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
   755   case vmIntrinsics::_nanoTime:                 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
   755   case vmIntrinsics::_nanoTime:                 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
   756   case vmIntrinsics::_allocateInstance:         return inline_unsafe_allocate();
   756   case vmIntrinsics::_allocateInstance:         return inline_unsafe_allocate();
   757   case vmIntrinsics::_copyMemory:               return inline_unsafe_copyMemory();
   757   case vmIntrinsics::_copyMemory:               return inline_unsafe_copyMemory();
  3284 #endif
  3284 #endif
  3285   set_result(value);
  3285   set_result(value);
  3286   return true;
  3286   return true;
  3287 }
  3287 }
  3288 
  3288 
  3289 #ifdef TRACE_HAVE_INTRINSICS
  3289 #ifdef JFR_HAVE_INTRINSICS
  3290 
  3290 
  3291 /*
  3291 /*
  3292 * oop -> myklass
  3292 * oop -> myklass
  3293 * myklass->trace_id |= USED
  3293 * myklass->trace_id |= USED
  3294 * return myklass->trace_id & ~0x3
  3294 * return myklass->trace_id & ~0x3
  3296 bool LibraryCallKit::inline_native_classID() {
  3296 bool LibraryCallKit::inline_native_classID() {
  3297   Node* cls = null_check(argument(0), T_OBJECT);
  3297   Node* cls = null_check(argument(0), T_OBJECT);
  3298   Node* kls = load_klass_from_mirror(cls, false, NULL, 0);
  3298   Node* kls = load_klass_from_mirror(cls, false, NULL, 0);
  3299   kls = null_check(kls, T_OBJECT);
  3299   kls = null_check(kls, T_OBJECT);
  3300 
  3300 
  3301   ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET;
  3301   ByteSize offset = KLASS_TRACE_ID_OFFSET;
  3302   Node* insp = basic_plus_adr(kls, in_bytes(offset));
  3302   Node* insp = basic_plus_adr(kls, in_bytes(offset));
  3303   Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered);
  3303   Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered);
  3304 
  3304 
  3305   Node* clsused = longcon(0x01l); // set the class bit
  3305   Node* clsused = longcon(0x01l); // set the class bit
  3306   Node* orl = _gvn.transform(new OrLNode(tvalue, clsused));
  3306   Node* orl = _gvn.transform(new OrLNode(tvalue, clsused));
  3309 
  3309 
  3310 #ifdef TRACE_ID_META_BITS
  3310 #ifdef TRACE_ID_META_BITS
  3311   Node* mbits = longcon(~TRACE_ID_META_BITS);
  3311   Node* mbits = longcon(~TRACE_ID_META_BITS);
  3312   tvalue = _gvn.transform(new AndLNode(tvalue, mbits));
  3312   tvalue = _gvn.transform(new AndLNode(tvalue, mbits));
  3313 #endif
  3313 #endif
  3314 #ifdef TRACE_ID_CLASS_SHIFT
  3314 #ifdef TRACE_ID_SHIFT
  3315   Node* cbits = intcon(TRACE_ID_CLASS_SHIFT);
  3315   Node* cbits = intcon(TRACE_ID_SHIFT);
  3316   tvalue = _gvn.transform(new URShiftLNode(tvalue, cbits));
  3316   tvalue = _gvn.transform(new URShiftLNode(tvalue, cbits));
  3317 #endif
  3317 #endif
  3318 
  3318 
  3319   set_result(tvalue);
  3319   set_result(tvalue);
  3320   return true;
  3320   return true;
  3321 
  3321 
  3322 }
  3322 }
  3323 
  3323 
  3324 bool LibraryCallKit::inline_native_getBufferWriter() {
  3324 bool LibraryCallKit::inline_native_getEventWriter() {
  3325   Node* tls_ptr = _gvn.transform(new ThreadLocalNode());
  3325   Node* tls_ptr = _gvn.transform(new ThreadLocalNode());
  3326 
  3326 
  3327   Node* jobj_ptr = basic_plus_adr(top(), tls_ptr,
  3327   Node* jobj_ptr = basic_plus_adr(top(), tls_ptr,
  3328                                   in_bytes(TRACE_THREAD_DATA_WRITER_OFFSET)
  3328                                   in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR)
  3329                                   );
  3329                                   );
  3330 
  3330 
  3331   Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
  3331   Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
  3332 
  3332 
  3333   Node* jobj_cmp_null = _gvn.transform( new CmpPNode(jobj, null()) );
  3333   Node* jobj_cmp_null = _gvn.transform( new CmpPNode(jobj, null()) );
  3356   set_result(result_rgn, result_val);
  3356   set_result(result_rgn, result_val);
  3357 
  3357 
  3358   return true;
  3358   return true;
  3359 }
  3359 }
  3360 
  3360 
  3361 #endif
  3361 #endif // JFR_HAVE_INTRINSICS
  3362 
  3362 
  3363 //------------------------inline_native_currentThread------------------
  3363 //------------------------inline_native_currentThread------------------
  3364 bool LibraryCallKit::inline_native_currentThread() {
  3364 bool LibraryCallKit::inline_native_currentThread() {
  3365   Node* junk = NULL;
  3365   Node* junk = NULL;
  3366   set_result(generate_current_thread(junk));
  3366   set_result(generate_current_thread(junk));