Merge "Neon-optimized version of the GNU symbol calculation"

This commit is contained in:
Ryan Prichard 2020-01-17 20:48:14 +00:00 committed by Gerrit Code Review
commit 0bf9aed92e
6 changed files with 653 additions and 1 deletions

View File

@ -178,6 +178,7 @@ filegroup {
name: "linker_sources_arm",
srcs: [
"arch/arm/begin.S",
"arch/arm_neon/linker_gnu_hash_neon.cpp",
],
}
@ -186,6 +187,7 @@ filegroup {
srcs: [
"arch/arm64/begin.S",
"arch/arm64/tlsdesc_resolver.S",
"arch/arm_neon/linker_gnu_hash_neon.cpp",
],
}
@ -458,6 +460,7 @@ cc_test {
"linked_list_test.cpp",
"linker_sleb128_test.cpp",
"linker_utils_test.cpp",
"linker_gnu_hash_test.cpp",
// Parts of the linker that we're testing.
"linker_block_allocator.cpp",
@ -472,4 +475,30 @@ cc_test {
"libbase",
"liblog",
],
arch: {
arm: {
srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
},
arm64: {
srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
},
},
}
cc_benchmark {
name: "linker-benchmarks",
srcs: [
"linker_gnu_hash_benchmark.cpp",
],
arch: {
arm: {
srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
},
arm64: {
srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
},
},
}

View File

