Skip to content

Commit

Permalink
Update Brotli from Chromium 114.0.5735.358
Browse files Browse the repository at this point in the history
Issue: 326748668
Reviewed-on: #3217
  • Loading branch information
dahlstrom-g authored May 15, 2024
2 parents 37e0d11 + 69fbf1d commit 2519c29
Show file tree
Hide file tree
Showing 81 changed files with 3,998 additions and 984 deletions.
41 changes: 22 additions & 19 deletions third_party/brotli/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/sanitizers/sanitizers.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

if (is_win) {
import("//build/config/win/visual_studio_version.gni")
}

config("brotli_defines") {
# By default, brotli depends on undefined behavior, but setting
# BROTLI_BUILD_PORTABLE should result in a build which does not.
if (is_ubsan) {
defines = [ "BROTLI_BUILD_PORTABLE" ]
}
}

config("includes") {
include_dirs = [ "include" ]
}
Expand All @@ -30,6 +40,8 @@ common_sources = [
"common/dictionary.h",
"common/platform.c",
"common/platform.h",
"common/shared_dictionary.c",
"common/shared_dictionary_internal.h",
"common/transform.c",
"common/transform.h",
"common/version.h",
Expand All @@ -38,12 +50,14 @@ common_sources = [
static_library("common") {
sources = common_sources
public_configs = [ ":includes" ]
configs += [ ":brotli_defines" ]
deps = [ ":headers" ]
}

static_library("common_no_dictionary_data") {
sources = common_sources
public_configs = [ ":includes" ]
configs += [ ":brotli_defines" ]
deps = [ ":headers" ]
defines = [ "BROTLI_EXTERNAL_DICTIONARY_DATA" ]
}
Expand All @@ -59,7 +73,6 @@ dec_sources = [
"dec/state.h",
]

if (!is_starboard) {
enc_sources = [
"enc/backward_references_hq.c",
"enc/backward_references_hq.h",
Expand All @@ -80,6 +93,8 @@ enc_sources = [
"enc/cluster.h",
"enc/command.c",
"enc/command.h",
"enc/compound_dictionary.c",
"enc/compound_dictionary.h",
"enc/compress_fragment_two_pass.c",
"enc/compress_fragment_two_pass.h",
"enc/compress_fragment.c",
Expand Down Expand Up @@ -124,53 +139,41 @@ enc_sources = [
"enc/utf8_util.h",
"enc/write_bits.h",
]
}

static_library("dec") {
sources = dec_sources
public_configs = [ ":includes" ]
configs += [ ":brotli_defines" ]
public_deps = [ ":headers" ]
deps = [ ":common" ]

if (is_starboard) {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
} else {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

# Since we never debug brotli, freeze the optimizations to -O2.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}

static_library("dec_no_dictionary_data") {
sources = dec_sources
public_configs = [ ":includes" ]
configs += [ ":brotli_defines" ]
public_deps = [ ":headers" ]
deps = [ ":common_no_dictionary_data" ]

if (is_starboard) {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
} else {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

# Since we never debug brotli, freeze the optimizations to -O2.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}

if (!is_starboard) {
static_library("enc") {
sources = enc_sources
public_configs = [ ":includes" ]

configs += [ ":brotli_defines" ]
public_deps = [ ":headers" ]
deps = [ ":common" ]

Expand All @@ -186,6 +189,7 @@ if (current_toolchain == host_toolchain) {
executable("brotli") {
sources = [ "tools/brotli.c" ]
public_configs = [ ":includes" ]
configs += [ ":brotli_defines" ]

deps = [
":common",
Expand All @@ -210,8 +214,7 @@ if (current_toolchain == host_toolchain) {
}

fuzzer_test("brotli_fuzzer") {
sources = [ "fuzz/decode_fuzzer.cc" ]
sources = [ "fuzz/decode_fuzzer.c" ]
deps = [ ":dec" ]
libfuzzer_options = [ "max_len=1280" ]
}
}
4 changes: 2 additions & 2 deletions third_party/brotli/METADATA
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ description:
third_party {
identifier {
type: "ChromiumVersion"
value: "102.0.5005.193" # from https://chromereleases.googleblog.com/2022/12/long-term-support-channel-update-for_14.html
value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "1218c4f5fdcc00016ccd2531932e9f3dec0151e6"
version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02"
}
identifier {
type: "UpstreamSubdir"
Expand Down
2 changes: 1 addition & 1 deletion third_party/brotli/README.chromium
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: Brotli
URL: https://github.com/google/brotli
Version: e61745a6b7add50d380cfd7d3883dd6c62fc2c71
Version: 9801a2c5d6c67c467ffad676ac301379bb877fc3
License: MIT
License File: LICENSE
Security Critical: yes
Expand Down
2 changes: 1 addition & 1 deletion third_party/brotli/common/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#include "./constants.h"
#include "constants.h"

const BrotliPrefixCodeRange
_kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = {
Expand Down
2 changes: 1 addition & 1 deletion third_party/brotli/common/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef BROTLI_COMMON_CONSTANTS_H_
#define BROTLI_COMMON_CONSTANTS_H_

#include "./platform.h"
#include "platform.h"
#include <brotli/port.h>
#include <brotli/types.h>

Expand Down
2 changes: 1 addition & 1 deletion third_party/brotli/common/context.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "./context.h"
#include "context.h"

#include <brotli/types.h>

Expand Down
6 changes: 4 additions & 2 deletions third_party/brotli/common/dictionary.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#include "./dictionary.h"
#include "./platform.h"
#include "dictionary.h"
#include "platform.h"

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

#if !defined(BROTLI_EXTERNAL_DICTIONARY_DATA)
static const uint8_t kBrotliDictionaryData[] =
/* GENERATED CODE START */
{
116,105,109,101,100,111,119,110,108,105,102,101,108,101,102,116,98,97,99,107,99,
111,100,101,100,97,116,97,115,104,111,119,111,110,108,121,115,105,116,101,99,105
Expand Down Expand Up @@ -5860,6 +5861,7 @@ static const uint8_t kBrotliDictionaryData[] =
,164,181,224,164,190,224,164,136,224,164,184,224,164,149,224,165,141,224,164,176
,224,164,191,224,164,175,224,164,164,224,164,190
}
/* GENERATED CODE END */
;
#endif /* !BROTLI_EXTERNAL_DICTIONARY_DATA */

Expand Down
2 changes: 1 addition & 1 deletion third_party/brotli/common/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <stdlib.h>

#include "./platform.h"
#include "platform.h"
#include <brotli/types.h>

/* Default brotli_alloc_func */
Expand Down
37 changes: 5 additions & 32 deletions third_party/brotli/common/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
#endif

#if BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
#if BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
#include <intrin.h>
#endif

Expand Down Expand Up @@ -156,24 +156,6 @@ To apply compiler hint, enclose the branching condition into macros, like this:
#define BROTLI_NOINLINE
#endif

/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */
#if !defined(BROTLI_INTERNAL)
#if defined(_WIN32) || defined(__CYGWIN__)
#define BROTLI_INTERNAL
#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \
BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \
BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
(BROTLI_TI_VERSION_CHECK(7, 3, 0) && \
defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden")))
#else
#define BROTLI_INTERNAL
#endif
#endif

/* <<< <<< <<< end of hedley macros. */

#if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \
Expand Down Expand Up @@ -243,14 +225,6 @@ To apply compiler hint, enclose the branching condition into macros, like this:
#define brotli_reg_t uint32_t
#endif

#if defined(STARBOARD)
#include "starboard/configuration.h"
#if SB_IS(BIG_ENDIAN)
#define BROTLI_BIG_ENDIAN 1
#else
#define BROTLI_LITTLE_ENDIAN 1
#endif
#else /* not defined STARBOARD */
#if defined(BROTLI_BUILD_BIG_ENDIAN)
#define BROTLI_BIG_ENDIAN 1
#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
Expand All @@ -271,7 +245,6 @@ To apply compiler hint, enclose the branching condition into macros, like this:
#define BROTLI_BIG_ENDIAN 1
#endif
#endif /* BROTLI_X_BYTE_ORDER */
#endif /* STARBOARD */

#if !defined(BROTLI_LITTLE_ENDIAN)
#define BROTLI_LITTLE_ENDIAN 0
Expand Down Expand Up @@ -494,11 +467,11 @@ static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
#define BROTLI_DUMP() (void)(0)
#endif

/* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */
/* TODO(eustas): add appropriate icc/sunpro/arm/ibm/ti checks. */
#if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \
!defined(BROTLI_BUILD_NO_RBIT)
#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)
/* TODO: detect ARMv6T2 and enable this code for it. */
/* TODO(eustas): detect ARMv6T2 and enable this code for it. */
static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) {
brotli_reg_t output;
__asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
Expand Down Expand Up @@ -538,7 +511,7 @@ BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_ctzll, 3, 4, 0) || \
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
#define BROTLI_TZCNT64 __builtin_ctzll
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
#elif BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
#if defined(BROTLI_TARGET_X64)
#define BROTLI_TZCNT64 _tzcnt_u64
#else /* BROTLI_TARGET_X64 */
Expand All @@ -555,7 +528,7 @@ static BROTLI_INLINE uint32_t BrotliBsf64Msvc(uint64_t x) {
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_clz, 3, 4, 0) || \
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
#define BROTLI_BSR32(x) (31u ^ (uint32_t)__builtin_clz(x))
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
#elif BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
static BROTLI_INLINE uint32_t BrotliBsr32Msvc(uint32_t x) {
unsigned long msb;
_BitScanReverse(&msb, x);
Expand Down
Loading

0 comments on commit 2519c29

Please sign in to comment.