src/hotspot/os_cpu/solaris_x86/count_trailing_zeros_solaris_x86.hpp
author erikj
Fri, 05 Oct 2018 09:59:30 -0700
branchihse-runtestprebuilt-branch
changeset 56931 aff106ae3507
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
permissions -rw-r--r--
Fix CDS support. Change ParseKeywordVariable parameter name to enable JTREG_KEYWORDS parameter. Fix test list arg.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46437
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     1
/*
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     4
 *
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     8
 *
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    14
 *
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    18
 *
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    21
 * questions.
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    22
 *
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    23
 */
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    24
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    25
#ifndef OS_CPU_SOLARIS_X86_VM_COUNTTRAILINGZEROS_HPP
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    26
#define OS_CPU_SOLARIS_X86_VM_COUNTTRAILINGZEROS_HPP
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    27
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    29
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    30
inline unsigned count_trailing_zeros(uintx x) {
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    31
  assert(x != 0, "precondition");
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    32
  uintx result;
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    33
  __asm__(" rep bsfq %1, %0" : "=r" (result) : "rm" (x));
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    34
  return result;
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    35
}
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    36
cda23e690843 8179004: Add an efficient implementation of the "count trailing zeros" operation
kbarrett
parents:
diff changeset
    37
#endif // include guard