Separate slices from mdelems for static data (#27372)

* separate slice into internal and refcount, with refcount being the minimal base

* python3-ize

* Separate slices from mdelems for static data

Allows us to separate a small build target with just some slice basics
from the rest, which will help simplify the build system longer term.

Additionally exposed an opportunity to eliminate an init function.

Should also help in a month or so when it's time to jettison interned
metadata and slices entirely.

* fix compilation

* Automated change: Fix sanity tests

* fixes

* fixfixfix

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/27438/head
Craig Tiller 3 years ago committed by GitHub
parent f79189359b
commit 66ae0d5c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      BUILD
  2. 4
      CMakeLists.txt
  3. 4
      Makefile
  4. 10
      build_autogenerated.yaml
  5. 2
      config.m4
  6. 2
      config.w32
  7. 6
      gRPC-C++.podspec
  8. 8
      gRPC-Core.podspec
  9. 5
      grpc.gemspec
  10. 4
      grpc.gyp
  11. 5
      package.xml
  12. 1
      src/core/ext/transport/binder/transport/BUILD
  13. 4
      src/core/ext/transport/chttp2/transport/hpack_parser_table.h
  14. 21
      src/core/lib/slice/slice_intern.cc
  15. 244
      src/core/lib/slice/slice_internal.h
  16. 17
      src/core/lib/slice/slice_refcount.cc
  17. 121
      src/core/lib/slice/slice_refcount.h
  18. 173
      src/core/lib/slice/slice_refcount_base.h
  19. 529
      src/core/lib/slice/static_slice.cc
  20. 331
      src/core/lib/slice/static_slice.h
  21. 3
      src/core/lib/surface/init.cc
  22. 8
      src/core/lib/transport/metadata.cc
  23. 1505
      src/core/lib/transport/static_metadata.cc
  24. 490
      src/core/lib/transport/static_metadata.h
  25. 2
      src/python/grpcio/grpc_core_dependencies.py
  26. 12
      test/core/slice/slice_test.cc
  27. 2
      test/core/transport/metadata_test.cc
  28. 2
      test/core/transport/static_metadata_test.cc
  29. 486
      tools/codegen/core/gen_static_metadata.py
  30. 5
      tools/doxygen/Doxyfile.c++.internal
  31. 5
      tools/doxygen/Doxyfile.core.internal

26
BUILD

@ -1265,6 +1265,27 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "slice_refcount",
srcs = [
"src/core/lib/slice/slice_refcount.cc",
"src/core/lib/slice/static_slice.cc",
],
hdrs = [
"src/core/lib/slice/slice_refcount.h",
"src/core/lib/slice/slice_refcount_base.h",
"src/core/lib/slice/slice_utils.h",
"src/core/lib/slice/static_slice.h",
],
public_hdrs = [
"include/grpc/slice.h",
],
deps = [
"gpr_base",
"ref_counted",
],
)
grpc_cc_library(
name = "grpc_base_c",
srcs = [
@ -1548,7 +1569,6 @@ grpc_cc_library(
"src/core/lib/slice/percent_encoding.h",
"src/core/lib/slice/slice_internal.h",
"src/core/lib/slice/slice_string_helpers.h",
"src/core/lib/slice/slice_utils.h",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/call.h",
"src/core/lib/surface/call_test_only.h",
@ -1605,6 +1625,7 @@ grpc_cc_library(
"orphanable",
"ref_counted",
"ref_counted_ptr",
"slice_refcount",
"useful",
],
)
@ -2065,6 +2086,7 @@ grpc_cc_library(
"grpc_transport_chttp2_client_secure",
"orphanable",
"ref_counted_ptr",
"slice_refcount",
"udpa_type_upb",
"udpa_type_upbdefs",
],
@ -2738,6 +2760,7 @@ grpc_cc_library(
"grpc_transport_chttp2_alpn",
"ref_counted",
"ref_counted_ptr",
"slice_refcount",
"tsi",
"tsi_interface",
"useful",
@ -3004,6 +3027,7 @@ grpc_cc_library(
"hpack_encoder_table",
"match",
"popularity_count",
"slice_refcount",
"useful",
],
)

4
CMakeLists.txt generated

@ -2054,7 +2054,9 @@ add_library(grpc
src/core/lib/slice/slice.cc
src/core/lib/slice/slice_buffer.cc
src/core/lib/slice/slice_intern.cc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/slice/static_slice.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/byte_buffer.cc
src/core/lib/surface/byte_buffer_reader.cc
@ -2634,7 +2636,9 @@ add_library(grpc_unsecure
src/core/lib/slice/slice.cc
src/core/lib/slice/slice_buffer.cc
src/core/lib/slice/slice_intern.cc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/slice/static_slice.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/byte_buffer.cc
src/core/lib/surface/byte_buffer_reader.cc

4
Makefile generated

@ -1545,7 +1545,9 @@ LIBGRPC_SRC = \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/static_slice.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
@ -1973,7 +1975,9 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/static_slice.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \

@ -895,8 +895,11 @@ libs:
- src/core/lib/slice/b64.h
- src/core/lib/slice/percent_encoding.h
- src/core/lib/slice/slice_internal.h
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_refcount_base.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/slice/slice_utils.h
- src/core/lib/slice/static_slice.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/call.h
- src/core/lib/surface/call_test_only.h
@ -1455,7 +1458,9 @@ libs:
- src/core/lib/slice/slice.cc
- src/core/lib/slice/slice_buffer.cc
- src/core/lib/slice/slice_intern.cc
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/slice/static_slice.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/byte_buffer.cc
- src/core/lib/surface/byte_buffer_reader.cc
@ -1891,8 +1896,11 @@ libs:
- src/core/lib/slice/b64.h
- src/core/lib/slice/percent_encoding.h
- src/core/lib/slice/slice_internal.h
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_refcount_base.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/slice/slice_utils.h
- src/core/lib/slice/static_slice.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/call.h
- src/core/lib/surface/call_test_only.h
@ -2169,7 +2177,9 @@ libs:
- src/core/lib/slice/slice.cc
- src/core/lib/slice/slice_buffer.cc
- src/core/lib/slice/slice_intern.cc
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/slice/static_slice.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/byte_buffer.cc
- src/core/lib/surface/byte_buffer_reader.cc

2
config.m4 generated

@ -598,7 +598,9 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/static_slice.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \

2
config.w32 generated

@ -564,7 +564,9 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\slice\\slice.cc " +
"src\\core\\lib\\slice\\slice_buffer.cc " +
"src\\core\\lib\\slice\\slice_intern.cc " +
"src\\core\\lib\\slice\\slice_refcount.cc " +
"src\\core\\lib\\slice\\slice_string_helpers.cc " +
"src\\core\\lib\\slice\\static_slice.cc " +
"src\\core\\lib\\surface\\api_trace.cc " +
"src\\core\\lib\\surface\\byte_buffer.cc " +
"src\\core\\lib\\surface\\byte_buffer_reader.cc " +

6
gRPC-C++.podspec generated

@ -707,8 +707,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/slice/slice_utils.h',
'src/core/lib/slice/static_slice.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
@ -1374,8 +1377,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/slice/slice_utils.h',
'src/core/lib/slice/static_slice.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',

8
gRPC-Core.podspec generated

@ -1256,9 +1256,14 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_intern.cc',
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/slice/slice_utils.h',
'src/core/lib/slice/static_slice.cc',
'src/core/lib/slice/static_slice.h',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/byte_buffer.cc',
@ -1957,8 +1962,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/slice/slice_utils.h',
'src/core/lib/slice/static_slice.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',

5
grpc.gemspec generated

@ -1169,9 +1169,14 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/slice/slice_buffer.cc )
s.files += %w( src/core/lib/slice/slice_intern.cc )
s.files += %w( src/core/lib/slice/slice_internal.h )
s.files += %w( src/core/lib/slice/slice_refcount.cc )
s.files += %w( src/core/lib/slice/slice_refcount.h )
s.files += %w( src/core/lib/slice/slice_refcount_base.h )
s.files += %w( src/core/lib/slice/slice_string_helpers.cc )
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
s.files += %w( src/core/lib/slice/slice_utils.h )
s.files += %w( src/core/lib/slice/static_slice.cc )
s.files += %w( src/core/lib/slice/static_slice.h )
s.files += %w( src/core/lib/surface/api_trace.cc )
s.files += %w( src/core/lib/surface/api_trace.h )
s.files += %w( src/core/lib/surface/byte_buffer.cc )

4
grpc.gyp generated

@ -986,7 +986,9 @@
'src/core/lib/slice/slice.cc',
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_intern.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/static_slice.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
@ -1389,7 +1391,9 @@
'src/core/lib/slice/slice.cc',
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_intern.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/static_slice.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',

5
package.xml generated

@ -1149,9 +1149,14 @@
<file baseinstalldir="/" name="src/core/lib/slice/slice_buffer.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_intern.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount_base.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/static_slice.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/static_slice.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/byte_buffer.cc" role="src" />

@ -41,6 +41,7 @@ grpc_cc_library(
"//:gpr_base",
"//:gpr_platform",
"//:grpc_base_c",
"//:slice_refcount",
"//src/core/ext/transport/binder/utils:transport_stream_receiver",
"//src/core/ext/transport/binder/wire_format:binder",
"//src/core/ext/transport/binder/wire_format:wire_reader",

@ -68,7 +68,7 @@ class HPackTable {
// reading the core static metadata table here; at that point we'd need our
// own singleton static metadata in the correct order.
if (index <= hpack_constants::kLastStaticEntry) {
return grpc_static_mdelem_manifested()[index - 1];
return g_static_mdelem_manifested[index - 1];
} else {
return LookupDynamic<take_ref>(index);
}
@ -120,7 +120,7 @@ class HPackTable {
inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) {
uintptr_t index =
reinterpret_cast<grpc_core::StaticMetadata*>(GRPC_MDELEM_DATA(md)) -
grpc_static_mdelem_table();
grpc_core::g_static_mdelem_table;
if (index < grpc_core::hpack_constants::kLastStaticEntry) {
return index + 1; // Hpack static metadata element indices start at 1
}

@ -136,12 +136,11 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) {
static_metadata_hash_ent ent =
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
const grpc_core::StaticMetadataSlice* static_slice_table =
grpc_static_slice_table();
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
grpc_slice_eq_static_interned(slice, static_slice_table[ent.idx])) {
grpc_slice_eq_static_interned(
slice, grpc_core::g_static_metadata_slice_table[ent.idx])) {
*returned_slice_is_different = true;
return static_slice_table[ent.idx];
return grpc_core::g_static_metadata_slice_table[ent.idx];
}
}
@ -167,11 +166,9 @@ static const grpc_core::StaticMetadataSlice* MatchStaticSlice(
for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) {
static_metadata_hash_ent ent =
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
const grpc_core::StaticMetadataSlice* static_slice_table =
grpc_static_slice_table();
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
static_slice_table[ent.idx] == args) {
return &static_slice_table[ent.idx];
grpc_core::g_static_metadata_slice_table[ent.idx] == args) {
return &grpc_core::g_static_metadata_slice_table[ent.idx];
}
}
return nullptr;
@ -323,11 +320,9 @@ void grpc_slice_intern_init(void) {
static_metadata_hash[i].idx = GRPC_STATIC_MDSTR_COUNT;
}
max_static_metadata_hash_probe = 0;
const grpc_core::StaticMetadataSlice* static_slice_table =
grpc_static_slice_table();
for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) {
grpc_static_metadata_hash_values[i] =
grpc_slice_default_hash_internal(static_slice_table[i]);
grpc_static_metadata_hash_values[i] = grpc_slice_default_hash_internal(
grpc_core::g_static_metadata_slice_table[i]);
for (size_t j = 0; j < GPR_ARRAY_SIZE(static_metadata_hash); j++) {
size_t slot = (grpc_static_metadata_hash_values[i] + j) %
GPR_ARRAY_SIZE(static_metadata_hash);
@ -343,7 +338,7 @@ void grpc_slice_intern_init(void) {
}
// Handle KV hash for all static mdelems.
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; ++i) {
grpc_static_mdelem_table()[i].HashInit();
grpc_core::g_static_mdelem_table[i].HashInit();
}
}

@ -30,252 +30,10 @@
#include "src/core/lib/gpr/murmur_hash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/slice/slice_refcount.h"
#include "src/core/lib/slice/slice_utils.h"
#include "src/core/lib/transport/static_metadata.h"
// Interned slices have specific fast-path operations for hashing. To inline
// these operations, we need to forward declare them here.
extern uint32_t grpc_static_metadata_hash_values[GRPC_STATIC_MDSTR_COUNT];
// grpc_slice_refcount : A reference count for grpc_slice.
//
// Non-inlined grpc_slice objects are refcounted. Historically this was
// implemented via grpc_slice_refcount, a C-style polymorphic class using a
// manually managed vtable of operations. Subclasses would define their own
// vtable; the 'virtual' methods (ref, unref, equals and hash) would simply call
// the function pointers in the vtable as necessary.
//
// Unfortunately, this leads to some inefficiencies in the generated code that
// can be improved upon. For example, equality checking for interned slices is a
// simple equality check on the refcount pointer. With the vtable approach, this
// would translate to roughly the following (high-level) instructions:
//
// grpc_slice_equals(slice1, slice2):
// load vtable->eq -> eq_func
// call eq_func(slice1, slice2)
//
// interned_slice_equals(slice1, slice2)
// load slice1.ref -> r1
// load slice2.ref -> r2
// cmp r1, r2 -> retval
// ret retval
//
// This leads to a function call for a function defined in another translation
// unit, which imposes memory barriers, which reduces the compiler's ability to
// optimize (in addition to the added overhead of call/ret). Additionally, it
// may be harder to reason about branch prediction when we're jumping to
// essentially arbitrarily provided function pointers.
//
// In addition, it is arguable that while virtualization was helpful for
// Equals()/Hash() methods, that it was fundamentally unnecessary for
// Ref()/Unref().
//
// Instead, grpc_slice_refcount provides the same functionality as the C-style
// virtual class, but in a de-virtualized manner - Eq(), Hash(), Ref() and
// Unref() are provided within this header file. Fastpaths for Eq()/Hash()
// (interned and static metadata slices), as well as the Ref() operation, can
// all be inlined without any memory barriers.
//
// It does this by:
// 1. Using grpc_core::RefCount<> (header-only) for Ref/Unref. Two special cases
// need support: No-op ref/unref (eg. static metadata slices) and stream
// slice references (where all the slices share the streamref). This is in
// addition to the normal case of '1 slice, 1 ref'.
// To support these cases, we explicitly track a nullable pointer to the
// underlying RefCount<>. No-op ref/unref is used by checking the pointer for
// null, and doing nothing if it is. Both stream slice refs and 'normal'
// slices use the same path for Ref/Unref (by targeting the non-null
// pointer).
//
// 2. introducing the notion of grpc_slice_refcount::Type. This describes if a
// slice ref is used by a static metadata slice, an interned slice, or other
// slices. We switch on the slice ref type in order to provide fastpaths for
// Equals() and Hash().
//
// In total, this saves us roughly 1-2% latency for unary calls, with smaller
// calls benefitting. The effect is present, but not as useful, for larger calls
// where the cost of sending the data dominates.
// TODO(arjunroy): Investigate if this can be removed with strongly typed
// grpc_slices.
struct grpc_slice_refcount {
public:
enum class Type {
STATIC, // Refcount for a static metadata slice.
INTERNED, // Refcount for an interned slice.
NOP, // No-Op
REGULAR // Refcount for non-static-metadata, non-interned slices.
};
typedef void (*DestroyerFn)(void*);
grpc_slice_refcount() = default;
explicit grpc_slice_refcount(Type t) : ref_type_(t) {}
explicit grpc_slice_refcount(grpc_slice_refcount* sub) : sub_refcount_(sub) {}
// Regular constructor for grpc_slice_refcount.
//
// Parameters:
// 1. grpc_slice_refcount::Type type
// Whether we are the refcount for a static
// metadata slice, an interned slice, or any other kind of slice.
//
// 2. RefCount* ref
// The pointer to the actual underlying grpc_core::RefCount. Rather than
// performing struct offset computations as in the original implementation to
// get to the refcount, which requires a virtual method, we devirtualize by
// using a nullable pointer to allow a single pair of Ref/Unref methods.
//
// 3. DestroyerFn destroyer_fn
// Called when the refcount goes to 0, with destroyer_arg as parameter.
//
// 4. void* destroyer_arg
// Argument for the virtualized destructor.
//
// 5. grpc_slice_refcount* sub
// Argument used for interned slices.
grpc_slice_refcount(grpc_slice_refcount::Type type, grpc_core::RefCount* ref,
DestroyerFn destroyer_fn, void* destroyer_arg,
grpc_slice_refcount* sub)
: ref_(ref),
ref_type_(type),
sub_refcount_(sub),
dest_fn_(destroyer_fn),
destroy_fn_arg_(destroyer_arg) {}
// Initializer for static refcounts.
grpc_slice_refcount(grpc_slice_refcount* sub, Type type)
: ref_type_(type), sub_refcount_(sub) {}
Type GetType() const { return ref_type_; }
int Eq(const grpc_slice& a, const grpc_slice& b);
uint32_t Hash(const grpc_slice& slice);
void Ref() {
if (ref_ == nullptr) return;
ref_->RefNonZero();
}
void Unref() {
if (ref_ == nullptr) return;
if (ref_->Unref()) {
dest_fn_(destroy_fn_arg_);
}
}
grpc_slice_refcount* sub_refcount() const { return sub_refcount_; }
private:
grpc_core::RefCount* ref_ = nullptr;
const Type ref_type_ = Type::REGULAR;
grpc_slice_refcount* sub_refcount_ = this;
DestroyerFn dest_fn_ = nullptr;
void* destroy_fn_arg_ = nullptr;
};
namespace grpc_core {
struct StaticSliceRefcount {
static grpc_slice_refcount kStaticSubRefcount;
explicit StaticSliceRefcount(uint32_t index)
: base(&kStaticSubRefcount, grpc_slice_refcount::Type::STATIC),
index(index) {}
grpc_slice_refcount base;
const uint32_t index;
};
extern grpc_slice_refcount kNoopRefcount;
struct InternedSliceRefcount {
static void Destroy(void* arg) {
auto* rc = static_cast<InternedSliceRefcount*>(arg);
rc->~InternedSliceRefcount();
gpr_free(rc);
}
InternedSliceRefcount(size_t length, uint32_t hash,
InternedSliceRefcount* bucket_next)
: base(grpc_slice_refcount::Type::INTERNED, &refcnt, Destroy, this, &sub),
sub(grpc_slice_refcount::Type::REGULAR, &refcnt, Destroy, this, &sub),
length(length),
hash(hash),
bucket_next(bucket_next) {}
~InternedSliceRefcount();
grpc_slice_refcount base;
grpc_slice_refcount sub;
const size_t length;
RefCount refcnt;
const uint32_t hash;
InternedSliceRefcount* bucket_next;
};
} // namespace grpc_core
inline size_t grpc_refcounted_slice_length(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
return slice.data.refcounted.length;
}
inline const uint8_t* grpc_refcounted_slice_data(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
return slice.data.refcounted.bytes;
}
inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) {
GPR_DEBUG_ASSERT(a.refcount != nullptr);
GPR_DEBUG_ASSERT(a.refcount == this);
switch (ref_type_) {
case Type::STATIC:
GPR_DEBUG_ASSERT(
(GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b)) ==
(a.refcount == b.refcount));
ABSL_FALLTHROUGH_INTENDED;
case Type::INTERNED:
return a.refcount == b.refcount;
case Type::NOP:
case Type::REGULAR:
break;
}
if (grpc_refcounted_slice_length(a) != GRPC_SLICE_LENGTH(b)) return false;
if (grpc_refcounted_slice_length(a) == 0) return true;
return 0 == memcmp(grpc_refcounted_slice_data(a), GRPC_SLICE_START_PTR(b),
grpc_refcounted_slice_length(a));
}
inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
GPR_DEBUG_ASSERT(slice.refcount == this);
switch (ref_type_) {
case Type::STATIC:
return ::grpc_static_metadata_hash_values[GRPC_STATIC_METADATA_INDEX(
slice)];
case Type::INTERNED:
return reinterpret_cast<grpc_core::InternedSliceRefcount*>(slice.refcount)
->hash;
case Type::NOP:
case Type::REGULAR:
break;
}
return gpr_murmur_hash3(grpc_refcounted_slice_data(slice),
grpc_refcounted_slice_length(slice),
grpc_core::g_hash_seed);
}
inline const grpc_slice& grpc_slice_ref_internal(const grpc_slice& slice) {
if (slice.refcount) {
slice.refcount->Ref();
}
return slice;
}
inline void grpc_slice_unref_internal(const grpc_slice& slice) {
if (slice.refcount) {
slice.refcount->Unref();
}
}
void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb);
void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb,
size_t idx);

