Skip to content

Commit f331eba

Browse files
Auto-generate files after cl/908760363
1 parent 36e53a1 commit f331eba

4 files changed

Lines changed: 70 additions & 42 deletions

File tree

‎php/ext/google/protobuf/php-upb.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8925,6 +8925,7 @@ UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(upb_Message* msg,
89258925
size_t len,
89268926
upb_Arena* arena,
89278927
bool alias) {
8928+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
89288929
{
89298930
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
89308931
// Alias fast path was already checked in the inline function that calls

‎php/ext/google/protobuf/php-upb.h‎

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,6 +3958,36 @@ typedef enum {
39583958
kUpb_AddUnknown_AliasAllowMerge = 2,
39593959
} upb_AddUnknownMode;
39603960

3961+
UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(
3962+
_upb_Message_TryAddUnknownAliasAllowMerge)(struct upb_Message* msg,
3963+
const char* data, size_t len,
3964+
upb_Arena* arena,
3965+
upb_AddUnknownMode mode) {
3966+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
3967+
UPB_ASSERT(mode == kUpb_AddUnknown_AliasAllowMerge);
3968+
// Aliasing parse of a message with sequential unknown fields is a simple
3969+
// pointer bump, so inline it.
3970+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
3971+
if (in && in->size) {
3972+
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
3973+
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
3974+
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
3975+
// Fast path if the field we're adding is immediately after the last
3976+
// added unknown field.
3977+
//
3978+
// The caller has guaranteed to us, by passing
3979+
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
3980+
// regions of memory are from different objects that are contiguous in
3981+
// memory by coincidence.
3982+
if (existing->data + existing->size == data) {
3983+
existing->size += len;
3984+
return true;
3985+
}
3986+
}
3987+
}
3988+
return false;
3989+
}
3990+
39613991
// Adds unknown data (serialized protobuf data) to the given message. The data
39623992
// must represent one or more complete and well formed proto fields.
39633993
//
@@ -3972,27 +4002,10 @@ UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(
39724002
struct upb_Message* msg, const char* data, size_t len, upb_Arena* arena,
39734003
upb_AddUnknownMode mode) {
39744004
UPB_ASSERT(!upb_Message_IsFrozen(msg));
3975-
if (mode == kUpb_AddUnknown_AliasAllowMerge) {
3976-
// Aliasing parse of a message with sequential unknown fields is a simple
3977-
// pointer bump, so inline it.
3978-
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
3979-
if (in && in->size) {
3980-
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
3981-
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
3982-
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
3983-
// Fast path if the field we're adding is immediately after the last
3984-
// added unknown field.
3985-
//
3986-
// The caller has guaranteed to us, by passing
3987-
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
3988-
// regions of memory are from different objects that are contiguous in
3989-
// memory by coincidence.
3990-
if (existing->data + existing->size == data) {
3991-
existing->size += len;
3992-
return true;
3993-
}
3994-
}
3995-
}
4005+
if (mode == kUpb_AddUnknown_AliasAllowMerge &&
4006+
UPB_PRIVATE(_upb_Message_TryAddUnknownAliasAllowMerge)(msg, data, len,
4007+
arena, mode)) {
4008+
return true;
39964009
}
39974010
return UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
39984011
msg, data, len, arena, mode != kUpb_AddUnknown_Copy);

‎ruby/ext/google/protobuf_c/ruby-upb.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7744,6 +7744,7 @@ UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(upb_Message* msg,
77447744
size_t len,
77457745
upb_Arena* arena,
77467746
bool alias) {
7747+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
77477748
{
77487749
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
77497750
// Alias fast path was already checked in the inline function that calls

‎ruby/ext/google/protobuf_c/ruby-upb.h‎

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,6 +3958,36 @@ typedef enum {
39583958
kUpb_AddUnknown_AliasAllowMerge = 2,
39593959
} upb_AddUnknownMode;
39603960

3961+
UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(
3962+
_upb_Message_TryAddUnknownAliasAllowMerge)(struct upb_Message* msg,
3963+
const char* data, size_t len,
3964+
upb_Arena* arena,
3965+
upb_AddUnknownMode mode) {
3966+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
3967+
UPB_ASSERT(mode == kUpb_AddUnknown_AliasAllowMerge);
3968+
// Aliasing parse of a message with sequential unknown fields is a simple
3969+
// pointer bump, so inline it.
3970+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
3971+
if (in && in->size) {
3972+
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
3973+
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
3974+
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
3975+
// Fast path if the field we're adding is immediately after the last
3976+
// added unknown field.
3977+
//
3978+
// The caller has guaranteed to us, by passing
3979+
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
3980+
// regions of memory are from different objects that are contiguous in
3981+
// memory by coincidence.
3982+
if (existing->data + existing->size == data) {
3983+
existing->size += len;
3984+
return true;
3985+
}
3986+
}
3987+
}
3988+
return false;
3989+
}
3990+
39613991
// Adds unknown data (serialized protobuf data) to the given message. The data
39623992
// must represent one or more complete and well formed proto fields.
39633993
//
@@ -3972,27 +4002,10 @@ UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(
39724002
struct upb_Message* msg, const char* data, size_t len, upb_Arena* arena,
39734003
upb_AddUnknownMode mode) {
39744004
UPB_ASSERT(!upb_Message_IsFrozen(msg));
3975-
if (mode == kUpb_AddUnknown_AliasAllowMerge) {
3976-
// Aliasing parse of a message with sequential unknown fields is a simple
3977-
// pointer bump, so inline it.
3978-
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
3979-
if (in && in->size) {
3980-
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
3981-
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
3982-
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
3983-
// Fast path if the field we're adding is immediately after the last
3984-
// added unknown field.
3985-
//
3986-
// The caller has guaranteed to us, by passing
3987-
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
3988-
// regions of memory are from different objects that are contiguous in
3989-
// memory by coincidence.
3990-
if (existing->data + existing->size == data) {
3991-
existing->size += len;
3992-
return true;
3993-
}
3994-
}
3995-
}
4005+
if (mode == kUpb_AddUnknown_AliasAllowMerge &&
4006+
UPB_PRIVATE(_upb_Message_TryAddUnknownAliasAllowMerge)(msg, data, len,
4007+
arena, mode)) {
4008+
return true;
39964009
}
39974010
return UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
39984011
msg, data, len, arena, mode != kUpb_AddUnknown_Copy);

0 commit comments

Comments
 (0)