src/share/vm/opto/library_call.cpp

changeset 1078
c771b7f43bbf
parent 1040
98cb887364d3
child 1116
fbde8ec322d0
     1.1 --- a/src/share/vm/opto/library_call.cpp	Thu Mar 12 10:37:46 2009 -0700
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Fri Mar 13 11:35:17 2009 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1999-2009 Sun Microsystems, Inc.  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 @@ -221,6 +221,7 @@
    1.11    bool inline_unsafe_CAS(BasicType type);
    1.12    bool inline_unsafe_ordered_store(BasicType type);
    1.13    bool inline_fp_conversions(vmIntrinsics::ID id);
    1.14 +  bool inline_bitCount(vmIntrinsics::ID id);
    1.15    bool inline_reverseBytes(vmIntrinsics::ID id);
    1.16  };
    1.17  
    1.18 @@ -314,6 +315,11 @@
    1.19      if (!JDK_Version::is_gte_jdk14x_version())  return NULL;
    1.20      break;
    1.21  
    1.22 +  case vmIntrinsics::_bitCount_i:
    1.23 +  case vmIntrinsics::_bitCount_l:
    1.24 +    if (!UsePopCountInstruction)  return NULL;
    1.25 +    break;
    1.26 +
    1.27   default:
    1.28      break;
    1.29    }
    1.30 @@ -617,6 +623,10 @@
    1.31    case vmIntrinsics::_longBitsToDouble:
    1.32      return inline_fp_conversions(intrinsic_id());
    1.33  
    1.34 +  case vmIntrinsics::_bitCount_i:
    1.35 +  case vmIntrinsics::_bitCount_l:
    1.36 +    return inline_bitCount(intrinsic_id());
    1.37 +
    1.38    case vmIntrinsics::_reverseBytes_i:
    1.39    case vmIntrinsics::_reverseBytes_l:
    1.40      return inline_reverseBytes((vmIntrinsics::ID) intrinsic_id());
    1.41 @@ -1714,6 +1724,27 @@
    1.42    }
    1.43  }
    1.44  
    1.45 +//----------------------------inline_bitCount_int/long-----------------------
    1.46 +// inline int Integer.bitCount(int)
    1.47 +// inline int Long.bitCount(long)
    1.48 +bool LibraryCallKit::inline_bitCount(vmIntrinsics::ID id) {
    1.49 +  assert(id == vmIntrinsics::_bitCount_i || id == vmIntrinsics::_bitCount_l, "not bitCount");
    1.50 +  if (id == vmIntrinsics::_bitCount_i && !Matcher::has_match_rule(Op_PopCountI)) return false;
    1.51 +  if (id == vmIntrinsics::_bitCount_l && !Matcher::has_match_rule(Op_PopCountL)) return false;
    1.52 +  _sp += arg_size();  // restore stack pointer
    1.53 +  switch (id) {
    1.54 +  case vmIntrinsics::_bitCount_i:
    1.55 +    push(_gvn.transform(new (C, 2) PopCountINode(pop())));
    1.56 +    break;
    1.57 +  case vmIntrinsics::_bitCount_l:
    1.58 +    push(_gvn.transform(new (C, 2) PopCountLNode(pop_pair())));
    1.59 +    break;
    1.60 +  default:
    1.61 +    ShouldNotReachHere();
    1.62 +  }
    1.63 +  return true;
    1.64 +}
    1.65 +
    1.66  //----------------------------inline_reverseBytes_int/long-------------------
    1.67  // inline Integer.reverseBytes(int)
    1.68  // inline Long.reverseBytes(long)

mercurial