@ -0,0 +1,17 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <grpc/support/port_platform.h>
#include "src/core/lib/slice/slice_refcount.h"

@ -0,0 +1,121 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_H
#define GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/slice/slice_refcount_base.h"
#include "src/core/lib/slice/static_slice.h"
// Interned slices have specific fast-path operations for hashing. To inline
// these operations, we need to forward declare them here.
extern uint32_t grpc_static_metadata_hash_values[GRPC_STATIC_MDSTR_COUNT];
namespace grpc_core {
extern grpc_slice_refcount kNoopRefcount;
struct InternedSliceRefcount {
static void Destroy(void* arg) {
auto* rc = static_cast<InternedSliceRefcount*>(arg);
rc->~InternedSliceRefcount();
gpr_free(rc);
}
InternedSliceRefcount(size_t length, uint32_t hash,
InternedSliceRefcount* bucket_next)
: base(grpc_slice_refcount::Type::INTERNED, &refcnt, Destroy, this, &sub),
sub(grpc_slice_refcount::Type::REGULAR, &refcnt, Destroy, this, &sub),
length(length),
hash(hash),
bucket_next(bucket_next) {}
~InternedSliceRefcount();
grpc_slice_refcount base;
grpc_slice_refcount sub;
const size_t length;
RefCount refcnt;
const uint32_t hash;
InternedSliceRefcount* bucket_next;
};
} // namespace grpc_core
inline size_t grpc_refcounted_slice_length(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
return slice.data.refcounted.length;
}
inline const uint8_t* grpc_refcounted_slice_data(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
return slice.data.refcounted.bytes;
}
inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) {
GPR_DEBUG_ASSERT(a.refcount != nullptr);
GPR_DEBUG_ASSERT(a.refcount == this);
switch (ref_type_) {
case Type::STATIC:
GPR_DEBUG_ASSERT(
(GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b)) ==
(a.refcount == b.refcount));
ABSL_FALLTHROUGH_INTENDED;
case Type::INTERNED:
return a.refcount == b.refcount;
case Type::NOP:
case Type::REGULAR:
break;
}
if (grpc_refcounted_slice_length(a) != GRPC_SLICE_LENGTH(b)) return false;
if (grpc_refcounted_slice_length(a) == 0) return true;
return 0 == memcmp(grpc_refcounted_slice_data(a), GRPC_SLICE_START_PTR(b),
grpc_refcounted_slice_length(a));
}
inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
GPR_DEBUG_ASSERT(slice.refcount == this);
switch (ref_type_) {
case Type::STATIC:
return ::grpc_static_metadata_hash_values[GRPC_STATIC_METADATA_INDEX(
slice)];
case Type::INTERNED:
return reinterpret_cast<grpc_core::InternedSliceRefcount*>(slice.refcount)
->hash;
case Type::NOP:
case Type::REGULAR:
break;
}
return gpr_murmur_hash3(grpc_refcounted_slice_data(slice),
grpc_refcounted_slice_length(slice),
grpc_core::g_hash_seed);
}
inline const grpc_slice& grpc_slice_ref_internal(const grpc_slice& slice) {
if (slice.refcount) {
slice.refcount->Ref();
}
return slice;
}
inline void grpc_slice_unref_internal(const grpc_slice& slice) {
if (slice.refcount) {
slice.refcount->Unref();
}
}
#endif /* GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_H */

@ -0,0 +1,173 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_BASE_H
#define GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_BASE_H
#include <grpc/support/port_platform.h>
#include <grpc/slice.h>
#include "src/core/lib/gprpp/ref_counted.h"
// grpc_slice_refcount : A reference count for grpc_slice.
//
// Non-inlined grpc_slice objects are refcounted. Historically this was
// implemented via grpc_slice_refcount, a C-style polymorphic class using a
// manually managed vtable of operations. Subclasses would define their own
// vtable; the 'virtual' methods (ref, unref, equals and hash) would simply call
// the function pointers in the vtable as necessary.
//
// Unfortunately, this leads to some inefficiencies in the generated code that
// can be improved upon. For example, equality checking for interned slices is a
// simple equality check on the refcount pointer. With the vtable approach, this
// would translate to roughly the following (high-level) instructions:
//
// grpc_slice_equals(slice1, slice2):
// load vtable->eq -> eq_func
// call eq_func(slice1, slice2)
//
// interned_slice_equals(slice1, slice2)
// load slice1.ref -> r1
// load slice2.ref -> r2
// cmp r1, r2 -> retval
// ret retval
//
// This leads to a function call for a function defined in another translation
// unit, which imposes memory barriers, which reduces the compiler's ability to
// optimize (in addition to the added overhead of call/ret). Additionally, it
// may be harder to reason about branch prediction when we're jumping to
// essentially arbitrarily provided function pointers.
//
// In addition, it is arguable that while virtualization was helpful for
// Equals()/Hash() methods, that it was fundamentally unnecessary for
// Ref()/Unref().
//
// Instead, grpc_slice_refcount provides the same functionality as the C-style
// virtual class, but in a de-virtualized manner - Eq(), Hash(), Ref() and
// Unref() are provided within this header file. Fastpaths for Eq()/Hash()
// (interned and static metadata slices), as well as the Ref() operation, can
// all be inlined without any memory barriers.
//
// It does this by:
// 1. Using grpc_core::RefCount<> (header-only) for Ref/Unref. Two special cases
// need support: No-op ref/unref (eg. static metadata slices) and stream
// slice references (where all the slices share the streamref). This is in
// addition to the normal case of '1 slice, 1 ref'.
// To support these cases, we explicitly track a nullable pointer to the
// underlying RefCount<>. No-op ref/unref is used by checking the pointer for
// null, and doing nothing if it is. Both stream slice refs and 'normal'
// slices use the same path for Ref/Unref (by targeting the non-null
// pointer).
//
// 2. introducing the notion of grpc_slice_refcount::Type. This describes if a
// slice ref is used by a static metadata slice, an interned slice, or other
// slices. We switch on the slice ref type in order to provide fastpaths for
// Equals() and Hash().
//
// In total, this saves us roughly 1-2% latency for unary calls, with smaller
// calls benefitting. The effect is present, but not as useful, for larger calls
// where the cost of sending the data dominates.
// TODO(arjunroy): Investigate if this can be removed with strongly typed
// grpc_slices.
struct grpc_slice_refcount {
public:
enum class Type {
STATIC, // Refcount for a static metadata slice.
INTERNED, // Refcount for an interned slice.
NOP, // No-Op
REGULAR // Refcount for non-static-metadata, non-interned slices.
};
typedef void (*DestroyerFn)(void*);
grpc_slice_refcount() = default;
explicit grpc_slice_refcount(Type t) : ref_type_(t) {}
explicit grpc_slice_refcount(grpc_slice_refcount* sub) : sub_refcount_(sub) {}
// Regular constructor for grpc_slice_refcount.
//
// Parameters:
// 1. grpc_slice_refcount::Type type
// Whether we are the refcount for a static
// metadata slice, an interned slice, or any other kind of slice.
//
// 2. RefCount* ref
// The pointer to the actual underlying grpc_core::RefCount. Rather than
// performing struct offset computations as in the original implementation to
// get to the refcount, which requires a virtual method, we devirtualize by
// using a nullable pointer to allow a single pair of Ref/Unref methods.
//
// 3. DestroyerFn destroyer_fn
// Called when the refcount goes to 0, with destroyer_arg as parameter.
//
// 4. void* destroyer_arg
// Argument for the virtualized destructor.
//
// 5. grpc_slice_refcount* sub
// Argument used for interned slices.
grpc_slice_refcount(grpc_slice_refcount::Type type, grpc_core::RefCount* ref,
DestroyerFn destroyer_fn, void* destroyer_arg,
grpc_slice_refcount* sub)
: ref_(ref),
ref_type_(type),
sub_refcount_(sub),
dest_fn_(destroyer_fn),
destroy_fn_arg_(destroyer_arg) {}
// Initializer for static refcounts.
grpc_slice_refcount(grpc_slice_refcount* sub, Type type)
: ref_type_(type), sub_refcount_(sub) {}
Type GetType() const { return ref_type_; }
int Eq(const grpc_slice& a, const grpc_slice& b);
uint32_t Hash(const grpc_slice& slice);
void Ref() {
if (ref_ == nullptr) return;
ref_->RefNonZero();
}
void Unref() {
if (ref_ == nullptr) return;
if (ref_->Unref()) {
dest_fn_(destroy_fn_arg_);
}
}
grpc_slice_refcount* sub_refcount() const { return sub_refcount_; }
private:
grpc_core::RefCount* ref_ = nullptr;
const Type ref_type_ = Type::REGULAR;
grpc_slice_refcount* sub_refcount_ = this;
DestroyerFn dest_fn_ = nullptr;
void* destroy_fn_arg_ = nullptr;
};
namespace grpc_core {
struct StaticSliceRefcount {
static grpc_slice_refcount kStaticSubRefcount;
explicit StaticSliceRefcount(uint32_t index)
: base(&kStaticSubRefcount, grpc_slice_refcount::Type::STATIC),
index(index) {}
grpc_slice_refcount base;
const uint32_t index;
};
} // namespace grpc_core
#endif // GRPC_CORE_LIB_SLICE_SLICE_REFCOUNT_BASE_H

