Skip to content

Commit c225da7

Browse files
Auto-generate files after cl/760024649
1 parent 1288606 commit c225da7

File tree

4 files changed

+182
-134
lines changed

4 files changed

+182
-134
lines changed

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

Lines changed: 90 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7591,20 +7591,6 @@ const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
75917591
return ptr;
75927592
}
75937593

7594-
UPB_FORCEINLINE
7595-
bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
7596-
upb_Message* msg, const upb_MiniTable* m) {
7597-
#if UPB_FASTTABLE
7598-
if (m && m->UPB_PRIVATE(table_mask) != (unsigned char)-1) {
7599-
uint16_t tag = _upb_FastDecoder_LoadTag(*ptr);
7600-
intptr_t table = decode_totable(m);
7601-
*ptr = _upb_FastDecoder_TagDispatch(d, *ptr, msg, table, 0, tag);
7602-
return true;
7603-
}
7604-
#endif
7605-
return false;
7606-
}
7607-
76087594
static const char* upb_Decoder_SkipField(upb_Decoder* d, const char* ptr,
76097595
uint32_t tag) {
76107596
int field_number = tag >> 3;
@@ -8087,79 +8073,115 @@ static const char* _upb_Decoder_DecodeUnknownField(upb_Decoder* d,
80878073
return ptr;
80888074
}
80898075

8090-
UPB_NOINLINE
8091-
const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
8092-
upb_Message* msg,
8093-
const upb_MiniTable* layout) {
8094-
#if UPB_FASTTABLE
8095-
// The first time we want to skip fast dispatch, because we may have just been
8096-
// invoked by the fast parser to handle a case that it bailed on.
8097-
if (!_upb_Decoder_IsDone(d, &ptr)) goto nofast;
8076+
UPB_FORCEINLINE
8077+
const char* _upb_Decoder_DecodeFieldTag(upb_Decoder* d, const char* ptr,
8078+
int* field_number, int* wire_type) {
8079+
#ifndef NDEBUG
8080+
d->debug_tagstart = ptr;
80988081
#endif
80998082

8100-
while (!_upb_Decoder_IsDone(d, &ptr)) {
8101-
uint32_t tag;
8102-
const upb_MiniTableField* field;
8103-
int field_number;
8104-
int wire_type;
8105-
wireval val;
8106-
int op;
8107-
8108-
if (_upb_Decoder_TryFastDispatch(d, &ptr, msg, layout)) break;
8109-
8110-
#if UPB_FASTTABLE
8111-
nofast:
8112-
#endif
8083+
uint32_t tag;
8084+
UPB_ASSERT(ptr < d->input.limit_ptr);
8085+
ptr = _upb_Decoder_DecodeTag(d, ptr, &tag);
8086+
*field_number = tag >> 3;
8087+
*wire_type = tag & 7;
8088+
return ptr;
8089+
}
81138090

8091+
UPB_FORCEINLINE
8092+
const char* _upb_Decoder_DecodeFieldData(upb_Decoder* d, const char* ptr,
8093+
upb_Message* msg,
8094+
const upb_MiniTable* mt,
8095+
int field_number, int wire_type) {
81148096
#ifndef NDEBUG
8115-
d->debug_tagstart = ptr;
8097+
d->debug_valstart = ptr;
81168098
#endif
81178099

8118-
UPB_ASSERT(ptr < d->input.limit_ptr);
8119-
ptr = _upb_Decoder_DecodeTag(d, ptr, &tag);
8120-
field_number = tag >> 3;
8121-
wire_type = tag & 7;
8100+
int op;
8101+
wireval val;
81228102

8123-
#ifndef NDEBUG
8124-
d->debug_valstart = ptr;
8125-
#endif
8103+
const upb_MiniTableField* field =
8104+
_upb_Decoder_FindField(d, mt, field_number, wire_type);
8105+
ptr = _upb_Decoder_DecodeWireValue(d, ptr, mt, field, wire_type, &val, &op);
81268106

8127-
if (wire_type == kUpb_WireType_EndGroup) {
8128-
d->end_group = field_number;
8129-
return ptr;
8107+
if (op >= 0) {
8108+
return _upb_Decoder_DecodeKnownField(d, ptr, msg, mt, field, op, &val);
8109+
} else {
8110+
switch (op) {
8111+
case kUpb_DecodeOp_UnknownField:
8112+
return _upb_Decoder_DecodeUnknownField(d, ptr, msg, field_number,
8113+
wire_type, val);
8114+
case kUpb_DecodeOp_MessageSetItem:
8115+
return upb_Decoder_DecodeMessageSetItem(d, ptr, msg, mt);
8116+
default:
8117+
UPB_UNREACHABLE();
81308118
}
8119+
}
8120+
}
81318121

8132-
field = _upb_Decoder_FindField(d, layout, field_number, wire_type);
8133-
ptr = _upb_Decoder_DecodeWireValue(d, ptr, layout, field, wire_type, &val,
8134-
&op);
8122+
static const char* _upb_Decoder_EndMessage(upb_Decoder* d, const char* ptr) {
8123+
d->message_is_done = true;
8124+
return ptr;
8125+
}
81358126

8136-
if (op >= 0) {
8137-
ptr = _upb_Decoder_DecodeKnownField(d, ptr, msg, layout, field, op, &val);
8138-
} else {
8139-
switch (op) {
8140-
case kUpb_DecodeOp_UnknownField:
8141-
ptr = _upb_Decoder_DecodeUnknownField(d, ptr, msg, field_number,
8142-
wire_type, val);
8143-
break;
8144-
case kUpb_DecodeOp_MessageSetItem:
8145-
ptr = upb_Decoder_DecodeMessageSetItem(d, ptr, msg, layout);
8146-
break;
8147-
}
8148-
}
8127+
UPB_FORCEINLINE
8128+
const char* _upb_Decoder_DecodeFieldNoFast(upb_Decoder* d, const char* ptr,
8129+
upb_Message* msg,
8130+
const upb_MiniTable* mt) {
8131+
int field_number;
8132+
int wire_type;
8133+
8134+
ptr = _upb_Decoder_DecodeFieldTag(d, ptr, &field_number, &wire_type);
8135+
8136+
if (wire_type == kUpb_WireType_EndGroup) {
8137+
d->end_group = field_number;
8138+
return _upb_Decoder_EndMessage(d, ptr);
8139+
}
8140+
8141+
return _upb_Decoder_DecodeFieldData(d, ptr, msg, mt, field_number, wire_type);
8142+
}
8143+
8144+
UPB_FORCEINLINE
8145+
const char* _upb_Decoder_DecodeField(upb_Decoder* d, const char* ptr,
8146+
upb_Message* msg, const upb_MiniTable* mt,
8147+
uint64_t last_field_index, uint64_t data) {
8148+
if (_upb_Decoder_IsDone(d, &ptr)) {
8149+
return _upb_Decoder_EndMessage(d, ptr);
8150+
}
8151+
8152+
#if UPB_FASTTABLE
8153+
if (mt && mt->UPB_PRIVATE(table_mask) != (unsigned char)-1) {
8154+
uint16_t tag = _upb_FastDecoder_LoadTag(ptr);
8155+
intptr_t table = decode_totable(mt);
8156+
ptr = _upb_FastDecoder_TagDispatch(d, ptr, msg, table, 0, tag);
8157+
if (d->message_is_done) return ptr;
81498158
}
8159+
#endif
8160+
8161+
return _upb_Decoder_DecodeFieldNoFast(d, ptr, msg, mt);
8162+
}
8163+
8164+
UPB_NOINLINE
8165+
const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
8166+
upb_Message* msg,
8167+
const upb_MiniTable* mt) {
8168+
UPB_ASSERT(d->message_is_done == false);
8169+
8170+
do {
8171+
ptr = _upb_Decoder_DecodeField(d, ptr, msg, mt, 0, 0);
8172+
} while (!d->message_is_done);
8173+
d->message_is_done = false;
81508174

8151-
return UPB_UNLIKELY(layout && layout->UPB_PRIVATE(required_count))
8152-
? _upb_Decoder_CheckRequired(d, ptr, msg, layout)
8175+
return UPB_UNLIKELY(mt && mt->UPB_PRIVATE(required_count))
8176+
? _upb_Decoder_CheckRequired(d, ptr, msg, mt)
81538177
: ptr;
81548178
}
81558179

81568180
static upb_DecodeStatus _upb_Decoder_DecodeTop(struct upb_Decoder* d,
81578181
const char* buf,
81588182
upb_Message* msg,
81598183
const upb_MiniTable* m) {
8160-
if (!_upb_Decoder_TryFastDispatch(d, &buf, msg, m)) {
8161-
_upb_Decoder_DecodeMessage(d, buf, msg, m);
8162-
}
8184+
_upb_Decoder_DecodeMessage(d, buf, msg, m);
81638185
if (d->end_group != DECODE_NOGROUP) return kUpb_DecodeStatus_Malformed;
81648186
if (d->missing_required) return kUpb_DecodeStatus_MissingRequired;
81658187
return kUpb_DecodeStatus_Ok;
@@ -8209,6 +8231,7 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
82098231
decoder.options = (uint16_t)options;
82108232
decoder.missing_required = false;
82118233
decoder.status = kUpb_DecodeStatus_Ok;
8234+
decoder.message_is_done = false;
82128235

82138236
// Violating the encapsulation of the arena for performance reasons.
82148237
// This is a temporary arena that we swap into and swap out of when we are

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15471,6 +15471,7 @@ typedef struct upb_Decoder {
1547115471
uint32_t end_group; // field number of END_GROUP tag, else DECODE_NOGROUP.
1547215472
uint16_t options;
1547315473
bool missing_required;
15474+
bool message_is_done;
1547415475
union {
1547515476
upb_Arena arena;
1547615477
void* foo[UPB_ARENA_SIZE_HACK];

0 commit comments

Comments
 (0)