generated_message_tctable_decl.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // This file contains declarations needed in generated headers for messages
32 // that use tail-call table parsing. Everything in this file is for internal
33 // use only.
34 
35 #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
36 #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
37 
38 #include <cstdint>
39 #include <type_traits>
40 
41 #include <google/protobuf/parse_context.h>
42 #include <google/protobuf/message_lite.h>
43 
44 // Must come last:
45 #include <google/protobuf/port_def.inc>
46 
47 namespace google {
48 namespace protobuf {
49 namespace internal {
50 
51 // Additional information about this field:
52 struct TcFieldData {
53  constexpr TcFieldData() : data(0) {}
55  : data(static_cast<uint64_t>(offset) << 48 |
56  static_cast<uint64_t>(hasbit_idx) << 16 | coded_tag) {}
57 
58  template <typename TagType = uint16_t>
59  TagType coded_tag() const {
60  return static_cast<TagType>(data);
61  }
62  uint8_t hasbit_idx() const { return static_cast<uint8_t>(data >> 16); }
63  uint16_t offset() const { return static_cast<uint16_t>(data >> 48); }
64 
66 };
67 
68 struct TcParseTableBase;
69 
70 // TailCallParseFunc is the function pointer type used in the tailcall table.
71 typedef const char* (*TailCallParseFunc)(PROTOBUF_TC_PARAM_DECL);
72 
73 #if defined(_MSC_VER) && !defined(_WIN64)
74 #pragma warning(push)
75 // TcParseTableBase is intentionally overaligned on 32 bit targets.
76 #pragma warning(disable : 4324)
77 #endif
78 
79 // Base class for message-level table with info for the tail-call parser.
80 struct alignas(uint64_t) TcParseTableBase {
81  // Common attributes for message layout:
90 
91  // Handler for fields which are not handled by table dispatch.
93 
94  // Table entry for fast-path tailcall dispatch handling.
95  struct FastFieldEntry {
96  // Target function for dispatch:
98  // Field data used during parse:
100  };
101  // There is always at least one table entry.
102  const FastFieldEntry* fast_entry(size_t idx) const {
103  return reinterpret_cast<const FastFieldEntry*>(this + 1) + idx;
104  }
105 };
106 
107 #if defined(_MSC_VER) && !defined(_WIN64)
108 #pragma warning(pop)
109 #endif
110 
111 static_assert(sizeof(TcParseTableBase::FastFieldEntry) <= 16,
112  "Field entry is too big.");
113 
114 template <size_t kFastTableSizeLog2>
115 struct TcParseTable {
117 
118  // Entries for each field.
119  //
120  // Fields are indexed by the lowest bits of their field number. The field
121  // number is masked to fit inside the table. Note that the parsing logic
122  // generally calls `TailCallParseTableBase::table()` instead of accessing
123  // this field directly.
124  TcParseTableBase::FastFieldEntry entries[(1 << kFastTableSizeLog2)];
125 };
126 
127 static_assert(std::is_standard_layout<TcParseTable<1>>::value,
128  "TcParseTable must be standard layout.");
129 
130 static_assert(offsetof(TcParseTable<1>, entries) == sizeof(TcParseTableBase),
131  "Table entries must be laid out after TcParseTableBase.");
132 
133 } // namespace internal
134 } // namespace protobuf
135 } // namespace google
136 
137 #include <google/protobuf/port_undef.inc>
138 
139 #endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
google::protobuf.internal::TcParseTableBase::fallback
TailCallParseFunc fallback
Definition: generated_message_tctable_decl.h:92
google::protobuf.internal::TailCallParseFunc
const typedef char *(* TailCallParseFunc)(PROTOBUF_TC_PARAM_DECL)
Definition: generated_message_tctable_decl.h:71
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf.internal::TcParseTableBase::fast_entry
const FastFieldEntry * fast_entry(size_t idx) const
Definition: generated_message_tctable_decl.h:102
google::protobuf.internal::TcParseTableBase::has_bits_offset
uint16_t has_bits_offset
Definition: generated_message_tctable_decl.h:82
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf.internal::TcFieldData
Definition: generated_message_tctable_decl.h:52
google::protobuf.internal::TcParseTable
Definition: generated_message_tctable_decl.h:115
google::protobuf.internal::TcParseTableBase::extension_range_high
uint32_t extension_range_high
Definition: generated_message_tctable_decl.h:85
google::protobuf::MessageLite
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:184
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf.internal::TcParseTableBase
Definition: generated_message_tctable_decl.h:80
google::protobuf.internal::TcFieldData::data
uint64_t data
Definition: generated_message_tctable_decl.h:65
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf.internal::TcParseTableBase::reserved
uint8_t reserved
Definition: generated_message_tctable_decl.h:87
google::protobuf.internal::TcParseTableBase::default_instance
const MessageLite * default_instance
Definition: generated_message_tctable_decl.h:89
google::protobuf.internal::TcFieldData::TcFieldData
constexpr TcFieldData()
Definition: generated_message_tctable_decl.h:53
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf.internal::TcParseTableBase::num_fields
uint16_t num_fields
Definition: generated_message_tctable_decl.h:88
google::protobuf.internal::TcParseTableBase::extension_range_low
uint32_t extension_range_low
Definition: generated_message_tctable_decl.h:84
google::protobuf.internal::TcParseTableBase::FastFieldEntry
Definition: generated_message_tctable_decl.h:95
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
google::protobuf.internal::TcFieldData::coded_tag
TagType coded_tag() const
Definition: generated_message_tctable_decl.h:59
google::protobuf.internal::TcFieldData::hasbit_idx
uint8_t hasbit_idx() const
Definition: generated_message_tctable_decl.h:62
google::protobuf.internal::TcParseTableBase::FastFieldEntry::bits
TcFieldData bits
Definition: generated_message_tctable_decl.h:99
google::protobuf.internal::TcParseTable::header
TcParseTableBase header
Definition: generated_message_tctable_decl.h:116
google::protobuf.internal::TcFieldData::offset
uint16_t offset() const
Definition: generated_message_tctable_decl.h:63
google::protobuf.internal::TcParseTableBase::fast_idx_mask
uint8_t fast_idx_mask
Definition: generated_message_tctable_decl.h:86
google::protobuf.internal::TcParseTableBase::FastFieldEntry::target
TailCallParseFunc target
Definition: generated_message_tctable_decl.h:97
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::TcParseTableBase::extension_offset
uint16_t extension_offset
Definition: generated_message_tctable_decl.h:83
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf.internal::TcFieldData::TcFieldData
constexpr TcFieldData(uint16_t coded_tag, uint8_t hasbit_idx, uint16_t offset)
Definition: generated_message_tctable_decl.h:54
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:24