summaryrefslogtreecommitdiff
path: root/chromium/third_party/snappy
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-24 11:30:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-30 12:56:19 +0000
commit6036726eb981b6c4b42047513b9d3f4ac865daac (patch)
tree673593e70678e7789766d1f732eb51f613a2703b /chromium/third_party/snappy
parent466052c4e7c052268fd931888cd58961da94c586 (diff)
downloadqtwebengine-chromium-6036726eb981b6c4b42047513b9d3f4ac865daac.tar.gz
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/snappy')
-rw-r--r--chromium/third_party/snappy/README.chromium2
-rw-r--r--chromium/third_party/snappy/linux/config.h9
-rw-r--r--chromium/third_party/snappy/linux/snappy-stubs-public.h45
-rw-r--r--chromium/third_party/snappy/mac/config.h9
-rw-r--r--chromium/third_party/snappy/mac/snappy-stubs-public.h59
-rw-r--r--chromium/third_party/snappy/src/.appveyor.yml7
-rw-r--r--chromium/third_party/snappy/src/.travis.yml28
-rw-r--r--chromium/third_party/snappy/src/CMakeLists.txt55
-rw-r--r--chromium/third_party/snappy/src/cmake/config.h.in9
-rw-r--r--chromium/third_party/snappy/src/snappy-stubs-internal.h12
-rw-r--r--chromium/third_party/snappy/src/snappy-stubs-public.h.in45
-rw-r--r--chromium/third_party/snappy/src/snappy-test.h2
-rw-r--r--chromium/third_party/snappy/src/snappy.cc208
-rw-r--r--chromium/third_party/snappy/src/snappy.h2
-rw-r--r--chromium/third_party/snappy/src/snappy_unittest.cc2
-rw-r--r--chromium/third_party/snappy/win32/config.h9
-rw-r--r--chromium/third_party/snappy/win32/snappy-stubs-public.h41
17 files changed, 278 insertions, 266 deletions
diff --git a/chromium/third_party/snappy/README.chromium b/chromium/third_party/snappy/README.chromium
index d0855367470..ab39894ff93 100644
--- a/chromium/third_party/snappy/README.chromium
+++ b/chromium/third_party/snappy/README.chromium
@@ -1,7 +1,7 @@
Name: Snappy: A fast compressor/decompressor
Short Name: snappy
URL: http://google.github.io/snappy/
-Version: 1.1.7.git.ca37ab7fb9b718e056009babb4fea591626e5882
+Version: 1.1.7.git.ea660b57d65d68d521287c903459b6dd3b2804d0
License: New BSD
License File: src/COPYING
Security Critical: yes
diff --git a/chromium/third_party/snappy/linux/config.h b/chromium/third_party/snappy/linux/config.h
index 2595d0e0caa..5dc7a4b17a4 100644
--- a/chromium/third_party/snappy/linux/config.h
+++ b/chromium/third_party/snappy/linux/config.h
@@ -28,12 +28,6 @@
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
/* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */
@@ -55,6 +49,9 @@
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
+/* Define to 1 if you target processors with SSSE3+ and have <tmmintrin.h>. */
+#define SNAPPY_HAVE_SSSE3 0
+
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef SNAPPY_IS_BIG_ENDIAN */
diff --git a/chromium/third_party/snappy/linux/snappy-stubs-public.h b/chromium/third_party/snappy/linux/snappy-stubs-public.h
index 590cae0a6fd..feefa70672d 100644
--- a/chromium/third_party/snappy/linux/snappy-stubs-public.h
+++ b/chromium/third_party/snappy/linux/snappy-stubs-public.h
@@ -36,13 +36,9 @@
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#if 1 // HAVE_STDINT_H
-#include <stdint.h>
-#endif // HAVE_STDDEF_H
-
-#if 1 // HAVE_STDDEF_H
-#include <stddef.h>
-#endif // HAVE_STDDEF_H
+#include <cstddef>
+#include <cstdint>
+#include <string>
#if 1 // HAVE_SYS_UIO_H
#include <sys/uio.h>
@@ -54,38 +50,25 @@
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-#include <string>
-
namespace snappy {
-#if 1 // HAVE_STDINT_H
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif // HAVE_STDINT_H
+using int8 = std::int8_t;
+using uint8 = std::uint8_t;
+using int16 = std::int16_t;
+using uint16 = std::uint16_t;
+using int32 = std::int32_t;
+using uint32 = std::uint32_t;
+using int64 = std::int64_t;
+using uint64 = std::uint64_t;
-typedef std::string string;
+using string = std::string;
#if !1 // !HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
- void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
#endif // !HAVE_SYS_UIO_H
diff --git a/chromium/third_party/snappy/mac/config.h b/chromium/third_party/snappy/mac/config.h
index 16bb03153f2..a0d92285c59 100644
--- a/chromium/third_party/snappy/mac/config.h
+++ b/chromium/third_party/snappy/mac/config.h
@@ -28,12 +28,6 @@
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
/* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */
@@ -55,6 +49,9 @@
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
+/* Define to 1 if you target processors with SSSE3+ and have <tmmintrin.h>. */
+#define SNAPPY_HAVE_SSSE3 0
+
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef SNAPPY_IS_BIG_ENDIAN */
diff --git a/chromium/third_party/snappy/mac/snappy-stubs-public.h b/chromium/third_party/snappy/mac/snappy-stubs-public.h
index 442d599db06..feefa70672d 100644
--- a/chromium/third_party/snappy/mac/snappy-stubs-public.h
+++ b/chromium/third_party/snappy/mac/snappy-stubs-public.h
@@ -36,17 +36,13 @@
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#if 1
-#include <stdint.h>
-#endif
-
-#if 1
-#include <stddef.h>
-#endif
+#include <cstddef>
+#include <cstdint>
+#include <string>
-#if 1
+#if 1 // HAVE_SYS_UIO_H
#include <sys/uio.h>
-#endif
+#endif // HAVE_SYS_UIO_H
#define SNAPPY_MAJOR 1
#define SNAPPY_MINOR 1
@@ -54,46 +50,27 @@
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-#include <string>
-
namespace snappy {
-#if 1
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif
-
-typedef std::string string;
+using int8 = std::int8_t;
+using uint8 = std::uint8_t;
+using int16 = std::int16_t;
+using uint16 = std::uint16_t;
+using int32 = std::int32_t;
+using uint32 = std::uint32_t;
+using int64 = std::int64_t;
+using uint64 = std::uint64_t;
-#ifndef DISALLOW_COPY_AND_ASSIGN
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-#endif
+using string = std::string;
-#if !1
+#if !1 // !HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
- void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
-#endif
+#endif // !HAVE_SYS_UIO_H
} // namespace snappy
diff --git a/chromium/third_party/snappy/src/.appveyor.yml b/chromium/third_party/snappy/src/.appveyor.yml
index 2ed49f95f26..f2329ec8701 100644
--- a/chromium/third_party/snappy/src/.appveyor.yml
+++ b/chromium/third_party/snappy/src/.appveyor.yml
@@ -11,9 +11,6 @@ environment:
- JOB: Visual Studio 2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017
- - JOB: Visual Studio 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- CMAKE_GENERATOR: Visual Studio 14 2015
platform:
- x86
@@ -33,9 +30,9 @@ build_script:
- if "%platform%"=="x64" set CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64
- cmake --version
- cmake .. -G "%CMAKE_GENERATOR%"
- -DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%"
+ -DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%" -DSNAPPY_REQUIRE_AVX=ON
- cmake --build . --config %CONFIGURATION%
- cd ..
test_script:
- - out\%CONFIGURATION%\snappy_unittest \ No newline at end of file
+ - out\%CONFIGURATION%\snappy_unittest
diff --git a/chromium/third_party/snappy/src/.travis.yml b/chromium/third_party/snappy/src/.travis.yml
index 8816edbf383..b89add8a9e3 100644
--- a/chromium/third_party/snappy/src/.travis.yml
+++ b/chromium/third_party/snappy/src/.travis.yml
@@ -18,9 +18,11 @@ env:
- BUILD_TYPE=RelWithDebInfo
matrix:
- allow_failures:
- - compiler: clang
- env: BUILD_TYPE=RelWithDebInfo
+ exclude:
+ # GCC fails on recent Travis OSX images.
+ # https://github.com/travis-ci/travis-ci/issues/9640
+ - compiler: gcc
+ os: osx
addons:
apt:
@@ -30,27 +32,27 @@ addons:
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
sources:
- ubuntu-toolchain-r-test
- - llvm-toolchain-trusty-4.0
+ - llvm-toolchain-trusty-6.0
packages:
- cmake
- - gcc-6
- - g++-6
- - clang-4.0
+ - gcc-8
+ - g++-8
+ - clang-6.0
install:
# Travis doesn't have a DSL for installing homebrew packages yet. Status tracked
# in https://github.com/travis-ci/travis-ci/issues/5377
# The Travis VM image for Mac already has a link at /usr/local/include/c++,
-# causing Homebrew's gcc@6 installation to error out. This was reported to
+# causing Homebrew's gcc@7 installation to error out. This was reported to
# Homebrew maintainers at https://github.com/Homebrew/brew/issues/1742 and
# removing the link emerged as a workaround.
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update;
if [ -L /usr/local/include/c++ ]; then rm /usr/local/include/c++; fi;
- brew install gcc@6;
+ brew install gcc@8;
fi
-# /usr/bin/gcc is stuck to old versions by on both Linux and OSX.
-- if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
+# /usr/bin/gcc is stuck to old versions on both Linux and OSX.
+- if [ "$CXX" = "g++" ]; then export CXX="g++-8" CC="gcc-8"; fi
- echo ${CC}
- echo ${CXX}
- ${CXX} --version
@@ -58,9 +60,9 @@ install:
before_script:
- mkdir -p build && cd build
-- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
+- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSNAPPY_REQUIRE_AVX=ON
- cmake --build .
- cd ..
script:
-- build/snappy_unittest \ No newline at end of file
+- build/snappy_unittest
diff --git a/chromium/third_party/snappy/src/CMakeLists.txt b/chromium/third_party/snappy/src/CMakeLists.txt
index 3f534b134eb..41a21242996 100644
--- a/chromium/third_party/snappy/src/CMakeLists.txt
+++ b/chromium/third_party/snappy/src/CMakeLists.txt
@@ -1,19 +1,24 @@
cmake_minimum_required(VERSION 3.1)
project(Snappy VERSION 1.1.7 LANGUAGES C CXX)
+# This project requires C++11.
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
# it prominent in the GUI.
option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
+option(SNAPPY_REQUIRE_AVX "Target processors with AVX support." OFF)
+
include(TestBigEndian)
test_big_endian(SNAPPY_IS_BIG_ENDIAN)
include(CheckIncludeFile)
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
-check_include_file("stddef.h" HAVE_STDDEF_H)
-check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
@@ -26,12 +31,40 @@ include(CheckLibraryExists)
check_library_exists(z zlibVersion "" HAVE_LIBZ)
check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
-include(CheckCXXSourceCompiles)
-check_cxx_source_compiles(
- "int main(void) { return __builtin_expect(0, 1); }" HAVE_BUILTIN_EXPECT)
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("/arch:AVX" HAVE_VISUAL_STUDIO_ARCH_AVX)
+CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_CLANG_MAVX)
+if (SNAPPY_REQUIRE_AVX)
+ if(HAVE_VISUAL_STUDIO_ARCH_AVX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
+ endif(HAVE_VISUAL_STUDIO_ARCH_AVX)
+ if(HAVE_CLANG_MAVX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
+ endif(HAVE_CLANG_MAVX)
+endif(SNAPPY_REQUIRE_AVX)
-check_cxx_source_compiles(
- "int main(void) { return __builtin_ctzll(0); }" HAVE_BUILTIN_CTZ)
+include(CheckCXXSourceCompiles)
+check_cxx_source_compiles("
+int main() {
+ return __builtin_expect(0, 1);
+}" HAVE_BUILTIN_EXPECT)
+
+check_cxx_source_compiles("
+int main() {
+ return __builtin_ctzll(0);
+}" HAVE_BUILTIN_CTZ)
+
+check_cxx_source_compiles("
+#include <tmmintrin.h>
+
+int main() {
+ const __m128i *src = 0;
+ __m128i dest;
+ const __m128i shuffle_mask = _mm_load_si128(src);
+ const __m128i pattern = _mm_shuffle_epi8(_mm_loadl_epi64(src), shuffle_mask);
+ _mm_storeu_si128(&dest, pattern);
+ return 0;
+}" SNAPPY_HAVE_SSSE3)
include(CheckSymbolExists)
check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
@@ -55,15 +88,7 @@ configure_file(
# We don't want to define HAVE_ macros in public headers. Instead, we use
# CMake's variable substitution with 0/1 variables, which will be seen by the
# preprocessor as constants.
-set(HAVE_STDINT_H_01 ${HAVE_STDINT_H})
-set(HAVE_STDDEF_H_01 ${HAVE_STDDEF_H})
set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
-if(NOT HAVE_STDINT_H_01)
- set(HAVE_STDINT_H_01 0)
-endif(NOT HAVE_STDINT_H_01)
-if(NOT HAVE_STDDEF_H_01)
- set(HAVE_STDDEF_H_01 0)
-endif(NOT HAVE_STDDEF_H_01)
if(NOT HAVE_SYS_UIO_H_01)
set(HAVE_SYS_UIO_H_01 0)
endif(NOT HAVE_SYS_UIO_H_01)
diff --git a/chromium/third_party/snappy/src/cmake/config.h.in b/chromium/third_party/snappy/src/cmake/config.h.in
index 97cd8185f2c..3027b62ac6d 100644
--- a/chromium/third_party/snappy/src/cmake/config.h.in
+++ b/chromium/third_party/snappy/src/cmake/config.h.in
@@ -28,12 +28,6 @@
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
-/* Define to 1 if you have the <stddef.h> header file. */
-#cmakedefine HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#cmakedefine HAVE_STDINT_H 1
-
/* Define to 1 if you have the <sys/endian.h> header file. */
#cmakedefine HAVE_SYS_ENDIAN_H 1
@@ -55,6 +49,9 @@
/* Define to 1 if you have the <windows.h> header file. */
#cmakedefine HAVE_WINDOWS_H 1
+/* Define to 1 if you target processors with SSSE3+ and have <tmmintrin.h>. */
+#cmakedefine01 SNAPPY_HAVE_SSSE3
+
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#cmakedefine SNAPPY_IS_BIG_ENDIAN 1
diff --git a/chromium/third_party/snappy/src/snappy-stubs-internal.h b/chromium/third_party/snappy/src/snappy-stubs-internal.h
index cb605f82d0f..f834bdb40f8 100644
--- a/chromium/third_party/snappy/src/snappy-stubs-internal.h
+++ b/chromium/third_party/snappy/src/snappy-stubs-internal.h
@@ -53,6 +53,18 @@
#include <intrin.h>
#endif // defined(_MSC_VER)
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+#if __has_feature(memory_sanitizer)
+#include <sanitizer/msan_interface.h>
+#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
+ __msan_unpoison((address), (size))
+#else
+#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */
+#endif // __has_feature(memory_sanitizer)
+
#include "snappy-stubs-public.h"
#if defined(__x86_64__)
diff --git a/chromium/third_party/snappy/src/snappy-stubs-public.h.in b/chromium/third_party/snappy/src/snappy-stubs-public.h.in
index bb5b2226bf1..b8fe2305dd6 100644
--- a/chromium/third_party/snappy/src/snappy-stubs-public.h.in
+++ b/chromium/third_party/snappy/src/snappy-stubs-public.h.in
@@ -36,13 +36,9 @@
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
-#include <stdint.h>
-#endif // HAVE_STDDEF_H
-
-#if ${HAVE_STDDEF_H_01} // HAVE_STDDEF_H
-#include <stddef.h>
-#endif // HAVE_STDDEF_H
+#include <cstddef>
+#include <cstdint>
+#include <string>
#if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H
#include <sys/uio.h>
@@ -54,38 +50,25 @@
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-#include <string>
-
namespace snappy {
-#if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif // HAVE_STDINT_H
+using int8 = std::int8_t;
+using uint8 = std::uint8_t;
+using int16 = std::int16_t;
+using uint16 = std::uint16_t;
+using int32 = std::int32_t;
+using uint32 = std::uint32_t;
+using int64 = std::int64_t;
+using uint64 = std::uint64_t;
-typedef std::string string;
+using string = std::string;
#if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
- void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
#endif // !HAVE_SYS_UIO_H
diff --git a/chromium/third_party/snappy/src/snappy-test.h b/chromium/third_party/snappy/src/snappy-test.h
index 078f3211046..ec9d4dbfd3a 100644
--- a/chromium/third_party/snappy/src/snappy-test.h
+++ b/chromium/third_party/snappy/src/snappy-test.h
@@ -55,8 +55,6 @@
#include <windows.h>
#endif
-#include <string>
-
#ifdef HAVE_GTEST
#include <gtest/gtest.h>
diff --git a/chromium/third_party/snappy/src/snappy.cc b/chromium/third_party/snappy/src/snappy.cc
index d0eb323c917..e594bb96dad 100644
--- a/chromium/third_party/snappy/src/snappy.cc
+++ b/chromium/third_party/snappy/src/snappy.cc
@@ -30,18 +30,23 @@
#include "snappy-internal.h"
#include "snappy-sinksource.h"
-#ifndef SNAPPY_HAVE_SSE2
-#if defined(__SSE2__) || defined(_M_X64) || \
- (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
-#define SNAPPY_HAVE_SSE2 1
+#if !defined(SNAPPY_HAVE_SSSE3)
+// __SSSE3__ is defined by GCC and Clang. Visual Studio doesn't target SIMD
+// support between SSE2 and AVX (so SSSE3 instructions require AVX support), and
+// defines __AVX__ when AVX support is available.
+#if defined(__SSSE3__) || defined(__AVX__)
+#define SNAPPY_HAVE_SSSE3 1
#else
-#define SNAPPY_HAVE_SSE2 0
-#endif
+#define SNAPPY_HAVE_SSSE3 0
#endif
+#endif // !defined(SNAPPY_HAVE_SSSE3)
-#if SNAPPY_HAVE_SSE2
-#include <emmintrin.h>
+#if SNAPPY_HAVE_SSSE3
+// Please do not replace with <x86intrin.h>. or with headers that assume more
+// advanced SSE versions without checking with all the OWNERS.
+#include <tmmintrin.h>
#endif
+
#include <stdio.h>
#include <algorithm>
@@ -103,16 +108,12 @@ void UnalignedCopy64(const void* src, void* dst) {
}
void UnalignedCopy128(const void* src, void* dst) {
- // TODO(alkis): Remove this when we upgrade to a recent compiler that emits
- // SSE2 moves for memcpy(dst, src, 16).
-#if SNAPPY_HAVE_SSE2
- __m128i x = _mm_loadu_si128(static_cast<const __m128i*>(src));
- _mm_storeu_si128(static_cast<__m128i*>(dst), x);
-#else
+ // memcpy gets vectorized when the appropriate compiler options are used.
+ // For example, x86 compilers targeting SSE2+ will optimize to an SSE2 load
+ // and store.
char tmp[16];
memcpy(tmp, src, 16);
memcpy(dst, tmp, 16);
-#endif
}
// Copy [src, src+(op_limit-op)) to [op, (op_limit-op)) a byte at a time. Used
@@ -138,6 +139,23 @@ inline char* IncrementalCopySlow(const char* src, char* op,
return op_limit;
}
+#if SNAPPY_HAVE_SSSE3
+
+// This is a table of shuffle control masks that can be used as the source
+// operand for PSHUFB to permute the contents of the destination XMM register
+// into a repeating byte pattern.
+alignas(16) const char pshufb_fill_patterns[7][16] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
+ {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0},
+ {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3},
+ {0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0},
+ {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3},
+ {0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1},
+};
+
+#endif // SNAPPY_HAVE_SSSE3
+
// Copy [src, src+(op_limit-op)) to [op, (op_limit-op)) but faster than
// IncrementalCopySlow. buf_limit is the address past the end of the writable
// region of the buffer.
@@ -182,6 +200,37 @@ inline char* IncrementalCopy(const char* src, char* op, char* const op_limit,
// Handle the uncommon case where pattern is less than 8 bytes.
if (SNAPPY_PREDICT_FALSE(pattern_size < 8)) {
+#if SNAPPY_HAVE_SSSE3
+ // Load the first eight bytes into an 128-bit XMM register, then use PSHUFB
+ // to permute the register's contents in-place into a repeating sequence of
+ // the first "pattern_size" bytes.
+ // For example, suppose:
+ // src == "abc"
+ // op == op + 3
+ // After _mm_shuffle_epi8(), "pattern" will have five copies of "abc"
+ // followed by one byte of slop: abcabcabcabcabca.
+ //
+ // The non-SSE fallback implementation suffers from store-forwarding stalls
+ // because its loads and stores partly overlap. By expanding the pattern
+ // in-place, we avoid the penalty.
+ if (SNAPPY_PREDICT_TRUE(op <= buf_limit - 16)) {
+ const __m128i shuffle_mask = _mm_load_si128(
+ reinterpret_cast<const __m128i*>(pshufb_fill_patterns)
+ + pattern_size - 1);
+ const __m128i pattern = _mm_shuffle_epi8(
+ _mm_loadl_epi64(reinterpret_cast<const __m128i*>(src)), shuffle_mask);
+ // Uninitialized bytes are masked out by the shuffle mask.
+ SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(&pattern, sizeof(pattern));
+ pattern_size *= 16 / pattern_size;
+ char* op_end = std::min(op_limit, buf_limit - 15);
+ while (op < op_end) {
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op), pattern);
+ op += pattern_size;
+ }
+ if (SNAPPY_PREDICT_TRUE(op >= op_limit)) return op_limit;
+ }
+ return IncrementalCopySlow(src, op, op_limit);
+#else // !SNAPPY_HAVE_SSSE3
// If plenty of buffer space remains, expand the pattern to at least 8
// bytes. The way the following loop is written, we need 8 bytes of buffer
// space if pattern_size >= 4, 11 bytes if pattern_size is 1 or 3, and 10
@@ -198,6 +247,7 @@ inline char* IncrementalCopy(const char* src, char* op, char* const op_limit,
} else {
return IncrementalCopySlow(src, op, op_limit);
}
+#endif // SNAPPY_HAVE_SSSE3
}
assert(pattern_size >= 8);
@@ -459,7 +509,7 @@ char* CompressFragment(const char* input,
// "ip" is the input pointer, and "op" is the output pointer.
const char* ip = input;
assert(input_size <= kBlockSize);
- assert((table_size & (table_size - 1)) == 0); // table must be power of two
+ assert((table_size & (table_size - 1)) == 0); // table must be power of two
const int shift = 32 - Bits::Log2Floor(table_size);
assert(static_cast<int>(kuint32max >> shift) == table_size - 1);
const char* ip_end = input + input_size;
@@ -671,7 +721,7 @@ class SnappyDecompressor {
}
// Read the uncompressed length stored at the start of the compressed data.
- // On succcess, stores the length in *result and returns true.
+ // On success, stores the length in *result and returns true.
// On failure, returns false.
bool ReadUncompressedLength(uint32* result) {
assert(ip_ == NULL); // Must not have read anything yet
@@ -998,14 +1048,22 @@ size_t Compress(Source* reader, Sink* writer) {
// Writer template argument to SnappyDecompressor::DecompressAllTags().
class SnappyIOVecWriter {
private:
+ // output_iov_end_ is set to iov + count and used to determine when
+ // the end of the iovs is reached.
+ const struct iovec* output_iov_end_;
+
+#if !defined(NDEBUG)
const struct iovec* output_iov_;
- const size_t output_iov_count_;
+#endif // !defined(NDEBUG)
- // We are currently writing into output_iov_[curr_iov_index_].
- size_t curr_iov_index_;
+ // Current iov that is being written into.
+ const struct iovec* curr_iov_;
- // Bytes written to output_iov_[curr_iov_index_] so far.
- size_t curr_iov_written_;
+ // Pointer to current iov's write location.
+ char* curr_iov_output_;
+
+ // Remaining bytes to write into curr_iov_output.
+ size_t curr_iov_remaining_;
// Total bytes decompressed into output_iov_ so far.
size_t total_written_;
@@ -1013,22 +1071,24 @@ class SnappyIOVecWriter {
// Maximum number of bytes that will be decompressed into output_iov_.
size_t output_limit_;
- inline char* GetIOVecPointer(size_t index, size_t offset) {
- return reinterpret_cast<char*>(output_iov_[index].iov_base) +
- offset;
+ static inline char* GetIOVecPointer(const struct iovec* iov, size_t offset) {
+ return reinterpret_cast<char*>(iov->iov_base) + offset;
}
public:
// Does not take ownership of iov. iov must be valid during the
// entire lifetime of the SnappyIOVecWriter.
inline SnappyIOVecWriter(const struct iovec* iov, size_t iov_count)
- : output_iov_(iov),
- output_iov_count_(iov_count),
- curr_iov_index_(0),
- curr_iov_written_(0),
+ : output_iov_end_(iov + iov_count),
+#if !defined(NDEBUG)
+ output_iov_(iov),
+#endif // !defined(NDEBUG)
+ curr_iov_(iov),
+ curr_iov_output_(iov_count ? reinterpret_cast<char*>(iov->iov_base)
+ : nullptr),
+ curr_iov_remaining_(iov_count ? iov->iov_len : 0),
total_written_(0),
- output_limit_(-1) {
- }
+ output_limit_(-1) {}
inline void SetExpectedLength(size_t len) {
output_limit_ = len;
@@ -1043,23 +1103,25 @@ class SnappyIOVecWriter {
return false;
}
+ return AppendNoCheck(ip, len);
+ }
+
+ inline bool AppendNoCheck(const char* ip, size_t len) {
while (len > 0) {
- assert(curr_iov_written_ <= output_iov_[curr_iov_index_].iov_len);
- if (curr_iov_written_ >= output_iov_[curr_iov_index_].iov_len) {
+ if (curr_iov_remaining_ == 0) {
// This iovec is full. Go to the next one.
- if (curr_iov_index_ + 1 >= output_iov_count_) {
+ if (curr_iov_ + 1 >= output_iov_end_) {
return false;
}
- curr_iov_written_ = 0;
- ++curr_iov_index_;
+ ++curr_iov_;
+ curr_iov_output_ = reinterpret_cast<char*>(curr_iov_->iov_base);
+ curr_iov_remaining_ = curr_iov_->iov_len;
}
- const size_t to_write = std::min(
- len, output_iov_[curr_iov_index_].iov_len - curr_iov_written_);
- memcpy(GetIOVecPointer(curr_iov_index_, curr_iov_written_),
- ip,
- to_write);
- curr_iov_written_ += to_write;
+ const size_t to_write = std::min(len, curr_iov_remaining_);
+ memcpy(curr_iov_output_, ip, to_write);
+ curr_iov_output_ += to_write;
+ curr_iov_remaining_ -= to_write;
total_written_ += to_write;
ip += to_write;
len -= to_write;
@@ -1071,11 +1133,11 @@ class SnappyIOVecWriter {
inline bool TryFastAppend(const char* ip, size_t available, size_t len) {
const size_t space_left = output_limit_ - total_written_;
if (len <= 16 && available >= 16 + kMaximumTagLength && space_left >= 16 &&
- output_iov_[curr_iov_index_].iov_len - curr_iov_written_ >= 16) {
+ curr_iov_remaining_ >= 16) {
// Fast path, used for the majority (about 95%) of invocations.
- char* ptr = GetIOVecPointer(curr_iov_index_, curr_iov_written_);
- UnalignedCopy128(ip, ptr);
- curr_iov_written_ += len;
+ UnalignedCopy128(ip, curr_iov_output_);
+ curr_iov_output_ += len;
+ curr_iov_remaining_ -= len;
total_written_ += len;
return true;
}
@@ -1084,7 +1146,9 @@ class SnappyIOVecWriter {
}
inline bool AppendFromSelf(size_t offset, size_t len) {
- if (offset > total_written_ || offset == 0) {
+ // See SnappyArrayWriter::AppendFromSelf for an explanation of
+ // the "offset - 1u" trick.
+ if (offset - 1u >= total_written_) {
return false;
}
const size_t space_left = output_limit_ - total_written_;
@@ -1093,8 +1157,8 @@ class SnappyIOVecWriter {
}
// Locate the iovec from which we need to start the copy.
- size_t from_iov_index = curr_iov_index_;
- size_t from_iov_offset = curr_iov_written_;
+ const iovec* from_iov = curr_iov_;
+ size_t from_iov_offset = curr_iov_->iov_len - curr_iov_remaining_;
while (offset > 0) {
if (from_iov_offset >= offset) {
from_iov_offset -= offset;
@@ -1102,47 +1166,47 @@ class SnappyIOVecWriter {
}
offset -= from_iov_offset;
- assert(from_iov_index > 0);
- --from_iov_index;
- from_iov_offset = output_iov_[from_iov_index].iov_len;
+ --from_iov;
+#if !defined(NDEBUG)
+ assert(from_iov >= output_iov_);
+#endif // !defined(NDEBUG)
+ from_iov_offset = from_iov->iov_len;
}
// Copy <len> bytes starting from the iovec pointed to by from_iov_index to
// the current iovec.
while (len > 0) {
- assert(from_iov_index <= curr_iov_index_);
- if (from_iov_index != curr_iov_index_) {
- const size_t to_copy = std::min(
- output_iov_[from_iov_index].iov_len - from_iov_offset,
- len);
- Append(GetIOVecPointer(from_iov_index, from_iov_offset), to_copy);
+ assert(from_iov <= curr_iov_);
+ if (from_iov != curr_iov_) {
+ const size_t to_copy =
+ std::min(from_iov->iov_len - from_iov_offset, len);
+ AppendNoCheck(GetIOVecPointer(from_iov, from_iov_offset), to_copy);
len -= to_copy;
if (len > 0) {
- ++from_iov_index;
+ ++from_iov;
from_iov_offset = 0;
}
} else {
- assert(curr_iov_written_ <= output_iov_[curr_iov_index_].iov_len);
- size_t to_copy = std::min(output_iov_[curr_iov_index_].iov_len -
- curr_iov_written_,
- len);
+ size_t to_copy = curr_iov_remaining_;
if (to_copy == 0) {
// This iovec is full. Go to the next one.
- if (curr_iov_index_ + 1 >= output_iov_count_) {
+ if (curr_iov_ + 1 >= output_iov_end_) {
return false;
}
- ++curr_iov_index_;
- curr_iov_written_ = 0;
+ ++curr_iov_;
+ curr_iov_output_ = reinterpret_cast<char*>(curr_iov_->iov_base);
+ curr_iov_remaining_ = curr_iov_->iov_len;
continue;
}
if (to_copy > len) {
to_copy = len;
}
- IncrementalCopySlow(
- GetIOVecPointer(from_iov_index, from_iov_offset),
- GetIOVecPointer(curr_iov_index_, curr_iov_written_),
- GetIOVecPointer(curr_iov_index_, curr_iov_written_) + to_copy);
- curr_iov_written_ += to_copy;
+
+ IncrementalCopy(GetIOVecPointer(from_iov, from_iov_offset),
+ curr_iov_output_, curr_iov_output_ + to_copy,
+ curr_iov_output_ + curr_iov_remaining_);
+ curr_iov_output_ += to_copy;
+ curr_iov_remaining_ -= to_copy;
from_iov_offset += to_copy;
total_written_ += to_copy;
len -= to_copy;
@@ -1566,4 +1630,4 @@ bool Uncompress(Source* compressed, Sink* uncompressed) {
}
}
-} // end namespace snappy
+} // namespace snappy
diff --git a/chromium/third_party/snappy/src/snappy.h b/chromium/third_party/snappy/src/snappy.h
index 4568db890d6..f4d36ef3444 100644
--- a/chromium/third_party/snappy/src/snappy.h
+++ b/chromium/third_party/snappy/src/snappy.h
@@ -39,7 +39,7 @@
#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__
#define THIRD_PARTY_SNAPPY_SNAPPY_H__
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include "snappy-stubs-public.h"
diff --git a/chromium/third_party/snappy/src/snappy_unittest.cc b/chromium/third_party/snappy/src/snappy_unittest.cc
index fcb3261d20a..0548d2a9a31 100644
--- a/chromium/third_party/snappy/src/snappy_unittest.cc
+++ b/chromium/third_party/snappy/src/snappy_unittest.cc
@@ -421,7 +421,7 @@ static void VerifyIOVec(const string& input) {
if (rnd.OneIn(5)) {
iov[i].iov_len = 0;
} else {
- iov[i].iov_len = rnd.Uniform(input.size());
+ iov[i].iov_len = rnd.Uniform(input.size() - used_so_far);
}
}
used_so_far += iov[i].iov_len;
diff --git a/chromium/third_party/snappy/win32/config.h b/chromium/third_party/snappy/win32/config.h
index d0db90f03e5..995a8014f98 100644
--- a/chromium/third_party/snappy/win32/config.h
+++ b/chromium/third_party/snappy/win32/config.h
@@ -28,12 +28,6 @@
/* Define to 1 if you have the `z' library (-lz). */
/* #undef HAVE_LIBZ */
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
/* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */
@@ -55,6 +49,9 @@
/* Define to 1 if you have the <windows.h> header file. */
#define HAVE_WINDOWS_H 1
+/* Define to 1 if you target processors with SSSE3+ and have <tmmintrin.h>. */
+#define SNAPPY_HAVE_SSSE3 0
+
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef SNAPPY_IS_BIG_ENDIAN */
diff --git a/chromium/third_party/snappy/win32/snappy-stubs-public.h b/chromium/third_party/snappy/win32/snappy-stubs-public.h
index b3fddd3293d..7a6b771e7fc 100644
--- a/chromium/third_party/snappy/win32/snappy-stubs-public.h
+++ b/chromium/third_party/snappy/win32/snappy-stubs-public.h
@@ -36,13 +36,9 @@
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#if 1 // HAVE_STDINT_H
-#include <stdint.h>
-#endif // HAVE_STDDEF_H
-
-#if 1 // HAVE_STDDEF_H
-#include <stddef.h>
-#endif // HAVE_STDDEF_H
+#include <cstddef>
+#include <cstdint>
+#include <string>
#if 0 // HAVE_SYS_UIO_H
#include <sys/uio.h>
@@ -54,31 +50,18 @@
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-#include <string>
-
namespace snappy {
-#if 1 // HAVE_STDINT_H
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif // HAVE_STDINT_H
+using int8 = std::int8_t;
+using uint8 = std::uint8_t;
+using int16 = std::int16_t;
+using uint16 = std::uint16_t;
+using int32 = std::int32_t;
+using uint32 = std::uint32_t;
+using int64 = std::int64_t;
+using uint64 = std::uint64_t;
-typedef std::string string;
+using string = std::string;
#if !0 // !HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.