Internal change.

PiperOrigin-RevId: 546314630
pull/13241/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent d603b4199e
commit 3a3df3057b
  1. 5
      src/google/protobuf/compiler/cpp/helpers.cc
  2. 3
      src/google/protobuf/compiler/cpp/helpers.h
  3. 1
      src/google/protobuf/compiler/cpp/parse_function_generator.cc
  4. 1
      src/google/protobuf/generated_message_reflection.cc
  5. 12
      src/google/protobuf/generated_message_tctable_gen.cc
  6. 2
      src/google/protobuf/generated_message_tctable_gen.h

@ -896,6 +896,11 @@ bool IsRarelyPresent(const FieldDescriptor* field, const Options& options) {
return false; return false;
} }
float GetPresenceProbability(const FieldDescriptor* field,
const Options& options) {
return 1.f;
}
bool IsStringInlined(const FieldDescriptor* field, const Options& options) { bool IsStringInlined(const FieldDescriptor* field, const Options& options) {
(void)field; (void)field;
(void)options; (void)options;

@ -367,6 +367,9 @@ bool IsProfileDriven(const Options& options);
// Returns true if `field` is unlikely to be present based on PDProto profile. // Returns true if `field` is unlikely to be present based on PDProto profile.
bool IsRarelyPresent(const FieldDescriptor* field, const Options& options); bool IsRarelyPresent(const FieldDescriptor* field, const Options& options);
float GetPresenceProbability(const FieldDescriptor* field,
const Options& options);
// Returns true if `field` should be inlined based on PDProto profile. // Returns true if `field` should be inlined based on PDProto profile.
bool IsStringInlined(const FieldDescriptor* field, const Options& options); bool IsStringInlined(const FieldDescriptor* field, const Options& options);

@ -114,6 +114,7 @@ class ParseFunctionGenerator::GeneratedOptionProvider final
return internal::field_layout::TransformValidation{}; return internal::field_layout::TransformValidation{};
}; };
return { return {
GetPresenceProbability(field, gen_->options_),
verify_flag(), verify_flag(),
IsStringInlined(field, gen_->options_), IsStringInlined(field, gen_->options_),
IsImplicitWeakField(field, gen_->options_, gen_->scc_analyzer_), IsImplicitWeakField(field, gen_->options_, gen_->scc_analyzer_),

@ -3391,6 +3391,7 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const {
return internal::field_layout::TransformValidation{}; return internal::field_layout::TransformValidation{};
}; };
return { return {
1.f, // All fields are assumed present.
verify_flag(), // verify_flag(), //
ref_.IsInlined(field), // ref_.IsInlined(field), //

@ -391,12 +391,18 @@ std::vector<TailCallTableInfo::FastFieldInfo> SplitFastFieldsForSize(
TailCallTableInfo::FastFieldInfo& info = result[fast_idx]; TailCallTableInfo::FastFieldInfo& info = result[fast_idx];
if (!info.func_name.empty()) { if (!info.func_name.empty()) {
// This field entry is already filled. // Null field means END_GROUP which is guaranteed to be present.
continue; if (info.field == nullptr) continue;
// This field entry is already filled. Skip if previous entry is more
// likely present.
const auto prev_options = option_provider.GetForField(info.field);
if (prev_options.presence_probability >= options.presence_probability) {
continue;
}
} }
// Fill in this field's entry: // Fill in this field's entry:
ABSL_CHECK(info.func_name.empty()) << info.func_name;
PopulateFastFieldEntry(entry, options, info); PopulateFastFieldEntry(entry, options, info);
info.field = field; info.field = field;
info.coded_tag = tag; info.coded_tag = tag;

@ -57,6 +57,8 @@ enum TransformValidation : uint16_t;
// Helper class for generating tailcall parsing functions. // Helper class for generating tailcall parsing functions.
struct PROTOBUF_EXPORT TailCallTableInfo { struct PROTOBUF_EXPORT TailCallTableInfo {
struct PerFieldOptions { struct PerFieldOptions {
// For presence awareness (e.g. PDProto).
float presence_probability;
// kTvEager, kTvLazy, or 0 // kTvEager, kTvLazy, or 0
field_layout::TransformValidation lazy_opt; field_layout::TransformValidation lazy_opt;
bool is_string_inlined; bool is_string_inlined;

Loading…
Cancel
Save