src/share/vm/opto/library_call.cpp

changeset 3709
0105f367a14c
parent 3637
61b82be3b1ff
child 3760
8f972594effc
     1.1 --- a/src/share/vm/opto/library_call.cpp	Sun Apr 15 15:37:20 2012 -0700
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Tue Mar 06 12:36:59 2012 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -175,7 +175,11 @@
    1.11    bool inline_unsafe_allocate();
    1.12    bool inline_unsafe_copyMemory();
    1.13    bool inline_native_currentThread();
    1.14 -  bool inline_native_time_funcs(bool isNano);
    1.15 +#ifdef TRACE_HAVE_INTRINSICS
    1.16 +  bool inline_native_classID();
    1.17 +  bool inline_native_threadID();
    1.18 +#endif
    1.19 +  bool inline_native_time_funcs(address method, const char* funcName);
    1.20    bool inline_native_isInterrupted();
    1.21    bool inline_native_Class_query(vmIntrinsics::ID id);
    1.22    bool inline_native_subtype_check();
    1.23 @@ -638,10 +642,18 @@
    1.24    case vmIntrinsics::_isInterrupted:
    1.25      return inline_native_isInterrupted();
    1.26  
    1.27 +#ifdef TRACE_HAVE_INTRINSICS
    1.28 +  case vmIntrinsics::_classID:
    1.29 +    return inline_native_classID();
    1.30 +  case vmIntrinsics::_threadID:
    1.31 +    return inline_native_threadID();
    1.32 +  case vmIntrinsics::_counterTime:
    1.33 +    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime");
    1.34 +#endif
    1.35    case vmIntrinsics::_currentTimeMillis:
    1.36 -    return inline_native_time_funcs(false);
    1.37 +    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
    1.38    case vmIntrinsics::_nanoTime:
    1.39 -    return inline_native_time_funcs(true);
    1.40 +    return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
    1.41    case vmIntrinsics::_allocateInstance:
    1.42      return inline_unsafe_allocate();
    1.43    case vmIntrinsics::_copyMemory:
    1.44 @@ -2840,14 +2852,63 @@
    1.45    return true;
    1.46  }
    1.47  
    1.48 +#ifdef TRACE_HAVE_INTRINSICS
    1.49 +/*
    1.50 + * oop -> myklass
    1.51 + * myklass->trace_id |= USED
    1.52 + * return myklass->trace_id & ~0x3
    1.53 + */
    1.54 +bool LibraryCallKit::inline_native_classID() {
    1.55 +  int nargs = 1 + 1;
    1.56 +  null_check_receiver(callee());  // check then ignore argument(0)
    1.57 +  _sp += nargs;
    1.58 +  Node* cls = do_null_check(argument(1), T_OBJECT);
    1.59 +  _sp -= nargs;
    1.60 +  Node* kls = load_klass_from_mirror(cls, false, nargs, NULL, 0);
    1.61 +  _sp += nargs;
    1.62 +  kls = do_null_check(kls, T_OBJECT);
    1.63 +  _sp -= nargs;
    1.64 +  ByteSize offset = TRACE_ID_OFFSET;
    1.65 +  Node* insp = basic_plus_adr(kls, in_bytes(offset));
    1.66 +  Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG);
    1.67 +  Node* bits = longcon(~0x03l); // ignore bit 0 & 1
    1.68 +  Node* andl = _gvn.transform(new (C, 3) AndLNode(tvalue, bits));
    1.69 +  Node* clsused = longcon(0x01l); // set the class bit
    1.70 +  Node* orl = _gvn.transform(new (C, 3) OrLNode(tvalue, clsused));
    1.71 +
    1.72 +  const TypePtr *adr_type = _gvn.type(insp)->isa_ptr();
    1.73 +  store_to_memory(control(), insp, orl, T_LONG, adr_type);
    1.74 +  push_pair(andl);
    1.75 +  return true;
    1.76 +}
    1.77 +
    1.78 +bool LibraryCallKit::inline_native_threadID() {
    1.79 +  Node* tls_ptr = NULL;
    1.80 +  Node* cur_thr = generate_current_thread(tls_ptr);
    1.81 +  Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset()));
    1.82 +  Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS);
    1.83 +  p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::thread_id_offset()));
    1.84 +
    1.85 +  Node* threadid = NULL;
    1.86 +  size_t thread_id_size = OSThread::thread_id_size();
    1.87 +  if (thread_id_size == (size_t) BytesPerLong) {
    1.88 +    threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG));
    1.89 +    push(threadid);
    1.90 +  } else if (thread_id_size == (size_t) BytesPerInt) {
    1.91 +    threadid = make_load(control(), p, TypeInt::INT, T_INT);
    1.92 +    push(threadid);
    1.93 +  } else {
    1.94 +    ShouldNotReachHere();
    1.95 +  }
    1.96 +  return true;
    1.97 +}
    1.98 +#endif
    1.99 +
   1.100  //------------------------inline_native_time_funcs--------------
   1.101  // inline code for System.currentTimeMillis() and System.nanoTime()
   1.102  // these have the same type and signature
   1.103 -bool LibraryCallKit::inline_native_time_funcs(bool isNano) {
   1.104 -  address funcAddr = isNano ? CAST_FROM_FN_PTR(address, os::javaTimeNanos) :
   1.105 -                              CAST_FROM_FN_PTR(address, os::javaTimeMillis);
   1.106 -  const char * funcName = isNano ? "nanoTime" : "currentTimeMillis";
   1.107 -  const TypeFunc *tf = OptoRuntime::current_time_millis_Type();
   1.108 +bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* funcName) {
   1.109 +  const TypeFunc *tf = OptoRuntime::void_long_Type();
   1.110    const TypePtr* no_memory_effects = NULL;
   1.111    Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects);
   1.112    Node* value = _gvn.transform(new (C, 1) ProjNode(time, TypeFunc::Parms+0));

mercurial