@ -0,0 +1,199 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
// A Neon vectorized implementation of the GNU symbol hash function.
// This function generally accesses beyond the bounds of the name string. Specifically, it reads
// each aligned 8-byte chunk containing a byte of the string, including the final NUL byte. This
// should be acceptable for use with MTE, which uses 16-byte granules. Typically, the function is
// used to hash strings in an ELF file's string table, where MTE is presumably unaware of the
// bounds of each symbol, but the linker also hashes the symbol name passed to dlsym.
#include "linker_gnu_hash_neon.h"
#include <arm_neon.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
struct __attribute__((aligned(8))) GnuHashInitEntry {
uint64_t ignore_mask;
uint32_t accum;
};
constexpr uint32_t kStep0 = 1;
constexpr uint32_t kStep1 = kStep0 * 33;
constexpr uint32_t kStep2 = kStep1 * 33;
constexpr uint32_t kStep3 = kStep2 * 33;
constexpr uint32_t kStep4 = kStep3 * 33;
constexpr uint32_t kStep5 = kStep4 * 33;
constexpr uint32_t kStep6 = kStep5 * 33;
constexpr uint32_t kStep7 = kStep6 * 33;
constexpr uint32_t kStep8 = kStep7 * 33;
constexpr uint32_t kStep9 = kStep8 * 33;
constexpr uint32_t kStep10 = kStep9 * 33;
constexpr uint32_t kStep11 = kStep10 * 33;
// Step by -1 through -7: 33 * 0x3e0f83e1 == 1 (mod 2**32)
constexpr uint32_t kStepN1 = kStep0 * 0x3e0f83e1;
constexpr uint32_t kStepN2 = kStepN1 * 0x3e0f83e1;
constexpr uint32_t kStepN3 = kStepN2 * 0x3e0f83e1;
constexpr uint32_t kStepN4 = kStepN3 * 0x3e0f83e1;
constexpr uint32_t kStepN5 = kStepN4 * 0x3e0f83e1;
constexpr uint32_t kStepN6 = kStepN5 * 0x3e0f83e1;
constexpr uint32_t kStepN7 = kStepN6 * 0x3e0f83e1;
// Calculate the GNU hash and string length of the symbol name.
//
// The hash calculation is an optimized version of this function:
//
// uint32_t calculate_gnu_hash(const uint8_t* name) {
// uint32_t h = 5381;
// for (; *name != '\0'; ++name) {
// h *= 33;
// h += *name;
// }
// return h;
// }
//
std::pair<uint32_t, uint32_t> calculate_gnu_hash_neon(const char* name) {
// The input string may be misaligned by 0-7 bytes (K). This function loads the first aligned
// 8-byte chunk, then counteracts the misalignment:
// - The initial K bytes are set to 0xff in the working chunk vector.
// - The accumulator is initialized to 5381 * modinv(33)**K.
// - The accumulator also cancels out each initial 0xff byte.
// If we could set bytes to NUL instead, then the accumulator wouldn't need to cancel out the
// 0xff values, but this would break the NUL check.
static const struct GnuHashInitEntry kInitTable[] = {
{ // (addr&7) == 0
0ull,
5381u*kStep0,
}, { // (addr&7) == 1
0xffull,
5381u*kStepN1 - 0xffu*kStepN1,
}, { // (addr&7) == 2
0xffffull,
5381u*kStepN2 - 0xffu*kStepN1 - 0xffu*kStepN2,
}, { // (addr&7) == 3
0xffffffull,
5381u*kStepN3 - 0xffu*kStepN1 - 0xffu*kStepN2 - 0xffu*kStepN3,
}, { // (addr&7) == 4
0xffffffffull,
5381u*kStepN4 - 0xffu*kStepN1 - 0xffu*kStepN2 - 0xffu*kStepN3 - 0xffu*kStepN4,
}, { // (addr&7) == 5
0xffffffffffull,
5381u*kStepN5 - 0xffu*kStepN1 - 0xffu*kStepN2 - 0xffu*kStepN3 - 0xffu*kStepN4 - 0xffu*kStepN5,
}, { // (addr&7) == 6
0xffffffffffffull,
5381u*kStepN6 - 0xffu*kStepN1 - 0xffu*kStepN2 - 0xffu*kStepN3 - 0xffu*kStepN4 - 0xffu*kStepN5 - 0xffu*kStepN6,
}, { // (addr&7) == 7
0xffffffffffffffull,
5381u*kStepN7 - 0xffu*kStepN1 - 0xffu*kStepN2 - 0xffu*kStepN3 - 0xffu*kStepN4 - 0xffu*kStepN5 - 0xffu*kStepN6 - 0xffu*kStepN7,
},
};
uint8_t offset = reinterpret_cast<uintptr_t>(name) & 7;
const uint64_t* chunk_ptr = reinterpret_cast<const uint64_t*>(reinterpret_cast<uintptr_t>(name) & ~7);
const struct GnuHashInitEntry* entry = &kInitTable[offset];
uint8x8_t chunk = vld1_u8(reinterpret_cast<const uint8_t*>(chunk_ptr));
chunk |= vld1_u8(reinterpret_cast<const uint8_t*>(&entry->ignore_mask));
uint32x4_t accum_lo = { 0 };
uint32x4_t accum_hi = { entry->accum, 0, 0, 0 };
const uint16x4_t kInclineVec = { kStep3, kStep2, kStep1, kStep0 };
const uint32x4_t kStep8Vec = vdupq_n_u32(kStep8);
uint8x8_t is_nul;
uint16x8_t expand;
while (1) {
// Exit the loop if any of the 8 bytes is NUL.
is_nul = vceq_u8(chunk, (uint8x8_t){ 0 });
expand = vmovl_u8(chunk);
uint64x1_t is_nul_64 = vreinterpret_u64_u8(is_nul);
if (vget_lane_u64(is_nul_64, 0)) break;
// Multiply both accumulators by 33**8.
accum_lo = vmulq_u32(accum_lo, kStep8Vec);
accum_hi = vmulq_u32(accum_hi, kStep8Vec);
// Multiply each 4-piece subchunk by (33**3, 33**2, 33*1, 1), then accumulate the result. The lo
// accumulator will be behind by 33**4 until the very end of the computation.
accum_lo = vmlal_u16(accum_lo, vget_low_u16(expand), kInclineVec);
accum_hi = vmlal_u16(accum_hi, vget_high_u16(expand), kInclineVec);
// Load the next chunk.
chunk = vld1_u8(reinterpret_cast<const uint8_t*>(++chunk_ptr));
}
// Reverse the is-NUL vector so we can use clz to count the number of remaining bytes.
is_nul = vrev64_u8(is_nul);
const uint64_t is_nul_u64 = vget_lane_u64(vreinterpret_u64_u8(is_nul), 0);
const uint32_t num_valid_bits = is_nul_u64 == 0 ? 64 : __builtin_clzll(is_nul_u64);
const uint32_t name_len = reinterpret_cast<const char*>(chunk_ptr) - name + (num_valid_bits >> 3);
static const uint32_t kFinalStepTable[] = {
kStep4, kStep0, // 0 remaining bytes
kStep5, kStep1, // 1 remaining byte
kStep6, kStep2, // 2 remaining bytes
kStep7, kStep3, // 3 remaining bytes
kStep8, kStep4, // 4 remaining bytes
kStep9, kStep5, // 5 remaining bytes
kStep10, kStep6, // 6 remaining bytes
kStep11, kStep7, // 7 remaining bytes
};
// Advance the lo/hi accumulators appropriately for the number of remaining bytes. Multiply 33**4
// into the lo accumulator to catch it up with the hi accumulator.
const uint32_t* final_step = &kFinalStepTable[num_valid_bits >> 2];
accum_lo = vmulq_u32(accum_lo, vdupq_n_u32(final_step[0]));
accum_lo = vmlaq_u32(accum_lo, accum_hi, vdupq_n_u32(final_step[1]));
static const uint32_t kFinalInclineTable[] = {
0, kStep6, kStep5, kStep4, kStep3, kStep2, kStep1, kStep0,
0, 0, 0, 0, 0, 0, 0, 0,
};
// Prepare a vector to multiply powers of 33 into each of the remaining bytes.
const uint32_t* const incline = &kFinalInclineTable[8 - (num_valid_bits >> 3)];
const uint32x4_t incline_lo = vld1q_u32(incline);
const uint32x4_t incline_hi = vld1q_u32(incline + 4);
// Multiply 33 into each of the remaining 4-piece vectors, then accumulate everything into
// accum_lo. Combine everything into a single 32-bit result.
accum_lo = vmlaq_u32(accum_lo, vmovl_u16(vget_low_u16(expand)), incline_lo);
accum_lo = vmlaq_u32(accum_lo, vmovl_u16(vget_high_u16(expand)), incline_hi);
uint32x2_t sum = vadd_u32(vget_low_u32(accum_lo), vget_high_u32(accum_lo));
const uint32_t hash = sum[0] + sum[1];
return { hash, name_len };
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#pragma once
#include <stdint.h>
#include <utility>
std::pair<uint32_t, uint32_t> calculate_gnu_hash_neon(const char* name);

View File

@ -32,7 +32,18 @@
#include <utility>
static inline std::pair<uint32_t, uint32_t> calculate_gnu_hash(const char* name) {
#if defined(__arm__) || defined(__aarch64__)
#define USE_GNU_HASH_NEON 1
#else
#define USE_GNU_HASH_NEON 0
#endif
#if USE_GNU_HASH_NEON
#include "arch/arm_neon/linker_gnu_hash_neon.h"
#endif
__attribute__((unused))
static std::pair<uint32_t, uint32_t> calculate_gnu_hash_simple(const char* name) {
uint32_t h = 5381;
const uint8_t* name_bytes = reinterpret_cast<const uint8_t*>(name);
#pragma unroll 8
@ -41,3 +52,11 @@ static inline std::pair<uint32_t, uint32_t> calculate_gnu_hash(const char* name)
}
return { h, reinterpret_cast<const char*>(name_bytes) - name };
}
static inline std::pair<uint32_t, uint32_t> calculate_gnu_hash(const char* name) {
#if USE_GNU_HASH_NEON
return calculate_gnu_hash_neon(name);
#else
return calculate_gnu_hash_simple(name);
#endif
}

View File

@ -0,0 +1,311 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <benchmark/benchmark.h>
#include "linker_gnu_hash.h"
// 250 symbols from the relocations of system/lib/libhwbinder.so in aosp/master, aosp_walleye.
// ROT13-encoded so as not to pollute code search.
static const char* const kSampleSymbolList[] = {
"_MA7naqebvq8uneqjner9OUjOvaqre8genafnpgRwEXAF0_6CnepryRCF2_wAFg3__18shapgvbaVSiEF2_RRR",
"_MA7naqebvq8uneqjner9OUjOvaqre11yvaxGbQrnguREXAF_2fcVAF0_7VOvaqre14QrnguErpvcvragRRRCiw",
"_MA7naqebvq8uneqjner9OUjOvaqre13hayvaxGbQrnguREXAF_2jcVAF0_7VOvaqre14QrnguErpvcvragRRRCiwCF5_",
"_MAX7naqebvq8uneqjner7VOvaqre13purpxFhopynffRCXi",
"_MA7naqebvq8uneqjner9OUjOvaqre12nggnpuBowrpgRCXiCiF4_CSiF3_F4_F4_R",
"_MAX7naqebvq8uneqjner9OUjOvaqre10svaqBowrpgRCXi",
"_MA7naqebvq8uneqjner9OUjOvaqre12qrgnpuBowrpgRCXi",
"_MA7naqebvq8uneqjner9OUjOvaqre11ybpnyOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqre12erzbgrOvaqreRi",
"_MA7naqebvq8uneqjner9OUjOvaqreQ1Ri",
"_MA7naqebvq8uneqjner9OUjOvaqreQ0Ri",
"_MA7naqebvq8uneqjner9OUjOvaqre10baGenafnpgRwEXAF0_6CnepryRCF2_wAFg3__18shapgvbaVSiEF2_RRR",
"_MGi0_a12_A7naqebvq8uneqjner9OUjOvaqreQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner9OUjOvaqreQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq8uneqjner11OcUjErsOnfrQ1Ri",
"_MA7naqebvq8uneqjner11OcUjErsOnfrQ0Ri",
"_MA7naqebvq8uneqjner11OcUjErsOnfr10baSvefgErsRi",
"_MA7naqebvq8uneqjner11OcUjErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq8uneqjner11OcUjErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MGi0_a12_A7naqebvq8uneqjner11OcUjErsOnfrQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner11OcUjErsOnfrQ0Ri",
"_MGi0_a16_A7naqebvq8uneqjner11OcUjErsOnfr10baSvefgErsRi",
"_MGi0_a20_A7naqebvq8uneqjner11OcUjErsOnfr15baYnfgFgebatErsRCXi",
"_MGi0_a24_A7naqebvq8uneqjner11OcUjErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MAX7naqebvq8uneqjner7VOvaqre13purpxFhopynffRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MA7naqebvq8uneqjner7VOvaqre11ybpnyOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqre12erzbgrOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MA7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MAX7naqebvq8uneqjner7VOvaqre13purpxFhopynffRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MA7naqebvq8uneqjner7VOvaqre11ybpnyOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqre12erzbgrOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MA7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq8uneqjner10OcUjOvaqre8genafnpgRwEXAF0_6CnepryRCF2_wAFg3__18shapgvbaVSiEF2_RRR",
"_MA7naqebvq8uneqjner10OcUjOvaqre11yvaxGbQrnguREXAF_2fcVAF0_7VOvaqre14QrnguErpvcvragRRRCiw",
"_MA7naqebvq8uneqjner10OcUjOvaqre13hayvaxGbQrnguREXAF_2jcVAF0_7VOvaqre14QrnguErpvcvragRRRCiwCF5_",
"_MAX7naqebvq8uneqjner7VOvaqre13purpxFhopynffRCXi",
"_MA7naqebvq8uneqjner10OcUjOvaqre12nggnpuBowrpgRCXiCiF4_CSiF3_F4_F4_R",
"_MAX7naqebvq8uneqjner10OcUjOvaqre10svaqBowrpgRCXi",
"_MA7naqebvq8uneqjner10OcUjOvaqre12qrgnpuBowrpgRCXi",
"_MA7naqebvq8uneqjner7VOvaqre11ybpnyOvaqreRi",
"_MA7naqebvq8uneqjner10OcUjOvaqre12erzbgrOvaqreRi",
"_MA7naqebvq8uneqjner10OcUjOvaqreQ1Ri",
"_MA7naqebvq8uneqjner10OcUjOvaqreQ0Ri",
"_MA7naqebvq8uneqjner10OcUjOvaqre10baSvefgErsRi",
"_MA7naqebvq8uneqjner10OcUjOvaqre15baYnfgFgebatErsRCXi",
"_MA7naqebvq8uneqjner10OcUjOvaqre20baVapFgebatNggrzcgrqRwCXi",
"_MGi0_a12_A7naqebvq8uneqjner10OcUjOvaqreQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner10OcUjOvaqreQ0Ri",
"_MGi0_a16_A7naqebvq8uneqjner10OcUjOvaqre10baSvefgErsRi",
"_MGi0_a20_A7naqebvq8uneqjner10OcUjOvaqre15baYnfgFgebatErsRCXi",
"_MGi0_a24_A7naqebvq8uneqjner10OcUjOvaqre20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MAX7naqebvq8uneqjner7VOvaqre13purpxFhopynffRCXi",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MA7naqebvq8uneqjner7VOvaqre11ybpnyOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqre12erzbgrOvaqreRi",
"_MA7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MA7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner7VOvaqreQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchgQ2Ri",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchgQ0Ri",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg5cevagRCXpw",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10zbirVaqragRv",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10chfuOhaqyrRi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg9cbcOhaqyrRi",
"__pkn_cher_iveghny",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq8uneqjner10VVagresnprQ1Ri",
"_MA7naqebvq8uneqjner10VVagresnprQ0Ri",
"__pkn_cher_iveghny",
"_MGi0_a12_A7naqebvq8uneqjner10VVagresnprQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner10VVagresnprQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MAFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MAFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MGua8_AFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MGua8_AFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MGi0_a12_AFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MGi0_a12_AFg3__114onfvp_vbfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MAFg3__113onfvp_vfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MAFg3__113onfvp_vfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MGi0_a12_AFg3__113onfvp_vfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MGi0_a12_AFg3__113onfvp_vfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MAFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MAFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MGi0_a12_AFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRRQ1Ri",
"_MGi0_a12_AFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRRQ0Ri",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR5vzohrREXAF_6ybpnyrR",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR6frgohsRCpv",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR4flapRi",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR9fubjznalpRi",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR6kftrgaRCpv",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR5hsybjRi",
"_MAFg3__115onfvp_fgernzohsVpAF_11pune_genvgfVpRRR6kfchgaRCXpv",
"_MA7naqebvq8uneqjner12CebprffFgngrQ1Ri",
"_MA7naqebvq8uneqjner12CebprffFgngrQ0Ri",
"_MGi0_a12_A7naqebvq8uneqjner12CebprffFgngrQ1Ri",
"_MGi0_a12_A7naqebvq8uneqjner12CebprffFgngrQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq6Guernq3ehaRCXpvw",
"_MA7naqebvq6Guernq11erdhrfgRkvgRi",
"_MA7naqebvq6Guernq10ernqlGbEhaRi",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq6GuernqQ1Ri",
"_MA7naqebvq6GuernqQ0Ri",
"_MA7naqebvq6Guernq3ehaRCXpvw",
"_MA7naqebvq6Guernq11erdhrfgRkvgRi",
"_MA7naqebvq6Guernq10ernqlGbEhaRi",
"__pkn_cher_iveghny",
"_MGi0_a12_A7naqebvq6GuernqQ1Ri",
"_MGi0_a12_A7naqebvq6GuernqQ0Ri",
"_MA7naqebvq7ErsOnfr10baSvefgErsRi",
"_MA7naqebvq7ErsOnfr15baYnfgFgebatErsRCXi",
"_MA7naqebvq7ErsOnfr20baVapFgebatNggrzcgrqRwCXi",
"_MA7naqebvq7ErsOnfr13baYnfgJrnxErsRCXi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchgQ2Ri",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg5cevagRCXpw",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10zbirVaqragRv",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10chfuOhaqyrRi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg9cbcOhaqyrRi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchgQ2Ri",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg5cevagRCXpw",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10zbirVaqragRv",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg10chfuOhaqyrRi",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg9cbcOhaqyrRi",
"_MA7naqebvq8uneqjner10GrkgBhgchgQ2Ri",
"_MA7naqebvq8uneqjner10GrkgBhgchgQ0Ri",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"__pkn_cher_iveghny",
"_MGIA7naqebvq8uneqjner9OUjOvaqreR",
"_MGPA7naqebvq8uneqjner9OUjOvaqreR0_AF0_7VOvaqreR",
"_MGPA7naqebvq8uneqjner9OUjOvaqreR0_AF0_7VOvaqreR",
"_MGIA7naqebvq8uneqjner9OUjOvaqreR",
"_MGIA7naqebvq8uneqjner11OcUjErsOnfrR",
"_MGIA7naqebvq8uneqjner11OcUjErsOnfrR",
"_MGIA7naqebvq8uneqjner7VOvaqreR",
"_MGIA7naqebvq8uneqjner7VOvaqreR",
"_MGIA7naqebvq8uneqjner10OcUjOvaqreR",
"_MGPA7naqebvq8uneqjner10OcUjOvaqreR0_AF0_7VOvaqreR",
"_MGPA7naqebvq8uneqjner10OcUjOvaqreR0_AF0_7VOvaqreR",
"_MGIA7naqebvq8uneqjner10OcUjOvaqreR",
"_MGIA7naqebvq8uneqjner10VVagresnprR",
"_MGIA7naqebvq8uneqjner10VVagresnprR",
"_MGIAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_14onfvp_vbfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_13onfvp_vfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_13onfvp_vfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR8_AF_13onfvp_bfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR8_AF_13onfvp_bfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_14onfvp_vbfgernzVpF2_RR",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_14onfvp_vbfgernzVpF2_RR",
"_MGIAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR",
"_MGIAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR",
"_MGIA7naqebvq8uneqjner12CebprffFgngrR",
"_MGIA7naqebvq8uneqjner12CebprffFgngrR",
"_MGIA7naqebvq8uneqjner10CbbyGuernqR",
"_MGPA7naqebvq8uneqjner10CbbyGuernqR0_AF_6GuernqR",
"_MGPA7naqebvq8uneqjner10CbbyGuernqR0_AF_6GuernqR",
"_MGIA7naqebvq8uneqjner10CbbyGuernqR",
"_MGIA7naqebvq8uneqjner9OUjOvaqreR",
"__fgnpx_pux_thneq",
"_MGIA7naqebvq8uneqjner11OcUjErsOnfrR",
"_MGIA7naqebvq12FbegrqIrpgbeVAF_16xrl_inyhr_cnve_gVCXiAF_8uneqjner10OcUjOvaqre13BowrpgZnantre7ragel_gRRRRR",
"_MGPA7naqebvq8uneqjner10OcUjOvaqreR0_AF0_7VOvaqreR",
"_MGIA7naqebvq8uneqjner10OcUjOvaqreR",
"_MGIA7naqebvq6IrpgbeVAF_8uneqjner10OcUjOvaqre8BovghnelRRR",
"_MGGA7naqebvq8uneqjner10OcUjOvaqreR",
"_MGIA7naqebvq6IrpgbeVAF_2fcVAF_8uneqjner18OhssrerqGrkgBhgchg11OhssreFgngrRRRRR",
"_MA7naqebvq8uneqjner18OhssrerqGrkgBhgchg16guernqQrfgehpgbeRCi",
"_MGIA7naqebvq8uneqjner18OhssrerqGrkgBhgchgR",
"_MA7naqebvq8uneqjner12tGrkgOhssrefR",
"_MGIA7naqebvq8uneqjner18OhssrerqGrkgBhgchg11OhssreFgngrR",
"_MA7naqebvq8uneqjner14VCPGuernqFgngr16guernqQrfgehpgbeRCi",
"_MA7naqebvq8uneqjner14VCPGuernqFgngr10serrOhssreRCAF0_6CnepryRCXuwCXlwCi",
"_MA7naqebvq8uneqjner18gur_pbagrkg_bowrpgR",
"_MA7naqebvq9PnyyFgnpx18trgPheeragVagreanyRv",
"_MA7naqebvq9PnyyFgnpx16ybtFgnpxVagreanyRCXpCXF0_19naqebvq_YbtCevbevgl",
"_MGIA7naqebvq6IrpgbeVCAF_8uneqjner9OUjOvaqreRRR",
"_MGIA7naqebvq6IrpgbeVCAF_7ErsOnfr12jrnxers_glcrRRR",
"_MGIA7naqebvq6IrpgbeVCAF_7ErsOnfrRRR",
"_MFg7abguebj",
"_MGPAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR0_AF_13onfvp_vfgernzVpF2_RR",
"_MGIAFg3__118onfvp_fgevatfgernzVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR",
"_MGIAFg3__115onfvp_fgevatohsVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRR",
"_MAFg3__15pglcrVpR2vqR",
"_MA7naqebvq8uneqjner13tCebprffZhgrkR",
"_MA7naqebvq8uneqjner8tCebprffR",
"_MGIA7naqebvq8uneqjner12CebprffFgngrR",
"_MGIA7naqebvq6IrpgbeVAF_8uneqjner12CebprffFgngr12unaqyr_ragelRRR",
"_MGIA7naqebvq12FbegrqIrpgbeVAF_16xrl_inyhr_cnve_gVAF_8Fgevat16RAF_2fcVAF_8uneqjner7VOvaqreRRRRRRR",
"_MGIA7naqebvq8uneqjner10CbbyGuernqR",
"_MGGA7naqebvq8uneqjner12CebprffFgngrR",
"_MGIA7naqebvq6IrpgbeVvRR",
"_MGIA7naqebvq8uneqjner13YbtGrkgBhgchgR",
};
static void BM_gnu_hash_simple(benchmark::State& state) {
for (auto _ : state) {
for (const char* sym_name : kSampleSymbolList) {
benchmark::DoNotOptimize(calculate_gnu_hash_simple(sym_name));
}
}
}
BENCHMARK(BM_gnu_hash_simple);
#if USE_GNU_HASH_NEON
static void BM_gnu_hash_neon(benchmark::State& state) {
for (auto _ : state) {
for (const char* sym_name : kSampleSymbolList) {
benchmark::DoNotOptimize(calculate_gnu_hash_neon(sym_name));
}
}
}
BENCHMARK(BM_gnu_hash_neon);
#endif // USE_GNU_HASH_NEON
BENCHMARK_MAIN();

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <gtest/gtest.h>
#include "linker_gnu_hash.h"
TEST(linker_gnu_hash, compare_neon_to_simple) {
#if USE_GNU_HASH_NEON
auto check_input = [&](const char* name) {
auto expected = calculate_gnu_hash_simple(name);
auto actual = calculate_gnu_hash_neon(name);
EXPECT_EQ(expected.first, actual.first) << name;
EXPECT_EQ(expected.second, actual.second) << name;
};
__attribute__((aligned(8))) const char test1[] = "abcdefghijklmnop\0qrstuvwxyz";
for (size_t i = 0; i < sizeof(test1) - 1; ++i) {
check_input(&test1[i]);
}
__attribute__((aligned(8))) const char test2[] = "abcdefghijklmnopqrs\0tuvwxyz";
for (size_t i = 0; i < sizeof(test2) - 1; ++i) {
check_input(&test2[i]);
}
__attribute__((aligned(8))) const char test3[] = "abcdefghijklmnopqrstuv\0wxyz";
for (size_t i = 0; i < sizeof(test3) - 1; ++i) {
check_input(&test3[i]);
}
#else
GTEST_SKIP() << "This test is only implemented on arm/arm64";
#endif
}