src/hotspot/share/gc/z/zHash.inline.hpp
author pliden
Tue, 10 Sep 2019 11:11:31 +0200
changeset 58066 8407928b9fe5
parent 51029 bfeee03c49fe
permissions -rw-r--r--
8230566: ZGC: Don't substitute klass pointer during array clearing Reviewed-by: stefank, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
51029
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
51029
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    24
/*
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    25
 * This file is available under and governed by the GNU General Public
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    26
 * License version 2 only, as published by the Free Software Foundation.
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    27
 * However, the following notice accompanied the original version of this
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    28
 * file:
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    29
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    30
 *  (C) 2009 by Remo Dentato (rdentato@gmail.com)
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    31
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    32
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    33
 * Redistribution and use in source and binary forms, with or without modification,
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    34
 * are permitted provided that the following conditions are met:
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    35
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    36
 *     * Redistributions of source code must retain the above copyright notice,
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    37
 *       this list of conditions and the following disclaimer.
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    38
 *     * Redistributions in binary form must reproduce the above copyright notice,
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    39
 *       this list of conditions and the following disclaimer in the documentation
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    40
 *       and/or other materials provided with the distribution.
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    41
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    42
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    43
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    44
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    45
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    46
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    47
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    48
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    49
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    50
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    51
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    52
 *
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    53
 * http://opensource.org/licenses/bsd-license.php
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    54
 */
bfeee03c49fe 8207007: Add missing license header to zHash.inline.hpp
mikael
parents: 50525
diff changeset
    55
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    56
#ifndef SHARE_GC_Z_ZHASH_INLINE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    57
#define SHARE_GC_Z_ZHASH_INLINE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    58
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    59
#include "gc/z/zHash.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    60
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    61
inline uint32_t ZHash::uint32_to_uint32(uint32_t key) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
  key = ~key + (key << 15);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
  key = key ^ (key >> 12);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
  key = key + (key << 2);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    65
  key = key ^ (key >> 4);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    66
  key = key * 2057;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    67
  key = key ^ (key >> 16);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    68
  return key;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    69
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    70
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    71
inline uint32_t ZHash::address_to_uint32(uintptr_t key) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    72
  return uint32_to_uint32((uint32_t)(key >> 3));
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    73
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    74
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    75
#endif // SHARE_GC_Z_ZHASH_INLINE_HPP