From 0f83755c6e676d1e0e67b5f99d06e525bd618944 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Fri, 10 May 2019 13:57:01 -0700 Subject: [PATCH] chttp2 hpack encoder: fast-pathed static md/slice ops --- .../chttp2/transport/hpack_encoder.cc | 105 +++-- .../transport/chttp2/transport/hpack_table.cc | 10 - .../transport/chttp2/transport/hpack_table.h | 11 +- src/core/lib/slice/slice.cc | 3 +- src/core/lib/slice/slice_hash_table.h | 4 +- src/core/lib/slice/slice_intern.cc | 21 +- src/core/lib/slice/slice_internal.h | 31 ++ src/core/lib/slice/slice_weak_hash_table.h | 4 +- src/core/lib/surface/server.cc | 10 +- src/core/lib/transport/metadata.cc | 36 +- src/core/lib/transport/metadata.h | 30 +- src/core/lib/transport/static_metadata.cc | 434 ++++++++++------- src/core/lib/transport/static_metadata.h | 435 +++++++++++------- tools/codegen/core/gen_static_metadata.py | 18 +- 14 files changed, 705 insertions(+), 447 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index d2607e97707..65f9ef4a53a 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -56,7 +56,10 @@ /* don't consider adding anything bigger than this to the hpack table */ #define MAX_DECODER_SPACE_USAGE 512 -static grpc_slice_refcount terminal_slice_refcount; +#define DATA_FRAME_HEADER_SIZE 9 + +static grpc_slice_refcount terminal_slice_refcount( + grpc_slice_refcount::Type::STATIC); static const grpc_slice terminal_slice = { &terminal_slice_refcount, /* refcount */ {{0, nullptr}} /* data.refcounted */ @@ -80,7 +83,8 @@ typedef struct { bool use_true_binary_metadata; } framer_state; -/* fills p (which is expected to be 9 bytes long) with a data frame header */ +/* fills p (which is expected to be DATA_FRAME_HEADER_SIZE bytes long) + * with a data frame header */ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, uint8_t flags) { GPR_ASSERT(len < 16777316); @@ -107,15 +111,17 @@ static void finish_frame(framer_state* st, int is_header_boundary, static_cast( (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) | (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0))); - st->stats->framing_bytes += 9; + st->stats->framing_bytes += DATA_FRAME_HEADER_SIZE; st->is_first_frame = 0; } /* begin a new frame: reserve off header space, remember how many bytes we'd output before beginning */ static void begin_frame(framer_state* st) { - st->header_idx = - grpc_slice_buffer_add_indexed(st->output, GRPC_SLICE_MALLOC(9)); + grpc_slice reserved; + reserved.refcount = nullptr; + reserved.data.inlined.length = DATA_FRAME_HEADER_SIZE; + st->header_idx = grpc_slice_buffer_add_indexed(st->output, reserved); st->output_length_at_start_of_frame = st->output->length; } @@ -188,8 +194,9 @@ static void evict_entry(grpc_chttp2_hpack_compressor* c) { static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, size_t elem_size) { uint32_t new_index = c->tail_remote_index + c->table_elems + 1; - GPR_ASSERT(elem_size < 65536); + GPR_DEBUG_ASSERT(elem_size < 65536); + // TODO(arjunroy): Re-examine semantics if (elem_size > c->max_table_size) { while (c->table_size > 0) { evict_entry(c); @@ -203,6 +210,7 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, while (c->table_size + elem_size > c->max_table_size) { evict_entry(c); } + // TODO(arjunroy): Are we conflating size in bytes vs. membership? GPR_ASSERT(c->table_elems < c->max_table_size); c->table_elem_size[new_index % c->cap_table_elems] = static_cast(elem_size); @@ -215,19 +223,19 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, // Add a key to the dynamic table. Both key and value will be added to table at // the decoder. static void add_key_with_index(grpc_chttp2_hpack_compressor* c, - grpc_mdelem elem, uint32_t new_index) { + grpc_mdelem elem, uint32_t new_index, + uint32_t key_hash) { if (new_index == 0) { return; } - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); - /* Store the key into {entries,indices}_keys */ - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)], - GRPC_MDKEY(elem))) { + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem))) { c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index; - } else if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)], - GRPC_MDKEY(elem))) { + } else if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_3(key_hash)], + GRPC_MDKEY(elem))) { c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index; } else if (c->entries_keys[HASH_FRAGMENT_2(key_hash)].refcount == &terminal_slice_refcount) { @@ -255,22 +263,20 @@ static void add_key_with_index(grpc_chttp2_hpack_compressor* c, /* add an element to the decoder table */ static void add_elem_with_index(grpc_chttp2_hpack_compressor* c, - grpc_mdelem elem, uint32_t new_index) { + grpc_mdelem elem, uint32_t new_index, + uint32_t elem_hash, uint32_t key_hash) { if (new_index == 0) { return; } - GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem)); - - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); - uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem)); - uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(elem)); /* Store this element into {entries,indices}_elem */ - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) { + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], + elem)) { /* already there: update with new index */ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index; - } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], - elem)) { + } else if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem)) { /* already there (cuckoo): update with new index */ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index; } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) { @@ -294,19 +300,19 @@ static void add_elem_with_index(grpc_chttp2_hpack_compressor* c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index; } - add_key_with_index(c, elem, new_index); + add_key_with_index(c, elem, new_index, key_hash); } static void add_elem(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, - size_t elem_size) { + size_t elem_size, uint32_t elem_hash, uint32_t key_hash) { uint32_t new_index = prepare_space_for_new_elem(c, elem_size); - add_elem_with_index(c, elem, new_index); + add_elem_with_index(c, elem, new_index, elem_hash, key_hash); } static void add_key(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, - size_t elem_size) { + size_t elem_size, uint32_t key_hash) { uint32_t new_index = prepare_space_for_new_elem(c, elem_size); - add_key_with_index(c, elem, new_index); + add_key_with_index(c, elem, new_index, key_hash); } static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index, @@ -488,27 +494,33 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, return; } - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); uint32_t elem_hash = 0; if (elem_interned) { - uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem)); - elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); + if (GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED) { + elem_hash = + reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + } else { + elem_hash = + reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + } inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems); /* is this elem currently in the decoders table? */ - - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && + if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { /* HIT: complete element (first cuckoo hash) */ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st); return; } - - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && + if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { /* HIT: complete element (second cuckoo hash) */ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), @@ -527,11 +539,12 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; + uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); auto emit_maybe_add = [&should_add_elem, &elem, &st, &c, &indices_key, - &decoder_space_usage] { + &decoder_space_usage, &elem_hash, &key_hash] { if (should_add_elem) { emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st); - add_elem(c, elem, decoder_space_usage); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); } else { emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st); } @@ -539,8 +552,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, /* no hits for the elem... maybe there's a key? */ indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)], - GRPC_MDKEY(elem)) && + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ emit_maybe_add(); @@ -548,8 +561,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, } indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)]; - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)], - GRPC_MDKEY(elem)) && + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_3(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ emit_maybe_add(); @@ -565,9 +578,9 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, emit_lithdr_noidx_v(c, 0, elem, st); } if (should_add_elem) { - add_elem(c, elem, decoder_space_usage); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); } else if (should_add_key) { - add_key(c, elem, decoder_space_usage); + add_key(c, elem, decoder_space_usage, key_hash); } } @@ -692,18 +705,18 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, } for (size_t i = 0; i < extra_headers_size; ++i) { grpc_mdelem md = *extra_headers[i]; - uint8_t static_index = grpc_chttp2_get_static_hpack_table_index(md); + uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(md); if (static_index) { - emit_indexed(c, static_index, &st); + emit_indexed(c, static_cast(static_index), &st); } else { hpack_enc(c, md, &st); } } grpc_metadata_batch_assert_ok(metadata); for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) { - uint8_t static_index = grpc_chttp2_get_static_hpack_table_index(l->md); + uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(l->md); if (static_index) { - emit_indexed(c, static_index, &st); + emit_indexed(c, static_cast(static_index), &st); } else { hpack_enc(c, l->md, &st); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 16aeb49df4d..f2cbd26f6b8 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -385,13 +385,3 @@ size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, return overhead_and_key + value_len; } } - -uint8_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { - if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { - uint8_t index = GRPC_MDELEM_DATA(md) - grpc_static_mdelem_table; - if (index < GRPC_CHTTP2_LAST_STATIC_ENTRY) { - return index + 1; // Hpack static metadata element indices start at 1 - } - } - return 0; -} diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index a0ffc6fab77..38f8bdda6ae 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -24,6 +24,7 @@ #include #include "src/core/lib/iomgr/error.h" #include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/static_metadata.h" /* HPACK header table */ @@ -90,7 +91,15 @@ size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, /* Returns the static hpack table index that corresponds to /a elem. Returns 0 if /a elem is not statically stored or if it is not in the static hpack table */ -uint8_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md); +inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { + uintptr_t index = + reinterpret_cast(GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table; + if (index < GRPC_CHTTP2_LAST_STATIC_ENTRY) { + return index + 1; // Hpack static metadata element indices start at 1 + } + return 0; +} /* Find a key/value pair in the table... returns the index in the table of the most similar entry, or 0 if the value was not found */ diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 75acb28e99c..3a3edebdc7a 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -68,7 +68,8 @@ void grpc_slice_unref(grpc_slice slice) { /* grpc_slice_from_static_string support structure - a refcount that does nothing */ -static grpc_slice_refcount NoopRefcount; +static grpc_slice_refcount NoopRefcount = + grpc_slice_refcount(grpc_slice_refcount::Type::NOP); size_t grpc_slice_memory_usage(grpc_slice s) { if (s.refcount == nullptr || s.refcount == &NoopRefcount) { diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index 942830a3e9c..c20eca9db77 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -138,7 +138,7 @@ SliceHashTable::~SliceHashTable() { template void SliceHashTable::Add(const grpc_slice& key, T& value) { - const size_t hash = grpc_slice_hash(key); + const size_t hash = grpc_slice_hash_internal(key); for (size_t offset = 0; offset < size_; ++offset) { const size_t idx = (hash + offset) % size_; if (!entries_[idx].is_set) { @@ -156,7 +156,7 @@ void SliceHashTable::Add(const grpc_slice& key, T& value) { template const T* SliceHashTable::Get(const grpc_slice& key) const { - const size_t hash = grpc_slice_hash(key); + const size_t hash = grpc_slice_hash_internal(key); // We cap the number of probes at the max number recorded when // populating the table. for (size_t offset = 0; offset <= max_num_probes_; ++offset) { diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index 15909d9b96f..81d34ddce25 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -128,10 +128,7 @@ int grpc_static_slice_eq(grpc_slice a, grpc_slice b) { return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); } -uint32_t grpc_slice_hash(grpc_slice s) { - return s.refcount == nullptr ? grpc_slice_default_hash_impl(s) - : s.refcount->Hash(s); -} +uint32_t grpc_slice_hash(grpc_slice s) { return grpc_slice_hash_internal(s); } grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, bool* returned_slice_is_different) { @@ -139,7 +136,7 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, return slice; } - uint32_t hash = grpc_slice_hash(slice); + uint32_t hash = grpc_slice_hash_internal(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)]; @@ -154,19 +151,13 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, return slice; } -bool grpc_slice_is_interned(const grpc_slice& slice) { - return (slice.refcount && - (slice.refcount->GetType() == grpc_slice_refcount::Type::INTERNED || - GRPC_IS_STATIC_METADATA_STRING(slice))); -} - grpc_slice grpc_slice_intern(grpc_slice slice) { GPR_TIMER_SCOPE("grpc_slice_intern", 0); if (GRPC_IS_STATIC_METADATA_STRING(slice)) { return slice; } - uint32_t hash = grpc_slice_hash(slice); + uint32_t hash = grpc_slice_hash_internal(slice); for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = @@ -238,7 +229,7 @@ void grpc_slice_intern_init(void) { max_static_metadata_hash_probe = 0; for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { grpc_static_metadata_hash_values[i] = - grpc_slice_default_hash_impl(grpc_static_slice_table[i]); + grpc_slice_default_hash_internal(grpc_static_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); @@ -252,6 +243,10 @@ 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(); + } } void grpc_slice_intern_shutdown(void) { diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index e4aba015315..23a2f6b81bc 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -99,12 +99,15 @@ struct grpc_slice_refcount { 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. // @@ -200,6 +203,7 @@ inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) { return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); case Type::INTERNED: return a.refcount == b.refcount; + case Type::NOP: case Type::REGULAR: break; } @@ -217,6 +221,7 @@ inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { case Type::INTERNED: return reinterpret_cast(slice.refcount) ->hash; + case Type::NOP: case Type::REGULAR: break; } @@ -258,6 +263,17 @@ void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, /* Check if a slice is interned */ bool grpc_slice_is_interned(const grpc_slice& slice); +inline bool grpc_slice_is_interned(const grpc_slice& slice) { + return (slice.refcount && + (slice.refcount->GetType() == grpc_slice_refcount::Type::INTERNED || + slice.refcount->GetType() == grpc_slice_refcount::Type::STATIC)); +} + +inline bool grpc_slice_static_interned_equal(const grpc_slice& a, + const grpc_slice& b) { + GPR_DEBUG_ASSERT(grpc_slice_is_interned(a) && grpc_slice_is_interned(b)); + return a.refcount == b.refcount; +} void grpc_slice_intern_init(void); void grpc_slice_intern_shutdown(void); @@ -271,6 +287,21 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, uint32_t grpc_static_slice_hash(grpc_slice s); int grpc_static_slice_eq(grpc_slice a, grpc_slice b); +inline uint32_t grpc_slice_hash_refcounted(const grpc_slice& s) { + GPR_DEBUG_ASSERT(s.refcount != nullptr); + return s.refcount->Hash(s); +} + +inline uint32_t grpc_slice_default_hash_internal(const grpc_slice& s) { + return gpr_murmur_hash3(GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s), + g_hash_seed); +} + +inline uint32_t grpc_slice_hash_internal(const grpc_slice& s) { + return s.refcount == nullptr ? grpc_slice_default_hash_internal(s) + : grpc_slice_hash_refcounted(s); +} + // Returns the memory used by this slice, not counting the slice structure // itself. This means that inlined and slices from static strings will return // 0. All other slices will return the size of the allocated chars. diff --git a/src/core/lib/slice/slice_weak_hash_table.h b/src/core/lib/slice/slice_weak_hash_table.h index 1335c817a39..8c5562bf196 100644 --- a/src/core/lib/slice/slice_weak_hash_table.h +++ b/src/core/lib/slice/slice_weak_hash_table.h @@ -47,7 +47,7 @@ class SliceWeakHashTable : public RefCounted> { /// Add a mapping from \a key to \a value, taking ownership of \a key. This /// operation will always succeed. It may discard older entries. void Add(const grpc_slice& key, T value) { - const size_t idx = grpc_slice_hash(key) % Size; + const size_t idx = grpc_slice_hash_internal(key) % Size; entries_[idx].Set(key, std::move(value)); return; } @@ -55,7 +55,7 @@ class SliceWeakHashTable : public RefCounted> { /// Returns the value from the table associated with / \a key or null if not /// found. const T* Get(const grpc_slice& key) const { - const size_t idx = grpc_slice_hash(key) % Size; + const size_t idx = grpc_slice_hash_internal(key) % Size; const auto& entry = entries_[idx]; return grpc_slice_eq(entry.key(), key) ? entry.value() : nullptr; } diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 19f61c548d6..44de0cd42dd 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -625,8 +625,8 @@ static void start_new_rpc(grpc_call_element* elem) { if (chand->registered_methods && calld->path_set && calld->host_set) { /* TODO(ctiller): unify these two searches */ /* check for an exact match with host */ - hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash(calld->host), - grpc_slice_hash(calld->path)); + hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_internal(calld->host), + grpc_slice_hash_internal(calld->path)); for (i = 0; i <= chand->registered_method_max_probes; i++) { rm = &chand->registered_methods[(hash + i) % chand->registered_method_slots]; @@ -644,7 +644,7 @@ static void start_new_rpc(grpc_call_element* elem) { return; } /* check for a wildcard method definition (no host set) */ - hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash(calld->path)); + hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash_internal(calld->path)); for (i = 0; i <= chand->registered_method_max_probes; i++) { rm = &chand->registered_methods[(hash + i) % chand->registered_method_slots]; @@ -1200,8 +1200,8 @@ void grpc_server_setup_transport( has_host = false; } method = grpc_slice_intern(grpc_slice_from_static_string(rm->method)); - hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash(host) : 0, - grpc_slice_hash(method)); + hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash_internal(host) : 0, + grpc_slice_hash_internal(method)); for (probes = 0; chand->registered_methods[(hash + probes) % slots] .server_registered_method != nullptr; probes++) diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 4609eb42cdc..2fdecc99d3e 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -43,6 +43,7 @@ using grpc_core::AllocatedMetadata; using grpc_core::InternedMetadata; +using grpc_core::StaticMetadata; using grpc_core::UserData; /* There are two kinds of mdelem and mdstr instances. @@ -100,6 +101,12 @@ void grpc_mdelem_trace_unref(void* md, const grpc_slice& key, #define TABLE_IDX(hash, capacity) (((hash) >> (LOG2_SHARD_COUNT)) % (capacity)) #define SHARD_IDX(hash) ((hash) & ((1 << (LOG2_SHARD_COUNT)) - 1)) +void StaticMetadata::HashInit() { + uint32_t k_hash = grpc_slice_hash_internal(kv_.key); + uint32_t v_hash = grpc_slice_hash_internal(kv_.value); + hash_ = GRPC_MDSTR_KV_HASH(k_hash, v_hash); +} + AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, const grpc_slice& value) : key_(grpc_slice_ref_internal(key)), @@ -133,8 +140,8 @@ InternedMetadata::InternedMetadata(const grpc_slice& key, InternedMetadata* next) : key_(grpc_slice_ref_internal(key)), value_(grpc_slice_ref_internal(value)), - refcnt_(1), hash_(hash), + refcnt_(1), link_(next) { #ifndef NDEBUG if (grpc_trace_metadata.enabled()) { @@ -223,11 +230,14 @@ void grpc_mdctx_global_shutdown() { } } +#ifndef NDEBUG static int is_mdelem_static(grpc_mdelem e) { - return GRPC_MDELEM_DATA(e) >= &grpc_static_mdelem_table[0] && - GRPC_MDELEM_DATA(e) < + return reinterpret_cast(GRPC_MDELEM_DATA(e)) >= + &grpc_static_mdelem_table[0] && + reinterpret_cast(GRPC_MDELEM_DATA(e)) < &grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; } +#endif void InternedMetadata::RefWithShardLocked(mdtab_shard* shard) { #ifndef NDEBUG @@ -323,8 +333,8 @@ grpc_mdelem grpc_mdelem_create( } } - uint32_t hash = - GRPC_MDSTR_KV_HASH(grpc_slice_hash(key), grpc_slice_hash(value)); + uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_refcounted(key), + grpc_slice_hash_refcounted(value)); InternedMetadata* md; mdtab_shard* shard = &g_shards[SHARD_IDX(hash)]; size_t idx; @@ -391,8 +401,11 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) { case GRPC_MDELEM_STORAGE_EXTERNAL: return nullptr; case GRPC_MDELEM_STORAGE_STATIC: - return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - - grpc_static_mdelem_table]; + return reinterpret_cast( + grpc_static_mdelem_user_data + [reinterpret_cast( + GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return get_user_data(am->user_data(), destroy_func); @@ -430,15 +443,18 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), return nullptr; case GRPC_MDELEM_STORAGE_STATIC: destroy_func(data); - return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - - grpc_static_mdelem_table]; + return reinterpret_cast( + grpc_static_mdelem_user_data + [reinterpret_cast( + GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return set_user_data(am->user_data(), destroy_func, data); } case GRPC_MDELEM_STORAGE_INTERNED: { auto* im = reinterpret_cast GRPC_MDELEM_DATA(md); - GPR_ASSERT(!is_mdelem_static(md)); + GPR_DEBUG_ASSERT(!is_mdelem_static(md)); return set_user_data(im->user_data(), destroy_func, data); } } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index f59476ccc21..74c69f97584 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -141,6 +141,16 @@ inline bool grpc_mdelem_static_value_eq(grpc_mdelem a, grpc_mdelem b_static) { if (a.payload == b_static.payload) return true; return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static)); } +#define GRPC_MDISNULL(md) (GRPC_MDELEM_DATA(md) == NULL) + +inline bool grpc_mdelem_both_interned_eq(grpc_mdelem a_interned, + grpc_mdelem b_interned) { + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(a_interned) || + GRPC_MDISNULL(a_interned)); + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(b_interned) || + GRPC_MDISNULL(b_interned)); + return a_interned.payload == b_interned.payload; +} /* Mutator and accessor for grpc_mdelem user data. The destructor function is used as a type tag and is checked during user_data fetch. */ @@ -169,6 +179,23 @@ struct UserData { grpc_core::Atomic data; }; +class StaticMetadata { + public: + StaticMetadata(const grpc_slice& key, const grpc_slice& value) + : kv_({key, value}), hash_(0) {} + + const grpc_mdelem_data& data() const { return kv_; } + + void HashInit(); + uint32_t hash() { return hash_; } + + private: + grpc_mdelem_data kv_; + + /* private only data */ + uint32_t hash_; +}; + class InternedMetadata { public: struct BucketLink { @@ -227,8 +254,8 @@ class InternedMetadata { grpc_slice value_; /* private only data */ - grpc_core::Atomic refcnt_; uint32_t hash_; + grpc_core::Atomic refcnt_; UserData user_data_; @@ -344,7 +371,6 @@ inline void grpc_mdelem_unref(grpc_mdelem gmd) { } #define GRPC_MDNULL GRPC_MAKE_MDELEM(NULL, GRPC_MDELEM_STORAGE_EXTERNAL) -#define GRPC_MDISNULL(md) (GRPC_MDELEM_DATA(md) == NULL) /* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ #define GRPC_MDELEM_LENGTH(e) \ diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index 61ee1d46f77..bbf1736b595 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -390,184 +390,270 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { uint32_t h = elems_phash(k); 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]], + ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL; } -grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { - {{&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}}, - {{&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}}, - {{&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}}, - {{&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}}, - {{&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}}, - {{&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}}, - {{&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}}, +grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, + {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, + {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, + {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, + {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 76, 77, 78, 79, 80, 81, 82}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index a3f23de0953..800ee04d6f9 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -269,266 +269,353 @@ extern grpc_slice_refcount ((static_slice).refcount - grpc_static_metadata_refcounts))) #define GRPC_STATIC_MDELEM_COUNT 86 -extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; +extern grpc_core::StaticMetadata + grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* ":authority": "" */ -#define GRPC_MDELEM_AUTHORITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[0], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORITY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[0].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "GET" */ -#define GRPC_MDELEM_METHOD_GET \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[1], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_GET \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[1].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "POST" */ -#define GRPC_MDELEM_METHOD_POST \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[2], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_POST \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[2].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":path": "/" */ -#define GRPC_MDELEM_PATH_SLASH \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[3], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[3].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":path": "/index.html" */ -#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[4], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[4].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "http" */ -#define GRPC_MDELEM_SCHEME_HTTP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[5], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[5].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "https" */ -#define GRPC_MDELEM_SCHEME_HTTPS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[6], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTPS \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[6].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "200" */ -#define GRPC_MDELEM_STATUS_200 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[7], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_200 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[7].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "204" */ -#define GRPC_MDELEM_STATUS_204 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[8], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_204 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[8].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "206" */ -#define GRPC_MDELEM_STATUS_206 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[9], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_206 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[9].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "304" */ -#define GRPC_MDELEM_STATUS_304 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[10], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_304 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[10].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "400" */ -#define GRPC_MDELEM_STATUS_400 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[11], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_400 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[11].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "404" */ -#define GRPC_MDELEM_STATUS_404 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[12], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_404 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[12].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "500" */ -#define GRPC_MDELEM_STATUS_500 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[13], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_500 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[13].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-charset": "" */ -#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[14], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[14].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "gzip, deflate" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[15], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[15].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-language": "" */ -#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[16], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[16].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-ranges": "" */ -#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[17], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[17].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept": "" */ -#define GRPC_MDELEM_ACCEPT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[18], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[18].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "access-control-allow-origin": "" */ -#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[19], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[19].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "age": "" */ -#define GRPC_MDELEM_AGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[20], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[20].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "allow": "" */ -#define GRPC_MDELEM_ALLOW_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[21], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ALLOW_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[21].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "authorization": "" */ -#define GRPC_MDELEM_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[22], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORIZATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[22].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "cache-control": "" */ -#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[23], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[23].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-disposition": "" */ -#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[24], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[24].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "" */ -#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[25], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[25].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-language": "" */ -#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[26], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[26].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-length": "" */ -#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[27], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[27].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-location": "" */ -#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[28], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[28].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-range": "" */ -#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[29], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[29].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-type": "" */ -#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[30], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[30].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "cookie": "" */ -#define GRPC_MDELEM_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[31], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_COOKIE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[31].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "date": "" */ -#define GRPC_MDELEM_DATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[32], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_DATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[32].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "etag": "" */ -#define GRPC_MDELEM_ETAG_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[33], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ETAG_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[33].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "expect": "" */ -#define GRPC_MDELEM_EXPECT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[34], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPECT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[34].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "expires": "" */ -#define GRPC_MDELEM_EXPIRES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[35], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPIRES_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[35].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "from": "" */ -#define GRPC_MDELEM_FROM_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[36], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_FROM_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[36].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "host": "" */ -#define GRPC_MDELEM_HOST_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[37], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_HOST_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[37].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-match": "" */ -#define GRPC_MDELEM_IF_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[38], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MATCH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[38].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-modified-since": "" */ -#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[39], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[39].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-none-match": "" */ -#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[40], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[40].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-range": "" */ -#define GRPC_MDELEM_IF_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[41], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[41].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-unmodified-since": "" */ -#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[42], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[42].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "last-modified": "" */ -#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[43], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[43].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "link": "" */ -#define GRPC_MDELEM_LINK_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[44], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LINK_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[44].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "location": "" */ -#define GRPC_MDELEM_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[45], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LOCATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[45].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "max-forwards": "" */ -#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[46], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[46].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authenticate": "" */ -#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[47], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[47].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authorization": "" */ -#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[48], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[48].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "range": "" */ -#define GRPC_MDELEM_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[49], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[49].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "referer": "" */ -#define GRPC_MDELEM_REFERER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[50], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFERER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[50].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "refresh": "" */ -#define GRPC_MDELEM_REFRESH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[51], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFRESH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[51].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "retry-after": "" */ -#define GRPC_MDELEM_RETRY_AFTER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[52], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RETRY_AFTER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[52].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "server": "" */ -#define GRPC_MDELEM_SERVER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[53], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SERVER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[53].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "set-cookie": "" */ -#define GRPC_MDELEM_SET_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[54], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SET_COOKIE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[54].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "strict-transport-security": "" */ -#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "transfer-encoding": "" */ -#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "user-agent": "" */ -#define GRPC_MDELEM_USER_AGENT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_USER_AGENT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "vary": "" */ -#define GRPC_MDELEM_VARY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VARY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "via": "" */ -#define GRPC_MDELEM_VIA_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VIA_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "www-authenticate": "" */ -#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "0" */ -#define GRPC_MDELEM_GRPC_STATUS_0 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_0 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "1" */ -#define GRPC_MDELEM_GRPC_STATUS_1 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_1 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "2" */ -#define GRPC_MDELEM_GRPC_STATUS_2 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_2 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "te": "trailers" */ -#define GRPC_MDELEM_TE_TRAILERS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TE_TRAILERS \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-type": "application/grpc" */ -#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "grpc" */ -#define GRPC_MDELEM_SCHEME_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_GRPC \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "PUT" */ -#define GRPC_MDELEM_METHOD_PUT \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_PUT \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "identity" */ -#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "gzip" */ -#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "lb-token": "" */ -#define GRPC_MDELEM_LB_TOKEN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_TOKEN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "lb-cost-bin": "" */ -#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[81], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[81].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[82], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[82].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "identity" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[83], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[83].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[84], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[84].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "identity,gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { @@ -597,14 +684,16 @@ typedef union { : GRPC_BATCH_CALLOUTS_COUNT) 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_static_accept_encoding_metadata[(algs)]], \ +#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)) 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_static_accept_stream_encoding_metadata[(algs)]], \ + [grpc_static_accept_stream_encoding_metadata[(algs)]] \ + .data(), \ GRPC_MDELEM_STORAGE_STATIC)) #endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index d66fdc3e835..b534d8dab7e 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -447,14 +447,15 @@ for i, elem in enumerate(all_elems): [len(elem[1])] + [ord(c) for c in elem[1]])) print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) -print >> H, ('extern grpc_mdelem_data ' +print >> H, ('extern grpc_core::StaticMetadata ' 'grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];') print >> H, ('extern uintptr_t ' 'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];') for i, elem in enumerate(all_elems): print >> H, '/* "%s": "%s" */' % elem - print >> H, ('#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], ' - 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i) + print >> H, ( + '#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d].data(), ' + 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i) print >> H print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] ' @@ -544,13 +545,14 @@ print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intpt print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' print >> C, ' uint32_t k = static_cast(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]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' +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 >> C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' +print >> C, 'grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' for a, b in all_elems: - print >> C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b))) + print >> C, 'grpc_core::StaticMetadata(%s,%s),' % (slice_def(str_idx(a)), + slice_def(str_idx(b))) print >> C, '};' print >> H, 'typedef enum {' @@ -579,7 +581,7 @@ 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)]], GRPC_MDELEM_STORAGE_STATIC))' +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];' % ( @@ -590,7 +592,7 @@ 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)]], GRPC_MDELEM_STORAGE_STATIC))' +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 */'