@ -0,0 +1,529 @@
/*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* WARNING: Auto-generated code.
*
* To make changes to this file, change
* tools/codegen/core/gen_static_metadata.py, and then re-run it.
*
* See metadata.h for an explanation of the interface here, and metadata.cc for
* an explanation of what's going on.
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/slice/static_slice.h"
namespace grpc_core {
const uint8_t g_static_metadata_bytes[] = {
58, 112, 97, 116, 104, 58, 109, 101, 116, 104, 111, 100, 58, 115, 116,
97, 116, 117, 115, 58, 97, 117, 116, 104, 111, 114, 105, 116, 121, 58,
115, 99, 104, 101, 109, 101, 116, 101, 103, 114, 112, 99, 45, 109, 101,
115, 115, 97, 103, 101, 103, 114, 112, 99, 45, 115, 116, 97, 116, 117,
115, 103, 114, 112, 99, 45, 112, 97, 121, 108, 111, 97, 100, 45, 98,
105, 110, 103, 114, 112, 99, 45, 101, 110, 99, 111, 100, 105, 110, 103,
103, 114, 112, 99, 45, 97, 99, 99, 101, 112, 116, 45, 101, 110, 99,
111, 100, 105, 110, 103, 103, 114, 112, 99, 45, 115, 101, 114, 118, 101,
114, 45, 115, 116, 97, 116, 115, 45, 98, 105, 110, 103, 114, 112, 99,
45, 116, 97, 103, 115, 45, 98, 105, 110, 103, 114, 112, 99, 45, 116,
114, 97, 99, 101, 45, 98, 105, 110, 99, 111, 110, 116, 101, 110, 116,
45, 116, 121, 112, 101, 99, 111, 110, 116, 101, 110, 116, 45, 101, 110,
99, 111, 100, 105, 110, 103, 97, 99, 99, 101, 112, 116, 45, 101, 110,
99, 111, 100, 105, 110, 103, 103, 114, 112, 99, 45, 105, 110, 116, 101,
114, 110, 97, 108, 45, 101, 110, 99, 111, 100, 105, 110, 103, 45, 114,
101, 113, 117, 101, 115, 116, 103, 114, 112, 99, 45, 105, 110, 116, 101,
114, 110, 97, 108, 45, 115, 116, 114, 101, 97, 109, 45, 101, 110, 99,
111, 100, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 117, 115,
101, 114, 45, 97, 103, 101, 110, 116, 104, 111, 115, 116, 103, 114, 112,
99, 45, 112, 114, 101, 118, 105, 111, 117, 115, 45, 114, 112, 99, 45,
97, 116, 116, 101, 109, 112, 116, 115, 103, 114, 112, 99, 45, 114, 101,
116, 114, 121, 45, 112, 117, 115, 104, 98, 97, 99, 107, 45, 109, 115,
120, 45, 101, 110, 100, 112, 111, 105, 110, 116, 45, 108, 111, 97, 100,
45, 109, 101, 116, 114, 105, 99, 115, 45, 98, 105, 110, 103, 114, 112,
99, 45, 116, 105, 109, 101, 111, 117, 116, 49, 50, 51, 52, 103, 114,
112, 99, 46, 119, 97, 105, 116, 95, 102, 111, 114, 95, 114, 101, 97,
100, 121, 103, 114, 112, 99, 46, 116, 105, 109, 101, 111, 117, 116, 103,
114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 113, 117, 101, 115, 116,
95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 103,
114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 115, 112, 111, 110, 115,
101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115,
47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97,
100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, 108, 97, 110,
99, 101, 76, 111, 97, 100, 47, 101, 110, 118, 111, 121, 46, 115, 101,
114, 118, 105, 99, 101, 46, 108, 111, 97, 100, 95, 115, 116, 97, 116,
115, 46, 118, 50, 46, 76, 111, 97, 100, 82, 101, 112, 111, 114, 116,
105, 110, 103, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101,
97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, 101, 110, 118,
111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 108, 111, 97, 100,
95, 115, 116, 97, 116, 115, 46, 118, 51, 46, 76, 111, 97, 100, 82,
101, 112, 111, 114, 116, 105, 110, 103, 83, 101, 114, 118, 105, 99, 101,
47, 83, 116, 114, 101, 97, 109, 76, 111, 97, 100, 83, 116, 97, 116,
115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118,
49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, 104, 47,
101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 100,
105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, 103, 103,
114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, 101, 114,
121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109,
65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, 111, 117,
114, 99, 101, 115, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118,
105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118,
51, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115,
99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83,
116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100,
82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116,
101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105,
112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120,
46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50,
48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52,
48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97,
114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97,
116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97,
103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115,
97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111,
110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105,
103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104,
111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45,
99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45,
100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116,
101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110,
116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116,
101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110,
116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105,
101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116,
101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109,
97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100,
45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109,
97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45,
117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99,
101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108,
105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45,
102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97,
117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120,
121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110,
114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102,
114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114,
115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105,
101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111,
114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110,
115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97,
114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110,
116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121,
116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97,
116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85,
84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101,
110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100,
101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108,
97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116,
121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112};
grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;
StaticSliceRefcount g_static_metadata_slice_refcounts[GRPC_STATIC_MDSTR_COUNT] =
{
StaticSliceRefcount(0), StaticSliceRefcount(1),
StaticSliceRefcount(2), StaticSliceRefcount(3),
StaticSliceRefcount(4), StaticSliceRefcount(5),
StaticSliceRefcount(6), StaticSliceRefcount(7),
StaticSliceRefcount(8), StaticSliceRefcount(9),
StaticSliceRefcount(10), StaticSliceRefcount(11),
StaticSliceRefcount(12), StaticSliceRefcount(13),
StaticSliceRefcount(14), StaticSliceRefcount(15),
StaticSliceRefcount(16), StaticSliceRefcount(17),
StaticSliceRefcount(18), StaticSliceRefcount(19),
StaticSliceRefcount(20), StaticSliceRefcount(21),
StaticSliceRefcount(22), StaticSliceRefcount(23),
StaticSliceRefcount(24), StaticSliceRefcount(25),
StaticSliceRefcount(26), StaticSliceRefcount(27),
StaticSliceRefcount(28), StaticSliceRefcount(29),
StaticSliceRefcount(30), StaticSliceRefcount(31),
StaticSliceRefcount(32), StaticSliceRefcount(33),
StaticSliceRefcount(34), StaticSliceRefcount(35),
StaticSliceRefcount(36), StaticSliceRefcount(37),
StaticSliceRefcount(38), StaticSliceRefcount(39),
StaticSliceRefcount(40), StaticSliceRefcount(41),
StaticSliceRefcount(42), StaticSliceRefcount(43),
StaticSliceRefcount(44), StaticSliceRefcount(45),
StaticSliceRefcount(46), StaticSliceRefcount(47),
StaticSliceRefcount(48), StaticSliceRefcount(49),
StaticSliceRefcount(50), StaticSliceRefcount(51),
StaticSliceRefcount(52), StaticSliceRefcount(53),
StaticSliceRefcount(54), StaticSliceRefcount(55),
StaticSliceRefcount(56), StaticSliceRefcount(57),
StaticSliceRefcount(58), StaticSliceRefcount(59),
StaticSliceRefcount(60), StaticSliceRefcount(61),
StaticSliceRefcount(62), StaticSliceRefcount(63),
StaticSliceRefcount(64), StaticSliceRefcount(65),
StaticSliceRefcount(66), StaticSliceRefcount(67),
StaticSliceRefcount(68), StaticSliceRefcount(69),
StaticSliceRefcount(70), StaticSliceRefcount(71),
StaticSliceRefcount(72), StaticSliceRefcount(73),
StaticSliceRefcount(74), StaticSliceRefcount(75),
StaticSliceRefcount(76), StaticSliceRefcount(77),
StaticSliceRefcount(78), StaticSliceRefcount(79),
StaticSliceRefcount(80), StaticSliceRefcount(81),
StaticSliceRefcount(82), StaticSliceRefcount(83),
StaticSliceRefcount(84), StaticSliceRefcount(85),
StaticSliceRefcount(86), StaticSliceRefcount(87),
StaticSliceRefcount(88), StaticSliceRefcount(89),
StaticSliceRefcount(90), StaticSliceRefcount(91),
StaticSliceRefcount(92), StaticSliceRefcount(93),
StaticSliceRefcount(94), StaticSliceRefcount(95),
StaticSliceRefcount(96), StaticSliceRefcount(97),
StaticSliceRefcount(98), StaticSliceRefcount(99),
StaticSliceRefcount(100), StaticSliceRefcount(101),
StaticSliceRefcount(102), StaticSliceRefcount(103),
StaticSliceRefcount(104), StaticSliceRefcount(105),
StaticSliceRefcount(106), StaticSliceRefcount(107),
StaticSliceRefcount(108), StaticSliceRefcount(109),
};
const StaticMetadataSlice
g_static_metadata_slice_table[GRPC_STATIC_MDSTR_COUNT] = {
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[0].base, 5,
g_static_metadata_bytes + 0),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[1].base, 7,
g_static_metadata_bytes + 5),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[2].base, 7,
g_static_metadata_bytes + 12),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[3].base, 10,
g_static_metadata_bytes + 19),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[4].base, 7,
g_static_metadata_bytes + 29),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[5].base, 2,
g_static_metadata_bytes + 36),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[6].base, 12,
g_static_metadata_bytes + 38),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[7].base, 11,
g_static_metadata_bytes + 50),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[8].base, 16,
g_static_metadata_bytes + 61),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[9].base, 13,
g_static_metadata_bytes + 77),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[10].base, 20,
g_static_metadata_bytes + 90),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[11].base, 21,
g_static_metadata_bytes + 110),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[12].base, 13,
g_static_metadata_bytes + 131),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[13].base, 14,
g_static_metadata_bytes + 144),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[14].base, 12,
g_static_metadata_bytes + 158),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[15].base, 16,
g_static_metadata_bytes + 170),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[16].base, 15,
g_static_metadata_bytes + 186),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[17].base, 30,
g_static_metadata_bytes + 201),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[18].base, 37,
g_static_metadata_bytes + 231),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[19].base, 10,
g_static_metadata_bytes + 268),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[20].base, 4,
g_static_metadata_bytes + 278),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[21].base, 26,
g_static_metadata_bytes + 282),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[22].base, 22,
g_static_metadata_bytes + 308),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[23].base, 27,
g_static_metadata_bytes + 330),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[24].base, 12,
g_static_metadata_bytes + 357),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[25].base, 1,
g_static_metadata_bytes + 369),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[26].base, 1,
g_static_metadata_bytes + 370),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[27].base, 1,
g_static_metadata_bytes + 371),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[28].base, 1,
g_static_metadata_bytes + 372),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[29].base, 0,
g_static_metadata_bytes + 373),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[30].base, 19,
g_static_metadata_bytes + 373),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[31].base, 12,
g_static_metadata_bytes + 392),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[32].base, 30,
g_static_metadata_bytes + 404),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[33].base, 31,
g_static_metadata_bytes + 434),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[34].base, 36,
g_static_metadata_bytes + 465),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[35].base, 65,
g_static_metadata_bytes + 501),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[36].base, 65,
g_static_metadata_bytes + 566),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[37].base, 28,
g_static_metadata_bytes + 631),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[38].base, 80,
g_static_metadata_bytes + 659),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[39].base, 80,
g_static_metadata_bytes + 739),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[40].base, 7,
g_static_metadata_bytes + 819),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[41].base, 4,
g_static_metadata_bytes + 826),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[42].base, 11,
g_static_metadata_bytes + 830),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[43].base, 3,
g_static_metadata_bytes + 841),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[44].base, 4,
g_static_metadata_bytes + 844),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[45].base, 1,
g_static_metadata_bytes + 848),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[46].base, 11,
g_static_metadata_bytes + 849),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[47].base, 4,
g_static_metadata_bytes + 860),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[48].base, 5,
g_static_metadata_bytes + 864),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[49].base, 3,
g_static_metadata_bytes + 869),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[50].base, 3,
g_static_metadata_bytes + 872),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[51].base, 3,
g_static_metadata_bytes + 875),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[52].base, 3,
g_static_metadata_bytes + 878),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[53].base, 3,
g_static_metadata_bytes + 881),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[54].base, 3,
g_static_metadata_bytes + 884),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[55].base, 3,
g_static_metadata_bytes + 887),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[56].base, 14,
g_static_metadata_bytes + 890),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[57].base, 13,
g_static_metadata_bytes + 904),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[58].base, 15,
g_static_metadata_bytes + 917),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[59].base, 13,
g_static_metadata_bytes + 932),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[60].base, 6,
g_static_metadata_bytes + 945),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[61].base, 27,
g_static_metadata_bytes + 951),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[62].base, 3,
g_static_metadata_bytes + 978),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[63].base, 5,
g_static_metadata_bytes + 981),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[64].base, 13,
g_static_metadata_bytes + 986),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[65].base, 13,
g_static_metadata_bytes + 999),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[66].base, 19,
g_static_metadata_bytes + 1012),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[67].base, 16,
g_static_metadata_bytes + 1031),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[68].base, 14,
g_static_metadata_bytes + 1047),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[69].base, 16,
g_static_metadata_bytes + 1061),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[70].base, 13,
g_static_metadata_bytes + 1077),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[71].base, 6,
g_static_metadata_bytes + 1090),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[72].base, 4,
g_static_metadata_bytes + 1096),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[73].base, 4,
g_static_metadata_bytes + 1100),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[74].base, 6,
g_static_metadata_bytes + 1104),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[75].base, 7,
g_static_metadata_bytes + 1110),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[76].base, 4,
g_static_metadata_bytes + 1117),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[77].base, 8,
g_static_metadata_bytes + 1121),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[78].base, 17,
g_static_metadata_bytes + 1129),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[79].base, 13,
g_static_metadata_bytes + 1146),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[80].base, 8,
g_static_metadata_bytes + 1159),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[81].base, 19,
g_static_metadata_bytes + 1167),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[82].base, 13,
g_static_metadata_bytes + 1186),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[83].base, 4,
g_static_metadata_bytes + 1199),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[84].base, 8,
g_static_metadata_bytes + 1203),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[85].base, 12,
g_static_metadata_bytes + 1211),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[86].base, 18,
g_static_metadata_bytes + 1223),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[87].base, 19,
g_static_metadata_bytes + 1241),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[88].base, 5,
g_static_metadata_bytes + 1260),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[89].base, 7,
g_static_metadata_bytes + 1265),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[90].base, 7,
g_static_metadata_bytes + 1272),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[91].base, 11,
g_static_metadata_bytes + 1279),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[92].base, 6,
g_static_metadata_bytes + 1290),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[93].base, 10,
g_static_metadata_bytes + 1296),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[94].base, 25,
g_static_metadata_bytes + 1306),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[95].base, 17,
g_static_metadata_bytes + 1331),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[96].base, 4,
g_static_metadata_bytes + 1348),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[97].base, 3,
g_static_metadata_bytes + 1352),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[98].base, 16,
g_static_metadata_bytes + 1355),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[99].base, 1,
g_static_metadata_bytes + 1371),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[100].base, 8,
g_static_metadata_bytes + 1372),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[101].base, 8,
g_static_metadata_bytes + 1380),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[102].base, 16,
g_static_metadata_bytes + 1388),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[103].base, 4,
g_static_metadata_bytes + 1404),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[104].base, 3,
g_static_metadata_bytes + 1408),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[105].base, 11,
g_static_metadata_bytes + 1411),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[106].base, 16,
g_static_metadata_bytes + 1422),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[107].base, 13,
g_static_metadata_bytes + 1438),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[108].base, 12,
g_static_metadata_bytes + 1451),
grpc_core::StaticMetadataSlice(
&g_static_metadata_slice_refcounts[109].base, 21,
g_static_metadata_bytes + 1463),
};
} // namespace grpc_core

@ -0,0 +1,331 @@
/*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* WARNING: Auto-generated code.
*
* To make changes to this file, change
* tools/codegen/core/gen_static_metadata.py, and then re-run it.
*
* See metadata.h for an explanation of the interface here, and metadata.cc for
* an explanation of what's going on.
*/
#ifndef GRPC_CORE_LIB_SLICE_STATIC_SLICE_H
#define GRPC_CORE_LIB_SLICE_STATIC_SLICE_H
#include <grpc/support/port_platform.h>
#include <cstdint>
#include <type_traits>
#include "src/core/lib/slice/slice_refcount_base.h"
#include "src/core/lib/slice/slice_utils.h"
static_assert(
std::is_trivially_destructible<grpc_core::StaticMetadataSlice>::value,
"grpc_core::StaticMetadataSlice must be trivially destructible.");
#define GRPC_STATIC_MDSTR_COUNT 110
/* ":path" */
#define GRPC_MDSTR_PATH (::grpc_core::g_static_metadata_slice_table[0])
/* ":method" */
#define GRPC_MDSTR_METHOD (::grpc_core::g_static_metadata_slice_table[1])
/* ":status" */
#define GRPC_MDSTR_STATUS (::grpc_core::g_static_metadata_slice_table[2])
/* ":authority" */
#define GRPC_MDSTR_AUTHORITY (::grpc_core::g_static_metadata_slice_table[3])
/* ":scheme" */
#define GRPC_MDSTR_SCHEME (::grpc_core::g_static_metadata_slice_table[4])
/* "te" */
#define GRPC_MDSTR_TE (::grpc_core::g_static_metadata_slice_table[5])
/* "grpc-message" */
#define GRPC_MDSTR_GRPC_MESSAGE (::grpc_core::g_static_metadata_slice_table[6])
/* "grpc-status" */
#define GRPC_MDSTR_GRPC_STATUS (::grpc_core::g_static_metadata_slice_table[7])
/* "grpc-payload-bin" */
#define GRPC_MDSTR_GRPC_PAYLOAD_BIN \
(::grpc_core::g_static_metadata_slice_table[8])
/* "grpc-encoding" */
#define GRPC_MDSTR_GRPC_ENCODING (::grpc_core::g_static_metadata_slice_table[9])
/* "grpc-accept-encoding" */
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING \
(::grpc_core::g_static_metadata_slice_table[10])
/* "grpc-server-stats-bin" */
#define GRPC_MDSTR_GRPC_SERVER_STATS_BIN \
(::grpc_core::g_static_metadata_slice_table[11])
/* "grpc-tags-bin" */
#define GRPC_MDSTR_GRPC_TAGS_BIN \
(::grpc_core::g_static_metadata_slice_table[12])
/* "grpc-trace-bin" */
#define GRPC_MDSTR_GRPC_TRACE_BIN \
(::grpc_core::g_static_metadata_slice_table[13])
/* "content-type" */
#define GRPC_MDSTR_CONTENT_TYPE (::grpc_core::g_static_metadata_slice_table[14])
/* "content-encoding" */
#define GRPC_MDSTR_CONTENT_ENCODING \
(::grpc_core::g_static_metadata_slice_table[15])
/* "accept-encoding" */
#define GRPC_MDSTR_ACCEPT_ENCODING \
(::grpc_core::g_static_metadata_slice_table[16])
/* "grpc-internal-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST \
(::grpc_core::g_static_metadata_slice_table[17])
/* "grpc-internal-stream-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST \
(::grpc_core::g_static_metadata_slice_table[18])
/* "user-agent" */
#define GRPC_MDSTR_USER_AGENT (::grpc_core::g_static_metadata_slice_table[19])
/* "host" */
#define GRPC_MDSTR_HOST (::grpc_core::g_static_metadata_slice_table[20])
/* "grpc-previous-rpc-attempts" */
#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS \
(::grpc_core::g_static_metadata_slice_table[21])
/* "grpc-retry-pushback-ms" */
#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS \
(::grpc_core::g_static_metadata_slice_table[22])
/* "x-endpoint-load-metrics-bin" */
#define GRPC_MDSTR_X_ENDPOINT_LOAD_METRICS_BIN \
(::grpc_core::g_static_metadata_slice_table[23])
/* "grpc-timeout" */
#define GRPC_MDSTR_GRPC_TIMEOUT (::grpc_core::g_static_metadata_slice_table[24])
/* "1" */
#define GRPC_MDSTR_1 (::grpc_core::g_static_metadata_slice_table[25])
/* "2" */
#define GRPC_MDSTR_2 (::grpc_core::g_static_metadata_slice_table[26])
/* "3" */
#define GRPC_MDSTR_3 (::grpc_core::g_static_metadata_slice_table[27])
/* "4" */
#define GRPC_MDSTR_4 (::grpc_core::g_static_metadata_slice_table[28])
/* "" */
#define GRPC_MDSTR_EMPTY (::grpc_core::g_static_metadata_slice_table[29])
/* "grpc.wait_for_ready" */
#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY \
(::grpc_core::g_static_metadata_slice_table[30])
/* "grpc.timeout" */
#define GRPC_MDSTR_GRPC_DOT_TIMEOUT \
(::grpc_core::g_static_metadata_slice_table[31])
/* "grpc.max_request_message_bytes" */
#define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \
(::grpc_core::g_static_metadata_slice_table[32])
/* "grpc.max_response_message_bytes" */
#define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \
(::grpc_core::g_static_metadata_slice_table[33])
/* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \
(::grpc_core::g_static_metadata_slice_table[34])
/* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
(::grpc_core::g_static_metadata_slice_table[35])
/* "/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats" */
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
(::grpc_core::g_static_metadata_slice_table[36])
/* "/grpc.health.v1.Health/Watch" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \
(::grpc_core::g_static_metadata_slice_table[37])
/* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources"
*/
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
(::grpc_core::g_static_metadata_slice_table[38])
/* "/envoy.service.discovery.v3.AggregatedDiscoveryService/StreamAggregatedResources"
*/
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
(::grpc_core::g_static_metadata_slice_table[39])
/* "deflate" */
#define GRPC_MDSTR_DEFLATE (::grpc_core::g_static_metadata_slice_table[40])
/* "gzip" */
#define GRPC_MDSTR_GZIP (::grpc_core::g_static_metadata_slice_table[41])
/* "stream/gzip" */
#define GRPC_MDSTR_STREAM_SLASH_GZIP \
(::grpc_core::g_static_metadata_slice_table[42])
/* "GET" */
#define GRPC_MDSTR_GET (::grpc_core::g_static_metadata_slice_table[43])
/* "POST" */
#define GRPC_MDSTR_POST (::grpc_core::g_static_metadata_slice_table[44])
/* "/" */
#define GRPC_MDSTR_SLASH (::grpc_core::g_static_metadata_slice_table[45])
/* "/index.html" */
#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML \
(::grpc_core::g_static_metadata_slice_table[46])
/* "http" */
#define GRPC_MDSTR_HTTP (::grpc_core::g_static_metadata_slice_table[47])
/* "https" */
#define GRPC_MDSTR_HTTPS (::grpc_core::g_static_metadata_slice_table[48])
/* "200" */
#define GRPC_MDSTR_200 (::grpc_core::g_static_metadata_slice_table[49])
/* "204" */
#define GRPC_MDSTR_204 (::grpc_core::g_static_metadata_slice_table[50])
/* "206" */
#define GRPC_MDSTR_206 (::grpc_core::g_static_metadata_slice_table[51])
/* "304" */
#define GRPC_MDSTR_304 (::grpc_core::g_static_metadata_slice_table[52])
/* "400" */
#define GRPC_MDSTR_400 (::grpc_core::g_static_metadata_slice_table[53])
/* "404" */
#define GRPC_MDSTR_404 (::grpc_core::g_static_metadata_slice_table[54])
/* "500" */
#define GRPC_MDSTR_500 (::grpc_core::g_static_metadata_slice_table[55])
/* "accept-charset" */
#define GRPC_MDSTR_ACCEPT_CHARSET \
(::grpc_core::g_static_metadata_slice_table[56])
/* "gzip, deflate" */
#define GRPC_MDSTR_GZIP_COMMA_DEFLATE \
(::grpc_core::g_static_metadata_slice_table[57])
/* "accept-language" */
#define GRPC_MDSTR_ACCEPT_LANGUAGE \
(::grpc_core::g_static_metadata_slice_table[58])
/* "accept-ranges" */
#define GRPC_MDSTR_ACCEPT_RANGES \
(::grpc_core::g_static_metadata_slice_table[59])
/* "accept" */
#define GRPC_MDSTR_ACCEPT (::grpc_core::g_static_metadata_slice_table[60])
/* "access-control-allow-origin" */
#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN \
(::grpc_core::g_static_metadata_slice_table[61])
/* "age" */
#define GRPC_MDSTR_AGE (::grpc_core::g_static_metadata_slice_table[62])
/* "allow" */
#define GRPC_MDSTR_ALLOW (::grpc_core::g_static_metadata_slice_table[63])
/* "authorization" */
#define GRPC_MDSTR_AUTHORIZATION \
(::grpc_core::g_static_metadata_slice_table[64])
/* "cache-control" */
#define GRPC_MDSTR_CACHE_CONTROL \
(::grpc_core::g_static_metadata_slice_table[65])
/* "content-disposition" */
#define GRPC_MDSTR_CONTENT_DISPOSITION \
(::grpc_core::g_static_metadata_slice_table[66])
/* "content-language" */
#define GRPC_MDSTR_CONTENT_LANGUAGE \
(::grpc_core::g_static_metadata_slice_table[67])
/* "content-length" */
#define GRPC_MDSTR_CONTENT_LENGTH \
(::grpc_core::g_static_metadata_slice_table[68])
/* "content-location" */
#define GRPC_MDSTR_CONTENT_LOCATION \
(::grpc_core::g_static_metadata_slice_table[69])
/* "content-range" */
#define GRPC_MDSTR_CONTENT_RANGE \
(::grpc_core::g_static_metadata_slice_table[70])
/* "cookie" */
#define GRPC_MDSTR_COOKIE (::grpc_core::g_static_metadata_slice_table[71])
/* "date" */
#define GRPC_MDSTR_DATE (::grpc_core::g_static_metadata_slice_table[72])
/* "etag" */
#define GRPC_MDSTR_ETAG (::grpc_core::g_static_metadata_slice_table[73])
/* "expect" */
#define GRPC_MDSTR_EXPECT (::grpc_core::g_static_metadata_slice_table[74])
/* "expires" */
#define GRPC_MDSTR_EXPIRES (::grpc_core::g_static_metadata_slice_table[75])
/* "from" */
#define GRPC_MDSTR_FROM (::grpc_core::g_static_metadata_slice_table[76])
/* "if-match" */
#define GRPC_MDSTR_IF_MATCH (::grpc_core::g_static_metadata_slice_table[77])
/* "if-modified-since" */
#define GRPC_MDSTR_IF_MODIFIED_SINCE \
(::grpc_core::g_static_metadata_slice_table[78])
/* "if-none-match" */
#define GRPC_MDSTR_IF_NONE_MATCH \
(::grpc_core::g_static_metadata_slice_table[79])
/* "if-range" */
#define GRPC_MDSTR_IF_RANGE (::grpc_core::g_static_metadata_slice_table[80])
/* "if-unmodified-since" */
#define GRPC_MDSTR_IF_UNMODIFIED_SINCE \
(::grpc_core::g_static_metadata_slice_table[81])
/* "last-modified" */
#define GRPC_MDSTR_LAST_MODIFIED \
(::grpc_core::g_static_metadata_slice_table[82])
/* "link" */
#define GRPC_MDSTR_LINK (::grpc_core::g_static_metadata_slice_table[83])
/* "location" */
#define GRPC_MDSTR_LOCATION (::grpc_core::g_static_metadata_slice_table[84])
/* "max-forwards" */
#define GRPC_MDSTR_MAX_FORWARDS (::grpc_core::g_static_metadata_slice_table[85])
/* "proxy-authenticate" */
#define GRPC_MDSTR_PROXY_AUTHENTICATE \
(::grpc_core::g_static_metadata_slice_table[86])
/* "proxy-authorization" */
#define GRPC_MDSTR_PROXY_AUTHORIZATION \
(::grpc_core::g_static_metadata_slice_table[87])
/* "range" */
#define GRPC_MDSTR_RANGE (::grpc_core::g_static_metadata_slice_table[88])
/* "referer" */
#define GRPC_MDSTR_REFERER (::grpc_core::g_static_metadata_slice_table[89])
/* "refresh" */
#define GRPC_MDSTR_REFRESH (::grpc_core::g_static_metadata_slice_table[90])
/* "retry-after" */
#define GRPC_MDSTR_RETRY_AFTER (::grpc_core::g_static_metadata_slice_table[91])
/* "server" */
#define GRPC_MDSTR_SERVER (::grpc_core::g_static_metadata_slice_table[92])
/* "set-cookie" */
#define GRPC_MDSTR_SET_COOKIE (::grpc_core::g_static_metadata_slice_table[93])
/* "strict-transport-security" */
#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY \
(::grpc_core::g_static_metadata_slice_table[94])
/* "transfer-encoding" */
#define GRPC_MDSTR_TRANSFER_ENCODING \
(::grpc_core::g_static_metadata_slice_table[95])
/* "vary" */
#define GRPC_MDSTR_VARY (::grpc_core::g_static_metadata_slice_table[96])
/* "via" */
#define GRPC_MDSTR_VIA (::grpc_core::g_static_metadata_slice_table[97])
/* "www-authenticate" */
#define GRPC_MDSTR_WWW_AUTHENTICATE \
(::grpc_core::g_static_metadata_slice_table[98])
/* "0" */
#define GRPC_MDSTR_0 (::grpc_core::g_static_metadata_slice_table[99])
/* "identity" */
#define GRPC_MDSTR_IDENTITY (::grpc_core::g_static_metadata_slice_table[100])
/* "trailers" */
#define GRPC_MDSTR_TRAILERS (::grpc_core::g_static_metadata_slice_table[101])
/* "application/grpc" */
#define GRPC_MDSTR_APPLICATION_SLASH_GRPC \
(::grpc_core::g_static_metadata_slice_table[102])
/* "grpc" */
#define GRPC_MDSTR_GRPC (::grpc_core::g_static_metadata_slice_table[103])
/* "PUT" */
#define GRPC_MDSTR_PUT (::grpc_core::g_static_metadata_slice_table[104])
/* "lb-cost-bin" */
#define GRPC_MDSTR_LB_COST_BIN (::grpc_core::g_static_metadata_slice_table[105])
/* "identity,deflate" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE \
(::grpc_core::g_static_metadata_slice_table[106])
/* "identity,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_GZIP \
(::grpc_core::g_static_metadata_slice_table[107])
/* "deflate,gzip" */
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP \
(::grpc_core::g_static_metadata_slice_table[108])
/* "identity,deflate,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
(::grpc_core::g_static_metadata_slice_table[109])
namespace grpc_core {
extern StaticSliceRefcount
g_static_metadata_slice_refcounts[GRPC_STATIC_MDSTR_COUNT];
extern const StaticMetadataSlice
g_static_metadata_slice_table[GRPC_STATIC_MDSTR_COUNT];
extern const uint8_t g_static_metadata_bytes[];
} // namespace grpc_core
#define GRPC_IS_STATIC_METADATA_STRING(slice) \
((slice).refcount != NULL && \
(slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC)
#define GRPC_STATIC_METADATA_INDEX(static_slice) \
(reinterpret_cast<grpc_core::StaticSliceRefcount*>((static_slice).refcount) \
->index)
#endif /* GRPC_CORE_LIB_SLICE_STATIC_SLICE_H */

