Internal change.

PiperOrigin-RevId: 580990149
pull/14711/head
Cong Liu 1 year ago committed by Copybara-Service
parent 1c8ee7c44e
commit 1511b7dc1e
  1. 14
      src/google/protobuf/generated_message_reflection.cc
  2. 29
      src/google/protobuf/generated_message_tctable_lite_test.cc

@ -3222,7 +3222,12 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTableReflectionOnly()
// `operator delete` unconditionally.
void* p = ::operator new(sizeof(Table));
auto* full_table = ::new (p)
Table{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, schema_.default_instance_, nullptr},
Table{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, schema_.default_instance_, nullptr
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
,
nullptr
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{{{&internal::TcParser::ReflectionParseLoop, {}}}}};
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
// We'll prefetch `to_prefetch->to_prefetch` unconditionally to avoid
@ -3459,7 +3464,12 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const {
static_cast<uint16_t>(table_info.aux_entries.size()),
aux_offset,
schema_.default_instance_,
&internal::TcParser::ReflectionFallback};
&internal::TcParser::ReflectionFallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
,
nullptr
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
};
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
// We'll prefetch `to_prefetch->to_prefetch` unconditionally to avoid
// branches. Here we don't know which field is the hottest, so set the pointer

@ -14,6 +14,11 @@
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/wire_format_lite.h"
// clang-format off
#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
namespace protobuf {
namespace internal {
@ -83,6 +88,9 @@ TEST(FastVarints, NameHere) {
offsetof(decltype(parse_table), field_names), // no aux_entries
nullptr, // default instance
FastParserGaveUp, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
// Fast Table:
{{
@ -274,6 +282,9 @@ TEST(IsEntryForFieldNumTest, Matcher) {
0, 0, // num_aux_entries, aux_offset,
nullptr, // default instance
nullptr, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}};
// clang-format on
int table_field_numbers[] = {1, 2, 3};
@ -342,6 +353,9 @@ TEST_F(FindFieldEntryTest, SequentialFieldRange) {
0, 0, // num_aux_entries, aux_offset,
nullptr, // default instance
{}, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{}, // fast_entries
// field_lookup_table for 2, 3, 4, 5, 111:
@ -382,6 +396,9 @@ TEST_F(FindFieldEntryTest, SmallScanRange) {
0, 0, // num_aux_entries, aux_offset,
nullptr, // default instance
{}, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{}, // fast_entries
// field_lookup_table for 1, 3, 4, 5, 7, 111:
@ -430,6 +447,9 @@ TEST_F(FindFieldEntryTest, BinarySearchRange) {
0, 0, // num_aux_entries, aux_offset,
nullptr, // default instance
{}, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{}, // fast_entries
// field_lookup_table for 1, 3, 4, 5, 6, 8, 9, 11, 12, 70
@ -475,6 +495,9 @@ TEST_F(FindFieldEntryTest, OutOfRange) {
offsetof(decltype(table), field_names), // no aux_entries
nullptr, // default instance
{}, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{}, // fast_entries
{{// field lookup table
@ -525,6 +548,9 @@ TEST_F(FindFieldEntryTest, EmptyMessage) {
offsetof(TableType, field_names),
nullptr, // default instance
nullptr, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{}, // fast_entries
{{// empty field lookup table
@ -575,6 +601,9 @@ const TcParseTable<5, 134, 5, 2176, 55> test_all_types_table = {
offsetof(decltype(test_all_types_table), aux_entries),
nullptr, // default instance
nullptr, // fallback function
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
nullptr, // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
},
{{
// tail-call table

Loading…
Cancel
Save