@ -134,7 +134,6 @@ void grpc_init(void) {
grpc_core::Fork::GlobalInit();
grpc_fork_handlers_auto_register();
grpc_stats_init();
grpc_init_static_metadata_ctx();
grpc_slice_intern_init();
grpc_mdctx_global_init();
grpc_channel_init_init();
@ -189,8 +188,6 @@ void grpc_shutdown_internal_locked(void)
grpc_core::ApplicationCallbackExecCtx::GlobalShutdown();
g_shutting_down = false;
g_shutting_down_cv->SignalAll();
// Absolute last action will be to delete static metadata context.
grpc_destroy_static_metadata_ctx();
}
void grpc_shutdown_internal(void* /*ignored*/) {

@ -279,9 +279,9 @@ void grpc_mdctx_global_shutdown() {
#ifndef NDEBUG
static int is_mdelem_static(grpc_mdelem e) {
return reinterpret_cast<grpc_core::StaticMetadata*>(GRPC_MDELEM_DATA(e)) >=
&grpc_static_mdelem_table()[0] &&
&grpc_core::g_static_mdelem_table[0] &&
reinterpret_cast<grpc_core::StaticMetadata*>(GRPC_MDELEM_DATA(e)) <
&grpc_static_mdelem_table()[GRPC_STATIC_MDELEM_COUNT];
&grpc_core::g_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
}
#endif
@ -577,7 +577,7 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) {
grpc_static_mdelem_user_data
[reinterpret_cast<grpc_core::StaticMetadata*>(
GRPC_MDELEM_DATA(md)) -
grpc_static_mdelem_table()]);
grpc_core::g_static_mdelem_table]);
case GRPC_MDELEM_STORAGE_ALLOCATED: {
auto* am = reinterpret_cast<AllocatedMetadata*>(GRPC_MDELEM_DATA(md));
return get_user_data(am->user_data(), destroy_func);
@ -619,7 +619,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
grpc_static_mdelem_user_data
[reinterpret_cast<grpc_core::StaticMetadata*>(
GRPC_MDELEM_DATA(md)) -
grpc_static_mdelem_table()]);
grpc_core::g_static_mdelem_table]);
case GRPC_MDELEM_STORAGE_ALLOCATED: {
auto* am = reinterpret_cast<AllocatedMetadata*>(GRPC_MDELEM_DATA(md));
return set_user_data(am->user_data(), destroy_func, data);

File diff suppressed because it is too large Load Diff

@ -31,493 +31,233 @@
#include <cstdint>
#include "src/core/lib/slice/static_slice.h"
#include "src/core/lib/transport/metadata.h"
static_assert(
std::is_trivially_destructible<grpc_core::StaticMetadataSlice>::value,
"grpc_core::StaticMetadataSlice must be trivially destructible.");
#define GRPC_STATIC_MDSTR_COUNT 110
void grpc_init_static_metadata_ctx(void);
void grpc_destroy_static_metadata_ctx(void);
namespace grpc_core {
#ifndef NDEBUG
constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L;
uint64_t StaticMetadataInitCanary();
#endif
extern const StaticMetadataSlice* g_static_metadata_slice_table;
} // namespace grpc_core
inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_table != nullptr);
return grpc_core::g_static_metadata_slice_table;
}
/* ":path" */
#define GRPC_MDSTR_PATH (grpc_static_slice_table()[0])
/* ":method" */
#define GRPC_MDSTR_METHOD (grpc_static_slice_table()[1])
/* ":status" */
#define GRPC_MDSTR_STATUS (grpc_static_slice_table()[2])
/* ":authority" */
#define GRPC_MDSTR_AUTHORITY (grpc_static_slice_table()[3])
/* ":scheme" */
#define GRPC_MDSTR_SCHEME (grpc_static_slice_table()[4])
/* "te" */
#define GRPC_MDSTR_TE (grpc_static_slice_table()[5])
/* "grpc-message" */
#define GRPC_MDSTR_GRPC_MESSAGE (grpc_static_slice_table()[6])
/* "grpc-status" */
#define GRPC_MDSTR_GRPC_STATUS (grpc_static_slice_table()[7])
/* "grpc-payload-bin" */
#define GRPC_MDSTR_GRPC_PAYLOAD_BIN (grpc_static_slice_table()[8])
/* "grpc-encoding" */
#define GRPC_MDSTR_GRPC_ENCODING (grpc_static_slice_table()[9])
/* "grpc-accept-encoding" */
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (grpc_static_slice_table()[10])
/* "grpc-server-stats-bin" */
#define GRPC_MDSTR_GRPC_SERVER_STATS_BIN (grpc_static_slice_table()[11])
/* "grpc-tags-bin" */
#define GRPC_MDSTR_GRPC_TAGS_BIN (grpc_static_slice_table()[12])
/* "grpc-trace-bin" */
#define GRPC_MDSTR_GRPC_TRACE_BIN (grpc_static_slice_table()[13])
/* "content-type" */
#define GRPC_MDSTR_CONTENT_TYPE (grpc_static_slice_table()[14])
/* "content-encoding" */
#define GRPC_MDSTR_CONTENT_ENCODING (grpc_static_slice_table()[15])
/* "accept-encoding" */
#define GRPC_MDSTR_ACCEPT_ENCODING (grpc_static_slice_table()[16])
/* "grpc-internal-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST \
(grpc_static_slice_table()[17])
/* "grpc-internal-stream-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST \
(grpc_static_slice_table()[18])
/* "user-agent" */
#define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table()[19])
/* "host" */
#define GRPC_MDSTR_HOST (grpc_static_slice_table()[20])
/* "grpc-previous-rpc-attempts" */
#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table()[21])
/* "grpc-retry-pushback-ms" */
#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table()[22])
/* "x-endpoint-load-metrics-bin" */
#define GRPC_MDSTR_X_ENDPOINT_LOAD_METRICS_BIN (grpc_static_slice_table()[23])
/* "grpc-timeout" */
#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table()[24])
/* "1" */
#define GRPC_MDSTR_1 (grpc_static_slice_table()[25])
/* "2" */
#define GRPC_MDSTR_2 (grpc_static_slice_table()[26])
/* "3" */
#define GRPC_MDSTR_3 (grpc_static_slice_table()[27])
/* "4" */
#define GRPC_MDSTR_4 (grpc_static_slice_table()[28])
/* "" */
#define GRPC_MDSTR_EMPTY (grpc_static_slice_table()[29])
/* "grpc.wait_for_ready" */
#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table()[30])
/* "grpc.timeout" */
#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table()[31])
/* "grpc.max_request_message_bytes" */
#define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \
(grpc_static_slice_table()[32])
/* "grpc.max_response_message_bytes" */
#define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \
(grpc_static_slice_table()[33])
/* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \
(grpc_static_slice_table()[34])
/* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
(grpc_static_slice_table()[35])
/* "/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats" */
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
(grpc_static_slice_table()[36])
/* "/grpc.health.v1.Health/Watch" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \
(grpc_static_slice_table()[37])
/* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources"
*/
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
(grpc_static_slice_table()[38])
/* "/envoy.service.discovery.v3.AggregatedDiscoveryService/StreamAggregatedResources"
*/
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
(grpc_static_slice_table()[39])
/* "deflate" */
#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[40])
/* "gzip" */
#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[41])
/* "stream/gzip" */
#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[42])
/* "GET" */
#define GRPC_MDSTR_GET (grpc_static_slice_table()[43])
/* "POST" */
#define GRPC_MDSTR_POST (grpc_static_slice_table()[44])
/* "/" */
#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[45])
/* "/index.html" */
#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[46])
/* "http" */
#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[47])
/* "https" */
#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[48])
/* "200" */
#define GRPC_MDSTR_200 (grpc_static_slice_table()[49])
/* "204" */
#define GRPC_MDSTR_204 (grpc_static_slice_table()[50])
/* "206" */
#define GRPC_MDSTR_206 (grpc_static_slice_table()[51])
/* "304" */
#define GRPC_MDSTR_304 (grpc_static_slice_table()[52])
/* "400" */
#define GRPC_MDSTR_400 (grpc_static_slice_table()[53])
/* "404" */
#define GRPC_MDSTR_404 (grpc_static_slice_table()[54])
/* "500" */
#define GRPC_MDSTR_500 (grpc_static_slice_table()[55])
/* "accept-charset" */
#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[56])
/* "gzip, deflate" */
#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[57])
/* "accept-language" */
#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[58])
/* "accept-ranges" */
#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[59])
/* "accept" */
#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[60])
/* "access-control-allow-origin" */
#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[61])
/* "age" */
#define GRPC_MDSTR_AGE (grpc_static_slice_table()[62])
/* "allow" */
#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[63])
/* "authorization" */
#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[64])
/* "cache-control" */
#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[65])
/* "content-disposition" */
#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[66])
/* "content-language" */
#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[67])
/* "content-length" */
#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[68])
/* "content-location" */
#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[69])
/* "content-range" */
#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[70])
/* "cookie" */
#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[71])
/* "date" */
#define GRPC_MDSTR_DATE (grpc_static_slice_table()[72])
/* "etag" */
#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[73])
/* "expect" */
#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[74])
/* "expires" */
#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[75])
/* "from" */
#define GRPC_MDSTR_FROM (grpc_static_slice_table()[76])
/* "if-match" */
#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[77])
/* "if-modified-since" */
#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[78])
/* "if-none-match" */
#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[79])
/* "if-range" */
#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[80])
/* "if-unmodified-since" */
#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[81])
/* "last-modified" */
#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[82])
/* "link" */
#define GRPC_MDSTR_LINK (grpc_static_slice_table()[83])
/* "location" */
#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[84])
/* "max-forwards" */
#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[85])
/* "proxy-authenticate" */
#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[86])
/* "proxy-authorization" */
#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[87])
/* "range" */
#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[88])
/* "referer" */
#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[89])
/* "refresh" */
#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[90])
/* "retry-after" */
#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[91])
/* "server" */
#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[92])
/* "set-cookie" */
#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[93])
/* "strict-transport-security" */
#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[94])
/* "transfer-encoding" */
#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[95])
/* "vary" */
#define GRPC_MDSTR_VARY (grpc_static_slice_table()[96])
/* "via" */
#define GRPC_MDSTR_VIA (grpc_static_slice_table()[97])
/* "www-authenticate" */
#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[98])
/* "0" */
#define GRPC_MDSTR_0 (grpc_static_slice_table()[99])
/* "identity" */
#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[100])
/* "trailers" */
#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[101])
/* "application/grpc" */
#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[102])
/* "grpc" */
#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[103])
/* "PUT" */
#define GRPC_MDSTR_PUT (grpc_static_slice_table()[104])
/* "lb-cost-bin" */
#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[105])
/* "identity,deflate" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[106])
/* "identity,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[107])
/* "deflate,gzip" */
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[108])
/* "identity,deflate,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
(grpc_static_slice_table()[109])
namespace grpc_core {
struct StaticSliceRefcount;
extern StaticSliceRefcount* g_static_metadata_slice_refcounts;
} // namespace grpc_core
inline grpc_core::StaticSliceRefcount* grpc_static_metadata_refcounts() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_refcounts != nullptr);
return grpc_core::g_static_metadata_slice_refcounts;
}
#define GRPC_IS_STATIC_METADATA_STRING(slice) \
((slice).refcount != NULL && \
(slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC)
#define GRPC_STATIC_METADATA_INDEX(static_slice) \
(reinterpret_cast<grpc_core::StaticSliceRefcount*>((static_slice).refcount) \
->index)
#define GRPC_STATIC_MDELEM_COUNT 85
namespace grpc_core {
extern StaticMetadata* g_static_mdelem_table;
extern grpc_mdelem* g_static_mdelem_manifested;
extern StaticMetadata g_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
extern grpc_mdelem g_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT];
} // namespace grpc_core
inline grpc_core::StaticMetadata* grpc_static_mdelem_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_table != nullptr);
return grpc_core::g_static_mdelem_table;
}
inline grpc_mdelem* grpc_static_mdelem_manifested() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_manifested != nullptr);
return grpc_core::g_static_mdelem_manifested;
}
extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
/* ":authority": "" */
#define GRPC_MDELEM_AUTHORITY_EMPTY (grpc_static_mdelem_manifested()[0])
#define GRPC_MDELEM_AUTHORITY_EMPTY (::grpc_core::g_static_mdelem_manifested[0])
/* ":method": "GET" */
#define GRPC_MDELEM_METHOD_GET (grpc_static_mdelem_manifested()[1])
#define GRPC_MDELEM_METHOD_GET (::grpc_core::g_static_mdelem_manifested[1])
/* ":method": "POST" */
#define GRPC_MDELEM_METHOD_POST (grpc_static_mdelem_manifested()[2])
#define GRPC_MDELEM_METHOD_POST (::grpc_core::g_static_mdelem_manifested[2])
/* ":path": "/" */
#define GRPC_MDELEM_PATH_SLASH (grpc_static_mdelem_manifested()[3])
#define GRPC_MDELEM_PATH_SLASH (::grpc_core::g_static_mdelem_manifested[3])
/* ":path": "/index.html" */
#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \
(grpc_static_mdelem_manifested()[4])
(::grpc_core::g_static_mdelem_manifested[4])
/* ":scheme": "http" */
#define GRPC_MDELEM_SCHEME_HTTP (grpc_static_mdelem_manifested()[5])
#define GRPC_MDELEM_SCHEME_HTTP (::grpc_core::g_static_mdelem_manifested[5])
/* ":scheme": "https" */
#define GRPC_MDELEM_SCHEME_HTTPS (grpc_static_mdelem_manifested()[6])
#define GRPC_MDELEM_SCHEME_HTTPS (::grpc_core::g_static_mdelem_manifested[6])
/* ":status": "200" */
#define GRPC_MDELEM_STATUS_200 (grpc_static_mdelem_manifested()[7])
#define GRPC_MDELEM_STATUS_200 (::grpc_core::g_static_mdelem_manifested[7])
/* ":status": "204" */
#define GRPC_MDELEM_STATUS_204 (grpc_static_mdelem_manifested()[8])
#define GRPC_MDELEM_STATUS_204 (::grpc_core::g_static_mdelem_manifested[8])
/* ":status": "206" */
#define GRPC_MDELEM_STATUS_206 (grpc_static_mdelem_manifested()[9])
#define GRPC_MDELEM_STATUS_206 (::grpc_core::g_static_mdelem_manifested[9])
/* ":status": "304" */
#define GRPC_MDELEM_STATUS_304 (grpc_static_mdelem_manifested()[10])
#define GRPC_MDELEM_STATUS_304 (::grpc_core::g_static_mdelem_manifested[10])
/* ":status": "400" */
#define GRPC_MDELEM_STATUS_400 (grpc_static_mdelem_manifested()[11])
#define GRPC_MDELEM_STATUS_400 (::grpc_core::g_static_mdelem_manifested[11])
/* ":status": "404" */
#define GRPC_MDELEM_STATUS_404 (grpc_static_mdelem_manifested()[12])
#define GRPC_MDELEM_STATUS_404 (::grpc_core::g_static_mdelem_manifested[12])
/* ":status": "500" */
#define GRPC_MDELEM_STATUS_500 (grpc_static_mdelem_manifested()[13])
#define GRPC_MDELEM_STATUS_500 (::grpc_core::g_static_mdelem_manifested[13])
/* "accept-charset": "" */
#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (grpc_static_mdelem_manifested()[14])
#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \
(::grpc_core::g_static_mdelem_manifested[14])
/* "accept-encoding": "gzip, deflate" */
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \
(grpc_static_mdelem_manifested()[15])
(::grpc_core::g_static_mdelem_manifested[15])
/* "accept-language": "" */
#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[16])
#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[16])
/* "accept-ranges": "" */
#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (grpc_static_mdelem_manifested()[17])
#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \
(::grpc_core::g_static_mdelem_manifested[17])
/* "accept": "" */
#define GRPC_MDELEM_ACCEPT_EMPTY (grpc_static_mdelem_manifested()[18])
#define GRPC_MDELEM_ACCEPT_EMPTY (::grpc_core::g_static_mdelem_manifested[18])
/* "access-control-allow-origin": "" */
#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \
(grpc_static_mdelem_manifested()[19])
(::grpc_core::g_static_mdelem_manifested[19])
/* "age": "" */
#define GRPC_MDELEM_AGE_EMPTY (grpc_static_mdelem_manifested()[20])
#define GRPC_MDELEM_AGE_EMPTY (::grpc_core::g_static_mdelem_manifested[20])
/* "allow": "" */
#define GRPC_MDELEM_ALLOW_EMPTY (grpc_static_mdelem_manifested()[21])
#define GRPC_MDELEM_ALLOW_EMPTY (::grpc_core::g_static_mdelem_manifested[21])
/* "authorization": "" */
#define GRPC_MDELEM_AUTHORIZATION_EMPTY (grpc_static_mdelem_manifested()[22])
#define GRPC_MDELEM_AUTHORIZATION_EMPTY \
(::grpc_core::g_static_mdelem_manifested[22])
/* "cache-control": "" */
#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (grpc_static_mdelem_manifested()[23])
#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \
(::grpc_core::g_static_mdelem_manifested[23])
/* "content-disposition": "" */
#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \
(grpc_static_mdelem_manifested()[24])
(::grpc_core::g_static_mdelem_manifested[24])
/* "content-encoding": "" */
#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (grpc_static_mdelem_manifested()[25])
#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \
(::grpc_core::g_static_mdelem_manifested[25])
/* "content-language": "" */
#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[26])
#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[26])
/* "content-length": "" */
#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (grpc_static_mdelem_manifested()[27])
#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \
(::grpc_core::g_static_mdelem_manifested[27])
/* "content-location": "" */
#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (grpc_static_mdelem_manifested()[28])
#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \
(::grpc_core::g_static_mdelem_manifested[28])
/* "content-range": "" */
#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (grpc_static_mdelem_manifested()[29])
#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[29])
/* "content-type": "" */
#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (grpc_static_mdelem_manifested()[30])
#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[30])
/* "cookie": "" */
#define GRPC_MDELEM_COOKIE_EMPTY (grpc_static_mdelem_manifested()[31])
#define GRPC_MDELEM_COOKIE_EMPTY (::grpc_core::g_static_mdelem_manifested[31])
/* "date": "" */
#define GRPC_MDELEM_DATE_EMPTY (grpc_static_mdelem_manifested()[32])
#define GRPC_MDELEM_DATE_EMPTY (::grpc_core::g_static_mdelem_manifested[32])
/* "etag": "" */
#define GRPC_MDELEM_ETAG_EMPTY (grpc_static_mdelem_manifested()[33])
#define GRPC_MDELEM_ETAG_EMPTY (::grpc_core::g_static_mdelem_manifested[33])
/* "expect": "" */
#define GRPC_MDELEM_EXPECT_EMPTY (grpc_static_mdelem_manifested()[34])
#define GRPC_MDELEM_EXPECT_EMPTY (::grpc_core::g_static_mdelem_manifested[34])
/* "expires": "" */
#define GRPC_MDELEM_EXPIRES_EMPTY (grpc_static_mdelem_manifested()[35])
#define GRPC_MDELEM_EXPIRES_EMPTY (::grpc_core::g_static_mdelem_manifested[35])
/* "from": "" */
#define GRPC_MDELEM_FROM_EMPTY (grpc_static_mdelem_manifested()[36])
#define GRPC_MDELEM_FROM_EMPTY (::grpc_core::g_static_mdelem_manifested[36])
/* "host": "" */
#define GRPC_MDELEM_HOST_EMPTY (grpc_static_mdelem_manifested()[37])
#define GRPC_MDELEM_HOST_EMPTY (::grpc_core::g_static_mdelem_manifested[37])
/* "if-match": "" */
#define GRPC_MDELEM_IF_MATCH_EMPTY (grpc_static_mdelem_manifested()[38])
#define GRPC_MDELEM_IF_MATCH_EMPTY (::grpc_core::g_static_mdelem_manifested[38])
/* "if-modified-since": "" */
#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \
(grpc_static_mdelem_manifested()[39])
(::grpc_core::g_static_mdelem_manifested[39])
/* "if-none-match": "" */
#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (grpc_static_mdelem_manifested()[40])
#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \
(::grpc_core::g_static_mdelem_manifested[40])
/* "if-range": "" */
#define GRPC_MDELEM_IF_RANGE_EMPTY (grpc_static_mdelem_manifested()[41])
#define GRPC_MDELEM_IF_RANGE_EMPTY (::grpc_core::g_static_mdelem_manifested[41])
/* "if-unmodified-since": "" */
#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \
(grpc_static_mdelem_manifested()[42])
(::grpc_core::g_static_mdelem_manifested[42])
/* "last-modified": "" */
#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (grpc_static_mdelem_manifested()[43])
#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \
(::grpc_core::g_static_mdelem_manifested[43])
/* "link": "" */
#define GRPC_MDELEM_LINK_EMPTY (grpc_static_mdelem_manifested()[44])
#define GRPC_MDELEM_LINK_EMPTY (::grpc_core::g_static_mdelem_manifested[44])
/* "location": "" */
#define GRPC_MDELEM_LOCATION_EMPTY (grpc_static_mdelem_manifested()[45])
#define GRPC_MDELEM_LOCATION_EMPTY (::grpc_core::g_static_mdelem_manifested[45])
/* "max-forwards": "" */
#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (grpc_static_mdelem_manifested()[46])
#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \
(::grpc_core::g_static_mdelem_manifested[46])
/* "proxy-authenticate": "" */
#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \
(grpc_static_mdelem_manifested()[47])
(::grpc_core::g_static_mdelem_manifested[47])
/* "proxy-authorization": "" */
#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \
(grpc_static_mdelem_manifested()[48])
(::grpc_core::g_static_mdelem_manifested[48])
/* "range": "" */
#define GRPC_MDELEM_RANGE_EMPTY (grpc_static_mdelem_manifested()[49])
#define GRPC_MDELEM_RANGE_EMPTY (::grpc_core::g_static_mdelem_manifested[49])
/* "referer": "" */
#define GRPC_MDELEM_REFERER_EMPTY (grpc_static_mdelem_manifested()[50])
#define GRPC_MDELEM_REFERER_EMPTY (::grpc_core::g_static_mdelem_manifested[50])
/* "refresh": "" */
#define GRPC_MDELEM_REFRESH_EMPTY (grpc_static_mdelem_manifested()[51])
#define GRPC_MDELEM_REFRESH_EMPTY (::grpc_core::g_static_mdelem_manifested[51])
/* "retry-after": "" */
#define GRPC_MDELEM_RETRY_AFTER_EMPTY (grpc_static_mdelem_manifested()[52])
#define GRPC_MDELEM_RETRY_AFTER_EMPTY \
(::grpc_core::g_static_mdelem_manifested[52])
/* "server": "" */
#define GRPC_MDELEM_SERVER_EMPTY (grpc_static_mdelem_manifested()[53])
#define GRPC_MDELEM_SERVER_EMPTY (::grpc_core::g_static_mdelem_manifested[53])
/* "set-cookie": "" */
#define GRPC_MDELEM_SET_COOKIE_EMPTY (grpc_static_mdelem_manifested()[54])
#define GRPC_MDELEM_SET_COOKIE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[54])
/* "strict-transport-security": "" */
#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \
(grpc_static_mdelem_manifested()[55])
(::grpc_core::g_static_mdelem_manifested[55])
/* "transfer-encoding": "" */
#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \
(grpc_static_mdelem_manifested()[56])
(::grpc_core::g_static_mdelem_manifested[56])
/* "user-agent": "" */
#define GRPC_MDELEM_USER_AGENT_EMPTY (grpc_static_mdelem_manifested()[57])
#define GRPC_MDELEM_USER_AGENT_EMPTY \
(::grpc_core::g_static_mdelem_manifested[57])
/* "vary": "" */
#define GRPC_MDELEM_VARY_EMPTY (grpc_static_mdelem_manifested()[58])
#define GRPC_MDELEM_VARY_EMPTY (::grpc_core::g_static_mdelem_manifested[58])
/* "via": "" */
#define GRPC_MDELEM_VIA_EMPTY (grpc_static_mdelem_manifested()[59])
#define GRPC_MDELEM_VIA_EMPTY (::grpc_core::g_static_mdelem_manifested[59])
/* "www-authenticate": "" */
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested()[60])
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \
(::grpc_core::g_static_mdelem_manifested[60])
/* "grpc-status": "0" */
#define GRPC_MDELEM_GRPC_STATUS_0 (grpc_static_mdelem_manifested()[61])
#define GRPC_MDELEM_GRPC_STATUS_0 (::grpc_core::g_static_mdelem_manifested[61])
/* "grpc-status": "1" */
#define GRPC_MDELEM_GRPC_STATUS_1 (grpc_static_mdelem_manifested()[62])
#define GRPC_MDELEM_GRPC_STATUS_1 (::grpc_core::g_static_mdelem_manifested[62])
/* "grpc-status": "2" */
#define GRPC_MDELEM_GRPC_STATUS_2 (grpc_static_mdelem_manifested()[63])
#define GRPC_MDELEM_GRPC_STATUS_2 (::grpc_core::g_static_mdelem_manifested[63])
/* "grpc-encoding": "identity" */
#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (grpc_static_mdelem_manifested()[64])
#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \
(::grpc_core::g_static_mdelem_manifested[64])
/* "grpc-encoding": "gzip" */
#define GRPC_MDELEM_GRPC_ENCODING_GZIP (grpc_static_mdelem_manifested()[65])
#define GRPC_MDELEM_GRPC_ENCODING_GZIP \
(::grpc_core::g_static_mdelem_manifested[65])
/* "grpc-encoding": "deflate" */
#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (grpc_static_mdelem_manifested()[66])
#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \
(::grpc_core::g_static_mdelem_manifested[66])
/* "te": "trailers" */
#define GRPC_MDELEM_TE_TRAILERS (grpc_static_mdelem_manifested()[67])
#define GRPC_MDELEM_TE_TRAILERS (::grpc_core::g_static_mdelem_manifested[67])
/* "content-type": "application/grpc" */
#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \
(grpc_static_mdelem_manifested()[68])
(::grpc_core::g_static_mdelem_manifested[68])
/* ":scheme": "grpc" */
#define GRPC_MDELEM_SCHEME_GRPC (grpc_static_mdelem_manifested()[69])
#define GRPC_MDELEM_SCHEME_GRPC (::grpc_core::g_static_mdelem_manifested[69])
/* ":method": "PUT" */
#define GRPC_MDELEM_METHOD_PUT (grpc_static_mdelem_manifested()[70])
#define GRPC_MDELEM_METHOD_PUT (::grpc_core::g_static_mdelem_manifested[70])
/* "accept-encoding": "" */
#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (grpc_static_mdelem_manifested()[71])
#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \
(::grpc_core::g_static_mdelem_manifested[71])
/* "content-encoding": "identity" */
#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \
(grpc_static_mdelem_manifested()[72])
(::grpc_core::g_static_mdelem_manifested[72])
/* "content-encoding": "gzip" */
#define GRPC_MDELEM_CONTENT_ENCODING_GZIP (grpc_static_mdelem_manifested()[73])
#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \
(::grpc_core::g_static_mdelem_manifested[73])
/* "lb-cost-bin": "" */
#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested()[74])
#define GRPC_MDELEM_LB_COST_BIN_EMPTY \
(::grpc_core::g_static_mdelem_manifested[74])
/* "grpc-accept-encoding": "identity" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \
(grpc_static_mdelem_manifested()[75])
(::grpc_core::g_static_mdelem_manifested[75])
/* "grpc-accept-encoding": "deflate" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \
(grpc_static_mdelem_manifested()[76])
(::grpc_core::g_static_mdelem_manifested[76])
/* "grpc-accept-encoding": "identity,deflate" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \
(grpc_static_mdelem_manifested()[77])
(::grpc_core::g_static_mdelem_manifested[77])
/* "grpc-accept-encoding": "gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \
(grpc_static_mdelem_manifested()[78])
(::grpc_core::g_static_mdelem_manifested[78])
/* "grpc-accept-encoding": "identity,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \
(grpc_static_mdelem_manifested()[79])
(::grpc_core::g_static_mdelem_manifested[79])
/* "grpc-accept-encoding": "deflate,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \
(grpc_static_mdelem_manifested()[80])
(::grpc_core::g_static_mdelem_manifested[80])
/* "grpc-accept-encoding": "identity,deflate,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
(grpc_static_mdelem_manifested()[81])
(::grpc_core::g_static_mdelem_manifested[81])
/* "accept-encoding": "identity" */
#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \
(grpc_static_mdelem_manifested()[82])
(::grpc_core::g_static_mdelem_manifested[82])
/* "accept-encoding": "gzip" */
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested()[83])
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \
(::grpc_core::g_static_mdelem_manifested[83])
/* "accept-encoding": "identity,gzip" */
#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \
(grpc_static_mdelem_manifested()[84])
(::grpc_core::g_static_mdelem_manifested[84])
grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b);
typedef enum {
@ -590,14 +330,14 @@ typedef union {
extern const uint8_t grpc_static_accept_encoding_metadata[8];
#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \
(GRPC_MAKE_MDELEM(&grpc_static_mdelem_table() \
(GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table \
[grpc_static_accept_encoding_metadata[(algs)]] \
.data(), \
GRPC_MDELEM_STORAGE_STATIC))
extern const uint8_t grpc_static_accept_stream_encoding_metadata[4];
#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) \
(GRPC_MAKE_MDELEM(&grpc_static_mdelem_table() \
(GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table \
[grpc_static_accept_stream_encoding_metadata[(algs)]] \
.data(), \
GRPC_MDELEM_STORAGE_STATIC))

@ -573,7 +573,9 @@ CORE_SOURCE_FILES = [
'src/core/lib/slice/slice.cc',
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_intern.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/static_slice.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',

@ -270,8 +270,8 @@ static void test_static_slice_interning(void) {
for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) {
GPR_ASSERT(grpc_slice_is_equivalent(
grpc_static_slice_table()[i],
grpc_slice_intern(grpc_static_slice_table()[i])));
grpc_core::g_static_metadata_slice_table[i],
grpc_slice_intern(grpc_core::g_static_metadata_slice_table[i])));
}
}
@ -281,9 +281,11 @@ static void test_static_slice_copy_interning(void) {
grpc_init();
for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) {
grpc_slice copy = grpc_slice_dup(grpc_static_slice_table()[i]);
GPR_ASSERT(grpc_static_slice_table()[i].refcount != copy.refcount);
GPR_ASSERT(grpc_static_slice_table()[i].refcount ==
grpc_slice copy =
grpc_slice_dup(grpc_core::g_static_metadata_slice_table[i]);
GPR_ASSERT(grpc_core::g_static_metadata_slice_table[i].refcount !=
copy.refcount);
GPR_ASSERT(grpc_core::g_static_metadata_slice_table[i].refcount ==
grpc_slice_intern(copy).refcount);
grpc_slice_unref(copy);
}

@ -331,7 +331,7 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
grpc_core::ExecCtx exec_ctx;
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[i],
grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table[i],
GRPC_MDELEM_STORAGE_STATIC);
grpc_mdelem q =
grpc_mdelem_from_slices(maybe_dup(GRPC_MDKEY(p), dup_key),

@ -32,7 +32,7 @@ TEST(StaticMetadataTest, ReadAllStaticElements) {
// This makes sure that all static elements are returned when
// grpc_mdelem_from_slices is called with key pairs pregenerated.
for (int i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
const grpc_mdelem mdelem = grpc_static_mdelem_manifested()[i];
const grpc_mdelem mdelem = g_static_mdelem_manifested[i];
const grpc_mdelem mdelem2 =
grpc_mdelem_from_slices(GRPC_MDKEY(mdelem), GRPC_MDVALUE(mdelem));
EXPECT_EQ(mdelem.payload, mdelem2.payload);

@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
# Copyright 2015 gRPC authors.
#
@ -249,11 +249,11 @@ def fake_hash(elem):
# utility: print a big comment block into a set of files
def put_banner(files, banner):
for f in files:
print >> f, '/*'
print('/*', file=f)
for line in banner:
print >> f, ' * %s' % line
print >> f, ' */'
print >> f
print(' * %s' % line, file=f)
print(' */', file=f)
print('', file=f)
# build a list of all the strings we need
@ -303,29 +303,45 @@ for mask in range(1, 1 << len(STREAM_COMPRESSION_ALGORITHMS)):
# output configuration
args = sys.argv[1:]
H = None
C = None
MD_H = None
MD_C = None
STR_H = None
STR_C = None
D = None
if args:
if 'header' in args:
H = sys.stdout
if 'md_header' in args:
MD_H = sys.stdout
else:
H = open('/dev/null', 'w')
if 'source' in args:
C = sys.stdout
MD_H = open('/dev/null', 'w')
if 'md_source' in args:
MD_C = sys.stdout
else:
C = open('/dev/null', 'w')
MD_C = open('/dev/null', 'w')
if 'str_header' in args:
STR_H = sys.stdout
else:
STR_H = open('/dev/null', 'w')
if 'str_source' in args:
STR_C = sys.stdout
else:
STR_C = open('/dev/null', 'w')
if 'dictionary' in args:
D = sys.stdout
else:
D = open('/dev/null', 'w')
else:
H = open(
MD_H = open(
os.path.join(os.path.dirname(sys.argv[0]),
'../../../src/core/lib/transport/static_metadata.h'), 'w')
C = open(
MD_C = open(
os.path.join(os.path.dirname(sys.argv[0]),
'../../../src/core/lib/transport/static_metadata.cc'), 'w')
STR_H = open(
os.path.join(os.path.dirname(sys.argv[0]),
'../../../src/core/lib/slice/static_slice.h'), 'w')
STR_C = open(
os.path.join(os.path.dirname(sys.argv[0]),
'../../../src/core/lib/slice/static_slice.cc'), 'w')
D = open(
os.path.join(os.path.dirname(sys.argv[0]),
'../../../test/core/end2end/fuzzers/hpack.dictionary'),
@ -345,7 +361,8 @@ with open(sys.argv[0]) as my_source:
if line[0] != '#':
break
copyright.append(line)
put_banner([H, C], [line[2:].rstrip() for line in copyright])
put_banner([MD_H, MD_C, STR_H, STR_C],
[line[2:].rstrip() for line in copyright])
hex_bytes = [ord(c) for c in 'abcdefABCDEF0123456789']
@ -363,7 +380,7 @@ def esc_dict(line):
return out + "\""
put_banner([H, C], """WARNING: Auto-generated code.
put_banner([MD_H, MD_C, STR_H, STR_C], """WARNING: Auto-generated code.
To make changes to this file, change
tools/codegen/core/gen_static_metadata.py, and then re-run it.
@ -372,21 +389,36 @@ See metadata.h for an explanation of the interface here, and metadata.cc for
an explanation of what's going on.
""".splitlines())
print >> H, '#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H'
print >> H, '#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H'
print >> H
print >> H, '#include <grpc/support/port_platform.h>'
print >> H
print >> H, '#include <cstdint>'
print >> H
print >> H, '#include "src/core/lib/transport/metadata.h"'
print >> H
print >> C, '#include <grpc/support/port_platform.h>'
print >> C
print >> C, '#include "src/core/lib/transport/static_metadata.h"'
print >> C
print >> C, '#include "src/core/lib/slice/slice_internal.h"'
print >> C
print('#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H', file=MD_H)
print('#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H', file=MD_H)
print('', file=MD_H)
print('#include <grpc/support/port_platform.h>', file=MD_H)
print('', file=MD_H)
print('#include <cstdint>', file=MD_H)
print('', file=MD_H)
print('#include "src/core/lib/transport/metadata.h"', file=MD_H)
print('#include "src/core/lib/slice/static_slice.h"', file=MD_H)
print('', file=MD_H)
print('#ifndef GRPC_CORE_LIB_SLICE_STATIC_SLICE_H', file=STR_H)
print('#define GRPC_CORE_LIB_SLICE_STATIC_SLICE_H', file=STR_H)
print('', file=STR_H)
print('#include <grpc/support/port_platform.h>', file=STR_H)
print('', file=STR_H)
print('#include <cstdint>', file=STR_H)
print('#include <type_traits>', file=STR_H)
print('#include "src/core/lib/slice/slice_utils.h"', file=STR_H)
print('#include "src/core/lib/slice/slice_refcount_base.h"', file=STR_H)
print('', file=STR_H)
print('#include <grpc/support/port_platform.h>', file=MD_C)
print('', file=MD_C)
print('#include "src/core/lib/transport/static_metadata.h"', file=MD_C)
print('', file=MD_C)
print('#include "src/core/lib/slice/slice_internal.h"', file=MD_C)
print('', file=MD_C)
print('#include <grpc/support/port_platform.h>', file=STR_C)
print('', file=STR_C)
print('#include "src/core/lib/slice/static_slice.h"', file=STR_C)
print('', file=STR_C)
str_ofs = 0
id2strofs = {}
@ -397,13 +429,13 @@ for i, elem in enumerate(all_strs):
def slice_def_for_ctx(i):
return (
'grpc_core::StaticMetadataSlice(&refcounts[%d].base, %d, g_bytes+%d)'
'grpc_core::StaticMetadataSlice(&g_static_metadata_slice_refcounts[%d].base, %d, g_static_metadata_bytes+%d)'
) % (i, len(all_strs[i]), id2strofs[i])
def slice_def(i):
return (
'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts()[%d].base, %d, g_bytes+%d)'
'grpc_core::StaticMetadataSlice(&g_static_metadata_slice_refcounts[%d].base, %d, g_static_metadata_bytes+%d)'
) % (i, len(all_strs[i]), id2strofs[i])
@ -420,186 +452,132 @@ static_slice_dest_assert = (
'static_assert(std::is_trivially_destructible' +
'<grpc_core::StaticMetadataSlice>::value, '
'"grpc_core::StaticMetadataSlice must be trivially destructible.");')
print >> H, static_slice_dest_assert
print >> H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs)
print >> H, '''
void grpc_init_static_metadata_ctx(void);
void grpc_destroy_static_metadata_ctx(void);
namespace grpc_core {
#ifndef NDEBUG
constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L;
uint64_t StaticMetadataInitCanary();
#endif
extern const StaticMetadataSlice* g_static_metadata_slice_table;
}
inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary()
== grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_table != nullptr);
return grpc_core::g_static_metadata_slice_table;
}
'''
print(static_slice_dest_assert, file=STR_H)
print('#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs), file=STR_H)
for i, elem in enumerate(all_strs):
print >> H, '/* "%s" */' % elem
print >> H, '#define %s (grpc_static_slice_table()[%d])' % (
mangle(elem).upper(), i)
print >> H
print >> C, 'static constexpr uint8_t g_bytes[] = {%s};' % (','.join(
'%d' % ord(c) for c in ''.join(all_strs)))
print >> C
print >> H, '''
print('/* "%s" */' % elem, file=STR_H)
print('#define %s (::grpc_core::g_static_metadata_slice_table[%d])' %
(mangle(elem).upper(), i),
file=STR_H)
print('', file=STR_H)
print('namespace grpc_core {', file=STR_C)
print('',
'const uint8_t g_static_metadata_bytes[] = {%s};' %
(','.join('%d' % ord(c) for c in ''.join(all_strs))),
file=STR_C)
print('', file=STR_C)
print('''
namespace grpc_core {
struct StaticSliceRefcount;
extern StaticSliceRefcount* g_static_metadata_slice_refcounts;
}
inline grpc_core::StaticSliceRefcount* grpc_static_metadata_refcounts() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary()
== grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_refcounts != nullptr);
return grpc_core::g_static_metadata_slice_refcounts;
extern StaticSliceRefcount g_static_metadata_slice_refcounts[GRPC_STATIC_MDSTR_COUNT];
extern const StaticMetadataSlice g_static_metadata_slice_table[GRPC_STATIC_MDSTR_COUNT];
extern const uint8_t g_static_metadata_bytes[];
}
'''
print >> C, 'grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;'
print >> C, '''
namespace grpc_core {
struct StaticMetadataCtx {
#ifndef NDEBUG
const uint64_t init_canary = kGrpcStaticMetadataInitCanary;
#endif
StaticSliceRefcount
refcounts[GRPC_STATIC_MDSTR_COUNT] = {
'''
''',
file=STR_H)
print('grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;',
file=STR_C)
print('''
StaticSliceRefcount
g_static_metadata_slice_refcounts[GRPC_STATIC_MDSTR_COUNT] = {
''',
file=STR_C)
for i, elem in enumerate(all_strs):
print >> C, ' StaticSliceRefcount(%d), ' % i
print >> C, '};' # static slice refcounts
print >> C
print >> C, '''
print(' StaticSliceRefcount(%d), ' % i, file=STR_C)
print('};', file=STR_C) # static slice refcounts
print('', file=STR_C)
print('''
const StaticMetadataSlice
slices[GRPC_STATIC_MDSTR_COUNT] = {
'''
g_static_metadata_slice_table[GRPC_STATIC_MDSTR_COUNT] = {
''',
file=STR_C)
for i, elem in enumerate(all_strs):
print >> C, slice_def_for_ctx(i) + ','
print >> C, '};' # static slices
print >> C, 'StaticMetadata static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {'
print(slice_def_for_ctx(i) + ',', file=STR_C)
print('};', file=STR_C) # static slices
print('namespace grpc_core {', file=MD_C)
print('StaticMetadata g_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {',
file=MD_C)
for idx, (a, b) in enumerate(all_elems):
print >> C, 'StaticMetadata(%s,%s, %d),' % (slice_def_for_ctx(
str_idx(a)), slice_def_for_ctx(str_idx(b)), idx)
print >> C, '};' # static_mdelem_table
print >> C, ('''
print('StaticMetadata(%s,%s, %d),' %
(slice_def_for_ctx(str_idx(a)), slice_def_for_ctx(str_idx(b)), idx),
file=MD_C)
print('};', file=MD_C) # static_mdelem_table
print(('''
/* Warning: the core static metadata currently operates under the soft constraint
that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must contain
metadata specified by the http2 hpack standard. The CHTTP2 transport reads the
core metadata with this assumption in mind. If the order of the core static
metadata is to be changed, then the CHTTP2 transport must be changed as well to
stop relying on the core metadata. */
''')
print >> C, ('grpc_mdelem '
'static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = {')
print >> C, '// clang-format off'
'''),
file=MD_C)
print(('grpc_mdelem '
'g_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = {'),
file=MD_C)
print('// clang-format off', file=MD_C)
static_mds = []
for i, elem in enumerate(all_elems):
md_name = mangle(elem).upper()
md_human_readable = '"%s": "%s"' % elem
md_spec = ' /* %s: \n %s */\n' % (md_name, md_human_readable)
md_spec += ' GRPC_MAKE_MDELEM(\n'
md_spec += ((' &static_mdelem_table[%d].data(),\n' % i) +
md_spec += ((' &g_static_mdelem_table[%d].data(),\n' % i) +
' GRPC_MDELEM_STORAGE_STATIC)')
static_mds.append(md_spec)
print >> C, ',\n'.join(static_mds)
print >> C, '// clang-format on'
print >> C, ('};') # static_mdelem_manifested
print >> C, '};' # struct StaticMetadataCtx
print >> C, '}' # namespace grpc_core
print >> C, '''
namespace grpc_core {
static StaticMetadataCtx* g_static_metadata_slice_ctx = nullptr;
const StaticMetadataSlice* g_static_metadata_slice_table = nullptr;
StaticSliceRefcount* g_static_metadata_slice_refcounts = nullptr;
StaticMetadata* g_static_mdelem_table = nullptr;
grpc_mdelem* g_static_mdelem_manifested = nullptr;
#ifndef NDEBUG
uint64_t StaticMetadataInitCanary() {
return g_static_metadata_slice_ctx->init_canary;
}
#endif
}
void grpc_init_static_metadata_ctx(void) {
grpc_core::g_static_metadata_slice_ctx
= new grpc_core::StaticMetadataCtx();
grpc_core::g_static_metadata_slice_table
= grpc_core::g_static_metadata_slice_ctx->slices;
grpc_core::g_static_metadata_slice_refcounts
= grpc_core::g_static_metadata_slice_ctx->refcounts;
grpc_core::g_static_mdelem_table
= grpc_core::g_static_metadata_slice_ctx->static_mdelem_table;
grpc_core::g_static_mdelem_manifested =
grpc_core::g_static_metadata_slice_ctx->static_mdelem_manifested;
}
void grpc_destroy_static_metadata_ctx(void) {
delete grpc_core::g_static_metadata_slice_ctx;
grpc_core::g_static_metadata_slice_ctx = nullptr;
grpc_core::g_static_metadata_slice_table = nullptr;
grpc_core::g_static_metadata_slice_refcounts = nullptr;
grpc_core::g_static_mdelem_table = nullptr;
grpc_core::g_static_mdelem_manifested = nullptr;
}
'''
print >> C
print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\'
print >> H, (' ((slice).refcount != NULL && (slice).refcount->GetType() == '
'grpc_slice_refcount::Type::STATIC)')
print >> H
print >> C
print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\'
print >> H, '(reinterpret_cast<grpc_core::StaticSliceRefcount*>((static_slice).refcount)->index)'
print >> H
print >> D, '# hpack fuzzing dictionary'
print(',\n'.join(static_mds), file=MD_C)
print('// clang-format on', file=MD_C)
print(('};'), file=MD_C) # static_mdelem_manifested
print('}', file=MD_C) # namespace grpc_core
print('}', file=STR_C) # namespace grpc_core
print('', file=MD_C)
print('#define GRPC_IS_STATIC_METADATA_STRING(slice) \\', file=STR_H)
print((' ((slice).refcount != NULL && (slice).refcount->GetType() == '
'grpc_slice_refcount::Type::STATIC)'),
file=STR_H)
print('', file=STR_H)
print('', file=STR_C)
print('#define GRPC_STATIC_METADATA_INDEX(static_slice) \\', file=STR_H)
print(
'(reinterpret_cast<grpc_core::StaticSliceRefcount*>((static_slice).refcount)->index)',
file=STR_H)
print('', file=STR_H)
print('# hpack fuzzing dictionary', file=D)
for i, elem in enumerate(all_strs):
print >> D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem]))
print('%s' % (esc_dict([len(elem)] + [ord(c) for c in elem])), file=D)
for i, elem in enumerate(all_elems):
print >> D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] +
[len(elem[1])] + [ord(c) for c in elem[1]]))
print('%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] +
[len(elem[1])] + [ord(c) for c in elem[1]])),
file=D)
print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems)
print >> H, '''
print('#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems), file=MD_H)
print('''
namespace grpc_core {
extern StaticMetadata* g_static_mdelem_table;
extern grpc_mdelem* g_static_mdelem_manifested;
}
inline grpc_core::StaticMetadata* grpc_static_mdelem_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary()
== grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_table != nullptr);
return grpc_core::g_static_mdelem_table;
extern StaticMetadata g_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
extern grpc_mdelem g_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT];
}
inline grpc_mdelem* grpc_static_mdelem_manifested() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary()
== grpc_core::kGrpcStaticMetadataInitCanary);
GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_manifested != nullptr);
return grpc_core::g_static_mdelem_manifested;
}
'''
print >> H, ('extern uintptr_t '
'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];')
''',
file=MD_H)
print(('extern uintptr_t '
'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];'),
file=MD_H)
for i, elem in enumerate(all_elems):
md_name = mangle(elem).upper()
print >> H, '/* "%s": "%s" */' % elem
print >> H, ('#define %s (grpc_static_mdelem_manifested()[%d])' %
(md_name, i))
print >> H
print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] '
'= {')
print >> C, ' %s' % ','.join(
'%d' % static_userdata.get(elem, 0) for elem in all_elems)
print >> C, '};'
print >> C
print('/* "%s": "%s" */' % elem, file=MD_H)
print(('#define %s (::grpc_core::g_static_mdelem_manifested[%d])' %
(md_name, i)),
file=MD_H)
print('', file=MD_H)
print(('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] '
'= {'),
file=MD_C)
print(' %s' %
','.join('%d' % static_userdata.get(elem, 0) for elem in all_elems),
file=MD_C)
print('};', file=MD_C)
print('', file=MD_C)
def md_idx(m):
@ -621,7 +599,7 @@ def perfect_hash(keys, name):
def f(i, p=p):
i += p.offset
x = i % p.t
y = i / p.t
y = i // p.t
return x + p.r[y]
return {
@ -657,7 +635,7 @@ elem_keys = [
str_idx(elem[0]) * len(all_strs) + str_idx(elem[1]) for elem in all_elems
]
elem_hash = perfect_hash(elem_keys, 'elems')
print >> C, elem_hash['code']
print(elem_hash['code'], file=MD_C)
keys = [0] * int(elem_hash['PHASHNKEYS'])
idxs = [255] * int(elem_hash['PHASHNKEYS'])
@ -666,35 +644,46 @@ for i, k in enumerate(elem_keys):
assert keys[h] == 0
keys[h] = k
idxs[h] = i
print >> C, 'static const uint16_t elem_keys[] = {%s};' % ','.join(
'%d' % k for k in keys)
print >> C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join(
'%d' % i for i in idxs)
print >> C
print >> H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b);'
print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) {'
print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;'
print >> C, ' uint32_t k = static_cast<uint32_t>(a * %d + b);' % len(all_strs)
print >> C, ' uint32_t h = elems_phash(k);'
print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;'
print >> C, '}'
print >> C
print >> H, 'typedef enum {'
print('static const uint16_t elem_keys[] = {%s};' %
','.join('%d' % k for k in keys),
file=MD_C)
print('static const uint8_t elem_idxs[] = {%s};' %
','.join('%d' % i for i in idxs),
file=MD_C)
print('', file=MD_C)
print(
'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b);',
file=MD_H)
print(
'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) {',
file=MD_C)
print(' if (a == -1 || b == -1) return GRPC_MDNULL;', file=MD_C)
print(' uint32_t k = static_cast<uint32_t>(a * %d + b);' % len(all_strs),
file=MD_C)
print(' uint32_t h = elems_phash(k);', file=MD_C)
print(
' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;',
file=MD_C)
print('}', file=MD_C)
print('', file=MD_C)
print('typedef enum {', file=MD_H)
for elem in METADATA_BATCH_CALLOUTS:
print >> H, ' %s,' % mangle(elem, 'batch').upper()
print >> H, ' GRPC_BATCH_CALLOUTS_COUNT'
print >> H, '} grpc_metadata_batch_callouts_index;'
print >> H
print >> H, 'typedef union {'
print >> H, ' struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];'
print >> H, ' struct {'
print(' %s,' % mangle(elem, 'batch').upper(), file=MD_H)
print(' GRPC_BATCH_CALLOUTS_COUNT', file=MD_H)
print('} grpc_metadata_batch_callouts_index;', file=MD_H)
print('', file=MD_H)
print('typedef union {', file=MD_H)
print(' struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];',
file=MD_H)
print(' struct {', file=MD_H)
for elem in METADATA_BATCH_CALLOUTS:
print >> H, ' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower()
print >> H, ' } named;'
print >> H, '} grpc_metadata_batch_callouts;'
print >> H
print(' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower(),
file=MD_H)
print(' } named;', file=MD_H)
print('} grpc_metadata_batch_callouts;', file=MD_H)
print('', file=MD_H)
batch_idx_of_hdr = '#define GRPC_BATCH_INDEX_OF(slice) \\'
static_slice = 'GRPC_IS_STATIC_METADATA_STRING((slice))'
@ -714,31 +703,44 @@ batch_idx_of_pieces = [
batch_invalid_u32, '?', slice_ref_idx_to_batch_idx, ':', batch_invalid_idx,
')'
]
print >> H, ''.join(batch_idx_of_pieces)
print >> H
print >> H, 'extern const uint8_t grpc_static_accept_encoding_metadata[%d];' % (
1 << len(COMPRESSION_ALGORITHMS))
print >> C, 'const uint8_t grpc_static_accept_encoding_metadata[%d] = {' % (
1 << len(COMPRESSION_ALGORITHMS))
print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems)
print >> C, '};'
print >> C
print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[grpc_static_accept_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))'
print >> H
print >> H, 'extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d];' % (
1 << len(STREAM_COMPRESSION_ALGORITHMS))
print >> C, 'const uint8_t grpc_static_accept_stream_encoding_metadata[%d] = {' % (
1 << len(STREAM_COMPRESSION_ALGORITHMS))
print >> C, '0,%s' % ','.join(
'%d' % md_idx(elem) for elem in stream_compression_elems)
print >> C, '};'
print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[grpc_static_accept_stream_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))'
print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */'
H.close()
C.close()
print(''.join(batch_idx_of_pieces), file=MD_H)
print('', file=MD_H)
print('extern const uint8_t grpc_static_accept_encoding_metadata[%d];' %
(1 << len(COMPRESSION_ALGORITHMS)),
file=MD_H)
print('const uint8_t grpc_static_accept_encoding_metadata[%d] = {' %
(1 << len(COMPRESSION_ALGORITHMS)),
file=MD_C)
print('0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems),
file=MD_C)
print('};', file=MD_C)
print('', file=MD_C)
print(
'#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))',
file=MD_H)
print('', file=MD_H)
print('extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d];' %
(1 << len(STREAM_COMPRESSION_ALGORITHMS)),
file=MD_H)
print('const uint8_t grpc_static_accept_stream_encoding_metadata[%d] = {' %
(1 << len(STREAM_COMPRESSION_ALGORITHMS)),
file=MD_C)
print('0,%s' %
','.join('%d' % md_idx(elem) for elem in stream_compression_elems),
file=MD_C)
print('};', file=MD_C)
print(
'#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_core::g_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))',
file=MD_H)
print('#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */', file=MD_H)
print('#endif /* GRPC_CORE_LIB_SLICE_STATIC_SLICE_H */', file=STR_H)
MD_H.close()
MD_C.close()
STR_H.close()
STR_C.close()

@ -2102,9 +2102,14 @@ src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_internal.h \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_refcount.h \
src/core/lib/slice/slice_refcount_base.h \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
src/core/lib/slice/slice_utils.h \
src/core/lib/slice/static_slice.cc \
src/core/lib/slice/static_slice.h \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/api_trace.h \
src/core/lib/surface/byte_buffer.cc \

@ -1942,9 +1942,14 @@ src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_internal.h \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_refcount.h \
src/core/lib/slice/slice_refcount_base.h \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
src/core/lib/slice/slice_utils.h \
src/core/lib/slice/static_slice.cc \
src/core/lib/slice/static_slice.h \
src/core/lib/surface/README.md \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/api_trace.h \

Loading…
Cancel
Save