google-protobuf 4.35.1 → 4.36.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +4 -4
- data/ext/google/protobuf_c/convert.h +3 -3
- data/ext/google/protobuf_c/map.h +5 -5
- data/ext/google/protobuf_c/message.c +9 -3
- data/ext/google/protobuf_c/protobuf.c +38 -38
- data/ext/google/protobuf_c/repeated_field.c +13 -6
- data/ext/google/protobuf_c/ruby-upb.c +1707 -1231
- data/ext/google/protobuf_c/ruby-upb.h +1868 -853
- data/lib/google/protobuf/descriptor_pb.rb +3 -1
- data/lib/google/protobuf/ffi/message.rb +6 -4
- data/lib/google/protobuf/ffi/repeated_field.rb +3 -3
- metadata +6 -6
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
#define UPB_HAS_ATTRIBUTE(x) 0
|
|
48
48
|
#endif
|
|
49
49
|
|
|
50
|
+
#ifdef __has_c_attribute
|
|
51
|
+
#define UPB_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
|
|
52
|
+
#else
|
|
53
|
+
#define UPB_HAS_C_ATTRIBUTE(x) 0
|
|
54
|
+
#endif
|
|
55
|
+
|
|
50
56
|
#if defined(__cplusplus) && defined(__has_cpp_attribute)
|
|
51
57
|
// NOTE: requiring __cplusplus above should not be necessary, but
|
|
52
58
|
// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
|
|
@@ -285,12 +291,23 @@ Error, UINTPTR_MAX is undefined
|
|
|
285
291
|
#define UPB_PRINTF(str, first_vararg)
|
|
286
292
|
#endif
|
|
287
293
|
|
|
288
|
-
#if
|
|
294
|
+
#if UPB_HAS_ATTRIBUTE(noderef)
|
|
289
295
|
#define UPB_NODEREF __attribute__((noderef))
|
|
290
296
|
#else
|
|
291
297
|
#define UPB_NODEREF
|
|
292
298
|
#endif
|
|
293
299
|
|
|
300
|
+
// Will be defined properly once call sites are updated
|
|
301
|
+
#if false && UPB_HAS_C_ATTRIBUTE(nodiscard)
|
|
302
|
+
#define UPB_NODISCARD [[nodiscard]]
|
|
303
|
+
#elif false && UPB_HAS_ATTRIBUTE(warn_unused_result)
|
|
304
|
+
#define UPB_NODISCARD __attribute__((warn_unused_result))
|
|
305
|
+
#elif false && UPB_HAS_CPP_ATTRIBUTE(nodiscard)
|
|
306
|
+
#define UPB_NODISCARD [[nodiscard]]
|
|
307
|
+
#else
|
|
308
|
+
#define UPB_NODISCARD
|
|
309
|
+
#endif
|
|
310
|
+
|
|
294
311
|
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
295
312
|
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
|
|
296
313
|
|
|
@@ -339,21 +356,42 @@ Error, UINTPTR_MAX is undefined
|
|
|
339
356
|
#endif
|
|
340
357
|
|
|
341
358
|
#if defined(__GNUC__) || defined(__clang__)
|
|
342
|
-
#define
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
359
|
+
#define UPB_PRETTY_FUNCTION __PRETTY_FUNCTION__
|
|
360
|
+
#else
|
|
361
|
+
#define UPB_PRETTY_FUNCTION NULL
|
|
362
|
+
#endif
|
|
363
|
+
|
|
364
|
+
#ifdef __cplusplus
|
|
365
|
+
extern "C" {
|
|
366
|
+
#endif
|
|
367
|
+
UPB_NORETURN void _upb_UnreachableFailure(const char* file, int line,
|
|
368
|
+
const char* function_name);
|
|
369
|
+
#if !defined(NDEBUG)
|
|
370
|
+
#define UPB_UNREACHABLE_FAILURE() \
|
|
371
|
+
_upb_UnreachableFailure(__FILE__, __LINE__, UPB_PRETTY_FUNCTION);
|
|
372
|
+
#else
|
|
373
|
+
#define UPB_UNREACHABLE_FAILURE()
|
|
374
|
+
#endif
|
|
375
|
+
#ifdef __cplusplus
|
|
376
|
+
} /* extern "C" */
|
|
377
|
+
#endif
|
|
378
|
+
|
|
379
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
380
|
+
#define UPB_UNREACHABLE() \
|
|
381
|
+
do { \
|
|
382
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
383
|
+
__builtin_unreachable(); \
|
|
346
384
|
} while (0)
|
|
347
385
|
#elif defined(_MSC_VER)
|
|
348
|
-
#define UPB_UNREACHABLE()
|
|
349
|
-
do {
|
|
350
|
-
|
|
351
|
-
__assume(0);
|
|
386
|
+
#define UPB_UNREACHABLE() \
|
|
387
|
+
do { \
|
|
388
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
389
|
+
__assume(0); \
|
|
352
390
|
} while (0)
|
|
353
391
|
#else
|
|
354
|
-
#define UPB_UNREACHABLE()
|
|
355
|
-
do {
|
|
356
|
-
|
|
392
|
+
#define UPB_UNREACHABLE() \
|
|
393
|
+
do { \
|
|
394
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
357
395
|
} while (0)
|
|
358
396
|
#endif
|
|
359
397
|
|
|
@@ -448,21 +486,10 @@ Error, UINTPTR_MAX is undefined
|
|
|
448
486
|
#define UPB_ARM64_BTI_DEFAULT 0
|
|
449
487
|
#endif
|
|
450
488
|
|
|
451
|
-
/*
|
|
452
|
-
*
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
* GCC/Clang can mostly be trusted to generate tail calls as long as
|
|
456
|
-
* optimization is enabled, but, debug builds will not generate tail calls
|
|
457
|
-
* unless "musttail" is available.
|
|
458
|
-
*
|
|
459
|
-
* We should probably either:
|
|
460
|
-
* 1. require that the compiler supports musttail.
|
|
461
|
-
* 2. add some fallback code for when musttail isn't available (ie. return
|
|
462
|
-
* instead of tail calling). This is safe and portable, but this comes at
|
|
463
|
-
* a CPU cost.
|
|
464
|
-
*/
|
|
465
|
-
#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
|
|
489
|
+
/* aarch64 supports big and little endian modes; fasttable performs multibyte
|
|
490
|
+
* tag loads assumes the tag of a varint is in the low bits. */
|
|
491
|
+
#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \
|
|
492
|
+
UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail)
|
|
466
493
|
#define UPB_FASTTABLE_SUPPORTED 1
|
|
467
494
|
#else
|
|
468
495
|
#define UPB_FASTTABLE_SUPPORTED 0
|
|
@@ -473,7 +500,7 @@ Error, UINTPTR_MAX is undefined
|
|
|
473
500
|
* for example for testing or benchmarking. */
|
|
474
501
|
#if defined(UPB_ENABLE_FASTTABLE)
|
|
475
502
|
#if !UPB_FASTTABLE_SUPPORTED
|
|
476
|
-
#error fasttable is x86-64/
|
|
503
|
+
#error fasttable is x86-64/ARM64le only and requires preserve_none and musttail.
|
|
477
504
|
#endif
|
|
478
505
|
#define UPB_FASTTABLE 1
|
|
479
506
|
/* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
|
|
@@ -711,7 +738,7 @@ Error, UINTPTR_MAX is undefined
|
|
|
711
738
|
__asm__(".private_extern _" #to); \
|
|
712
739
|
__asm__(".set _" #to ", _" #from);
|
|
713
740
|
|
|
714
|
-
#elif defined(__ELF__)
|
|
741
|
+
#elif defined(__ELF__) || defined(__wasm__)
|
|
715
742
|
|
|
716
743
|
// On ELF, weak aliases work properly, so we can have all weak MiniTables point
|
|
717
744
|
// to the same empty singleton MiniTable. This reduces code size if many
|
|
@@ -740,12 +767,6 @@ Error, UINTPTR_MAX is undefined
|
|
|
740
767
|
#define UPB_WEAK_ALIAS(type, from, to) weak_alias_not_supported_on_this_platform
|
|
741
768
|
#define UPB_STRONG_ALIAS(type, from, to) \
|
|
742
769
|
strong_alias_not_supported_on_this_platform
|
|
743
|
-
#endif
|
|
744
|
-
|
|
745
|
-
// Future versions of upb will include breaking changes to some APIs.
|
|
746
|
-
// This macro can be set to enable these API changes ahead of time, so that
|
|
747
|
-
// user code can be updated before upgrading versions of protobuf.
|
|
748
|
-
#ifdef UPB_FUTURE_BREAKING_CHANGES
|
|
749
770
|
|
|
750
771
|
#endif
|
|
751
772
|
|
|
@@ -776,10 +797,14 @@ static const google__protobuf__FileDescriptorSet_msg_init_Fields google_protobuf
|
|
|
776
797
|
|
|
777
798
|
const upb_MiniTable google__protobuf__FileDescriptorSet_msg_init = {
|
|
778
799
|
&google_protobuf_FileDescriptorSet__fields.fields[0],
|
|
779
|
-
16, 1, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(
|
|
800
|
+
16, 1, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
|
780
801
|
#ifdef UPB_TRACING_ENABLED
|
|
781
802
|
"google.protobuf.FileDescriptorSet",
|
|
782
803
|
#endif
|
|
804
|
+
UPB_FASTTABLE_INIT({
|
|
805
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
806
|
+
{0x000800003f02000a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
807
|
+
})
|
|
783
808
|
};
|
|
784
809
|
|
|
785
810
|
typedef struct {
|
|
@@ -820,21 +845,21 @@ const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init = {
|
|
|
820
845
|
"google.protobuf.FileDescriptorProto",
|
|
821
846
|
#endif
|
|
822
847
|
UPB_FASTTABLE_INIT({
|
|
823
|
-
{0x0000000000000000, &
|
|
848
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
824
849
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
825
850
|
{0x0020000001000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
826
851
|
{0x004000003f00001a, &upb_DecodeFast_Bytes_Repeated_Tag1Byte},
|
|
827
|
-
{
|
|
828
|
-
{
|
|
829
|
-
{
|
|
830
|
-
{
|
|
831
|
-
{
|
|
832
|
-
{
|
|
852
|
+
{0x004800003f150022, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
853
|
+
{0x005000003f16002a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
854
|
+
{0x005800003f170032, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
855
|
+
{0x006000003f18003a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
856
|
+
{0x0068000002190042, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
857
|
+
{0x00700000031a004a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
833
858
|
{0x007800003f000050, &upb_DecodeFast_Varint32_Repeated_Tag1Byte},
|
|
834
859
|
{0x008000003f000058, &upb_DecodeFast_Varint32_Repeated_Tag1Byte},
|
|
835
860
|
{0x0030000004000062, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
836
|
-
{0x0000000000000000, &
|
|
837
|
-
{
|
|
861
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
862
|
+
{0x000c0000051b0070, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
838
863
|
{0x008800003f00007a, &upb_DecodeFast_Bytes_Repeated_Tag1Byte},
|
|
839
864
|
})
|
|
840
865
|
};
|
|
@@ -876,22 +901,22 @@ const upb_MiniTable google__protobuf__DescriptorProto_msg_init = {
|
|
|
876
901
|
"google.protobuf.DescriptorProto",
|
|
877
902
|
#endif
|
|
878
903
|
UPB_FASTTABLE_INIT({
|
|
879
|
-
{0x0000000000000000, &
|
|
904
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
880
905
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
881
|
-
{
|
|
882
|
-
{
|
|
883
|
-
{
|
|
884
|
-
{
|
|
885
|
-
{
|
|
886
|
-
{
|
|
887
|
-
{
|
|
888
|
-
{
|
|
906
|
+
{0x002000003f110012, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
907
|
+
{0x002800003f12001a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
908
|
+
{0x003000003f130022, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
909
|
+
{0x003800003f14002a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
910
|
+
{0x004000003f150032, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
911
|
+
{0x004800000116003a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
912
|
+
{0x005000003f170042, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
913
|
+
{0x005800003f18004a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
889
914
|
{0x006000003f000052, &upb_DecodeFast_Bytes_Repeated_Tag1Byte},
|
|
890
|
-
{
|
|
891
|
-
{0x0000000000000000, &
|
|
892
|
-
{0x0000000000000000, &
|
|
893
|
-
{0x0000000000000000, &
|
|
894
|
-
{0x0000000000000000, &
|
|
915
|
+
{0x000c000002190058, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
916
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
917
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
918
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
919
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
895
920
|
})
|
|
896
921
|
};
|
|
897
922
|
|
|
@@ -916,10 +941,10 @@ const upb_MiniTable google__protobuf__DescriptorProto__ExtensionRange_msg_init =
|
|
|
916
941
|
"google.protobuf.DescriptorProto.ExtensionRange",
|
|
917
942
|
#endif
|
|
918
943
|
UPB_FASTTABLE_INIT({
|
|
919
|
-
{0x0000000000000000, &
|
|
944
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
920
945
|
{0x000c000000000008, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
921
946
|
{0x0010000001000010, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
922
|
-
{
|
|
947
|
+
{0x001800000205001a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
923
948
|
})
|
|
924
949
|
};
|
|
925
950
|
|
|
@@ -939,10 +964,10 @@ const upb_MiniTable google__protobuf__DescriptorProto__ReservedRange_msg_init =
|
|
|
939
964
|
"google.protobuf.DescriptorProto.ReservedRange",
|
|
940
965
|
#endif
|
|
941
966
|
UPB_FASTTABLE_INIT({
|
|
942
|
-
{0x0000000000000000, &
|
|
967
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
943
968
|
{0x000c000000000008, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
944
969
|
{0x0010000001000010, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
945
|
-
{0x0000000000000000, &
|
|
970
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
946
971
|
})
|
|
947
972
|
};
|
|
948
973
|
|
|
@@ -966,10 +991,44 @@ static const google__protobuf__ExtensionRangeOptions_msg_init_Fields google_prot
|
|
|
966
991
|
|
|
967
992
|
const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init = {
|
|
968
993
|
&google_protobuf_ExtensionRangeOptions__fields.fields[0],
|
|
969
|
-
UPB_SIZE(32, 40), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(
|
|
994
|
+
UPB_SIZE(32, 40), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
|
970
995
|
#ifdef UPB_TRACING_ENABLED
|
|
971
996
|
"google.protobuf.ExtensionRangeOptions",
|
|
972
997
|
#endif
|
|
998
|
+
UPB_FASTTABLE_INIT({
|
|
999
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1000
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1001
|
+
{0x001000003f060012, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
1002
|
+
{0x000c000000070018, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1003
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1004
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1005
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1006
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1007
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1008
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1009
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1010
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1011
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1012
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1013
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1014
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1015
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1016
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1017
|
+
{0x0018000001080392, &upb_DecodeFast_Message_Scalar_Tag2Byte},
|
|
1018
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1019
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1020
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1021
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1022
|
+
{0x002000003f093eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1023
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1024
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1025
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1026
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1027
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1028
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1029
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1030
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1031
|
+
})
|
|
973
1032
|
};
|
|
974
1033
|
|
|
975
1034
|
typedef struct {
|
|
@@ -991,14 +1050,14 @@ const upb_MiniTable google__protobuf__ExtensionRangeOptions__Declaration_msg_ini
|
|
|
991
1050
|
"google.protobuf.ExtensionRangeOptions.Declaration",
|
|
992
1051
|
#endif
|
|
993
1052
|
UPB_FASTTABLE_INIT({
|
|
994
|
-
{0x0000000000000000, &
|
|
1053
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
995
1054
|
{0x000c000000000008, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
996
1055
|
{0x0010000001000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
997
1056
|
{0x002000000200001a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
998
|
-
{0x0000000000000000, &
|
|
1057
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
999
1058
|
{0x0009000003000028, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1000
1059
|
{0x000a000004000030, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1001
|
-
{0x0000000000000000, &
|
|
1060
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1002
1061
|
})
|
|
1003
1062
|
};
|
|
1004
1063
|
|
|
@@ -1033,38 +1092,38 @@ const upb_MiniTable google__protobuf__FieldDescriptorProto_msg_init = {
|
|
|
1033
1092
|
"google.protobuf.FieldDescriptorProto",
|
|
1034
1093
|
#endif
|
|
1035
1094
|
UPB_FASTTABLE_INIT({
|
|
1036
|
-
{0x0000000000000000, &
|
|
1095
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1037
1096
|
{0x002000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1038
1097
|
{0x0030000001000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1039
1098
|
{0x000c000002000018, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1040
|
-
{
|
|
1041
|
-
{
|
|
1099
|
+
{0x0010000003110020, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1100
|
+
{0x0014000004120028, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1042
1101
|
{0x0040000005000032, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1043
1102
|
{0x005000000600003a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1044
|
-
{
|
|
1103
|
+
{0x0070000007130042, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1045
1104
|
{0x0018000008000048, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1046
1105
|
{0x0060000009000052, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1047
|
-
{0x0000000000000000, &
|
|
1048
|
-
{0x0000000000000000, &
|
|
1049
|
-
{0x0000000000000000, &
|
|
1050
|
-
{0x0000000000000000, &
|
|
1051
|
-
{0x0000000000000000, &
|
|
1052
|
-
{0x0000000000000000, &
|
|
1106
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1107
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1108
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1109
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1110
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1111
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1053
1112
|
{0x000a00000a000188, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1054
|
-
{0x0000000000000000, &
|
|
1055
|
-
{0x0000000000000000, &
|
|
1056
|
-
{0x0000000000000000, &
|
|
1057
|
-
{0x0000000000000000, &
|
|
1058
|
-
{0x0000000000000000, &
|
|
1059
|
-
{0x0000000000000000, &
|
|
1060
|
-
{0x0000000000000000, &
|
|
1061
|
-
{0x0000000000000000, &
|
|
1062
|
-
{0x0000000000000000, &
|
|
1063
|
-
{0x0000000000000000, &
|
|
1064
|
-
{0x0000000000000000, &
|
|
1065
|
-
{0x0000000000000000, &
|
|
1066
|
-
{0x0000000000000000, &
|
|
1067
|
-
{0x0000000000000000, &
|
|
1113
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1114
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1115
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1116
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1117
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1118
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1119
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1120
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1121
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1122
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1123
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1124
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1125
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1126
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1068
1127
|
})
|
|
1069
1128
|
};
|
|
1070
1129
|
|
|
@@ -1083,13 +1142,15 @@ static const google__protobuf__OneofDescriptorProto_msg_init_Fields google_proto
|
|
|
1083
1142
|
|
|
1084
1143
|
const upb_MiniTable google__protobuf__OneofDescriptorProto_msg_init = {
|
|
1085
1144
|
&google_protobuf_OneofDescriptorProto__fields.fields[0],
|
|
1086
|
-
UPB_SIZE(24, 40), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(
|
|
1145
|
+
UPB_SIZE(24, 40), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 0,
|
|
1087
1146
|
#ifdef UPB_TRACING_ENABLED
|
|
1088
1147
|
"google.protobuf.OneofDescriptorProto",
|
|
1089
1148
|
#endif
|
|
1090
1149
|
UPB_FASTTABLE_INIT({
|
|
1091
|
-
{0x0000000000000000, &
|
|
1150
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1092
1151
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1152
|
+
{0x0020000001030012, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1153
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1093
1154
|
})
|
|
1094
1155
|
};
|
|
1095
1156
|
|
|
@@ -1120,14 +1181,14 @@ const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init = {
|
|
|
1120
1181
|
"google.protobuf.EnumDescriptorProto",
|
|
1121
1182
|
#endif
|
|
1122
1183
|
UPB_FASTTABLE_INIT({
|
|
1123
|
-
{0x0000000000000000, &
|
|
1184
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1124
1185
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1125
|
-
{
|
|
1126
|
-
{
|
|
1127
|
-
{
|
|
1186
|
+
{0x002000003f090012, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
1187
|
+
{0x00280000010a001a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1188
|
+
{0x003000003f0b0022, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
1128
1189
|
{0x003800003f00002a, &upb_DecodeFast_Bytes_Repeated_Tag1Byte},
|
|
1129
|
-
{
|
|
1130
|
-
{0x0000000000000000, &
|
|
1190
|
+
{0x000c0000020c0030, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1191
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1131
1192
|
})
|
|
1132
1193
|
};
|
|
1133
1194
|
|
|
@@ -1147,10 +1208,10 @@ const upb_MiniTable google__protobuf__EnumDescriptorProto__EnumReservedRange_msg
|
|
|
1147
1208
|
"google.protobuf.EnumDescriptorProto.EnumReservedRange",
|
|
1148
1209
|
#endif
|
|
1149
1210
|
UPB_FASTTABLE_INIT({
|
|
1150
|
-
{0x0000000000000000, &
|
|
1211
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1151
1212
|
{0x000c000000000008, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1152
1213
|
{0x0010000001000010, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1153
|
-
{0x0000000000000000, &
|
|
1214
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1154
1215
|
})
|
|
1155
1216
|
};
|
|
1156
1217
|
|
|
@@ -1175,10 +1236,10 @@ const upb_MiniTable google__protobuf__EnumValueDescriptorProto_msg_init = {
|
|
|
1175
1236
|
"google.protobuf.EnumValueDescriptorProto",
|
|
1176
1237
|
#endif
|
|
1177
1238
|
UPB_FASTTABLE_INIT({
|
|
1178
|
-
{0x0000000000000000, &
|
|
1239
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1179
1240
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1180
1241
|
{0x000c000001000010, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1181
|
-
{
|
|
1242
|
+
{0x002000000205001a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1182
1243
|
})
|
|
1183
1244
|
};
|
|
1184
1245
|
|
|
@@ -1199,13 +1260,15 @@ static const google__protobuf__ServiceDescriptorProto_msg_init_Fields google_pro
|
|
|
1199
1260
|
|
|
1200
1261
|
const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init = {
|
|
1201
1262
|
&google_protobuf_ServiceDescriptorProto__fields.fields[0],
|
|
1202
|
-
UPB_SIZE(32, 48), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(
|
|
1263
|
+
UPB_SIZE(32, 48), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0,
|
|
1203
1264
|
#ifdef UPB_TRACING_ENABLED
|
|
1204
1265
|
"google.protobuf.ServiceDescriptorProto",
|
|
1205
1266
|
#endif
|
|
1206
1267
|
UPB_FASTTABLE_INIT({
|
|
1207
|
-
{0x0000000000000000, &
|
|
1268
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1208
1269
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1270
|
+
{0x002000003f050012, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
1271
|
+
{0x002800000106001a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1209
1272
|
})
|
|
1210
1273
|
};
|
|
1211
1274
|
|
|
@@ -1233,14 +1296,14 @@ const upb_MiniTable google__protobuf__MethodDescriptorProto_msg_init = {
|
|
|
1233
1296
|
"google.protobuf.MethodDescriptorProto",
|
|
1234
1297
|
#endif
|
|
1235
1298
|
UPB_FASTTABLE_INIT({
|
|
1236
|
-
{0x0000000000000000, &
|
|
1299
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1237
1300
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1238
1301
|
{0x0020000001000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1239
1302
|
{0x003000000200001a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1240
|
-
{
|
|
1303
|
+
{0x0040000003090022, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1241
1304
|
{0x0009000004000028, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1242
1305
|
{0x000a000005000030, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1243
|
-
{0x0000000000000000, &
|
|
1306
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1244
1307
|
})
|
|
1245
1308
|
};
|
|
1246
1309
|
|
|
@@ -1285,37 +1348,37 @@ const upb_MiniTable google__protobuf__FileOptions_msg_init = {
|
|
|
1285
1348
|
"google.protobuf.FileOptions",
|
|
1286
1349
|
#endif
|
|
1287
1350
|
UPB_FASTTABLE_INIT({
|
|
1288
|
-
{0x0000000000000000, &
|
|
1351
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1289
1352
|
{0x001800000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1290
|
-
{0x0000000000000000, &
|
|
1291
|
-
{0x0000000000000000, &
|
|
1292
|
-
{0x0000000000000000, &
|
|
1293
|
-
{0x0000000000000000, &
|
|
1294
|
-
{0x0000000000000000, &
|
|
1295
|
-
{0x0000000000000000, &
|
|
1353
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1354
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1355
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1356
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1357
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1358
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1296
1359
|
{0x0028000001000042, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1297
|
-
{
|
|
1360
|
+
{0x0014000002200048, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1298
1361
|
{0x000b000003000050, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1299
1362
|
{0x003800000400005a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1300
|
-
{0x0000000000000000, &
|
|
1301
|
-
{0x0000000000000000, &
|
|
1302
|
-
{0x0000000000000000, &
|
|
1303
|
-
{0x0000000000000000, &
|
|
1363
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1364
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1365
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1366
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1304
1367
|
{0x000c000005000180, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1305
1368
|
{0x000d000006000188, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1306
1369
|
{0x000e000007000190, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1307
|
-
{0x0000000000000000, &
|
|
1370
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1308
1371
|
{0x000f0000080001a0, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1309
1372
|
{0x005800000d0002aa, &upb_DecodeFast_Bytes_Scalar_Tag2Byte},
|
|
1310
|
-
{0x0000000000000000, &
|
|
1373
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1311
1374
|
{0x00100000090001b8, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1312
1375
|
{0x007800000f0002c2, &upb_DecodeFast_Bytes_Scalar_Tag2Byte},
|
|
1313
1376
|
{0x00880000100002ca, &upb_DecodeFast_Bytes_Scalar_Tag2Byte},
|
|
1314
|
-
{0x0000000000000000, &
|
|
1377
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1315
1378
|
{0x001100000a0001d8, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1316
1379
|
{0x00980000110002e2, &upb_DecodeFast_Bytes_Scalar_Tag2Byte},
|
|
1317
1380
|
{0x00a80000120002ea, &upb_DecodeFast_Bytes_Scalar_Tag2Byte},
|
|
1318
|
-
{0x0000000000000000, &
|
|
1381
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1319
1382
|
{0x001200000b0001f8, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1320
1383
|
})
|
|
1321
1384
|
};
|
|
@@ -1341,27 +1404,43 @@ static const google__protobuf__MessageOptions_msg_init_Fields google_protobuf_Me
|
|
|
1341
1404
|
|
|
1342
1405
|
const upb_MiniTable google__protobuf__MessageOptions_msg_init = {
|
|
1343
1406
|
&google_protobuf_MessageOptions__fields.fields[0],
|
|
1344
|
-
UPB_SIZE(24, 32), 7, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(
|
|
1407
|
+
UPB_SIZE(24, 32), 7, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0,
|
|
1345
1408
|
#ifdef UPB_TRACING_ENABLED
|
|
1346
1409
|
"google.protobuf.MessageOptions",
|
|
1347
1410
|
#endif
|
|
1348
1411
|
UPB_FASTTABLE_INIT({
|
|
1349
|
-
{0x0000000000000000, &
|
|
1412
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1350
1413
|
{0x0009000000000008, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1351
1414
|
{0x000a000001000010, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1352
1415
|
{0x000b000002000018, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1353
|
-
{0x0000000000000000, &
|
|
1354
|
-
{0x0000000000000000, &
|
|
1355
|
-
{0x0000000000000000, &
|
|
1416
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1417
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1418
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1356
1419
|
{0x000c000003000038, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1357
|
-
{0x0000000000000000, &
|
|
1358
|
-
{0x0000000000000000, &
|
|
1359
|
-
{0x0000000000000000, &
|
|
1420
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1421
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1422
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1360
1423
|
{0x000d000004000058, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1361
|
-
{
|
|
1362
|
-
{0x0000000000000000, &
|
|
1363
|
-
{0x0000000000000000, &
|
|
1364
|
-
{0x0000000000000000, &
|
|
1424
|
+
{0x00100000050b0062, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1425
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1426
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1427
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1428
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1429
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1430
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1431
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1432
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1433
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1434
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1435
|
+
{0x001800003f0c3eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1436
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1437
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1438
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1439
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1440
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1441
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1442
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1443
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1365
1444
|
})
|
|
1366
1445
|
};
|
|
1367
1446
|
|
|
@@ -1404,38 +1483,38 @@ const upb_MiniTable google__protobuf__FieldOptions_msg_init = {
|
|
|
1404
1483
|
"google.protobuf.FieldOptions",
|
|
1405
1484
|
#endif
|
|
1406
1485
|
UPB_FASTTABLE_INIT({
|
|
1407
|
-
{0x0000000000000000, &
|
|
1408
|
-
{
|
|
1486
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1487
|
+
{0x0010000000150008, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1409
1488
|
{0x000a000001000010, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1410
1489
|
{0x000b000002000018, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1411
|
-
{0x0000000000000000, &
|
|
1490
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1412
1491
|
{0x000c000003000028, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1413
|
-
{
|
|
1414
|
-
{0x0000000000000000, &
|
|
1415
|
-
{0x0000000000000000, &
|
|
1416
|
-
{0x0000000000000000, &
|
|
1492
|
+
{0x0014000004160030, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1493
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1494
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1495
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1417
1496
|
{0x000d000005000050, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1418
|
-
{0x0000000000000000, &
|
|
1419
|
-
{0x0000000000000000, &
|
|
1420
|
-
{0x0000000000000000, &
|
|
1421
|
-
{0x0000000000000000, &
|
|
1497
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1498
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1499
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1500
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1422
1501
|
{0x000e000006000078, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1423
1502
|
{0x000f000007000180, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1424
|
-
{
|
|
1425
|
-
{0x0000000000000000, &
|
|
1426
|
-
{
|
|
1427
|
-
{
|
|
1428
|
-
{
|
|
1429
|
-
{
|
|
1430
|
-
{
|
|
1431
|
-
{0x0000000000000000, &
|
|
1432
|
-
{0x0000000000000000, &
|
|
1433
|
-
{0x0000000000000000, &
|
|
1434
|
-
{0x0000000000000000, &
|
|
1435
|
-
{0x0000000000000000, &
|
|
1436
|
-
{0x0000000000000000, &
|
|
1437
|
-
{0x0000000000000000, &
|
|
1438
|
-
{0x0000000000000000, &
|
|
1503
|
+
{0x0018000008170188, &upb_DecodeFast_ClosedEnum_Scalar_Tag2Byte},
|
|
1504
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1505
|
+
{0x002000003f180198, &upb_DecodeFast_ClosedEnum_Repeated_Tag2Byte},
|
|
1506
|
+
{0x002800003f1901a2, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1507
|
+
{0x00300000091a01aa, &upb_DecodeFast_Message_Scalar_Tag2Byte},
|
|
1508
|
+
{0x003800000a1b01b2, &upb_DecodeFast_Message_Scalar_Tag2Byte},
|
|
1509
|
+
{0x004000003f1c3eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1510
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1511
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1512
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1513
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1514
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1515
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1516
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1517
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1439
1518
|
})
|
|
1440
1519
|
};
|
|
1441
1520
|
|
|
@@ -1459,10 +1538,10 @@ const upb_MiniTable google__protobuf__FieldOptions__EditionDefault_msg_init = {
|
|
|
1459
1538
|
"google.protobuf.FieldOptions.EditionDefault",
|
|
1460
1539
|
#endif
|
|
1461
1540
|
UPB_FASTTABLE_INIT({
|
|
1462
|
-
{0x0000000000000000, &
|
|
1463
|
-
{0x0000000000000000, &
|
|
1541
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1542
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1464
1543
|
{0x0010000000000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1465
|
-
{
|
|
1544
|
+
{0x000c000001030018, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1466
1545
|
})
|
|
1467
1546
|
};
|
|
1468
1547
|
|
|
@@ -1491,14 +1570,14 @@ const upb_MiniTable google__protobuf__FieldOptions__FeatureSupport_msg_init = {
|
|
|
1491
1570
|
"google.protobuf.FieldOptions.FeatureSupport",
|
|
1492
1571
|
#endif
|
|
1493
1572
|
UPB_FASTTABLE_INIT({
|
|
1494
|
-
{0x0000000000000000, &
|
|
1495
|
-
{
|
|
1496
|
-
{
|
|
1573
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1574
|
+
{0x000c000000080008, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1575
|
+
{0x0010000001090010, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1497
1576
|
{0x001800000200001a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1498
|
-
{
|
|
1577
|
+
{0x00140000030a0020, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1499
1578
|
{0x002800000400002a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1500
|
-
{0x0000000000000000, &
|
|
1501
|
-
{0x0000000000000000, &
|
|
1579
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1580
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1502
1581
|
})
|
|
1503
1582
|
};
|
|
1504
1583
|
|
|
@@ -1518,10 +1597,44 @@ static const google__protobuf__OneofOptions_msg_init_Fields google_protobuf_Oneo
|
|
|
1518
1597
|
|
|
1519
1598
|
const upb_MiniTable google__protobuf__OneofOptions_msg_init = {
|
|
1520
1599
|
&google_protobuf_OneofOptions__fields.fields[0],
|
|
1521
|
-
UPB_SIZE(24, 32), 2, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(
|
|
1600
|
+
UPB_SIZE(24, 32), 2, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0,
|
|
1522
1601
|
#ifdef UPB_TRACING_ENABLED
|
|
1523
1602
|
"google.protobuf.OneofOptions",
|
|
1524
1603
|
#endif
|
|
1604
|
+
UPB_FASTTABLE_INIT({
|
|
1605
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1606
|
+
{0x001000000003000a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1607
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1608
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1609
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1610
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1611
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1612
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1613
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1614
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1615
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1616
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1617
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1618
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1619
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1620
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1621
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1622
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1623
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1624
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1625
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1626
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1627
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1628
|
+
{0x001800003f043eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1629
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1630
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1631
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1632
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1633
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1634
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1635
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1636
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1637
|
+
})
|
|
1525
1638
|
};
|
|
1526
1639
|
|
|
1527
1640
|
typedef struct {
|
|
@@ -1543,19 +1656,43 @@ static const google__protobuf__EnumOptions_msg_init_Fields google_protobuf_EnumO
|
|
|
1543
1656
|
|
|
1544
1657
|
const upb_MiniTable google__protobuf__EnumOptions_msg_init = {
|
|
1545
1658
|
&google_protobuf_EnumOptions__fields.fields[0],
|
|
1546
|
-
UPB_SIZE(24, 32), 5, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(
|
|
1659
|
+
UPB_SIZE(24, 32), 5, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
|
1547
1660
|
#ifdef UPB_TRACING_ENABLED
|
|
1548
1661
|
"google.protobuf.EnumOptions",
|
|
1549
1662
|
#endif
|
|
1550
1663
|
UPB_FASTTABLE_INIT({
|
|
1551
|
-
{0x0000000000000000, &
|
|
1552
|
-
{0x0000000000000000, &
|
|
1664
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1665
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1553
1666
|
{0x0009000000000010, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1554
1667
|
{0x000a000001000018, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1555
|
-
{0x0000000000000000, &
|
|
1556
|
-
{0x0000000000000000, &
|
|
1668
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1669
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1557
1670
|
{0x000b000002000030, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1558
|
-
{
|
|
1671
|
+
{0x001000000308003a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1672
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1673
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1674
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1675
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1676
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1677
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1678
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1679
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1680
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1681
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1682
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1683
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1684
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1685
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1686
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1687
|
+
{0x001800003f093eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1688
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1689
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1690
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1691
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1692
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1693
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1694
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1695
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1559
1696
|
})
|
|
1560
1697
|
};
|
|
1561
1698
|
|
|
@@ -1579,15 +1716,43 @@ static const google__protobuf__EnumValueOptions_msg_init_Fields google_protobuf_
|
|
|
1579
1716
|
|
|
1580
1717
|
const upb_MiniTable google__protobuf__EnumValueOptions_msg_init = {
|
|
1581
1718
|
&google_protobuf_EnumValueOptions__fields.fields[0],
|
|
1582
|
-
UPB_SIZE(24, 40), 5, kUpb_ExtMode_Extendable, 4, UPB_FASTTABLE_MASK(
|
|
1719
|
+
UPB_SIZE(24, 40), 5, kUpb_ExtMode_Extendable, 4, UPB_FASTTABLE_MASK(248), 0,
|
|
1583
1720
|
#ifdef UPB_TRACING_ENABLED
|
|
1584
1721
|
"google.protobuf.EnumValueOptions",
|
|
1585
1722
|
#endif
|
|
1586
1723
|
UPB_FASTTABLE_INIT({
|
|
1587
|
-
{0x0000000000000000, &
|
|
1724
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1588
1725
|
{0x0009000000000008, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1589
|
-
{
|
|
1726
|
+
{0x0010000001080012, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1590
1727
|
{0x000a000002000018, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1728
|
+
{0x0018000003090022, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
1729
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1730
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1731
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1732
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1733
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1734
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1735
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1736
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1737
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1738
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1739
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1740
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1741
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1742
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1743
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1744
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1745
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1746
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1747
|
+
{0x002000003f0a3eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1748
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1749
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1750
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1751
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1752
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1753
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1754
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1755
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1591
1756
|
})
|
|
1592
1757
|
};
|
|
1593
1758
|
|
|
@@ -1613,38 +1778,38 @@ const upb_MiniTable google__protobuf__ServiceOptions_msg_init = {
|
|
|
1613
1778
|
"google.protobuf.ServiceOptions",
|
|
1614
1779
|
#endif
|
|
1615
1780
|
UPB_FASTTABLE_INIT({
|
|
1616
|
-
{0x0000000000000000, &
|
|
1617
|
-
{0x0000000000000000, &
|
|
1618
|
-
{0x0000000000000000, &
|
|
1619
|
-
{0x0000000000000000, &
|
|
1620
|
-
{0x0000000000000000, &
|
|
1621
|
-
{0x0000000000000000, &
|
|
1622
|
-
{0x0000000000000000, &
|
|
1623
|
-
{0x0000000000000000, &
|
|
1624
|
-
{0x0000000000000000, &
|
|
1625
|
-
{0x0000000000000000, &
|
|
1626
|
-
{0x0000000000000000, &
|
|
1627
|
-
{0x0000000000000000, &
|
|
1628
|
-
{0x0000000000000000, &
|
|
1629
|
-
{0x0000000000000000, &
|
|
1630
|
-
{0x0000000000000000, &
|
|
1631
|
-
{0x0000000000000000, &
|
|
1632
|
-
{0x0000000000000000, &
|
|
1781
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1782
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1783
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1784
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1785
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1786
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1787
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1788
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1789
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1790
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1791
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1792
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1793
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1794
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1795
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1796
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1797
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1633
1798
|
{0x0009000000000288, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1634
|
-
{
|
|
1635
|
-
{0x0000000000000000, &
|
|
1636
|
-
{0x0000000000000000, &
|
|
1637
|
-
{0x0000000000000000, &
|
|
1638
|
-
{0x0000000000000000, &
|
|
1639
|
-
{
|
|
1640
|
-
{0x0000000000000000, &
|
|
1641
|
-
{0x0000000000000000, &
|
|
1642
|
-
{0x0000000000000000, &
|
|
1643
|
-
{0x0000000000000000, &
|
|
1644
|
-
{0x0000000000000000, &
|
|
1645
|
-
{0x0000000000000000, &
|
|
1646
|
-
{0x0000000000000000, &
|
|
1647
|
-
{0x0000000000000000, &
|
|
1799
|
+
{0x0010000001050292, &upb_DecodeFast_Message_Scalar_Tag2Byte},
|
|
1800
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1801
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1802
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1803
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1804
|
+
{0x001800003f063eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1805
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1806
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1807
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1808
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1809
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1810
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1811
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1812
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1648
1813
|
})
|
|
1649
1814
|
};
|
|
1650
1815
|
|
|
@@ -1672,38 +1837,38 @@ const upb_MiniTable google__protobuf__MethodOptions_msg_init = {
|
|
|
1672
1837
|
"google.protobuf.MethodOptions",
|
|
1673
1838
|
#endif
|
|
1674
1839
|
UPB_FASTTABLE_INIT({
|
|
1675
|
-
{0x0000000000000000, &
|
|
1676
|
-
{0x0000000000000000, &
|
|
1677
|
-
{0x0000000000000000, &
|
|
1678
|
-
{0x0000000000000000, &
|
|
1679
|
-
{0x0000000000000000, &
|
|
1680
|
-
{0x0000000000000000, &
|
|
1681
|
-
{0x0000000000000000, &
|
|
1682
|
-
{0x0000000000000000, &
|
|
1683
|
-
{0x0000000000000000, &
|
|
1684
|
-
{0x0000000000000000, &
|
|
1685
|
-
{0x0000000000000000, &
|
|
1686
|
-
{0x0000000000000000, &
|
|
1687
|
-
{0x0000000000000000, &
|
|
1688
|
-
{0x0000000000000000, &
|
|
1689
|
-
{0x0000000000000000, &
|
|
1690
|
-
{0x0000000000000000, &
|
|
1691
|
-
{0x0000000000000000, &
|
|
1840
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1841
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1842
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1843
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1844
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1845
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1846
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1847
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1848
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1849
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1850
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1851
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1852
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1853
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1854
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1855
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1856
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1692
1857
|
{0x0009000000000288, &upb_DecodeFast_Bool_Scalar_Tag2Byte},
|
|
1693
|
-
{
|
|
1694
|
-
{
|
|
1695
|
-
{0x0000000000000000, &
|
|
1696
|
-
{0x0000000000000000, &
|
|
1697
|
-
{0x0000000000000000, &
|
|
1698
|
-
{
|
|
1699
|
-
{0x0000000000000000, &
|
|
1700
|
-
{0x0000000000000000, &
|
|
1701
|
-
{0x0000000000000000, &
|
|
1702
|
-
{0x0000000000000000, &
|
|
1703
|
-
{0x0000000000000000, &
|
|
1704
|
-
{0x0000000000000000, &
|
|
1705
|
-
{0x0000000000000000, &
|
|
1706
|
-
{0x0000000000000000, &
|
|
1858
|
+
{0x000c000001060290, &upb_DecodeFast_ClosedEnum_Scalar_Tag2Byte},
|
|
1859
|
+
{0x001000000207029a, &upb_DecodeFast_Message_Scalar_Tag2Byte},
|
|
1860
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1861
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1862
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1863
|
+
{0x001800003f083eba, &upb_DecodeFast_Message_Repeated_Tag2Byte},
|
|
1864
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1865
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1866
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1867
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1868
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1869
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1870
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1871
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1707
1872
|
})
|
|
1708
1873
|
};
|
|
1709
1874
|
|
|
@@ -1732,22 +1897,22 @@ const upb_MiniTable google__protobuf__UninterpretedOption_msg_init = {
|
|
|
1732
1897
|
"google.protobuf.UninterpretedOption",
|
|
1733
1898
|
#endif
|
|
1734
1899
|
UPB_FASTTABLE_INIT({
|
|
1735
|
-
{0x0000000000000000, &
|
|
1736
|
-
{0x0000000000000000, &
|
|
1737
|
-
{
|
|
1900
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1901
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1902
|
+
{0x004000003f0b0012, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
1738
1903
|
{0x001000000000001a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1739
1904
|
{0x0048000001000020, &upb_DecodeFast_Varint64_Scalar_Tag1Byte},
|
|
1740
1905
|
{0x0050000002000028, &upb_DecodeFast_Varint64_Scalar_Tag1Byte},
|
|
1741
1906
|
{0x0058000003000031, &upb_DecodeFast_Fixed64_Scalar_Tag1Byte},
|
|
1742
1907
|
{0x002000000400003a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1743
1908
|
{0x0030000005000042, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1744
|
-
{0x0000000000000000, &
|
|
1745
|
-
{0x0000000000000000, &
|
|
1746
|
-
{0x0000000000000000, &
|
|
1747
|
-
{0x0000000000000000, &
|
|
1748
|
-
{0x0000000000000000, &
|
|
1749
|
-
{0x0000000000000000, &
|
|
1750
|
-
{0x0000000000000000, &
|
|
1909
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1910
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1911
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1912
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1913
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1914
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1915
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1751
1916
|
})
|
|
1752
1917
|
};
|
|
1753
1918
|
|
|
@@ -1767,27 +1932,28 @@ const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init = {
|
|
|
1767
1932
|
"google.protobuf.UninterpretedOption.NamePart",
|
|
1768
1933
|
#endif
|
|
1769
1934
|
UPB_FASTTABLE_INIT({
|
|
1770
|
-
{0x0000000000000000, &
|
|
1935
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1771
1936
|
{0x001000000000000a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1772
1937
|
{0x0009000001000010, &upb_DecodeFast_Bool_Scalar_Tag1Byte},
|
|
1773
|
-
{0x0000000000000000, &
|
|
1938
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1774
1939
|
})
|
|
1775
1940
|
};
|
|
1776
1941
|
|
|
1777
1942
|
typedef struct {
|
|
1778
|
-
upb_MiniTableField fields[
|
|
1779
|
-
upb_MiniTableSubInternal subs[
|
|
1943
|
+
upb_MiniTableField fields[9];
|
|
1944
|
+
upb_MiniTableSubInternal subs[9];
|
|
1780
1945
|
} google__protobuf__FeatureSet_msg_init_Fields;
|
|
1781
1946
|
|
|
1782
1947
|
static const google__protobuf__FeatureSet_msg_init_Fields google_protobuf_FeatureSet__fields = {{
|
|
1783
|
-
{1, 12, 64,
|
|
1784
|
-
{2, 16, 65, UPB_SIZE(
|
|
1785
|
-
{3, 20, 66, UPB_SIZE(
|
|
1786
|
-
{4, 24, 67, UPB_SIZE(
|
|
1787
|
-
{5, 28, 68, UPB_SIZE(
|
|
1788
|
-
{6, 32, 69, UPB_SIZE(
|
|
1789
|
-
{7, 36, 70, UPB_SIZE(
|
|
1790
|
-
{8, 40, 71, UPB_SIZE(
|
|
1948
|
+
{1, 12, 64, UPB_SIZE(27, 28), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1949
|
+
{2, 16, 65, UPB_SIZE(25, 27), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1950
|
+
{3, 20, 66, UPB_SIZE(23, 26), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1951
|
+
{4, 24, 67, UPB_SIZE(21, 25), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1952
|
+
{5, 28, 68, UPB_SIZE(19, 24), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1953
|
+
{6, 32, 69, UPB_SIZE(17, 23), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1954
|
+
{7, 36, 70, UPB_SIZE(15, 22), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1955
|
+
{8, 40, 71, UPB_SIZE(13, 21), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1956
|
+
{9, 44, 72, UPB_SIZE(11, 20), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
|
1791
1957
|
},
|
|
1792
1958
|
{
|
|
1793
1959
|
{.UPB_PRIVATE(subenum) = &google__protobuf__FeatureSet__FieldPresence_enum_init},
|
|
@@ -1798,14 +1964,33 @@ static const google__protobuf__FeatureSet_msg_init_Fields google_protobuf_Featur
|
|
|
1798
1964
|
{.UPB_PRIVATE(subenum) = &google__protobuf__FeatureSet__JsonFormat_enum_init},
|
|
1799
1965
|
{.UPB_PRIVATE(subenum) = &google__protobuf__FeatureSet__EnforceNamingStyle_enum_init},
|
|
1800
1966
|
{.UPB_PRIVATE(subenum) = &google__protobuf__FeatureSet__VisibilityFeature__DefaultSymbolVisibility_enum_init},
|
|
1967
|
+
{.UPB_PRIVATE(subenum) = &google__protobuf__FeatureSet__ProtoLimitsFeature__EnforceProtoLimits_enum_init},
|
|
1801
1968
|
}};
|
|
1802
1969
|
|
|
1803
1970
|
const upb_MiniTable google__protobuf__FeatureSet_msg_init = {
|
|
1804
1971
|
&google_protobuf_FeatureSet__fields.fields[0],
|
|
1805
|
-
48,
|
|
1972
|
+
48, 9, kUpb_ExtMode_Extendable, 9, UPB_FASTTABLE_MASK(120), 0,
|
|
1806
1973
|
#ifdef UPB_TRACING_ENABLED
|
|
1807
1974
|
"google.protobuf.FeatureSet",
|
|
1808
1975
|
#endif
|
|
1976
|
+
UPB_FASTTABLE_INIT({
|
|
1977
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1978
|
+
{0x000c0000000e0008, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1979
|
+
{0x00100000010f0010, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1980
|
+
{0x0014000002100018, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1981
|
+
{0x0018000003110020, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1982
|
+
{0x001c000004120028, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1983
|
+
{0x0020000005130030, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1984
|
+
{0x0024000006140038, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1985
|
+
{0x0028000007150040, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1986
|
+
{0x002c000008160048, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
1987
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1988
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1989
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1990
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1991
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1992
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
1993
|
+
})
|
|
1809
1994
|
};
|
|
1810
1995
|
|
|
1811
1996
|
const upb_MiniTable google__protobuf__FeatureSet__VisibilityFeature_msg_init = {
|
|
@@ -1816,6 +2001,14 @@ const upb_MiniTable google__protobuf__FeatureSet__VisibilityFeature_msg_init = {
|
|
|
1816
2001
|
#endif
|
|
1817
2002
|
};
|
|
1818
2003
|
|
|
2004
|
+
const upb_MiniTable google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init = {
|
|
2005
|
+
NULL,
|
|
2006
|
+
8, 0, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(255), 0,
|
|
2007
|
+
#ifdef UPB_TRACING_ENABLED
|
|
2008
|
+
"google.protobuf.FeatureSet.ProtoLimitsFeature",
|
|
2009
|
+
#endif
|
|
2010
|
+
};
|
|
2011
|
+
|
|
1819
2012
|
typedef struct {
|
|
1820
2013
|
upb_MiniTableField fields[3];
|
|
1821
2014
|
upb_MiniTableSubInternal subs[3];
|
|
@@ -1834,10 +2027,20 @@ static const google__protobuf__FeatureSetDefaults_msg_init_Fields google_protobu
|
|
|
1834
2027
|
|
|
1835
2028
|
const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init = {
|
|
1836
2029
|
&google_protobuf_FeatureSetDefaults__fields.fields[0],
|
|
1837
|
-
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(
|
|
2030
|
+
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(56), 0,
|
|
1838
2031
|
#ifdef UPB_TRACING_ENABLED
|
|
1839
2032
|
"google.protobuf.FeatureSetDefaults",
|
|
1840
2033
|
#endif
|
|
2034
|
+
UPB_FASTTABLE_INIT({
|
|
2035
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2036
|
+
{0x001800003f05000a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
2037
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2038
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2039
|
+
{0x000c000000060020, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
2040
|
+
{0x0010000001070028, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
2041
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2042
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2043
|
+
})
|
|
1841
2044
|
};
|
|
1842
2045
|
|
|
1843
2046
|
typedef struct {
|
|
@@ -1858,10 +2061,20 @@ static const google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_
|
|
|
1858
2061
|
|
|
1859
2062
|
const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init = {
|
|
1860
2063
|
&google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields.fields[0],
|
|
1861
|
-
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(
|
|
2064
|
+
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(56), 0,
|
|
1862
2065
|
#ifdef UPB_TRACING_ENABLED
|
|
1863
2066
|
"google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault",
|
|
1864
2067
|
#endif
|
|
2068
|
+
UPB_FASTTABLE_INIT({
|
|
2069
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2070
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2071
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2072
|
+
{0x000c000000050018, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
2073
|
+
{0x0010000001060022, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
2074
|
+
{0x001800000207002a, &upb_DecodeFast_Message_Scalar_Tag1Byte},
|
|
2075
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2076
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2077
|
+
})
|
|
1865
2078
|
};
|
|
1866
2079
|
|
|
1867
2080
|
typedef struct {
|
|
@@ -1878,10 +2091,14 @@ static const google__protobuf__SourceCodeInfo_msg_init_Fields google_protobuf_So
|
|
|
1878
2091
|
|
|
1879
2092
|
const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init = {
|
|
1880
2093
|
&google_protobuf_SourceCodeInfo__fields.fields[0],
|
|
1881
|
-
16, 1, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(
|
|
2094
|
+
16, 1, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
|
1882
2095
|
#ifdef UPB_TRACING_ENABLED
|
|
1883
2096
|
"google.protobuf.SourceCodeInfo",
|
|
1884
2097
|
#endif
|
|
2098
|
+
UPB_FASTTABLE_INIT({
|
|
2099
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeExtensionOrUnknown},
|
|
2100
|
+
{0x000800003f02000a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
2101
|
+
})
|
|
1885
2102
|
};
|
|
1886
2103
|
|
|
1887
2104
|
typedef struct {
|
|
@@ -1903,14 +2120,14 @@ const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init = {
|
|
|
1903
2120
|
"google.protobuf.SourceCodeInfo.Location",
|
|
1904
2121
|
#endif
|
|
1905
2122
|
UPB_FASTTABLE_INIT({
|
|
1906
|
-
{0x0000000000000000, &
|
|
2123
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1907
2124
|
{0x003000003f00000a, &upb_DecodeFast_Varint32_Packed_Tag1Byte},
|
|
1908
2125
|
{0x003800003f000012, &upb_DecodeFast_Varint32_Packed_Tag1Byte},
|
|
1909
2126
|
{0x001000000000001a, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1910
2127
|
{0x0020000001000022, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1911
|
-
{0x0000000000000000, &
|
|
2128
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1912
2129
|
{0x004000003f000032, &upb_DecodeFast_Bytes_Repeated_Tag1Byte},
|
|
1913
|
-
{0x0000000000000000, &
|
|
2130
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1914
2131
|
})
|
|
1915
2132
|
};
|
|
1916
2133
|
|
|
@@ -1928,10 +2145,14 @@ static const google__protobuf__GeneratedCodeInfo_msg_init_Fields google_protobuf
|
|
|
1928
2145
|
|
|
1929
2146
|
const upb_MiniTable google__protobuf__GeneratedCodeInfo_msg_init = {
|
|
1930
2147
|
&google_protobuf_GeneratedCodeInfo__fields.fields[0],
|
|
1931
|
-
16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(
|
|
2148
|
+
16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
|
1932
2149
|
#ifdef UPB_TRACING_ENABLED
|
|
1933
2150
|
"google.protobuf.GeneratedCodeInfo",
|
|
1934
2151
|
#endif
|
|
2152
|
+
UPB_FASTTABLE_INIT({
|
|
2153
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2154
|
+
{0x000800003f02000a, &upb_DecodeFast_Message_Repeated_Tag1Byte},
|
|
2155
|
+
})
|
|
1935
2156
|
};
|
|
1936
2157
|
|
|
1937
2158
|
typedef struct {
|
|
@@ -1957,14 +2178,14 @@ const upb_MiniTable google__protobuf__GeneratedCodeInfo__Annotation_msg_init = {
|
|
|
1957
2178
|
"google.protobuf.GeneratedCodeInfo.Annotation",
|
|
1958
2179
|
#endif
|
|
1959
2180
|
UPB_FASTTABLE_INIT({
|
|
1960
|
-
{0x0000000000000000, &
|
|
2181
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1961
2182
|
{0x002800003f00000a, &upb_DecodeFast_Varint32_Packed_Tag1Byte},
|
|
1962
2183
|
{0x0018000000000012, &upb_DecodeFast_Bytes_Scalar_Tag1Byte},
|
|
1963
2184
|
{0x000c000001000018, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1964
2185
|
{0x0010000002000020, &upb_DecodeFast_Varint32_Scalar_Tag1Byte},
|
|
1965
|
-
{
|
|
1966
|
-
{0x0000000000000000, &
|
|
1967
|
-
{0x0000000000000000, &
|
|
2186
|
+
{0x0014000003080028, &upb_DecodeFast_ClosedEnum_Scalar_Tag1Byte},
|
|
2187
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
2188
|
+
{0x0000000000000000, &_upb_FastDecoder_DecodeUnknown},
|
|
1968
2189
|
})
|
|
1969
2190
|
};
|
|
1970
2191
|
|
|
@@ -2042,6 +2263,15 @@ const upb_MiniTableEnum google__protobuf__FeatureSet__MessageEncoding_enum_init
|
|
|
2042
2263
|
},
|
|
2043
2264
|
};
|
|
2044
2265
|
|
|
2266
|
+
const upb_MiniTableEnum google__protobuf__FeatureSet__ProtoLimitsFeature__EnforceProtoLimits_enum_init = {
|
|
2267
|
+
64,
|
|
2268
|
+
0,
|
|
2269
|
+
{
|
|
2270
|
+
0x7,
|
|
2271
|
+
0x0,
|
|
2272
|
+
},
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2045
2275
|
const upb_MiniTableEnum google__protobuf__FeatureSet__RepeatedFieldEncoding_enum_init = {
|
|
2046
2276
|
64,
|
|
2047
2277
|
0,
|
|
@@ -2159,7 +2389,7 @@ const upb_MiniTableEnum google__protobuf__SymbolVisibility_enum_init = {
|
|
|
2159
2389
|
},
|
|
2160
2390
|
};
|
|
2161
2391
|
|
|
2162
|
-
static const upb_MiniTable *messages_layout[
|
|
2392
|
+
static const upb_MiniTable *messages_layout[35] = {
|
|
2163
2393
|
&google__protobuf__FileDescriptorSet_msg_init,
|
|
2164
2394
|
&google__protobuf__FileDescriptorProto_msg_init,
|
|
2165
2395
|
&google__protobuf__DescriptorProto_msg_init,
|
|
@@ -2188,6 +2418,7 @@ static const upb_MiniTable *messages_layout[34] = {
|
|
|
2188
2418
|
&google__protobuf__UninterpretedOption__NamePart_msg_init,
|
|
2189
2419
|
&google__protobuf__FeatureSet_msg_init,
|
|
2190
2420
|
&google__protobuf__FeatureSet__VisibilityFeature_msg_init,
|
|
2421
|
+
&google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init,
|
|
2191
2422
|
&google__protobuf__FeatureSetDefaults_msg_init,
|
|
2192
2423
|
&google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init,
|
|
2193
2424
|
&google__protobuf__SourceCodeInfo_msg_init,
|
|
@@ -2196,7 +2427,7 @@ static const upb_MiniTable *messages_layout[34] = {
|
|
|
2196
2427
|
&google__protobuf__GeneratedCodeInfo__Annotation_msg_init,
|
|
2197
2428
|
};
|
|
2198
2429
|
|
|
2199
|
-
static const upb_MiniTableEnum *enums_layout[
|
|
2430
|
+
static const upb_MiniTableEnum *enums_layout[21] = {
|
|
2200
2431
|
&google__protobuf__Edition_enum_init,
|
|
2201
2432
|
&google__protobuf__ExtensionRangeOptions__VerificationState_enum_init,
|
|
2202
2433
|
&google__protobuf__FeatureSet__EnforceNamingStyle_enum_init,
|
|
@@ -2204,6 +2435,7 @@ static const upb_MiniTableEnum *enums_layout[20] = {
|
|
|
2204
2435
|
&google__protobuf__FeatureSet__FieldPresence_enum_init,
|
|
2205
2436
|
&google__protobuf__FeatureSet__JsonFormat_enum_init,
|
|
2206
2437
|
&google__protobuf__FeatureSet__MessageEncoding_enum_init,
|
|
2438
|
+
&google__protobuf__FeatureSet__ProtoLimitsFeature__EnforceProtoLimits_enum_init,
|
|
2207
2439
|
&google__protobuf__FeatureSet__RepeatedFieldEncoding_enum_init,
|
|
2208
2440
|
&google__protobuf__FeatureSet__Utf8Validation_enum_init,
|
|
2209
2441
|
&google__protobuf__FeatureSet__VisibilityFeature__DefaultSymbolVisibility_enum_init,
|
|
@@ -2223,8 +2455,8 @@ const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout = {
|
|
|
2223
2455
|
messages_layout,
|
|
2224
2456
|
enums_layout,
|
|
2225
2457
|
NULL,
|
|
2226
|
-
|
|
2227
|
-
|
|
2458
|
+
35,
|
|
2459
|
+
21,
|
|
2228
2460
|
0,
|
|
2229
2461
|
};
|
|
2230
2462
|
|
|
@@ -2296,17 +2528,6 @@ void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
|
|
|
2296
2528
|
|
|
2297
2529
|
// Must be last.
|
|
2298
2530
|
|
|
2299
|
-
#define UPB_MAXARRSIZE 16 // 2**16 = 64k.
|
|
2300
|
-
|
|
2301
|
-
// From Chromium.
|
|
2302
|
-
#define ARRAY_SIZE(x) \
|
|
2303
|
-
((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
|
|
2304
|
-
|
|
2305
|
-
/* The minimum utilization of the array part of a mixed hash/array table. This
|
|
2306
|
-
* is a speed/memory-usage tradeoff (though it's not straightforward because of
|
|
2307
|
-
* cache effects). The lower this is, the more memory we'll use. */
|
|
2308
|
-
static const double MIN_DENSITY = 0.1;
|
|
2309
|
-
|
|
2310
2531
|
#if defined(__has_builtin)
|
|
2311
2532
|
#if __has_builtin(__builtin_popcount)
|
|
2312
2533
|
#define UPB_FAST_POPCOUNT32(i) __builtin_popcount(i)
|
|
@@ -2337,16 +2558,6 @@ UPB_INLINE uint8_t _upb_log2_table_size(upb_table* t) {
|
|
|
2337
2558
|
return _upb_popcnt32(t->mask);
|
|
2338
2559
|
}
|
|
2339
2560
|
|
|
2340
|
-
static bool is_pow2(uint64_t v) { return v == 0 || (v & (v - 1)) == 0; }
|
|
2341
|
-
|
|
2342
|
-
static int log2ceil(uint64_t v) {
|
|
2343
|
-
int ret = 0;
|
|
2344
|
-
bool pow2 = is_pow2(v);
|
|
2345
|
-
while (v >>= 1) ret++;
|
|
2346
|
-
ret = pow2 ? ret : ret + 1; // Ceiling.
|
|
2347
|
-
return UPB_MIN(UPB_MAXARRSIZE, ret);
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
2561
|
/* A type to represent the lookup key of either a strtable, inttable or
|
|
2351
2562
|
* exttable. */
|
|
2352
2563
|
typedef union {
|
|
@@ -2380,13 +2591,13 @@ static uint32_t upb_inthash(uintptr_t key) {
|
|
|
2380
2591
|
UPB_STATIC_ASSERT(sizeof(uintptr_t) == 4 || sizeof(uintptr_t) == 8,
|
|
2381
2592
|
"Pointers don't fit");
|
|
2382
2593
|
if (sizeof(uintptr_t) == 8) {
|
|
2383
|
-
return (uint32_t)key ^ (uint32_t)(key >> 32);
|
|
2594
|
+
return (uint32_t)key ^ (uint32_t)((uint64_t)key >> 32);
|
|
2384
2595
|
} else {
|
|
2385
2596
|
return (uint32_t)key;
|
|
2386
2597
|
}
|
|
2387
2598
|
}
|
|
2388
2599
|
|
|
2389
|
-
static
|
|
2600
|
+
static upb_tabent* upb_getentry(const upb_table* t, uint32_t hash) {
|
|
2390
2601
|
return t->entries + (hash & t->mask);
|
|
2391
2602
|
}
|
|
2392
2603
|
|
|
@@ -2401,7 +2612,7 @@ static bool init(upb_table* t, uint8_t size_lg2, upb_Arena* a) {
|
|
|
2401
2612
|
return false;
|
|
2402
2613
|
}
|
|
2403
2614
|
t->count = 0;
|
|
2404
|
-
uint32_t size =
|
|
2615
|
+
uint32_t size = 1U << size_lg2;
|
|
2405
2616
|
t->mask = size - 1; // 0 mask if size_lg2 is 0
|
|
2406
2617
|
if (upb_table_size(t) > (SIZE_MAX / sizeof(upb_tabent))) {
|
|
2407
2618
|
return false;
|
|
@@ -2431,25 +2642,26 @@ static upb_tabent* emptyent(upb_table* t, upb_tabent* e) {
|
|
|
2431
2642
|
}
|
|
2432
2643
|
|
|
2433
2644
|
static upb_tabent* getentry_mutable(upb_table* t, uint32_t hash) {
|
|
2434
|
-
return
|
|
2645
|
+
return upb_getentry(t, hash);
|
|
2435
2646
|
}
|
|
2436
2647
|
|
|
2437
|
-
static
|
|
2438
|
-
|
|
2439
|
-
|
|
2648
|
+
static upb_tabent* findentry(const upb_table* t, lookupkey_t key, uint32_t hash,
|
|
2649
|
+
eqlfunc_t* eql) {
|
|
2650
|
+
upb_tabent* e;
|
|
2440
2651
|
|
|
2441
2652
|
if (t->count == 0) return NULL;
|
|
2442
2653
|
e = upb_getentry(t, hash);
|
|
2443
2654
|
if (upb_tabent_isempty(e)) return NULL;
|
|
2444
2655
|
while (1) {
|
|
2445
2656
|
if (eql(e->key, e->val, key)) return e;
|
|
2446
|
-
if ((e
|
|
2657
|
+
if (!upb_tabent_hasnext(e)) return NULL;
|
|
2658
|
+
e = upb_tabent_next(e);
|
|
2447
2659
|
}
|
|
2448
2660
|
}
|
|
2449
2661
|
|
|
2450
2662
|
static upb_tabent* findentry_mutable(upb_table* t, lookupkey_t key,
|
|
2451
2663
|
uint32_t hash, eqlfunc_t* eql) {
|
|
2452
|
-
return
|
|
2664
|
+
return findentry(t, key, hash, eql);
|
|
2453
2665
|
}
|
|
2454
2666
|
|
|
2455
2667
|
static bool lookup(const upb_table* t, lookupkey_t key, upb_value* v,
|
|
@@ -2477,7 +2689,7 @@ static void insert(upb_table* t, lookupkey_t key, upb_key tabkey, upb_value val,
|
|
|
2477
2689
|
|
|
2478
2690
|
if (upb_tabent_isempty(mainpos_e)) {
|
|
2479
2691
|
/* Our main position is empty; use it. */
|
|
2480
|
-
our_e
|
|
2692
|
+
upb_tabent_clearnext(our_e);
|
|
2481
2693
|
} else {
|
|
2482
2694
|
/* Collision. */
|
|
2483
2695
|
upb_tabent* new_e = emptyent(t, mainpos_e);
|
|
@@ -2488,21 +2700,32 @@ static void insert(upb_table* t, lookupkey_t key, upb_key tabkey, upb_value val,
|
|
|
2488
2700
|
/* Existing ent is in its main position (it has the same hash as us, and
|
|
2489
2701
|
* is the head of our chain). Insert to new ent and append to this chain.
|
|
2490
2702
|
*/
|
|
2491
|
-
|
|
2492
|
-
|
|
2703
|
+
if (upb_tabent_hasnext(mainpos_e)) {
|
|
2704
|
+
upb_tabent_setnext(new_e, upb_tabent_next(mainpos_e));
|
|
2705
|
+
} else {
|
|
2706
|
+
upb_tabent_clearnext(new_e);
|
|
2707
|
+
}
|
|
2708
|
+
upb_tabent_setnext(mainpos_e, new_e);
|
|
2493
2709
|
our_e = new_e;
|
|
2494
2710
|
} else {
|
|
2495
2711
|
/* Existing ent is not in its main position (it is a node in some other
|
|
2496
2712
|
* chain). This implies that no existing ent in the table has our hash.
|
|
2497
2713
|
* Evict it (updating its chain) and use its ent for head of our chain. */
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2714
|
+
new_e->key = mainpos_e->key;
|
|
2715
|
+
new_e->val = mainpos_e->val;
|
|
2716
|
+
if (upb_tabent_hasnext(mainpos_e)) {
|
|
2717
|
+
upb_tabent_setnext(new_e, upb_tabent_next(mainpos_e));
|
|
2718
|
+
} else {
|
|
2719
|
+
upb_tabent_clearnext(new_e);
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
while (upb_tabent_hasnext(chain) && upb_tabent_next(chain) != mainpos_e) {
|
|
2723
|
+
chain = upb_tabent_next(chain);
|
|
2501
2724
|
UPB_ASSERT(chain);
|
|
2502
2725
|
}
|
|
2503
|
-
chain
|
|
2726
|
+
upb_tabent_setnext(chain, new_e);
|
|
2504
2727
|
our_e = mainpos_e;
|
|
2505
|
-
our_e
|
|
2728
|
+
upb_tabent_clearnext(our_e);
|
|
2506
2729
|
}
|
|
2507
2730
|
}
|
|
2508
2731
|
our_e->key = tabkey;
|
|
@@ -2518,27 +2741,40 @@ static bool rm(upb_table* t, lookupkey_t key, upb_value* val, uint32_t hash,
|
|
|
2518
2741
|
/* Element to remove is at the head of its chain. */
|
|
2519
2742
|
t->count--;
|
|
2520
2743
|
if (val) *val = chain->val;
|
|
2521
|
-
if (chain
|
|
2522
|
-
upb_tabent* move = (
|
|
2523
|
-
|
|
2524
|
-
|
|
2744
|
+
if (upb_tabent_hasnext(chain)) {
|
|
2745
|
+
upb_tabent* move = upb_tabent_next(chain);
|
|
2746
|
+
chain->key = move->key;
|
|
2747
|
+
chain->val = move->val;
|
|
2748
|
+
if (upb_tabent_hasnext(move)) {
|
|
2749
|
+
upb_tabent_setnext(chain, upb_tabent_next(move));
|
|
2750
|
+
} else {
|
|
2751
|
+
upb_tabent_clearnext(chain);
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
upb_tabent_clear(move);
|
|
2525
2755
|
} else {
|
|
2526
|
-
chain
|
|
2756
|
+
upb_tabent_clear(chain);
|
|
2527
2757
|
}
|
|
2528
2758
|
return true;
|
|
2529
2759
|
} else {
|
|
2530
2760
|
/* Element to remove is either in a non-head position or not in the
|
|
2531
2761
|
* table. */
|
|
2532
|
-
while (
|
|
2533
|
-
|
|
2762
|
+
while (
|
|
2763
|
+
upb_tabent_hasnext(chain) &&
|
|
2764
|
+
!eql(upb_tabent_next(chain)->key, upb_tabent_next(chain)->val, key)) {
|
|
2765
|
+
chain = upb_tabent_next(chain);
|
|
2534
2766
|
}
|
|
2535
|
-
if (chain
|
|
2767
|
+
if (upb_tabent_hasnext(chain)) {
|
|
2536
2768
|
/* Found element to remove. */
|
|
2537
|
-
upb_tabent* rm = (
|
|
2769
|
+
upb_tabent* rm = upb_tabent_next(chain);
|
|
2538
2770
|
t->count--;
|
|
2539
|
-
if (val) *val =
|
|
2540
|
-
|
|
2541
|
-
|
|
2771
|
+
if (val) *val = rm->val;
|
|
2772
|
+
if (upb_tabent_hasnext(rm)) {
|
|
2773
|
+
upb_tabent_setnext(chain, upb_tabent_next(rm));
|
|
2774
|
+
} else {
|
|
2775
|
+
upb_tabent_clearnext(chain);
|
|
2776
|
+
}
|
|
2777
|
+
upb_tabent_clear(rm);
|
|
2542
2778
|
return true;
|
|
2543
2779
|
} else {
|
|
2544
2780
|
/* Element to remove is not in the table. */
|
|
@@ -2557,6 +2793,74 @@ static size_t next(const upb_table* t, size_t i) {
|
|
|
2557
2793
|
|
|
2558
2794
|
static size_t begin(const upb_table* t) { return next(t, -1); }
|
|
2559
2795
|
|
|
2796
|
+
UPB_FORCEINLINE
|
|
2797
|
+
bool _upb_tablenext(const upb_table* t, upb_tabent** ent, intptr_t* iter) {
|
|
2798
|
+
size_t tab_idx = next(t, *iter);
|
|
2799
|
+
if (tab_idx < upb_table_size(t)) {
|
|
2800
|
+
*ent = &t->entries[tab_idx];
|
|
2801
|
+
*iter = tab_idx;
|
|
2802
|
+
return true;
|
|
2803
|
+
}
|
|
2804
|
+
return false;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
UPB_FORCEINLINE
|
|
2808
|
+
bool _upb_table_done(const upb_table* t, intptr_t iter) {
|
|
2809
|
+
if (iter == INTPTR_MAX - 1 || (size_t)iter >= upb_table_size(t)) {
|
|
2810
|
+
return true;
|
|
2811
|
+
}
|
|
2812
|
+
return upb_tabent_isempty(&t->entries[iter]);
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
static void removeiter(upb_table* t, intptr_t* iter) {
|
|
2816
|
+
intptr_t i = *iter;
|
|
2817
|
+
upb_tabent* ent = &t->entries[i];
|
|
2818
|
+
upb_tabent* prev = NULL;
|
|
2819
|
+
|
|
2820
|
+
// Linear search, not great.
|
|
2821
|
+
upb_tabent* end = &t->entries[upb_table_size(t)];
|
|
2822
|
+
for (upb_tabent* e = t->entries; e != end; e++) {
|
|
2823
|
+
if (!upb_tabent_isempty(e) && upb_tabent_hasnext(e) &&
|
|
2824
|
+
upb_tabent_next(e) == ent) {
|
|
2825
|
+
prev = e;
|
|
2826
|
+
break;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
if (prev) {
|
|
2831
|
+
if (upb_tabent_hasnext(ent)) {
|
|
2832
|
+
upb_tabent_setnext(prev, upb_tabent_next(ent));
|
|
2833
|
+
} else {
|
|
2834
|
+
upb_tabent_clearnext(prev);
|
|
2835
|
+
}
|
|
2836
|
+
} else {
|
|
2837
|
+
// ent is the head of the chain, so we need to move its next element into
|
|
2838
|
+
// its slot if there is one.
|
|
2839
|
+
if (upb_tabent_hasnext(ent)) {
|
|
2840
|
+
upb_tabent* move = upb_tabent_next(ent);
|
|
2841
|
+
ent->key = move->key;
|
|
2842
|
+
ent->val = move->val;
|
|
2843
|
+
if (upb_tabent_hasnext(move)) {
|
|
2844
|
+
upb_tabent_setnext(ent, upb_tabent_next(move));
|
|
2845
|
+
} else {
|
|
2846
|
+
upb_tabent_clearnext(ent);
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
// If we moved an element from a higher index to a lower index, then we've
|
|
2850
|
+
// moved an element we haven't visited yet into the slot of the one that
|
|
2851
|
+
// was just removed; decrement iter so that the iterator visits it.
|
|
2852
|
+
if (move > ent) {
|
|
2853
|
+
*iter = i - 1;
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
ent = move;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
t->count--;
|
|
2861
|
+
upb_tabent_clear(ent);
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2560
2864
|
/* upb_strtable ***************************************************************/
|
|
2561
2865
|
|
|
2562
2866
|
// A simple "subclass" of upb_table that only adds a hash function for strings.
|
|
@@ -2832,8 +3136,7 @@ void upb_strtable_next(upb_strtable_iter* i) {
|
|
|
2832
3136
|
|
|
2833
3137
|
bool upb_strtable_done(const upb_strtable_iter* i) {
|
|
2834
3138
|
if (!i->t) return true;
|
|
2835
|
-
return
|
|
2836
|
-
upb_tabent_isempty(str_tabent(i));
|
|
3139
|
+
return _upb_table_done(&i->t->t, i->index);
|
|
2837
3140
|
}
|
|
2838
3141
|
|
|
2839
3142
|
upb_StringView upb_strtable_iter_key(const upb_strtable_iter* i) {
|
|
@@ -2859,39 +3162,17 @@ bool upb_strtable_iter_isequal(const upb_strtable_iter* i1,
|
|
|
2859
3162
|
|
|
2860
3163
|
bool upb_strtable_next2(const upb_strtable* t, upb_StringView* key,
|
|
2861
3164
|
upb_value* val, intptr_t* iter) {
|
|
2862
|
-
|
|
2863
|
-
if (
|
|
2864
|
-
upb_tabent* ent = &t->t.entries[tab_idx];
|
|
3165
|
+
upb_tabent* ent;
|
|
3166
|
+
if (_upb_tablenext(&t->t, &ent, iter)) {
|
|
2865
3167
|
*key = upb_key_strview(ent->key);
|
|
2866
3168
|
*val = ent->val;
|
|
2867
|
-
*iter = tab_idx;
|
|
2868
3169
|
return true;
|
|
2869
3170
|
}
|
|
2870
|
-
|
|
2871
3171
|
return false;
|
|
2872
3172
|
}
|
|
2873
3173
|
|
|
2874
3174
|
void upb_strtable_removeiter(upb_strtable* t, intptr_t* iter) {
|
|
2875
|
-
|
|
2876
|
-
upb_tabent* ent = &t->t.entries[i];
|
|
2877
|
-
upb_tabent* prev = NULL;
|
|
2878
|
-
|
|
2879
|
-
// Linear search, not great.
|
|
2880
|
-
upb_tabent* end = &t->t.entries[upb_table_size(&t->t)];
|
|
2881
|
-
for (upb_tabent* e = t->t.entries; e != end; e++) {
|
|
2882
|
-
if (e->next == ent) {
|
|
2883
|
-
prev = e;
|
|
2884
|
-
break;
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
|
|
2888
|
-
if (prev) {
|
|
2889
|
-
prev->next = ent->next;
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
|
-
t->t.count--;
|
|
2893
|
-
ent->key = upb_key_empty();
|
|
2894
|
-
ent->next = NULL;
|
|
3175
|
+
removeiter(&t->t, iter);
|
|
2895
3176
|
}
|
|
2896
3177
|
|
|
2897
3178
|
void upb_strtable_setentryvalue(upb_strtable* t, intptr_t iter, upb_value v) {
|
|
@@ -2992,18 +3273,6 @@ size_t upb_exttable_size(const upb_exttable* t) { return t->t.count; }
|
|
|
2992
3273
|
|
|
2993
3274
|
/* upb_inttable ***************************************************************/
|
|
2994
3275
|
|
|
2995
|
-
/* For inttables we use a hybrid structure where small keys are kept in an
|
|
2996
|
-
* array and large keys are put in the hash table. */
|
|
2997
|
-
|
|
2998
|
-
// The sentinel value used in the dense array part. Note that callers must
|
|
2999
|
-
// ensure that inttable is never used with a value of this sentinel type
|
|
3000
|
-
// (pointers and u32 values will never be; i32 needs to be handled carefully
|
|
3001
|
-
// to avoid sign-extending into this value).
|
|
3002
|
-
static const upb_value kInttableSentinel = {.val = UINT64_MAX};
|
|
3003
|
-
static uint32_t presence_mask_arr_size(uint32_t array_size) {
|
|
3004
|
-
return (array_size + 7) / 8; // sizeof(uint8_t) is always 1.
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
3276
|
static uint32_t inthash(upb_key key, upb_value val) {
|
|
3008
3277
|
UPB_UNUSED(val);
|
|
3009
3278
|
return upb_inthash(key.num);
|
|
@@ -3014,35 +3283,7 @@ static bool inteql(upb_key k1, upb_value v1, lookupkey_t k2) {
|
|
|
3014
3283
|
return k1.num == k2.num;
|
|
3015
3284
|
}
|
|
3016
3285
|
|
|
3017
|
-
|
|
3018
|
-
return (upb_value*)t->array;
|
|
3019
|
-
}
|
|
3020
|
-
|
|
3021
|
-
static const upb_value* inttable_array_get(const upb_inttable* t,
|
|
3022
|
-
uintptr_t key) {
|
|
3023
|
-
UPB_ASSERT(key < t->array_size);
|
|
3024
|
-
const upb_value* val = &t->array[key];
|
|
3025
|
-
return upb_inttable_arrhas(t, key) ? val : NULL;
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
static upb_value* inttable_val(upb_inttable* t, uintptr_t key) {
|
|
3029
|
-
if (key < t->array_size) {
|
|
3030
|
-
return (upb_value*)inttable_array_get(t, key);
|
|
3031
|
-
} else {
|
|
3032
|
-
upb_tabent* e =
|
|
3033
|
-
findentry_mutable(&t->t, intkey(key), upb_inthash(key), &inteql);
|
|
3034
|
-
return e ? &e->val : NULL;
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
|
-
static const upb_value* inttable_val_const(const upb_inttable* t,
|
|
3039
|
-
uintptr_t key) {
|
|
3040
|
-
return inttable_val((upb_inttable*)t, key);
|
|
3041
|
-
}
|
|
3042
|
-
|
|
3043
|
-
size_t upb_inttable_count(const upb_inttable* t) {
|
|
3044
|
-
return t->t.count + t->array_count;
|
|
3045
|
-
}
|
|
3286
|
+
size_t upb_inttable_count(const upb_inttable* t) { return t->t.count; }
|
|
3046
3287
|
|
|
3047
3288
|
static void check(upb_inttable* t) {
|
|
3048
3289
|
UPB_UNUSED(t);
|
|
@@ -3055,295 +3296,106 @@ static void check(upb_inttable* t) {
|
|
|
3055
3296
|
upb_value val;
|
|
3056
3297
|
while (upb_inttable_next(t, &key, &val, &iter)) {
|
|
3057
3298
|
UPB_ASSERT(upb_inttable_lookup(t, key, NULL));
|
|
3299
|
+
count++;
|
|
3058
3300
|
}
|
|
3059
3301
|
UPB_ASSERT(count == upb_inttable_count(t));
|
|
3060
3302
|
}
|
|
3061
3303
|
#endif
|
|
3062
3304
|
}
|
|
3063
3305
|
|
|
3064
|
-
bool upb_inttable_sizedinit(upb_inttable* t,
|
|
3065
|
-
|
|
3306
|
+
static bool upb_inttable_sizedinit(upb_inttable* t, int hsize_lg2,
|
|
3307
|
+
upb_Arena* a) {
|
|
3066
3308
|
if (!init(&t->t, hsize_lg2, a)) return false;
|
|
3067
|
-
/* Always make the array part at least 1 long, so that we know key 0
|
|
3068
|
-
* won't be in the hash part, which simplifies things. */
|
|
3069
|
-
t->array_size = UPB_MAX(1, asize);
|
|
3070
|
-
t->array_count = 0;
|
|
3071
|
-
#if UINT32_MAX >= SIZE_MAX
|
|
3072
|
-
if (UPB_UNLIKELY(SIZE_MAX / sizeof(upb_value) < t->array_size)) {
|
|
3073
|
-
return false;
|
|
3074
|
-
}
|
|
3075
|
-
#endif
|
|
3076
|
-
|
|
3077
|
-
// Allocate the array part and the presence mask array in one allocation.
|
|
3078
|
-
size_t array_bytes = t->array_size * sizeof(upb_value);
|
|
3079
|
-
uint32_t presence_bytes = presence_mask_arr_size(t->array_size);
|
|
3080
|
-
uintptr_t total_bytes = array_bytes + presence_bytes;
|
|
3081
|
-
if (UPB_UNLIKELY(total_bytes > SIZE_MAX)) {
|
|
3082
|
-
return false;
|
|
3083
|
-
}
|
|
3084
|
-
void* alloc = upb_Arena_Malloc(a, total_bytes);
|
|
3085
|
-
if (!alloc) {
|
|
3086
|
-
return false;
|
|
3087
|
-
}
|
|
3088
|
-
t->array = alloc;
|
|
3089
|
-
memset(mutable_array(t), 0xff, array_bytes);
|
|
3090
|
-
t->presence_mask = (uint8_t*)alloc + array_bytes;
|
|
3091
|
-
memset((uint8_t*)t->presence_mask, 0, presence_bytes);
|
|
3092
|
-
|
|
3093
3309
|
check(t);
|
|
3094
3310
|
return true;
|
|
3095
3311
|
}
|
|
3096
3312
|
|
|
3097
3313
|
bool upb_inttable_init(upb_inttable* t, upb_Arena* a) {
|
|
3098
|
-
|
|
3099
|
-
return upb_inttable_sizedinit(t, 0, 3, a);
|
|
3314
|
+
return upb_inttable_sizedinit(t, 3, a);
|
|
3100
3315
|
}
|
|
3101
3316
|
|
|
3102
3317
|
bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val,
|
|
3103
3318
|
upb_Arena* a) {
|
|
3104
|
-
if (
|
|
3105
|
-
|
|
3106
|
-
t->array_count++;
|
|
3107
|
-
mutable_array(t)[key] = val;
|
|
3108
|
-
((uint8_t*)t->presence_mask)[key / 8] |= (1 << (key % 8));
|
|
3109
|
-
} else {
|
|
3110
|
-
if (isfull(&t->t)) {
|
|
3111
|
-
/* Need to resize the hash part, but we re-use the array part. */
|
|
3112
|
-
size_t i;
|
|
3113
|
-
upb_table new_table;
|
|
3319
|
+
if (isfull(&t->t)) {
|
|
3320
|
+
upb_table new_table;
|
|
3114
3321
|
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3322
|
+
if (!init(&new_table, _upb_log2_table_size(&t->t) + 1, a)) {
|
|
3323
|
+
return false;
|
|
3324
|
+
}
|
|
3118
3325
|
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3326
|
+
for (size_t i = begin(&t->t); i < upb_table_size(&t->t);
|
|
3327
|
+
i = next(&t->t, i)) {
|
|
3328
|
+
const upb_tabent* e = &t->t.entries[i];
|
|
3329
|
+
insert(&new_table, intkey(e->key.num), e->key, e->val,
|
|
3330
|
+
inthash(e->key, e->val), &inthash, &inteql);
|
|
3331
|
+
}
|
|
3124
3332
|
|
|
3125
|
-
|
|
3333
|
+
UPB_ASSERT(t->t.count == new_table.count);
|
|
3126
3334
|
|
|
3127
|
-
|
|
3128
|
-
}
|
|
3129
|
-
upb_key tabkey = {.num = key};
|
|
3130
|
-
insert(&t->t, intkey(key), tabkey, val, upb_inthash(key), &inthash,
|
|
3131
|
-
&inteql);
|
|
3335
|
+
t->t = new_table;
|
|
3132
3336
|
}
|
|
3337
|
+
upb_key tabkey = {.num = key};
|
|
3338
|
+
insert(&t->t, intkey(key), tabkey, val, upb_inthash(key), &inthash, &inteql);
|
|
3133
3339
|
check(t);
|
|
3134
3340
|
return true;
|
|
3135
3341
|
}
|
|
3136
3342
|
|
|
3137
3343
|
bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v) {
|
|
3138
|
-
|
|
3139
|
-
if (!table_v) return false;
|
|
3140
|
-
if (v) *v = *table_v;
|
|
3141
|
-
return true;
|
|
3344
|
+
return lookup(&t->t, intkey(key), v, upb_inthash(key), &inteql);
|
|
3142
3345
|
}
|
|
3143
3346
|
|
|
3144
3347
|
bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val) {
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3348
|
+
upb_tabent* e =
|
|
3349
|
+
findentry_mutable(&t->t, intkey(key), upb_inthash(key), &inteql);
|
|
3350
|
+
if (!e) return false;
|
|
3351
|
+
e->val = val;
|
|
3148
3352
|
return true;
|
|
3149
3353
|
}
|
|
3150
3354
|
|
|
3151
3355
|
bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val) {
|
|
3152
|
-
bool success;
|
|
3153
|
-
if (key < t->array_size) {
|
|
3154
|
-
if (upb_inttable_arrhas(t, key)) {
|
|
3155
|
-
t->array_count--;
|
|
3156
|
-
if (val) {
|
|
3157
|
-
*val = t->array[key];
|
|
3158
|
-
}
|
|
3159
|
-
mutable_array(t)[key] = kInttableSentinel;
|
|
3160
|
-
((uint8_t*)t->presence_mask)[key / 8] &= ~(1 << (key % 8));
|
|
3161
|
-
success = true;
|
|
3162
|
-
} else {
|
|
3163
|
-
success = false;
|
|
3164
|
-
}
|
|
3165
|
-
} else {
|
|
3166
|
-
success = rm(&t->t, intkey(key), val, upb_inthash(key), &inteql);
|
|
3167
|
-
}
|
|
3356
|
+
bool success = rm(&t->t, intkey(key), val, upb_inthash(key), &inteql);
|
|
3168
3357
|
check(t);
|
|
3169
3358
|
return success;
|
|
3170
3359
|
}
|
|
3171
3360
|
|
|
3172
|
-
bool upb_inttable_compact(upb_inttable* t, upb_Arena* a) {
|
|
3173
|
-
/* A power-of-two histogram of the table keys. */
|
|
3174
|
-
uint32_t counts[UPB_MAXARRSIZE + 1] = {0};
|
|
3175
|
-
|
|
3176
|
-
/* The max key in each bucket. */
|
|
3177
|
-
uintptr_t max[UPB_MAXARRSIZE + 1] = {0};
|
|
3178
|
-
|
|
3179
|
-
{
|
|
3180
|
-
intptr_t iter = UPB_INTTABLE_BEGIN;
|
|
3181
|
-
uintptr_t key;
|
|
3182
|
-
upb_value val;
|
|
3183
|
-
while (upb_inttable_next(t, &key, &val, &iter)) {
|
|
3184
|
-
int bucket = log2ceil(key);
|
|
3185
|
-
max[bucket] = UPB_MAX(max[bucket], key);
|
|
3186
|
-
counts[bucket]++;
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
|
|
3190
|
-
/* Find the largest power of two that satisfies the MIN_DENSITY
|
|
3191
|
-
* definition (while actually having some keys). */
|
|
3192
|
-
uint32_t arr_count = upb_inttable_count(t);
|
|
3193
|
-
|
|
3194
|
-
// Scan all buckets except capped bucket
|
|
3195
|
-
int size_lg2 = ARRAY_SIZE(counts) - 1;
|
|
3196
|
-
for (; size_lg2 > 0; size_lg2--) {
|
|
3197
|
-
if (counts[size_lg2] == 0) {
|
|
3198
|
-
/* We can halve again without losing any entries. */
|
|
3199
|
-
continue;
|
|
3200
|
-
} else if (arr_count >= (1 << size_lg2) * MIN_DENSITY) {
|
|
3201
|
-
break;
|
|
3202
|
-
}
|
|
3203
|
-
|
|
3204
|
-
arr_count -= counts[size_lg2];
|
|
3205
|
-
}
|
|
3206
|
-
|
|
3207
|
-
UPB_ASSERT(arr_count <= upb_inttable_count(t));
|
|
3208
|
-
|
|
3209
|
-
upb_inttable new_t;
|
|
3210
|
-
{
|
|
3211
|
-
/* Insert all elements into new, perfectly-sized table. */
|
|
3212
|
-
uintptr_t arr_size = max[size_lg2] + 1; /* +1 so arr[max] will fit. */
|
|
3213
|
-
uint32_t hash_count = upb_inttable_count(t) - arr_count;
|
|
3214
|
-
size_t hash_size = hash_count ? _upb_entries_needed_for(hash_count) : 0;
|
|
3215
|
-
int hashsize_lg2 = log2ceil(hash_size);
|
|
3216
|
-
|
|
3217
|
-
if (!upb_inttable_sizedinit(&new_t, arr_size, hashsize_lg2, a)) {
|
|
3218
|
-
return false;
|
|
3219
|
-
}
|
|
3220
|
-
|
|
3221
|
-
{
|
|
3222
|
-
intptr_t iter = UPB_INTTABLE_BEGIN;
|
|
3223
|
-
uintptr_t key;
|
|
3224
|
-
upb_value val;
|
|
3225
|
-
while (upb_inttable_next(t, &key, &val, &iter)) {
|
|
3226
|
-
upb_inttable_insert(&new_t, key, val, a);
|
|
3227
|
-
}
|
|
3228
|
-
}
|
|
3229
|
-
|
|
3230
|
-
UPB_ASSERT(new_t.array_size == arr_size);
|
|
3231
|
-
}
|
|
3232
|
-
*t = new_t;
|
|
3233
|
-
return true;
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
3361
|
void upb_inttable_clear(upb_inttable* t) {
|
|
3237
|
-
// Clear the array part.
|
|
3238
|
-
size_t array_bytes = t->array_size * sizeof(upb_value);
|
|
3239
|
-
t->array_count = 0;
|
|
3240
|
-
// Clear the array by setting all bits to 1, as UINT64_MAX is the sentinel
|
|
3241
|
-
// value for an empty array.
|
|
3242
|
-
memset(mutable_array(t), 0xff, array_bytes);
|
|
3243
|
-
// Clear the presence mask array.
|
|
3244
|
-
memset((uint8_t*)t->presence_mask, 0, presence_mask_arr_size(t->array_size));
|
|
3245
|
-
// Clear the table part.
|
|
3246
3362
|
size_t bytes = upb_table_size(&t->t) * sizeof(upb_tabent);
|
|
3247
3363
|
t->t.count = 0;
|
|
3248
3364
|
memset((char*)t->t.entries, 0, bytes);
|
|
3249
3365
|
}
|
|
3250
3366
|
|
|
3251
|
-
// Iteration.
|
|
3252
|
-
|
|
3253
3367
|
bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val,
|
|
3254
3368
|
intptr_t* iter) {
|
|
3255
|
-
|
|
3256
|
-
if ((
|
|
3257
|
-
while ((size_t)++i < t->array_size) {
|
|
3258
|
-
const upb_value* ent = inttable_array_get(t, i);
|
|
3259
|
-
if (ent) {
|
|
3260
|
-
*key = i;
|
|
3261
|
-
*val = *ent;
|
|
3262
|
-
*iter = i;
|
|
3263
|
-
return true;
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
i--; // Back up to exactly one position before the start of the table.
|
|
3267
|
-
}
|
|
3268
|
-
|
|
3269
|
-
size_t tab_idx = next(&t->t, i - t->array_size);
|
|
3270
|
-
if (tab_idx < upb_table_size(&t->t)) {
|
|
3271
|
-
upb_tabent* ent = &t->t.entries[tab_idx];
|
|
3369
|
+
upb_tabent* ent;
|
|
3370
|
+
if (_upb_tablenext(&t->t, &ent, iter)) {
|
|
3272
3371
|
*key = ent->key.num;
|
|
3273
3372
|
*val = ent->val;
|
|
3274
|
-
*iter = tab_idx + t->array_size;
|
|
3275
3373
|
return true;
|
|
3276
|
-
} else {
|
|
3277
|
-
// We should set the iterator any way. When we are done, the iterator value
|
|
3278
|
-
// is invalidated. `upb_inttable_done` will check on the iterator value to
|
|
3279
|
-
// determine if the iteration is done.
|
|
3280
|
-
*iter = INTPTR_MAX - 1; // To disambiguate from UPB_INTTABLE_BEGIN, to
|
|
3281
|
-
// match the behavior of `upb_strtable_iter`.
|
|
3282
|
-
return false;
|
|
3283
3374
|
}
|
|
3375
|
+
*iter = INTPTR_MAX - 1;
|
|
3376
|
+
return false;
|
|
3284
3377
|
}
|
|
3285
3378
|
|
|
3286
3379
|
void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter) {
|
|
3287
|
-
|
|
3288
|
-
if ((size_t)i < t->array_size) {
|
|
3289
|
-
t->array_count--;
|
|
3290
|
-
mutable_array(t)[i].val = -1;
|
|
3291
|
-
} else {
|
|
3292
|
-
upb_tabent* ent = &t->t.entries[i - t->array_size];
|
|
3293
|
-
upb_tabent* prev = NULL;
|
|
3294
|
-
|
|
3295
|
-
// Linear search, not great.
|
|
3296
|
-
upb_tabent* end = &t->t.entries[upb_table_size(&t->t)];
|
|
3297
|
-
for (upb_tabent* e = t->t.entries; e != end; e++) {
|
|
3298
|
-
if (e->next == ent) {
|
|
3299
|
-
prev = e;
|
|
3300
|
-
break;
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
if (prev) {
|
|
3305
|
-
prev->next = ent->next;
|
|
3306
|
-
}
|
|
3307
|
-
|
|
3308
|
-
t->t.count--;
|
|
3309
|
-
ent->key = upb_key_empty();
|
|
3310
|
-
ent->next = NULL;
|
|
3311
|
-
}
|
|
3380
|
+
removeiter(&t->t, iter);
|
|
3312
3381
|
}
|
|
3313
3382
|
|
|
3314
3383
|
void upb_inttable_setentryvalue(upb_inttable* t, intptr_t iter, upb_value v) {
|
|
3315
|
-
|
|
3316
|
-
mutable_array(t)[iter] = v;
|
|
3317
|
-
} else {
|
|
3318
|
-
upb_tabent* ent = &t->t.entries[iter - t->array_size];
|
|
3319
|
-
ent->val = v;
|
|
3320
|
-
}
|
|
3384
|
+
t->t.entries[iter].val = v;
|
|
3321
3385
|
}
|
|
3322
3386
|
|
|
3323
3387
|
bool upb_inttable_done(const upb_inttable* t, intptr_t iter) {
|
|
3324
|
-
|
|
3325
|
-
return true;
|
|
3326
|
-
} else if ((size_t)iter < t->array_size) {
|
|
3327
|
-
return !upb_inttable_arrhas(t, iter);
|
|
3328
|
-
} else {
|
|
3329
|
-
return upb_tabent_isempty(&t->t.entries[iter - t->array_size]);
|
|
3330
|
-
}
|
|
3388
|
+
return _upb_table_done(&t->t, iter);
|
|
3331
3389
|
}
|
|
3332
3390
|
|
|
3333
3391
|
uintptr_t upb_inttable_iter_key(const upb_inttable* t, intptr_t iter) {
|
|
3334
3392
|
UPB_ASSERT(!upb_inttable_done(t, iter));
|
|
3335
|
-
return
|
|
3336
|
-
? iter
|
|
3337
|
-
: t->t.entries[iter - t->array_size].key.num;
|
|
3393
|
+
return t->t.entries[iter].key.num;
|
|
3338
3394
|
}
|
|
3339
3395
|
|
|
3340
3396
|
upb_value upb_inttable_iter_value(const upb_inttable* t, intptr_t iter) {
|
|
3341
3397
|
UPB_ASSERT(!upb_inttable_done(t, iter));
|
|
3342
|
-
|
|
3343
|
-
return t->array[iter];
|
|
3344
|
-
} else {
|
|
3345
|
-
return t->t.entries[iter - t->array_size].val;
|
|
3346
|
-
}
|
|
3398
|
+
return t->t.entries[iter].val;
|
|
3347
3399
|
}
|
|
3348
3400
|
|
|
3349
3401
|
|
|
@@ -3420,6 +3472,12 @@ UPB_NORETURN static void jsondec_err(jsondec* d, const char* msg) {
|
|
|
3420
3472
|
UPB_LONGJMP(d->err, 1);
|
|
3421
3473
|
}
|
|
3422
3474
|
|
|
3475
|
+
static void jsondec_checkoom(jsondec* d, bool ok) {
|
|
3476
|
+
if (UPB_UNLIKELY(!ok)) {
|
|
3477
|
+
jsondec_err(d, "Out of memory");
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3423
3481
|
UPB_PRINTF(2, 3)
|
|
3424
3482
|
UPB_NORETURN static void jsondec_errf(jsondec* d, const char* fmt, ...) {
|
|
3425
3483
|
va_list argp;
|
|
@@ -3751,10 +3809,12 @@ static size_t jsondec_unicode(jsondec* d, char* out) {
|
|
|
3751
3809
|
static void jsondec_resize(jsondec* d, char** buf, char** end, char** buf_end) {
|
|
3752
3810
|
size_t oldsize = *buf_end - *buf;
|
|
3753
3811
|
size_t len = *end - *buf;
|
|
3812
|
+
|
|
3813
|
+
jsondec_checkoom(d, oldsize <= SIZE_MAX / 2);
|
|
3754
3814
|
size_t size = UPB_MAX(8, 2 * oldsize);
|
|
3755
3815
|
|
|
3756
3816
|
*buf = upb_Arena_Realloc(d->arena, *buf, len, size);
|
|
3757
|
-
|
|
3817
|
+
jsondec_checkoom(d, *buf);
|
|
3758
3818
|
|
|
3759
3819
|
*end = *buf + len;
|
|
3760
3820
|
*buf_end = *buf + size;
|
|
@@ -3892,7 +3952,7 @@ static unsigned int jsondec_base64_tablelookup(const char ch) {
|
|
|
3892
3952
|
-1, -1, -1, -1};
|
|
3893
3953
|
|
|
3894
3954
|
/* Sign-extend return value so high bit will be set on any unexpected char. */
|
|
3895
|
-
return table[(unsigned)ch];
|
|
3955
|
+
return table[(unsigned char)ch];
|
|
3896
3956
|
}
|
|
3897
3957
|
|
|
3898
3958
|
static char* jsondec_partialbase64(jsondec* d, const char* ptr, const char* end,
|
|
@@ -4214,12 +4274,13 @@ static upb_MessageValue jsondec_bool(jsondec* d, const upb_FieldDef* f) {
|
|
|
4214
4274
|
static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
4215
4275
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
4216
4276
|
upb_Array* arr = upb_Message_Mutable(msg, f, d->arena).array;
|
|
4277
|
+
jsondec_checkoom(d, arr);
|
|
4217
4278
|
|
|
4218
4279
|
jsondec_arrstart(d);
|
|
4219
4280
|
while (jsondec_arrnext(d)) {
|
|
4220
4281
|
upb_JsonMessageValue elem = jsondec_value(d, f);
|
|
4221
4282
|
if (!elem.ignore) {
|
|
4222
|
-
upb_Array_Append(arr, elem.value, d->arena);
|
|
4283
|
+
jsondec_checkoom(d, upb_Array_Append(arr, elem.value, d->arena));
|
|
4223
4284
|
}
|
|
4224
4285
|
}
|
|
4225
4286
|
jsondec_arrend(d);
|
|
@@ -4228,6 +4289,7 @@ static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
|
4228
4289
|
static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
4229
4290
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
4230
4291
|
upb_Map* map = upb_Message_Mutable(msg, f, d->arena).map;
|
|
4292
|
+
jsondec_checkoom(d, map);
|
|
4231
4293
|
const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f);
|
|
4232
4294
|
const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry, 1);
|
|
4233
4295
|
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry, 2);
|
|
@@ -4240,7 +4302,7 @@ static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
|
4240
4302
|
jsondec_entrysep(d);
|
|
4241
4303
|
val = jsondec_value(d, val_f);
|
|
4242
4304
|
if (!val.ignore) {
|
|
4243
|
-
upb_Map_Set(map, key.value, val.value, d->arena);
|
|
4305
|
+
jsondec_checkoom(d, upb_Map_Set(map, key.value, val.value, d->arena));
|
|
4244
4306
|
}
|
|
4245
4307
|
}
|
|
4246
4308
|
jsondec_objend(d);
|
|
@@ -4260,6 +4322,7 @@ static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) {
|
|
|
4260
4322
|
const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f);
|
|
4261
4323
|
const upb_MiniTable* layout = upb_MessageDef_MiniTable(m);
|
|
4262
4324
|
upb_Message* msg = upb_Message_New(layout, d->arena);
|
|
4325
|
+
jsondec_checkoom(d, msg);
|
|
4263
4326
|
upb_MessageValue val;
|
|
4264
4327
|
|
|
4265
4328
|
jsondec_tomsg(d, msg, m);
|
|
@@ -4321,12 +4384,14 @@ static void jsondec_field(jsondec* d, upb_Message* msg,
|
|
|
4321
4384
|
jsondec_array(d, msg, f);
|
|
4322
4385
|
} else if (upb_FieldDef_IsSubMessage(f)) {
|
|
4323
4386
|
upb_Message* submsg = upb_Message_Mutable(msg, f, d->arena).msg;
|
|
4387
|
+
jsondec_checkoom(d, submsg);
|
|
4324
4388
|
const upb_MessageDef* subm = upb_FieldDef_MessageSubDef(f);
|
|
4325
4389
|
jsondec_tomsg(d, submsg, subm);
|
|
4326
4390
|
} else {
|
|
4327
4391
|
upb_JsonMessageValue val = jsondec_value(d, f);
|
|
4328
4392
|
if (!val.ignore) {
|
|
4329
|
-
|
|
4393
|
+
jsondec_checkoom(d,
|
|
4394
|
+
upb_Message_SetFieldByDef(msg, f, val.value, d->arena));
|
|
4330
4395
|
}
|
|
4331
4396
|
}
|
|
4332
4397
|
|
|
@@ -4490,10 +4555,12 @@ static void jsondec_timestamp(jsondec* d, upb_Message* msg,
|
|
|
4490
4555
|
jsondec_err(d, "Timestamp out of range");
|
|
4491
4556
|
}
|
|
4492
4557
|
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4558
|
+
jsondec_checkoom(
|
|
4559
|
+
d, upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 1),
|
|
4560
|
+
seconds, d->arena));
|
|
4561
|
+
jsondec_checkoom(
|
|
4562
|
+
d, upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 2),
|
|
4563
|
+
nanos, d->arena));
|
|
4497
4564
|
return;
|
|
4498
4565
|
|
|
4499
4566
|
malformed:
|
|
@@ -4527,10 +4594,12 @@ static void jsondec_duration(jsondec* d, upb_Message* msg,
|
|
|
4527
4594
|
nanos.int32_val = -nanos.int32_val;
|
|
4528
4595
|
}
|
|
4529
4596
|
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4597
|
+
jsondec_checkoom(
|
|
4598
|
+
d, upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 1),
|
|
4599
|
+
seconds, d->arena));
|
|
4600
|
+
jsondec_checkoom(
|
|
4601
|
+
d, upb_Message_SetFieldByDef(msg, upb_MessageDef_FindFieldByNumber(m, 2),
|
|
4602
|
+
nanos, d->arena));
|
|
4534
4603
|
}
|
|
4535
4604
|
|
|
4536
4605
|
static void jsondec_listvalue(jsondec* d, upb_Message* msg,
|
|
@@ -4540,13 +4609,15 @@ static void jsondec_listvalue(jsondec* d, upb_Message* msg,
|
|
|
4540
4609
|
const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(values_f);
|
|
4541
4610
|
const upb_MiniTable* value_layout = upb_MessageDef_MiniTable(value_m);
|
|
4542
4611
|
upb_Array* values = upb_Message_Mutable(msg, values_f, d->arena).array;
|
|
4612
|
+
jsondec_checkoom(d, values);
|
|
4543
4613
|
|
|
4544
4614
|
jsondec_arrstart(d);
|
|
4545
4615
|
while (jsondec_arrnext(d)) {
|
|
4546
4616
|
upb_Message* value_msg = upb_Message_New(value_layout, d->arena);
|
|
4617
|
+
jsondec_checkoom(d, value_msg);
|
|
4547
4618
|
upb_MessageValue value;
|
|
4548
4619
|
value.msg_val = value_msg;
|
|
4549
|
-
upb_Array_Append(values, value, d->arena);
|
|
4620
|
+
jsondec_checkoom(d, upb_Array_Append(values, value, d->arena));
|
|
4550
4621
|
jsondec_wellknownvalue(d, value_msg, value_m);
|
|
4551
4622
|
}
|
|
4552
4623
|
jsondec_arrend(d);
|
|
@@ -4561,14 +4632,16 @@ static void jsondec_struct(jsondec* d, upb_Message* msg,
|
|
|
4561
4632
|
const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(value_f);
|
|
4562
4633
|
const upb_MiniTable* value_layout = upb_MessageDef_MiniTable(value_m);
|
|
4563
4634
|
upb_Map* fields = upb_Message_Mutable(msg, fields_f, d->arena).map;
|
|
4635
|
+
jsondec_checkoom(d, fields);
|
|
4564
4636
|
|
|
4565
4637
|
jsondec_objstart(d);
|
|
4566
4638
|
while (jsondec_objnext(d)) {
|
|
4567
4639
|
upb_MessageValue key, value;
|
|
4568
4640
|
upb_Message* value_msg = upb_Message_New(value_layout, d->arena);
|
|
4641
|
+
jsondec_checkoom(d, value_msg);
|
|
4569
4642
|
key.str_val = jsondec_string(d);
|
|
4570
4643
|
value.msg_val = value_msg;
|
|
4571
|
-
upb_Map_Set(fields, key, value, d->arena);
|
|
4644
|
+
jsondec_checkoom(d, upb_Map_Set(fields, key, value, d->arena));
|
|
4572
4645
|
jsondec_entrysep(d);
|
|
4573
4646
|
jsondec_wellknownvalue(d, value_msg, value_m);
|
|
4574
4647
|
}
|
|
@@ -4616,19 +4689,21 @@ static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
|
|
|
4616
4689
|
/* Struct struct_value = 5; */
|
|
4617
4690
|
f = upb_MessageDef_FindFieldByNumber(m, 5);
|
|
4618
4691
|
submsg = upb_Message_Mutable(msg, f, d->arena).msg;
|
|
4692
|
+
jsondec_checkoom(d, submsg);
|
|
4619
4693
|
jsondec_struct(d, submsg, upb_FieldDef_MessageSubDef(f));
|
|
4620
4694
|
return;
|
|
4621
4695
|
case JD_ARRAY:
|
|
4622
4696
|
/* ListValue list_value = 6; */
|
|
4623
4697
|
f = upb_MessageDef_FindFieldByNumber(m, 6);
|
|
4624
4698
|
submsg = upb_Message_Mutable(msg, f, d->arena).msg;
|
|
4699
|
+
jsondec_checkoom(d, submsg);
|
|
4625
4700
|
jsondec_listvalue(d, submsg, upb_FieldDef_MessageSubDef(f));
|
|
4626
4701
|
return;
|
|
4627
4702
|
default:
|
|
4628
4703
|
UPB_UNREACHABLE();
|
|
4629
4704
|
}
|
|
4630
4705
|
|
|
4631
|
-
upb_Message_SetFieldByDef(msg, f, val, d->arena);
|
|
4706
|
+
jsondec_checkoom(d, upb_Message_SetFieldByDef(msg, f, val, d->arena));
|
|
4632
4707
|
}
|
|
4633
4708
|
|
|
4634
4709
|
static upb_StringView jsondec_mask(jsondec* d, const char* buf,
|
|
@@ -4646,6 +4721,7 @@ static upb_StringView jsondec_mask(jsondec* d, const char* buf,
|
|
|
4646
4721
|
}
|
|
4647
4722
|
|
|
4648
4723
|
out = upb_Arena_Malloc(d->arena, ret.size);
|
|
4724
|
+
jsondec_checkoom(d, out || ret.size == 0);
|
|
4649
4725
|
ptr = buf;
|
|
4650
4726
|
ret.data = out;
|
|
4651
4727
|
|
|
@@ -4670,6 +4746,7 @@ static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
|
|
|
4670
4746
|
/* repeated string paths = 1; */
|
|
4671
4747
|
const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
|
4672
4748
|
upb_Array* arr = upb_Message_Mutable(msg, paths_f, d->arena).array;
|
|
4749
|
+
jsondec_checkoom(d, arr);
|
|
4673
4750
|
upb_StringView str = jsondec_string(d);
|
|
4674
4751
|
const char* ptr = str.data;
|
|
4675
4752
|
const char* end = ptr + str.size;
|
|
@@ -4684,7 +4761,7 @@ static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
|
|
|
4684
4761
|
val.str_val = jsondec_mask(d, ptr, end);
|
|
4685
4762
|
ptr = end;
|
|
4686
4763
|
}
|
|
4687
|
-
upb_Array_Append(arr, val, d->arena);
|
|
4764
|
+
jsondec_checkoom(d, upb_Array_Append(arr, val, d->arena));
|
|
4688
4765
|
}
|
|
4689
4766
|
}
|
|
4690
4767
|
|
|
@@ -4718,7 +4795,8 @@ static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg,
|
|
|
4718
4795
|
upb_MessageValue val;
|
|
4719
4796
|
|
|
4720
4797
|
val.str_val = type_url;
|
|
4721
|
-
|
|
4798
|
+
jsondec_checkoom(d,
|
|
4799
|
+
upb_Message_SetFieldByDef(msg, type_url_f, val, d->arena));
|
|
4722
4800
|
|
|
4723
4801
|
/* Find message name after the last '/' */
|
|
4724
4802
|
while (ptr > type_url.data && *--ptr != '/') {
|
|
@@ -4774,10 +4852,12 @@ static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {
|
|
|
4774
4852
|
|
|
4775
4853
|
const upb_MiniTable* any_layout = upb_MessageDef_MiniTable(any_m);
|
|
4776
4854
|
any_msg = upb_Message_New(any_layout, d->arena);
|
|
4855
|
+
jsondec_checkoom(d, any_msg);
|
|
4777
4856
|
|
|
4778
4857
|
if (pre_type_data) {
|
|
4779
4858
|
size_t len = pre_type_end - pre_type_data + 1;
|
|
4780
4859
|
char* tmp = upb_Arena_Malloc(d->arena, len);
|
|
4860
|
+
jsondec_checkoom(d, tmp);
|
|
4781
4861
|
const char* saved_ptr = d->ptr;
|
|
4782
4862
|
const char* saved_end = d->end;
|
|
4783
4863
|
memcpy(tmp, pre_type_data, len - 1);
|
|
@@ -4801,9 +4881,11 @@ static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {
|
|
|
4801
4881
|
upb_EncodeStatus status =
|
|
4802
4882
|
upb_Encode(any_msg, upb_MessageDef_MiniTable(any_m), 0, d->arena,
|
|
4803
4883
|
(char**)&encoded.str_val.data, &encoded.str_val.size);
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4884
|
+
if (status != kUpb_EncodeStatus_Ok) {
|
|
4885
|
+
jsondec_errf(d, "Encode failed: %s", upb_EncodeStatus_String(status));
|
|
4886
|
+
}
|
|
4887
|
+
jsondec_checkoom(d,
|
|
4888
|
+
upb_Message_SetFieldByDef(msg, value_f, encoded, d->arena));
|
|
4807
4889
|
}
|
|
4808
4890
|
|
|
4809
4891
|
static void jsondec_wrapper(jsondec* d, upb_Message* msg,
|
|
@@ -4812,7 +4894,8 @@ static void jsondec_wrapper(jsondec* d, upb_Message* msg,
|
|
|
4812
4894
|
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
|
4813
4895
|
upb_JsonMessageValue val = jsondec_value(d, value_f);
|
|
4814
4896
|
UPB_ASSUME(val.ignore == false); // Wrapper cannot be an enum.
|
|
4815
|
-
|
|
4897
|
+
jsondec_checkoom(
|
|
4898
|
+
d, upb_Message_SetFieldByDef(msg, value_f, val.value, d->arena));
|
|
4816
4899
|
}
|
|
4817
4900
|
|
|
4818
4901
|
static void jsondec_wellknown(jsondec* d, upb_Message* msg,
|
|
@@ -5306,10 +5389,17 @@ static void jsonenc_fieldpath(jsonenc* e, upb_StringView path) {
|
|
|
5306
5389
|
char ch = *ptr;
|
|
5307
5390
|
|
|
5308
5391
|
if (ch >= 'A' && ch <= 'Z') {
|
|
5309
|
-
jsonenc_err(e,
|
|
5392
|
+
jsonenc_err(e,
|
|
5393
|
+
"Field mask path containing an uppercase letter cannot be "
|
|
5394
|
+
"successfully round tripped through JSON format. See "
|
|
5395
|
+
"https://github.com/protocolbuffers/protobuf/issues/25786");
|
|
5310
5396
|
} else if (ch == '_') {
|
|
5311
5397
|
if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') {
|
|
5312
|
-
jsonenc_err(e,
|
|
5398
|
+
jsonenc_err(e,
|
|
5399
|
+
"Underscore in FieldMask path must be followed by a "
|
|
5400
|
+
"lowercase letter to successfully round trip through JSON "
|
|
5401
|
+
"format. See "
|
|
5402
|
+
"https://github.com/protocolbuffers/protobuf/issues/25786");
|
|
5313
5403
|
}
|
|
5314
5404
|
ch = *++ptr - 32;
|
|
5315
5405
|
}
|
|
@@ -5763,84 +5853,6 @@ void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size) {
|
|
|
5763
5853
|
}
|
|
5764
5854
|
|
|
5765
5855
|
|
|
5766
|
-
#include <stdlib.h>
|
|
5767
|
-
#include <string.h>
|
|
5768
|
-
|
|
5769
|
-
// Must be last.
|
|
5770
|
-
|
|
5771
|
-
// Determine the locale-specific radix character by calling sprintf() to print
|
|
5772
|
-
// the number 1.5, then stripping off the digits. As far as I can tell, this
|
|
5773
|
-
// is the only portable, thread-safe way to get the C library to divulge the
|
|
5774
|
-
// locale's radix character. No, localeconv() is NOT thread-safe.
|
|
5775
|
-
|
|
5776
|
-
static int GetLocaleRadix(char *data, size_t capacity) {
|
|
5777
|
-
char temp[16];
|
|
5778
|
-
const int size = snprintf(temp, sizeof(temp), "%.1f", 1.5);
|
|
5779
|
-
UPB_ASSERT(temp[0] == '1');
|
|
5780
|
-
UPB_ASSERT(temp[size - 1] == '5');
|
|
5781
|
-
if (size < capacity) {
|
|
5782
|
-
return 0;
|
|
5783
|
-
}
|
|
5784
|
-
temp[size - 1] = '\0';
|
|
5785
|
-
strncpy(data, temp + 1, size);
|
|
5786
|
-
return size - 2;
|
|
5787
|
-
}
|
|
5788
|
-
|
|
5789
|
-
// Populates a string identical to *input except that the character pointed to
|
|
5790
|
-
// by pos (which should be '.') is replaced with the locale-specific radix.
|
|
5791
|
-
|
|
5792
|
-
static void LocalizeRadix(const char *input, const char *pos, char *output,
|
|
5793
|
-
int output_size) {
|
|
5794
|
-
const int len1 = pos - input;
|
|
5795
|
-
|
|
5796
|
-
char radix[8];
|
|
5797
|
-
const int len2 = GetLocaleRadix(radix, sizeof(radix));
|
|
5798
|
-
|
|
5799
|
-
const int n = output_size - len1 - len2 - 1;
|
|
5800
|
-
if (n < 0) {
|
|
5801
|
-
return;
|
|
5802
|
-
}
|
|
5803
|
-
|
|
5804
|
-
memcpy(output, input, len1);
|
|
5805
|
-
memcpy(output + len1, radix, len2);
|
|
5806
|
-
strncpy(output + len1 + len2, input + len1 + 1, n);
|
|
5807
|
-
output[output_size - 1] = '\0';
|
|
5808
|
-
}
|
|
5809
|
-
|
|
5810
|
-
double _upb_NoLocaleStrtod(const char *str, char **endptr) {
|
|
5811
|
-
// We cannot simply set the locale to "C" temporarily with setlocale()
|
|
5812
|
-
// as this is not thread-safe. Instead, we try to parse in the current
|
|
5813
|
-
// locale first. If parsing stops at a '.' character, then this is a
|
|
5814
|
-
// pretty good hint that we're actually in some other locale in which
|
|
5815
|
-
// '.' is not the radix character.
|
|
5816
|
-
|
|
5817
|
-
char *temp_endptr;
|
|
5818
|
-
double result = strtod(str, &temp_endptr);
|
|
5819
|
-
if (endptr != NULL) *endptr = temp_endptr;
|
|
5820
|
-
if (*temp_endptr != '.') return result;
|
|
5821
|
-
|
|
5822
|
-
// Parsing halted on a '.'. Perhaps we're in a different locale? Let's
|
|
5823
|
-
// try to replace the '.' with a locale-specific radix character and
|
|
5824
|
-
// try again.
|
|
5825
|
-
|
|
5826
|
-
char localized[80];
|
|
5827
|
-
LocalizeRadix(str, temp_endptr, localized, sizeof localized);
|
|
5828
|
-
char *localized_endptr;
|
|
5829
|
-
result = strtod(localized, &localized_endptr);
|
|
5830
|
-
if ((localized_endptr - &localized[0]) > (temp_endptr - str)) {
|
|
5831
|
-
// This attempt got further, so replacing the decimal must have helped.
|
|
5832
|
-
// Update endptr to point at the right location.
|
|
5833
|
-
if (endptr != NULL) {
|
|
5834
|
-
// size_diff is non-zero if the localized radix has multiple bytes.
|
|
5835
|
-
int size_diff = strlen(localized) - strlen(str);
|
|
5836
|
-
*endptr = (char *)str + (localized_endptr - &localized[0] - size_diff);
|
|
5837
|
-
}
|
|
5838
|
-
}
|
|
5839
|
-
|
|
5840
|
-
return result;
|
|
5841
|
-
}
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
5856
|
// Must be last.
|
|
5845
5857
|
|
|
5846
5858
|
int upb_Unicode_ToUTF8(uint32_t cp, char* out) {
|
|
@@ -5899,6 +5911,7 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
|
|
|
5899
5911
|
|
|
5900
5912
|
#include <stddef.h>
|
|
5901
5913
|
#include <stdint.h>
|
|
5914
|
+
#include <string.h>
|
|
5902
5915
|
|
|
5903
5916
|
|
|
5904
5917
|
// Must be last.
|
|
@@ -6007,6 +6020,9 @@ typedef struct {
|
|
|
6007
6020
|
static const size_t kUpb_MemblockReserve =
|
|
6008
6021
|
UPB_ALIGN_MALLOC(sizeof(upb_MemBlock));
|
|
6009
6022
|
|
|
6023
|
+
static const size_t kUpb_ArenaStateReserve =
|
|
6024
|
+
UPB_ALIGN_MALLOC(sizeof(upb_ArenaState));
|
|
6025
|
+
|
|
6010
6026
|
static const size_t kUpb_ArenaRefReserve =
|
|
6011
6027
|
UPB_ALIGN_MALLOC(sizeof(upb_ArenaRef));
|
|
6012
6028
|
|
|
@@ -6246,22 +6262,31 @@ bool upb_Arena_HasRefChain(const upb_Arena* from, const upb_Arena* to) {
|
|
|
6246
6262
|
|
|
6247
6263
|
#endif
|
|
6248
6264
|
|
|
6249
|
-
static
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
upb_SizedPtr alloc_result = upb_SizeReturningMalloc(alloc, size);
|
|
6265
|
+
static void* _upb_Arena_AllocBlockInternal(upb_alloc* alloc, size_t* size) {
|
|
6266
|
+
size_t sz = *size + kUpb_MemblockReserve;
|
|
6267
|
+
upb_SizedPtr alloc_result = upb_SizeReturningMalloc(alloc, sz);
|
|
6253
6268
|
if (!alloc_result.p) return NULL;
|
|
6254
6269
|
upb_MemBlock* block = alloc_result.p;
|
|
6255
6270
|
block->size = alloc_result.n;
|
|
6256
|
-
|
|
6271
|
+
*size = alloc_result.n - kUpb_MemblockReserve;
|
|
6272
|
+
return UPB_PTR_AT(block, kUpb_MemblockReserve, void);
|
|
6257
6273
|
}
|
|
6258
6274
|
|
|
6259
|
-
|
|
6275
|
+
void* UPB_PRIVATE(_upb_Arena_AllocBlock)(upb_Arena* a, size_t* size) {
|
|
6260
6276
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6261
|
-
|
|
6277
|
+
#if UPB_HWASAN
|
|
6278
|
+
*size = UPB_ALIGN_UP(*size, UPB_MALLOC_ALIGN);
|
|
6279
|
+
#endif
|
|
6280
|
+
void* ret =
|
|
6281
|
+
_upb_Arena_AllocBlockInternal(_upb_ArenaInternal_BlockAlloc(ai), size);
|
|
6282
|
+
#if UPB_HWASAN
|
|
6283
|
+
if (ret) *size = UPB_ALIGN_DOWN(*size, UPB_MALLOC_ALIGN);
|
|
6284
|
+
#endif
|
|
6285
|
+
return ret;
|
|
6262
6286
|
}
|
|
6263
6287
|
|
|
6264
|
-
|
|
6288
|
+
void UPB_PRIVATE(_upb_Arena_AddBlock)(upb_Arena* a, void* block) {
|
|
6289
|
+
upb_MemBlock* b = (upb_MemBlock*)((char*)block - kUpb_MemblockReserve);
|
|
6265
6290
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6266
6291
|
|
|
6267
6292
|
// Atomic add not required here, as threads won't race allocating blocks, plus
|
|
@@ -6270,122 +6295,127 @@ static void _upb_Arena_AddBlock(upb_Arena* a, upb_MemBlock* block) {
|
|
|
6270
6295
|
// size allocated.
|
|
6271
6296
|
uintptr_t old_space_allocated =
|
|
6272
6297
|
upb_Atomic_Load(&ai->space_allocated, memory_order_relaxed);
|
|
6273
|
-
upb_Atomic_Store(&ai->space_allocated, old_space_allocated +
|
|
6298
|
+
upb_Atomic_Store(&ai->space_allocated, old_space_allocated + b->size,
|
|
6274
6299
|
memory_order_relaxed);
|
|
6275
6300
|
|
|
6276
|
-
|
|
6277
|
-
ai->blocks =
|
|
6301
|
+
b->next = ai->blocks;
|
|
6302
|
+
ai->blocks = b;
|
|
6278
6303
|
}
|
|
6279
6304
|
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
UPB_PRIVATE(
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6305
|
+
void UPB_PRIVATE(_upb_Arena_UseBlock)(upb_Arena* a, void* ptr, size_t size) {
|
|
6306
|
+
UPB_ASSERT(UPB_ALIGN_DOWN((uintptr_t)ptr, UPB_MALLOC_ALIGN) ==
|
|
6307
|
+
(uintptr_t)ptr);
|
|
6308
|
+
#if UPB_HWASAN
|
|
6309
|
+
size = UPB_ALIGN_DOWN(size, UPB_MALLOC_ALIGN);
|
|
6310
|
+
#endif
|
|
6311
|
+
if (size <= UPB_PRIVATE(_upb_ArenaHas)(a)) return;
|
|
6312
|
+
a->UPB_ONLYBITS(ptr) = ptr;
|
|
6313
|
+
a->UPB_ONLYBITS(end) = UPB_PTR_AT(ptr, size, char);
|
|
6314
|
+
UPB_PRIVATE(upb_Xsan_PoisonRegion)(ptr, size);
|
|
6290
6315
|
}
|
|
6291
6316
|
|
|
6292
|
-
static
|
|
6293
|
-
_upb_Arena_UseBlockInternal(a, block, 0);
|
|
6294
|
-
}
|
|
6295
|
-
|
|
6296
|
-
static bool _upb_Arena_WouldReduceFreeSpace(upb_Arena* a, size_t size,
|
|
6317
|
+
static bool _upb_Arena_WouldReduceFreeSpace(upb_Arena* a, size_t span,
|
|
6297
6318
|
size_t block_size) {
|
|
6298
6319
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6299
6320
|
size_t current_free =
|
|
6300
6321
|
ai->blocks ? a->UPB_PRIVATE(end) - a->UPB_PRIVATE(ptr) : 0;
|
|
6301
|
-
size_t future_free = block_size -
|
|
6322
|
+
size_t future_free = block_size - span;
|
|
6302
6323
|
return current_free >= future_free;
|
|
6303
6324
|
}
|
|
6304
6325
|
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
void* UPB_PRIVATE(_upb_Arena_SlowMalloc)(upb_Arena* a, size_t size) {
|
|
6326
|
+
size_t UPB_PRIVATE(_upb_Arena_NextBlockSize)(upb_Arena* a, size_t span,
|
|
6327
|
+
bool* one_off) {
|
|
6308
6328
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6309
|
-
|
|
6329
|
+
bool is_one_off = false;
|
|
6310
6330
|
|
|
6311
|
-
// Whether to satisfy the allocation from a one-off block which is right-sized
|
|
6312
|
-
// for the current allocation. We do this if we suspect that the current
|
|
6313
|
-
// allocation is an outlier that does not represent the typical size of
|
|
6314
|
-
// allocations from this arena, or if we would reduce free space by
|
|
6315
|
-
// using exponential growth.
|
|
6316
|
-
bool one_off = false;
|
|
6317
|
-
|
|
6318
|
-
// Relaxed order is safe here as we don't need any ordering with the setter.
|
|
6319
6331
|
size_t max_block_size =
|
|
6320
6332
|
upb_Atomic_Load(&g_max_block_size, memory_order_relaxed);
|
|
6321
6333
|
size_t block_size = UPB_MIN(ai->last_block_size * 2, max_block_size);
|
|
6322
6334
|
|
|
6323
|
-
if (
|
|
6324
|
-
// A regular doubling would not yield a large enough block. Does size_hint
|
|
6325
|
-
// indicate that we have consistently needed large blocks?
|
|
6335
|
+
if (span > block_size) {
|
|
6326
6336
|
block_size = UPB_MIN(ai->size_hint * 2, max_block_size);
|
|
6327
|
-
if (
|
|
6328
|
-
|
|
6329
|
-
one_off = true;
|
|
6337
|
+
if (span > block_size) {
|
|
6338
|
+
is_one_off = true;
|
|
6330
6339
|
}
|
|
6331
6340
|
}
|
|
6332
6341
|
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6342
|
+
is_one_off =
|
|
6343
|
+
is_one_off || _upb_Arena_WouldReduceFreeSpace(a, span, block_size);
|
|
6344
|
+
|
|
6345
|
+
if (is_one_off) {
|
|
6346
|
+
block_size = span;
|
|
6347
|
+
}
|
|
6348
|
+
|
|
6349
|
+
if (one_off) *one_off = is_one_off;
|
|
6350
|
+
return block_size;
|
|
6351
|
+
}
|
|
6336
6352
|
|
|
6353
|
+
void UPB_PRIVATE(_upb_Arena_UpdateGrowthState)(upb_Arena* a, size_t span,
|
|
6354
|
+
size_t block_size,
|
|
6355
|
+
bool one_off) {
|
|
6356
|
+
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6357
|
+
size_t max_block_size =
|
|
6358
|
+
upb_Atomic_Load(&g_max_block_size, memory_order_relaxed);
|
|
6337
6359
|
if (one_off) {
|
|
6338
|
-
|
|
6339
|
-
|
|
6360
|
+
ai->size_hint = UPB_MIN(ai->size_hint + (span >> 1), max_block_size >> 1);
|
|
6361
|
+
} else {
|
|
6362
|
+
ai->last_block_size = UPB_MIN(block_size, UINT32_MAX);
|
|
6363
|
+
ai->size_hint = ai->last_block_size;
|
|
6340
6364
|
}
|
|
6365
|
+
}
|
|
6341
6366
|
|
|
6342
|
-
|
|
6343
|
-
|
|
6367
|
+
// Fulfills the allocation request by allocating a new block. Returns NULL on
|
|
6368
|
+
// allocation failure.
|
|
6369
|
+
void* UPB_PRIVATE(_upb_Arena_SlowMalloc)(upb_Arena* a, size_t span) {
|
|
6370
|
+
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6371
|
+
if (!_upb_ArenaInternal_BlockAlloc(ai)) return NULL;
|
|
6344
6372
|
|
|
6345
|
-
|
|
6373
|
+
bool one_off = false;
|
|
6374
|
+
size_t block_size = UPB_PRIVATE(_upb_Arena_NextBlockSize)(a, span, &one_off);
|
|
6375
|
+
|
|
6376
|
+
void* block = UPB_PRIVATE(_upb_Arena_AllocBlock)(a, &block_size);
|
|
6377
|
+
if (!block) return NULL;
|
|
6378
|
+
UPB_PRIVATE(_upb_Arena_AddBlock)(a, block);
|
|
6379
|
+
size_t size = span - UPB_PRIVATE(kUpb_Asan_GuardSize);
|
|
6346
6380
|
|
|
6347
6381
|
// Recheck size, in case the allocator gave us a much larger block than we
|
|
6348
6382
|
// requested and we want to make it the new allocating region.
|
|
6349
|
-
if (
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
return allocated;
|
|
6383
|
+
if (one_off && !_upb_Arena_WouldReduceFreeSpace(a, span, block_size)) {
|
|
6384
|
+
one_off = false;
|
|
6385
|
+
}
|
|
6386
|
+
|
|
6387
|
+
UPB_PRIVATE(_upb_Arena_UpdateGrowthState)(a, span, block_size, one_off);
|
|
6388
|
+
|
|
6389
|
+
if (one_off) {
|
|
6390
|
+
UPB_PRIVATE(upb_Xsan_PoisonRegion)(UPB_PTR_AT(block, size, void),
|
|
6391
|
+
block_size - size);
|
|
6392
|
+
return block;
|
|
6360
6393
|
} else {
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
UPB_ASSERT(UPB_PRIVATE(_upb_ArenaHas)(a) >= size);
|
|
6365
|
-
return upb_Arena_Malloc(a, size - UPB_PRIVATE(kUpb_Asan_GuardSize));
|
|
6394
|
+
UPB_PRIVATE(_upb_Arena_UseBlock)(a, block, block_size);
|
|
6395
|
+
UPB_ASSERT(UPB_PRIVATE(_upb_ArenaHas)(a) >= span);
|
|
6396
|
+
return upb_Arena_Malloc(a, size);
|
|
6366
6397
|
}
|
|
6367
6398
|
}
|
|
6368
6399
|
|
|
6369
6400
|
static upb_Arena* _upb_Arena_InitSlow(upb_alloc* alloc, size_t first_size) {
|
|
6370
|
-
const size_t first_block_overhead =
|
|
6371
|
-
UPB_ALIGN_MALLOC(kUpb_MemblockReserve + sizeof(upb_ArenaState));
|
|
6372
|
-
upb_ArenaState* a;
|
|
6373
|
-
|
|
6374
6401
|
if (!alloc) return NULL;
|
|
6375
6402
|
|
|
6376
6403
|
// We need to malloc the initial block.
|
|
6377
|
-
size_t block_size =
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6404
|
+
size_t block_size = kUpb_ArenaStateReserve +
|
|
6405
|
+
UPB_MAX(256, UPB_ALIGN_MALLOC(first_size) +
|
|
6406
|
+
UPB_PRIVATE(kUpb_Asan_GuardSize));
|
|
6407
|
+
void* block = _upb_Arena_AllocBlockInternal(alloc, &block_size);
|
|
6381
6408
|
if (!block) return NULL;
|
|
6382
6409
|
|
|
6383
6410
|
// Initialize the arena state in the first block. We "borrow" the memory from
|
|
6384
6411
|
// the block, because we can't yet call upb_Arena_Malloc.
|
|
6385
|
-
a =
|
|
6412
|
+
upb_ArenaState* a = block;
|
|
6386
6413
|
a->body.block_alloc = _upb_Arena_MakeBlockAlloc(alloc, 0);
|
|
6387
|
-
a->body.last_block_size = UPB_MIN(
|
|
6388
|
-
a->body.size_hint = UPB_MIN(
|
|
6414
|
+
a->body.last_block_size = UPB_MIN(block_size, UINT32_MAX);
|
|
6415
|
+
a->body.size_hint = UPB_MIN(block_size, UINT32_MAX);
|
|
6416
|
+
a->head.UPB_ONLYBITS(ptr) = NULL;
|
|
6417
|
+
a->head.UPB_ONLYBITS(end) = NULL;
|
|
6418
|
+
|
|
6389
6419
|
upb_Atomic_Init(&a->body.parent_or_count, _upb_Arena_TaggedFromRefcount(1));
|
|
6390
6420
|
upb_Atomic_Init(&a->body.next, NULL);
|
|
6391
6421
|
upb_Atomic_Init(&a->body.previous_or_tail,
|
|
@@ -6398,9 +6428,11 @@ static upb_Arena* _upb_Arena_InitSlow(upb_alloc* alloc, size_t first_size) {
|
|
|
6398
6428
|
a->body.upb_alloc_cleanup = NULL;
|
|
6399
6429
|
UPB_PRIVATE(upb_Xsan_Init)(UPB_XSAN(&a->body));
|
|
6400
6430
|
|
|
6401
|
-
_upb_Arena_AddBlock(&a->head, block);
|
|
6402
|
-
|
|
6403
|
-
|
|
6431
|
+
UPB_PRIVATE(_upb_Arena_AddBlock)(&a->head, block);
|
|
6432
|
+
|
|
6433
|
+
block = UPB_PTR_AT(block, kUpb_ArenaStateReserve, void);
|
|
6434
|
+
block_size -= kUpb_ArenaStateReserve;
|
|
6435
|
+
UPB_PRIVATE(_upb_Arena_UseBlock)(&a->head, block, block_size);
|
|
6404
6436
|
|
|
6405
6437
|
return &a->head;
|
|
6406
6438
|
}
|
|
@@ -6465,7 +6497,7 @@ static void _upb_Arena_DoFree(upb_ArenaInternal* ai) {
|
|
|
6465
6497
|
}
|
|
6466
6498
|
upb_alloc* block_alloc = _upb_ArenaInternal_BlockAlloc(ai);
|
|
6467
6499
|
upb_MemBlock* block = ai->blocks;
|
|
6468
|
-
upb_AllocCleanupFunc* alloc_cleanup =
|
|
6500
|
+
upb_AllocCleanupFunc* alloc_cleanup = ai->upb_alloc_cleanup;
|
|
6469
6501
|
while (block != NULL) {
|
|
6470
6502
|
// Load first since we are deleting block.
|
|
6471
6503
|
upb_MemBlock* next_block = block->next;
|
|
@@ -6881,7 +6913,8 @@ void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) {
|
|
|
6881
6913
|
UPB_PRIVATE(_upb_Arena_SwapIn)(des, src);
|
|
6882
6914
|
}
|
|
6883
6915
|
|
|
6884
|
-
bool
|
|
6916
|
+
bool _upb_Arena_WasLastAllocFromPreviousBlock(struct upb_Arena* a, void* ptr,
|
|
6917
|
+
size_t oldsize) {
|
|
6885
6918
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
|
6886
6919
|
upb_MemBlock* block = ai->blocks;
|
|
6887
6920
|
// Skip any arena refs.
|
|
@@ -6890,11 +6923,35 @@ bool _upb_Arena_WasLastAlloc(struct upb_Arena* a, void* ptr, size_t oldsize) {
|
|
|
6890
6923
|
}
|
|
6891
6924
|
if (block == NULL) return false;
|
|
6892
6925
|
char* start = UPB_PTR_AT(block, kUpb_MemblockReserve, char);
|
|
6926
|
+
|
|
6927
|
+
// We don't actually track the final pointer value, so we can only check that
|
|
6928
|
+
// the span is within the previous block.
|
|
6893
6929
|
return UPB_PRIVATE(upb_Xsan_PtrEq)(ptr, start) &&
|
|
6894
6930
|
UPB_PRIVATE(_upb_Arena_AllocSpan)(oldsize) ==
|
|
6895
6931
|
block->size - kUpb_MemblockReserve;
|
|
6896
6932
|
}
|
|
6897
6933
|
|
|
6934
|
+
void* UPB_PRIVATE(_upb_Arena_Steal)(struct upb_Arena* a, size_t* size) {
|
|
6935
|
+
UPB_PRIVATE(upb_Xsan_AccessReadWrite)(UPB_XSAN(a));
|
|
6936
|
+
size_t have = UPB_PRIVATE(_upb_ArenaHas)(a);
|
|
6937
|
+
if (have < *size) return NULL;
|
|
6938
|
+
|
|
6939
|
+
*size = have;
|
|
6940
|
+
void* ptr = a->UPB_ONLYBITS(ptr);
|
|
6941
|
+
a->UPB_ONLYBITS(ptr) += have;
|
|
6942
|
+
|
|
6943
|
+
return UPB_PRIVATE(upb_Xsan_NewUnpoisonedRegion)(UPB_XSAN(a), ptr, have);
|
|
6944
|
+
}
|
|
6945
|
+
|
|
6946
|
+
// Frees a block previously allocated with _upb_Arena_AllocBlock.
|
|
6947
|
+
void UPB_PRIVATE(_upb_Arena_FreeBlock)(upb_Arena* a, void* block) {
|
|
6948
|
+
UPB_PRIVATE(upb_Xsan_AccessReadWrite)(UPB_XSAN(a));
|
|
6949
|
+
upb_MemBlock* b =
|
|
6950
|
+
UPB_PTR_AT(block, -(ptrdiff_t)kUpb_MemblockReserve, upb_MemBlock);
|
|
6951
|
+
upb_alloc* alloc = upb_Arena_GetUpbAlloc(a);
|
|
6952
|
+
upb_free_sized(alloc, b, b->size);
|
|
6953
|
+
}
|
|
6954
|
+
|
|
6898
6955
|
|
|
6899
6956
|
|
|
6900
6957
|
// Must be last.
|
|
@@ -6928,7 +6985,7 @@ bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTableField* f,
|
|
|
6928
6985
|
|
|
6929
6986
|
upb_Array* upb_Array_New(upb_Arena* a, upb_CType type) {
|
|
6930
6987
|
const int lg2 = UPB_PRIVATE(_upb_CType_SizeLg2)(type);
|
|
6931
|
-
return UPB_PRIVATE(_upb_Array_New)(a,
|
|
6988
|
+
return UPB_PRIVATE(_upb_Array_New)(a, _UPB_ARRAY_DEFAULT_INITIAL_SIZE, lg2);
|
|
6932
6989
|
}
|
|
6933
6990
|
|
|
6934
6991
|
upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) {
|
|
@@ -7077,6 +7134,10 @@ bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_capacity,
|
|
|
7077
7134
|
}
|
|
7078
7135
|
}
|
|
7079
7136
|
|
|
7137
|
+
// If capacity doubling overflowed to SIZE_MAX, fail. No valid array can hold
|
|
7138
|
+
// SIZE_MAX elements, and downstream size calculations would overflow.
|
|
7139
|
+
if (new_capacity == SIZE_MAX) return false;
|
|
7140
|
+
|
|
7080
7141
|
size_t new_bytes = new_capacity;
|
|
7081
7142
|
if (upb_ShlOverflow(&new_bytes, lg2)) {
|
|
7082
7143
|
return false;
|
|
@@ -7410,14 +7471,7 @@ static bool _upb_mapsorter_resize(_upb_mapsorter* s, _upb_sortedmap* sorted,
|
|
|
7410
7471
|
|
|
7411
7472
|
bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
|
|
7412
7473
|
const upb_Map* map, _upb_sortedmap* sorted) {
|
|
7413
|
-
int map_size;
|
|
7414
|
-
if (map->UPB_PRIVATE(is_strtable)) {
|
|
7415
|
-
map_size = _upb_Map_Size(map);
|
|
7416
|
-
} else {
|
|
7417
|
-
// For inttable, only sort the table entries, since the array part is
|
|
7418
|
-
// already in a sorted order.
|
|
7419
|
-
map_size = map->t.inttable.t.count;
|
|
7420
|
-
}
|
|
7474
|
+
int map_size = _upb_Map_Size(map);
|
|
7421
7475
|
|
|
7422
7476
|
if (!_upb_mapsorter_resize(s, sorted, map_size)) return false;
|
|
7423
7477
|
|
|
@@ -7429,8 +7483,6 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
|
|
|
7429
7483
|
src = map->t.strtable.t.entries;
|
|
7430
7484
|
end = src + upb_table_size(&map->t.strtable.t);
|
|
7431
7485
|
} else {
|
|
7432
|
-
// For inttable, only sort the table entries, since the array part is
|
|
7433
|
-
// already in a sorted order.
|
|
7434
7486
|
src = map->t.inttable.t.entries;
|
|
7435
7487
|
end = src + upb_table_size(&map->t.inttable.t);
|
|
7436
7488
|
}
|
|
@@ -7462,7 +7514,7 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
|
|
|
7462
7514
|
_upb_sortedmap* sorted) {
|
|
7463
7515
|
size_t count = 0;
|
|
7464
7516
|
for (size_t i = 0; i < in->size; i++) {
|
|
7465
|
-
count +=
|
|
7517
|
+
count += upb_TaggedAuxPtr_IsCanonicalExtension(in->aux_data[i]);
|
|
7466
7518
|
}
|
|
7467
7519
|
if (!_upb_mapsorter_resize(s, sorted, count)) return false;
|
|
7468
7520
|
if (count == 0) return true;
|
|
@@ -7470,8 +7522,8 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
|
|
|
7470
7522
|
(const upb_Extension**)&s->entries[sorted->start];
|
|
7471
7523
|
for (size_t i = 0; i < in->size; i++) {
|
|
7472
7524
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
7473
|
-
if (
|
|
7474
|
-
*entry++ =
|
|
7525
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
7526
|
+
*entry++ = upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
7475
7527
|
}
|
|
7476
7528
|
}
|
|
7477
7529
|
qsort(&s->entries[sorted->start], count, sizeof(*s->entries),
|
|
@@ -7497,14 +7549,15 @@ UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(upb_Message* msg,
|
|
|
7497
7549
|
size_t len,
|
|
7498
7550
|
upb_Arena* arena,
|
|
7499
7551
|
bool alias) {
|
|
7552
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
7500
7553
|
{
|
|
7501
7554
|
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
7502
7555
|
// Alias fast path was already checked in the inline function that calls
|
|
7503
7556
|
// this one
|
|
7504
7557
|
if (!alias && in && in->size) {
|
|
7505
7558
|
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
|
|
7506
|
-
if (
|
|
7507
|
-
upb_StringView* existing =
|
|
7559
|
+
if (upb_TaggedAuxPtr_IsUnknownStringView(ptr)) {
|
|
7560
|
+
upb_StringView* existing = upb_TaggedPtrAux_StringViewRepr(ptr);
|
|
7508
7561
|
if (!upb_TaggedAuxPtr_IsUnknownAliased(ptr)) {
|
|
7509
7562
|
// If part of the existing field was deleted at the beginning, we can
|
|
7510
7563
|
// reconstruct it by comparing the address of the end with the address
|
|
@@ -7571,8 +7624,8 @@ bool UPB_PRIVATE(_upb_Message_AddUnknownV)(struct upb_Message* msg,
|
|
|
7571
7624
|
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
7572
7625
|
if (in && in->size) {
|
|
7573
7626
|
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
|
|
7574
|
-
if (
|
|
7575
|
-
upb_StringView* existing =
|
|
7627
|
+
if (upb_TaggedAuxPtr_IsUnknownStringView(ptr)) {
|
|
7628
|
+
upb_StringView* existing = upb_TaggedPtrAux_StringViewRepr(ptr);
|
|
7576
7629
|
if (!upb_TaggedAuxPtr_IsUnknownAliased(ptr)) {
|
|
7577
7630
|
size_t prev_alloc_size =
|
|
7578
7631
|
(existing->data + existing->size) - (char*)existing;
|
|
@@ -7621,7 +7674,7 @@ void _upb_Message_DiscardUnknown_shallow(upb_Message* msg) {
|
|
|
7621
7674
|
uint32_t size = 0;
|
|
7622
7675
|
for (uint32_t i = 0; i < in->size; i++) {
|
|
7623
7676
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
7624
|
-
if (
|
|
7677
|
+
if (upb_TaggedAuxPtr_IsSemanticallyKnown(tagged_ptr)) {
|
|
7625
7678
|
in->aux_data[size++] = tagged_ptr;
|
|
7626
7679
|
}
|
|
7627
7680
|
}
|
|
@@ -7632,60 +7685,20 @@ upb_Message_DeleteUnknownStatus upb_Message_DeleteUnknown(upb_Message* msg,
|
|
|
7632
7685
|
upb_StringView* data,
|
|
7633
7686
|
uintptr_t* iter,
|
|
7634
7687
|
upb_Arena* arena) {
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
UPB_ASSERT(
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
//
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
// Strip prefix
|
|
7648
|
-
unknown->data += data->size;
|
|
7649
|
-
unknown->size -= data->size;
|
|
7650
|
-
*data = *unknown;
|
|
7651
|
-
return kUpb_DeleteUnknown_IterUpdated;
|
|
7652
|
-
} else if (unknown->data + unknown->size == data->data + data->size) {
|
|
7653
|
-
// Truncate existing field
|
|
7654
|
-
unknown->size -= data->size;
|
|
7655
|
-
if (!upb_TaggedAuxPtr_IsUnknownAliased(unknown_ptr)) {
|
|
7656
|
-
in->aux_data[*iter - 1] =
|
|
7657
|
-
upb_TaggedAuxPtr_MakeUnknownDataAliased(unknown);
|
|
7658
|
-
}
|
|
7659
|
-
} else {
|
|
7660
|
-
UPB_ASSERT(unknown->data < data->data &&
|
|
7661
|
-
unknown->data + unknown->size > data->data + data->size);
|
|
7662
|
-
// Split in the middle
|
|
7663
|
-
upb_StringView* prefix = unknown;
|
|
7664
|
-
upb_StringView* suffix = upb_Arena_Malloc(arena, sizeof(upb_StringView));
|
|
7665
|
-
if (!suffix) {
|
|
7666
|
-
return kUpb_DeleteUnknown_AllocFail;
|
|
7667
|
-
}
|
|
7668
|
-
if (!UPB_PRIVATE(_upb_Message_ReserveSlot)(msg, arena)) {
|
|
7669
|
-
return kUpb_DeleteUnknown_AllocFail;
|
|
7670
|
-
}
|
|
7671
|
-
in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
7672
|
-
if (*iter != in->size) {
|
|
7673
|
-
// Shift later entries down so that unknown field ordering is preserved
|
|
7674
|
-
memmove(&in->aux_data[*iter + 1], &in->aux_data[*iter],
|
|
7675
|
-
sizeof(upb_TaggedAuxPtr) * (in->size - *iter));
|
|
7676
|
-
}
|
|
7677
|
-
in->aux_data[*iter] = upb_TaggedAuxPtr_MakeUnknownDataAliased(suffix);
|
|
7678
|
-
if (!upb_TaggedAuxPtr_IsUnknownAliased(unknown_ptr)) {
|
|
7679
|
-
in->aux_data[*iter - 1] = upb_TaggedAuxPtr_MakeUnknownDataAliased(prefix);
|
|
7680
|
-
}
|
|
7681
|
-
in->size++;
|
|
7682
|
-
suffix->data = data->data + data->size;
|
|
7683
|
-
suffix->size = (prefix->data + prefix->size) - suffix->data;
|
|
7684
|
-
prefix->size = data->data - prefix->data;
|
|
7688
|
+
upb_MessageUnknown unknown;
|
|
7689
|
+
unknown.type = kUpb_MessageUnknownType_StringView;
|
|
7690
|
+
unknown.value.bytes = *data;
|
|
7691
|
+
|
|
7692
|
+
upb_Message_DeleteUnknownStatus res =
|
|
7693
|
+
upb_Message_DeleteUnknown2(msg, &unknown, iter, arena);
|
|
7694
|
+
UPB_ASSERT(unknown.type == kUpb_MessageUnknownType_StringView);
|
|
7695
|
+
if (res == kUpb_DeleteUnknown_IterUpdated ||
|
|
7696
|
+
res == kUpb_DeleteUnknown_DeletedLast) {
|
|
7697
|
+
// the unknown data remains the same on the result of
|
|
7698
|
+
// kUpb_DeleteUnknown_AllocFail.
|
|
7699
|
+
*data = unknown.value.bytes;
|
|
7685
7700
|
}
|
|
7686
|
-
return
|
|
7687
|
-
? kUpb_DeleteUnknown_IterUpdated
|
|
7688
|
-
: kUpb_DeleteUnknown_DeletedLast;
|
|
7701
|
+
return res;
|
|
7689
7702
|
}
|
|
7690
7703
|
|
|
7691
7704
|
size_t upb_Message_ExtensionCount(const upb_Message* msg) {
|
|
@@ -7743,10 +7756,13 @@ void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) {
|
|
|
7743
7756
|
uint32_t size = in ? in->size : 0;
|
|
7744
7757
|
for (size_t i = 0; i < size; i++) {
|
|
7745
7758
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
7746
|
-
|
|
7759
|
+
upb_TaggedAux aux;
|
|
7760
|
+
upb_TaggedAuxType type = upb_TaggedAux_Get(tagged_ptr, &aux);
|
|
7761
|
+
if (type != kUpb_TaggedAuxType_CanonicalExtension &&
|
|
7762
|
+
type != kUpb_TaggedAuxType_NonCanonicalExtension) {
|
|
7747
7763
|
continue;
|
|
7748
7764
|
}
|
|
7749
|
-
const upb_Extension* ext =
|
|
7765
|
+
const upb_Extension* ext = aux.extension;
|
|
7750
7766
|
const upb_MiniTableExtension* e = ext->ext;
|
|
7751
7767
|
const upb_MiniTableField* f = &e->UPB_PRIVATE(field);
|
|
7752
7768
|
const upb_MiniTable* m2 = upb_MiniTableExtension_GetSubMessage(e);
|
|
@@ -7774,6 +7790,143 @@ void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) {
|
|
|
7774
7790
|
}
|
|
7775
7791
|
|
|
7776
7792
|
|
|
7793
|
+
#include <stddef.h>
|
|
7794
|
+
#include <stdint.h>
|
|
7795
|
+
#include <string.h>
|
|
7796
|
+
|
|
7797
|
+
|
|
7798
|
+
// Must be last.
|
|
7799
|
+
|
|
7800
|
+
static upb_FindUnknownRet2 upb_FindUnknownRet2_ParseError(void) {
|
|
7801
|
+
return (upb_FindUnknownRet2){.status = kUpb_FindUnknown_ParseError};
|
|
7802
|
+
}
|
|
7803
|
+
|
|
7804
|
+
upb_FindUnknownRet2 upb_Message_FindUnknown2(const struct upb_Message* msg,
|
|
7805
|
+
uint32_t field_number,
|
|
7806
|
+
int depth_limit) {
|
|
7807
|
+
depth_limit = depth_limit ? depth_limit : 100;
|
|
7808
|
+
upb_FindUnknownRet2 ret;
|
|
7809
|
+
ret.iter = kUpb_Message_UnknownBegin;
|
|
7810
|
+
while (upb_Message_NextUnknown2(msg, &ret.unknown, &ret.iter)) {
|
|
7811
|
+
if (ret.unknown.type == kUpb_MessageUnknownType_StringView) {
|
|
7812
|
+
upb_EpsCopyInputStream stream;
|
|
7813
|
+
const char* ptr = ret.unknown.value.bytes.data;
|
|
7814
|
+
upb_EpsCopyInputStream_Init(&stream, &ptr, ret.unknown.value.bytes.size);
|
|
7815
|
+
|
|
7816
|
+
while (!upb_EpsCopyInputStream_IsDone(&stream, &ptr)) {
|
|
7817
|
+
uint32_t tag;
|
|
7818
|
+
const char* unknown_begin = ptr;
|
|
7819
|
+
ptr = upb_WireReader_ReadTag(ptr, &tag, &stream);
|
|
7820
|
+
if (!ptr) return upb_FindUnknownRet2_ParseError();
|
|
7821
|
+
if (field_number == upb_WireReader_GetFieldNumber(tag)) {
|
|
7822
|
+
upb_StringView data;
|
|
7823
|
+
ret.status = kUpb_FindUnknown_Ok;
|
|
7824
|
+
upb_EpsCopyCapture capture;
|
|
7825
|
+
upb_EpsCopyCapture_Start(&capture, &stream, unknown_begin);
|
|
7826
|
+
ptr = _upb_WireReader_SkipValue(ptr, tag, depth_limit, &stream);
|
|
7827
|
+
if (!ptr || !upb_EpsCopyCapture_End(&capture, &stream, ptr, &data)) {
|
|
7828
|
+
return upb_FindUnknownRet2_ParseError();
|
|
7829
|
+
}
|
|
7830
|
+
ret.unknown.value.bytes = data;
|
|
7831
|
+
return ret;
|
|
7832
|
+
}
|
|
7833
|
+
|
|
7834
|
+
ptr = _upb_WireReader_SkipValue(ptr, tag, depth_limit, &stream);
|
|
7835
|
+
if (!ptr) return upb_FindUnknownRet2_ParseError();
|
|
7836
|
+
}
|
|
7837
|
+
} else if (ret.unknown.type ==
|
|
7838
|
+
kUpb_MessageUnknownType_NonCanonicalExtension) {
|
|
7839
|
+
uint32_t ext_field_number =
|
|
7840
|
+
upb_MiniTableExtension_Number(ret.unknown.value.extension->ext);
|
|
7841
|
+
if (ext_field_number == field_number) {
|
|
7842
|
+
ret.status = kUpb_FindUnknown_Ok;
|
|
7843
|
+
return ret;
|
|
7844
|
+
}
|
|
7845
|
+
}
|
|
7846
|
+
}
|
|
7847
|
+
ret.status = kUpb_FindUnknown_NotPresent;
|
|
7848
|
+
ret.unknown.type = kUpb_MessageUnknownType_StringView;
|
|
7849
|
+
ret.unknown.value.bytes.data = NULL;
|
|
7850
|
+
ret.unknown.value.bytes.size = 0;
|
|
7851
|
+
ret.iter = kUpb_Message_UnknownBegin;
|
|
7852
|
+
return ret;
|
|
7853
|
+
}
|
|
7854
|
+
|
|
7855
|
+
upb_Message_DeleteUnknownStatus upb_Message_DeleteUnknown2(
|
|
7856
|
+
struct upb_Message* msg, struct upb_MessageUnknown* data, uintptr_t* iter,
|
|
7857
|
+
struct upb_Arena* arena) {
|
|
7858
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
7859
|
+
UPB_ASSERT(*iter != kUpb_Message_UnknownBegin);
|
|
7860
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
7861
|
+
UPB_ASSERT(in);
|
|
7862
|
+
UPB_ASSERT(*iter <= in->size);
|
|
7863
|
+
upb_TaggedAuxPtr unknown_ptr = in->aux_data[*iter - 1];
|
|
7864
|
+
|
|
7865
|
+
if (data->type == kUpb_MessageUnknownType_NonCanonicalExtension) {
|
|
7866
|
+
UPB_ASSERT(upb_TaggedAuxPtr_IsNonCanonicalExtension(unknown_ptr));
|
|
7867
|
+
// When the unknown is a non-canonical extension, we just remove it from the
|
|
7868
|
+
// aux data array.
|
|
7869
|
+
in->aux_data[*iter - 1] = upb_TaggedAuxPtr_Null();
|
|
7870
|
+
return upb_Message_NextUnknown2(msg, data, iter)
|
|
7871
|
+
? kUpb_DeleteUnknown_IterUpdated
|
|
7872
|
+
: kUpb_DeleteUnknown_DeletedLast;
|
|
7873
|
+
}
|
|
7874
|
+
|
|
7875
|
+
UPB_ASSERT(upb_TaggedAuxPtr_IsUnknownStringView(unknown_ptr));
|
|
7876
|
+
upb_StringView* unknown = upb_TaggedPtrAux_StringViewRepr(unknown_ptr);
|
|
7877
|
+
UPB_ASSERT(data->type == kUpb_MessageUnknownType_StringView);
|
|
7878
|
+
upb_StringView* data_bytes = &data->value.bytes;
|
|
7879
|
+
if (unknown->data == data_bytes->data && unknown->size == data_bytes->size) {
|
|
7880
|
+
// Remove whole field
|
|
7881
|
+
in->aux_data[*iter - 1] = upb_TaggedAuxPtr_Null();
|
|
7882
|
+
} else if (unknown->data == data_bytes->data) {
|
|
7883
|
+
// Strip prefix
|
|
7884
|
+
unknown->data += data_bytes->size;
|
|
7885
|
+
unknown->size -= data_bytes->size;
|
|
7886
|
+
*data_bytes = *unknown;
|
|
7887
|
+
return kUpb_DeleteUnknown_IterUpdated;
|
|
7888
|
+
} else if (unknown->data + unknown->size ==
|
|
7889
|
+
data_bytes->data + data_bytes->size) {
|
|
7890
|
+
// Truncate existing field
|
|
7891
|
+
unknown->size -= data_bytes->size;
|
|
7892
|
+
if (!upb_TaggedAuxPtr_IsUnknownAliased(unknown_ptr)) {
|
|
7893
|
+
in->aux_data[*iter - 1] =
|
|
7894
|
+
upb_TaggedAuxPtr_MakeUnknownDataAliased(unknown);
|
|
7895
|
+
}
|
|
7896
|
+
} else {
|
|
7897
|
+
UPB_ASSERT(unknown->data < data_bytes->data &&
|
|
7898
|
+
unknown->data + unknown->size >
|
|
7899
|
+
data_bytes->data + data_bytes->size);
|
|
7900
|
+
// Split in the middle
|
|
7901
|
+
upb_StringView* prefix = unknown;
|
|
7902
|
+
upb_StringView* suffix = upb_Arena_Malloc(arena, sizeof(upb_StringView));
|
|
7903
|
+
if (!suffix) {
|
|
7904
|
+
return kUpb_DeleteUnknown_AllocFail;
|
|
7905
|
+
}
|
|
7906
|
+
if (!UPB_PRIVATE(_upb_Message_ReserveSlot)(msg, arena)) {
|
|
7907
|
+
return kUpb_DeleteUnknown_AllocFail;
|
|
7908
|
+
}
|
|
7909
|
+
in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
7910
|
+
if (*iter != in->size) {
|
|
7911
|
+
// Shift later entries down so that unknown field ordering is preserved
|
|
7912
|
+
memmove(&in->aux_data[*iter + 1], &in->aux_data[*iter],
|
|
7913
|
+
sizeof(upb_TaggedAuxPtr) * (in->size - *iter));
|
|
7914
|
+
}
|
|
7915
|
+
in->aux_data[*iter] = upb_TaggedAuxPtr_MakeUnknownDataAliased(suffix);
|
|
7916
|
+
if (!upb_TaggedAuxPtr_IsUnknownAliased(unknown_ptr)) {
|
|
7917
|
+
in->aux_data[*iter - 1] = upb_TaggedAuxPtr_MakeUnknownDataAliased(prefix);
|
|
7918
|
+
}
|
|
7919
|
+
in->size++;
|
|
7920
|
+
suffix->data = data_bytes->data + data_bytes->size;
|
|
7921
|
+
suffix->size = (prefix->data + prefix->size) - suffix->data;
|
|
7922
|
+
prefix->size = data_bytes->data - prefix->data;
|
|
7923
|
+
}
|
|
7924
|
+
return upb_Message_NextUnknown2(msg, data, iter)
|
|
7925
|
+
? kUpb_DeleteUnknown_IterUpdated
|
|
7926
|
+
: kUpb_DeleteUnknown_DeletedLast;
|
|
7927
|
+
}
|
|
7928
|
+
|
|
7929
|
+
|
|
7777
7930
|
#include <stddef.h>
|
|
7778
7931
|
#include <stdint.h>
|
|
7779
7932
|
|
|
@@ -8032,7 +8185,7 @@ static void upb_UnknownFields_Merge(upb_UnknownField* arr, size_t start,
|
|
|
8032
8185
|
if (ptr1 < end1) {
|
|
8033
8186
|
memcpy(out, ptr1, (end1 - ptr1) * sizeof(*out));
|
|
8034
8187
|
} else if (ptr2 < end2) {
|
|
8035
|
-
memcpy(out,
|
|
8188
|
+
memcpy(out, ptr2, (end2 - ptr2) * sizeof(*out));
|
|
8036
8189
|
}
|
|
8037
8190
|
}
|
|
8038
8191
|
|
|
@@ -8500,9 +8653,10 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
|
8500
8653
|
|
|
8501
8654
|
for (size_t i = 0; i < in->size; i++) {
|
|
8502
8655
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
8503
|
-
if (
|
|
8656
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
8504
8657
|
// Clone extension
|
|
8505
|
-
const upb_Extension* msg_ext =
|
|
8658
|
+
const upb_Extension* msg_ext =
|
|
8659
|
+
upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
8506
8660
|
const upb_MiniTableField* field = &msg_ext->ext->UPB_PRIVATE(field);
|
|
8507
8661
|
upb_Extension* dst_ext = UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
8508
8662
|
dst, msg_ext->ext, arena);
|
|
@@ -8522,9 +8676,9 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
|
8522
8676
|
}
|
|
8523
8677
|
dst_ext->data.array_val = cloned_array;
|
|
8524
8678
|
}
|
|
8525
|
-
} else if (
|
|
8679
|
+
} else if (upb_TaggedAuxPtr_IsUnknownStringView(tagged_ptr)) {
|
|
8526
8680
|
// Clone unknown
|
|
8527
|
-
upb_StringView* unknown =
|
|
8681
|
+
upb_StringView* unknown = upb_TaggedPtrAux_StringViewRepr(tagged_ptr);
|
|
8528
8682
|
// Make a copy into destination arena.
|
|
8529
8683
|
if (!UPB_PRIVATE(_upb_Message_AddUnknown)(
|
|
8530
8684
|
dst, unknown->data, unknown->size, arena, kUpb_AddUnknown_Copy)) {
|
|
@@ -8552,19 +8706,65 @@ upb_Message* upb_Message_DeepClone(const upb_Message* msg,
|
|
|
8552
8706
|
return _upb_Message_Copy(clone, msg, m, arena);
|
|
8553
8707
|
}
|
|
8554
8708
|
|
|
8555
|
-
// Performs a shallow copy.
|
|
8556
|
-
|
|
8557
|
-
const upb_MiniTable* m) {
|
|
8709
|
+
// Performs a shallow copy.
|
|
8710
|
+
bool upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
|
|
8711
|
+
const upb_MiniTable* m, upb_Arena* arena) {
|
|
8558
8712
|
UPB_ASSERT(!upb_Message_IsFrozen(dst));
|
|
8559
8713
|
memcpy(dst, src, m->UPB_PRIVATE(size));
|
|
8714
|
+
|
|
8715
|
+
const upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(src);
|
|
8716
|
+
if (!in) return true;
|
|
8717
|
+
|
|
8718
|
+
size_t size = UPB_SIZEOF_FLEX(upb_Message_Internal, aux_data, in->size);
|
|
8719
|
+
upb_Message_Internal* dst_in = upb_Arena_Malloc(arena, size);
|
|
8720
|
+
if (!dst_in) return false;
|
|
8721
|
+
|
|
8722
|
+
dst_in->size = in->size;
|
|
8723
|
+
dst_in->capacity = in->size;
|
|
8724
|
+
|
|
8725
|
+
for (size_t i = 0; i < in->size; i++) {
|
|
8726
|
+
upb_TaggedAux aux;
|
|
8727
|
+
switch (upb_TaggedAux_Get(in->aux_data[i], &aux)) {
|
|
8728
|
+
case kUpb_TaggedAuxType_CanonicalExtension: {
|
|
8729
|
+
const upb_Extension* msg_ext = aux.extension;
|
|
8730
|
+
upb_Extension* dst_ext = upb_Arena_Malloc(arena, sizeof(upb_Extension));
|
|
8731
|
+
if (!dst_ext) return false;
|
|
8732
|
+
*dst_ext = *msg_ext;
|
|
8733
|
+
dst_in->aux_data[i] = upb_TaggedAuxPtr_MakeCanonicalExtension(dst_ext);
|
|
8734
|
+
break;
|
|
8735
|
+
}
|
|
8736
|
+
case kUpb_TaggedAuxType_Unknown:
|
|
8737
|
+
case kUpb_TaggedAuxType_AliasedUnknown: {
|
|
8738
|
+
upb_StringView* dst_sv =
|
|
8739
|
+
upb_Arena_Malloc(arena, sizeof(upb_StringView));
|
|
8740
|
+
if (!dst_sv) return false;
|
|
8741
|
+
*dst_sv = *aux.unknown_data;
|
|
8742
|
+
dst_in->aux_data[i] = upb_TaggedAuxPtr_MakeUnknownDataAliased(dst_sv);
|
|
8743
|
+
break;
|
|
8744
|
+
}
|
|
8745
|
+
case kUpb_TaggedAuxType_NonCanonicalExtension: {
|
|
8746
|
+
const upb_Extension* msg_ext = aux.extension;
|
|
8747
|
+
upb_Extension* dst_ext = upb_Arena_Malloc(arena, sizeof(upb_Extension));
|
|
8748
|
+
if (!dst_ext) return false;
|
|
8749
|
+
*dst_ext = *msg_ext;
|
|
8750
|
+
dst_in->aux_data[i] =
|
|
8751
|
+
upb_TaggedAuxPtr_MakeNonCanonicalExtension(dst_ext);
|
|
8752
|
+
break;
|
|
8753
|
+
}
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
|
|
8757
|
+
UPB_PRIVATE(_upb_Message_SetInternal)(dst, dst_in);
|
|
8758
|
+
return true;
|
|
8560
8759
|
}
|
|
8561
8760
|
|
|
8562
|
-
// Performs a shallow clone.
|
|
8761
|
+
// Performs a shallow clone.
|
|
8563
8762
|
upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
|
|
8564
8763
|
const upb_MiniTable* m,
|
|
8565
8764
|
upb_Arena* arena) {
|
|
8566
8765
|
upb_Message* clone = upb_Message_New(m, arena);
|
|
8567
|
-
|
|
8766
|
+
if (!clone) return NULL;
|
|
8767
|
+
if (!upb_Message_ShallowCopy(clone, msg, m, arena)) return NULL;
|
|
8568
8768
|
return clone;
|
|
8569
8769
|
}
|
|
8570
8770
|
|
|
@@ -8612,8 +8812,9 @@ const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
|
|
|
8612
8812
|
|
|
8613
8813
|
for (size_t i = 0; i < in->size; i++) {
|
|
8614
8814
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
8615
|
-
if (
|
|
8616
|
-
const upb_Extension* ext =
|
|
8815
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
8816
|
+
const upb_Extension* ext =
|
|
8817
|
+
upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
8617
8818
|
if (ext->ext == e) {
|
|
8618
8819
|
return ext;
|
|
8619
8820
|
}
|
|
@@ -8623,8 +8824,9 @@ const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
|
|
|
8623
8824
|
return NULL;
|
|
8624
8825
|
}
|
|
8625
8826
|
|
|
8626
|
-
upb_Extension*
|
|
8627
|
-
struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a
|
|
8827
|
+
UPB_INLINE upb_Extension* _upb_Message_GetOrCreateExtensionInternal(
|
|
8828
|
+
struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a,
|
|
8829
|
+
bool canonical) {
|
|
8628
8830
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
8629
8831
|
upb_Extension* ext = (upb_Extension*)UPB_PRIVATE(_upb_Message_Getext)(msg, e);
|
|
8630
8832
|
if (ext) return ext;
|
|
@@ -8635,10 +8837,24 @@ upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
|
8635
8837
|
if (!ext) return NULL;
|
|
8636
8838
|
memset(ext, 0, sizeof(upb_Extension));
|
|
8637
8839
|
ext->ext = e;
|
|
8638
|
-
in->aux_data[in->size++] =
|
|
8840
|
+
in->aux_data[in->size++] =
|
|
8841
|
+
canonical ? upb_TaggedAuxPtr_MakeCanonicalExtension(ext)
|
|
8842
|
+
: upb_TaggedAuxPtr_MakeNonCanonicalExtension(ext);
|
|
8639
8843
|
return ext;
|
|
8640
8844
|
}
|
|
8641
8845
|
|
|
8846
|
+
upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
8847
|
+
struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a) {
|
|
8848
|
+
return _upb_Message_GetOrCreateExtensionInternal(msg, e, a,
|
|
8849
|
+
/*canonical=*/true);
|
|
8850
|
+
}
|
|
8851
|
+
|
|
8852
|
+
upb_Extension* UPB_PRIVATE(_upb_Message_CreateNonCanonicalExtension)(
|
|
8853
|
+
struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a) {
|
|
8854
|
+
return _upb_Message_GetOrCreateExtensionInternal(msg, e, a,
|
|
8855
|
+
/*canonical=*/false);
|
|
8856
|
+
}
|
|
8857
|
+
|
|
8642
8858
|
|
|
8643
8859
|
#include <math.h>
|
|
8644
8860
|
#include <stddef.h>
|
|
@@ -9358,6 +9574,10 @@ static const char* upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr,
|
|
|
9358
9574
|
return --ptr;
|
|
9359
9575
|
}
|
|
9360
9576
|
upb_MiniTableField* field = fields;
|
|
9577
|
+
if (*field_count == UINT16_MAX) {
|
|
9578
|
+
upb_MdDecoder_ErrorJmp(
|
|
9579
|
+
&d->base, "Fields in message exceed the limit of %u", UINT16_MAX);
|
|
9580
|
+
}
|
|
9361
9581
|
*field_count += 1;
|
|
9362
9582
|
fields = (char*)fields + field_size;
|
|
9363
9583
|
uint32_t number = ++last_field_number;
|
|
@@ -9389,6 +9609,9 @@ static const char* upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr,
|
|
|
9389
9609
|
ptr = upb_MdDecoder_DecodeBase92Varint(&d->base, ptr, ch,
|
|
9390
9610
|
kUpb_EncodedValue_MinSkip,
|
|
9391
9611
|
kUpb_EncodedValue_MaxSkip, &skip);
|
|
9612
|
+
if (skip == 0) {
|
|
9613
|
+
upb_MdDecoder_ErrorJmp(&d->base, "Invalid skip value: 0");
|
|
9614
|
+
}
|
|
9392
9615
|
last_field_number += skip;
|
|
9393
9616
|
last_field_number--; // Next field seen will increment.
|
|
9394
9617
|
} else {
|
|
@@ -9698,6 +9921,14 @@ done:
|
|
|
9698
9921
|
}
|
|
9699
9922
|
#endif
|
|
9700
9923
|
UPB_PRIVATE(upb_MiniTable_CheckInvariants)(ret);
|
|
9924
|
+
|
|
9925
|
+
#ifndef NDEBUG
|
|
9926
|
+
for (int i = 1; i < upb_MiniTable_FieldCount(ret); i++) {
|
|
9927
|
+
const upb_MiniTableField* f1 = upb_MiniTable_GetFieldByIndex(ret, i - 1);
|
|
9928
|
+
const upb_MiniTableField* f2 = upb_MiniTable_GetFieldByIndex(ret, i);
|
|
9929
|
+
UPB_ASSERT(upb_MiniTableField_Number(f2) > upb_MiniTableField_Number(f1));
|
|
9930
|
+
}
|
|
9931
|
+
#endif
|
|
9701
9932
|
return ret;
|
|
9702
9933
|
}
|
|
9703
9934
|
|
|
@@ -9761,6 +9992,18 @@ static const char* upb_MtDecoder_DoBuildMiniTableExtension(
|
|
|
9761
9992
|
if (!ret || count != 1) return NULL;
|
|
9762
9993
|
|
|
9763
9994
|
upb_MiniTableField* f = &ext->UPB_PRIVATE(field);
|
|
9995
|
+
uint32_t fieldnum = upb_MiniTableField_Number(f);
|
|
9996
|
+
|
|
9997
|
+
const uint32_t kMaxFieldNumber = (1 << 29) - 1;
|
|
9998
|
+
if (fieldnum == 0 ||
|
|
9999
|
+
(fieldnum > kMaxFieldNumber && !upb_MiniTable_IsMessageSet(extendee))) {
|
|
10000
|
+
upb_MdDecoder_ErrorJmp(&decoder->base, "Invalid extension field number");
|
|
10001
|
+
}
|
|
10002
|
+
|
|
10003
|
+
if (upb_MiniTable_FindFieldByNumber(extendee, fieldnum) != NULL) {
|
|
10004
|
+
upb_MdDecoder_ErrorJmp(&decoder->base,
|
|
10005
|
+
"Extension overlaps with a known field");
|
|
10006
|
+
}
|
|
9764
10007
|
|
|
9765
10008
|
f->UPB_PRIVATE(mode) |= kUpb_LabelFlags_IsExtension;
|
|
9766
10009
|
f->UPB_PRIVATE(offset) = 0;
|
|
@@ -9845,6 +10088,16 @@ upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len,
|
|
|
9845
10088
|
#include <string.h>
|
|
9846
10089
|
|
|
9847
10090
|
|
|
10091
|
+
// Our awkward dance for including fasttable only when it is enabled.
|
|
10092
|
+
#if UPB_FASTTABLE
|
|
10093
|
+
#define UPB_INCLUDE_FAST_DECODE
|
|
10094
|
+
#endif
|
|
10095
|
+
|
|
10096
|
+
#ifdef UPB_INCLUDE_FAST_DECODE
|
|
10097
|
+
#endif
|
|
10098
|
+
|
|
10099
|
+
#undef UPB_INCLUDE_FAST_DECODE
|
|
10100
|
+
|
|
9848
10101
|
// Must be last.
|
|
9849
10102
|
|
|
9850
10103
|
bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
|
|
@@ -9867,6 +10120,25 @@ bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
|
|
|
9867
10120
|
field->UPB_PRIVATE(mode) =
|
|
9868
10121
|
(field->UPB_PRIVATE(mode) & ~kUpb_FieldMode_Mask) |
|
|
9869
10122
|
kUpb_FieldMode_Map;
|
|
10123
|
+
|
|
10124
|
+
#if UPB_FASTTABLE
|
|
10125
|
+
// The fasttable decoder cannot decode maps. Unfortunately we do not
|
|
10126
|
+
// know until this moment that the field is a map, so we have to
|
|
10127
|
+
// overwrite the fasttable entry (if any) that we built for this field
|
|
10128
|
+
// previously.
|
|
10129
|
+
int size = table->UPB_PRIVATE(table_mask) == 0xff
|
|
10130
|
+
? 0
|
|
10131
|
+
: ((table->UPB_PRIVATE(table_mask) >> 3) + 1);
|
|
10132
|
+
for (int i = 0; i < size; i++) {
|
|
10133
|
+
_upb_FastTable_Entry* entry = &table->UPB_PRIVATE(fasttable)[i];
|
|
10134
|
+
uint32_t field_number = (((int)entry->field_data >> 3) & 0xf) |
|
|
10135
|
+
(((int)entry->field_data >> 4) & 0x7f0);
|
|
10136
|
+
if (field_number == upb_MiniTableField_Number(field)) {
|
|
10137
|
+
entry->field_parser = &_upb_FastDecoder_DecodeGeneric;
|
|
10138
|
+
entry->field_data = 0;
|
|
10139
|
+
}
|
|
10140
|
+
}
|
|
10141
|
+
#endif
|
|
9870
10142
|
}
|
|
9871
10143
|
break;
|
|
9872
10144
|
|
|
@@ -10336,12 +10608,6 @@ UPB_API upb_ExtensionRegistryStatus upb_ExtensionRegistry_Add(
|
|
|
10336
10608
|
uint32_t fieldnum = upb_MiniTableExtension_Number(e);
|
|
10337
10609
|
const upb_MiniTable* extendee = upb_MiniTableExtension_Extendee(e);
|
|
10338
10610
|
|
|
10339
|
-
const uint32_t kMaxFieldNumber = (1 << 29) - 1;
|
|
10340
|
-
if (fieldnum == 0 ||
|
|
10341
|
-
(fieldnum > kMaxFieldNumber && !upb_MiniTable_IsMessageSet(extendee))) {
|
|
10342
|
-
return kUpb_ExtensionRegistryStatus_InvalidExtension;
|
|
10343
|
-
}
|
|
10344
|
-
|
|
10345
10611
|
if (upb_exttable_lookup(&r->exts, extendee, fieldnum) != NULL) {
|
|
10346
10612
|
return kUpb_ExtensionRegistryStatus_DuplicateEntry;
|
|
10347
10613
|
}
|
|
@@ -10607,6 +10873,18 @@ const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_StaticallyTreeShaken) = {
|
|
|
10607
10873
|
.UPB_PRIVATE(required_count) = 0,
|
|
10608
10874
|
};
|
|
10609
10875
|
|
|
10876
|
+
#include <stdio.h>
|
|
10877
|
+
#include <stdlib.h>
|
|
10878
|
+
|
|
10879
|
+
// Must be last.
|
|
10880
|
+
|
|
10881
|
+
UPB_NORETURN void _upb_UnreachableFailure(const char* file, int line,
|
|
10882
|
+
const char* function_name) {
|
|
10883
|
+
fprintf(stderr, "%s:%d: Reached unreachable statement in function `%s`.\n",
|
|
10884
|
+
file, line, function_name ? function_name : "(unknown)");
|
|
10885
|
+
abort();
|
|
10886
|
+
}
|
|
10887
|
+
|
|
10610
10888
|
|
|
10611
10889
|
#include <assert.h>
|
|
10612
10890
|
#include <stddef.h>
|
|
@@ -10994,10 +11272,13 @@ static const upb_FileDef* upb_DefBuilder_AddFileToPool(
|
|
|
10994
11272
|
_upb_DefBuilder_OomErr(builder);
|
|
10995
11273
|
} else {
|
|
10996
11274
|
_upb_FileDef_Create(builder, file_proto);
|
|
10997
|
-
|
|
10998
|
-
|
|
11275
|
+
bool ok =
|
|
11276
|
+
upb_strtable_insert(&s->files, name.data, name.size,
|
|
11277
|
+
upb_value_constptr(builder->file), builder->arena);
|
|
11278
|
+
UPB_ASSERT(ok);
|
|
10999
11279
|
UPB_ASSERT(upb_Status_IsOk(status));
|
|
11000
|
-
upb_Arena_Fuse(s->arena, builder->arena);
|
|
11280
|
+
ok = upb_Arena_Fuse(s->arena, builder->arena);
|
|
11281
|
+
UPB_ASSERT(ok);
|
|
11001
11282
|
}
|
|
11002
11283
|
|
|
11003
11284
|
if (builder->arena) upb_Arena_Free(builder->arena);
|
|
@@ -11481,9 +11762,6 @@ static void create_enumdef(upb_DefBuilder* ctx, const char* prefix,
|
|
|
11481
11762
|
e->res_names = _upb_EnumReservedNames_New(ctx, n_res_name, res_names);
|
|
11482
11763
|
|
|
11483
11764
|
e->visibility = google_protobuf_EnumDescriptorProto_visibility(enum_proto);
|
|
11484
|
-
|
|
11485
|
-
if (!upb_inttable_compact(&e->iton, ctx->arena)) _upb_DefBuilder_OomErr(ctx);
|
|
11486
|
-
|
|
11487
11765
|
if (upb_EnumDef_IsClosed(e)) {
|
|
11488
11766
|
if (ctx->layout) {
|
|
11489
11767
|
e->layout = upb_MiniTableFile_Enum(ctx->layout, ctx->enum_count++);
|
|
@@ -12881,7 +13159,7 @@ const upb_FileDef* upb_FileDef_PublicDependency(const upb_FileDef* f, int i) {
|
|
|
12881
13159
|
}
|
|
12882
13160
|
|
|
12883
13161
|
const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i) {
|
|
12884
|
-
UPB_ASSERT(0 <= i && i < f->
|
|
13162
|
+
UPB_ASSERT(0 <= i && i < f->weak_dep_count);
|
|
12885
13163
|
return f->deps[f->weak_deps[i]];
|
|
12886
13164
|
}
|
|
12887
13165
|
|
|
@@ -13126,7 +13404,7 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
|
|
|
13126
13404
|
file->public_deps = UPB_DEFBUILDER_ALLOCARRAY(ctx, int32_t, n);
|
|
13127
13405
|
int32_t* mutable_public_deps = (int32_t*)file->public_deps;
|
|
13128
13406
|
for (size_t i = 0; i < n; i++) {
|
|
13129
|
-
if (public_deps[i] >= file->dep_count) {
|
|
13407
|
+
if (public_deps[i] < 0 || public_deps[i] >= file->dep_count) {
|
|
13130
13408
|
_upb_DefBuilder_Errf(ctx, "public_dep %d is out of range",
|
|
13131
13409
|
(int)public_deps[i]);
|
|
13132
13410
|
}
|
|
@@ -13138,7 +13416,7 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
|
|
|
13138
13416
|
file->weak_deps = UPB_DEFBUILDER_ALLOCARRAY(ctx, const int32_t, n);
|
|
13139
13417
|
int32_t* mutable_weak_deps = (int32_t*)file->weak_deps;
|
|
13140
13418
|
for (size_t i = 0; i < n; i++) {
|
|
13141
|
-
if (weak_deps[i] >= file->dep_count) {
|
|
13419
|
+
if (weak_deps[i] < 0 || weak_deps[i] >= file->dep_count) {
|
|
13142
13420
|
_upb_DefBuilder_Errf(ctx, "weak_dep %d is out of range",
|
|
13143
13421
|
(int)weak_deps[i]);
|
|
13144
13422
|
}
|
|
@@ -13708,7 +13986,9 @@ make:
|
|
|
13708
13986
|
}
|
|
13709
13987
|
|
|
13710
13988
|
val.array_val = ret.array;
|
|
13711
|
-
upb_Message_SetFieldByDef(msg, f, val, a)
|
|
13989
|
+
if (!upb_Message_SetFieldByDef(msg, f, val, a)) {
|
|
13990
|
+
ret.array = NULL;
|
|
13991
|
+
}
|
|
13712
13992
|
|
|
13713
13993
|
return ret;
|
|
13714
13994
|
}
|
|
@@ -13788,8 +14068,9 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
|
|
|
13788
14068
|
|
|
13789
14069
|
for (; (i - n) < in->size; i++) {
|
|
13790
14070
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i - n];
|
|
13791
|
-
if (
|
|
13792
|
-
const upb_Extension* ext =
|
|
14071
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
14072
|
+
const upb_Extension* ext =
|
|
14073
|
+
upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
13793
14074
|
memcpy(out_val, &ext->data, sizeof(*out_val));
|
|
13794
14075
|
*out_f = upb_DefPool_FindExtensionByMiniTable(ext_pool, ext->ext);
|
|
13795
14076
|
*iter = i;
|
|
@@ -14570,7 +14851,6 @@ static void create_msgdef(upb_DefBuilder* ctx, const char* prefix,
|
|
|
14570
14851
|
m->real_oneof_count = m->oneof_count - synthetic_count;
|
|
14571
14852
|
|
|
14572
14853
|
assign_msg_wellknowntype(m);
|
|
14573
|
-
if (!upb_inttable_compact(&m->itof, ctx->arena)) _upb_DefBuilder_OomErr(ctx);
|
|
14574
14854
|
|
|
14575
14855
|
const google_protobuf_EnumDescriptorProto* const* enums =
|
|
14576
14856
|
google_protobuf_DescriptorProto_enum_type(msg_proto, &n_enum);
|
|
@@ -15848,25 +16128,12 @@ enum {
|
|
|
15848
16128
|
#define OP_FIXPCK_LG2(n) (n + 5) /* n in [2, 3] => op in [7, 8] */
|
|
15849
16129
|
#define OP_VARPCK_LG2(n) (n + 9) /* n in [0, 2, 3] => op in [9, 11, 12] */
|
|
15850
16130
|
|
|
15851
|
-
typedef union {
|
|
15852
|
-
bool bool_val;
|
|
15853
|
-
uint32_t uint32_val;
|
|
15854
|
-
uint64_t uint64_val;
|
|
15855
|
-
uint32_t size;
|
|
15856
|
-
} wireval;
|
|
15857
|
-
|
|
15858
|
-
static void _upb_Decoder_AssumeEpsHasErrorHandler(upb_Decoder* d) {
|
|
15859
|
-
UPB_ASSUME(upb_EpsCopyInputStream_HasErrorHandler(&d->input));
|
|
15860
|
-
}
|
|
15861
|
-
|
|
15862
|
-
#define EPS(d) (_upb_Decoder_AssumeEpsHasErrorHandler(d), &(d)->input)
|
|
15863
|
-
|
|
15864
16131
|
static bool _upb_Decoder_Reserve(upb_Decoder* d, upb_Array* arr, size_t elem) {
|
|
15865
16132
|
bool need_realloc =
|
|
15866
16133
|
arr->UPB_PRIVATE(capacity) - arr->UPB_PRIVATE(size) < elem;
|
|
15867
16134
|
if (need_realloc && !UPB_PRIVATE(_upb_Array_Realloc)(
|
|
15868
16135
|
arr, arr->UPB_PRIVATE(size) + elem, &d->arena)) {
|
|
15869
|
-
upb_ErrorHandler_ThrowError(
|
|
16136
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
15870
16137
|
}
|
|
15871
16138
|
return need_realloc;
|
|
15872
16139
|
}
|
|
@@ -15887,6 +16154,20 @@ const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
|
|
|
15887
16154
|
return ptr;
|
|
15888
16155
|
}
|
|
15889
16156
|
|
|
16157
|
+
UPB_FORCEINLINE upb_AddUnknownMode
|
|
16158
|
+
_upb_Decoder_GetAddUnknownMode(upb_Decoder* d, const char* data) {
|
|
16159
|
+
if (d->options & kUpb_DecodeOption_AliasString) {
|
|
16160
|
+
if (data != d->input.buffer_start) {
|
|
16161
|
+
// If the data is not from the beginning of the input buffer, then we can
|
|
16162
|
+
// safely attempt to coalesce this region with the previous one.
|
|
16163
|
+
return kUpb_AddUnknown_AliasAllowMerge;
|
|
16164
|
+
} else {
|
|
16165
|
+
return kUpb_AddUnknown_Alias;
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
16168
|
+
return kUpb_AddUnknown_Copy;
|
|
16169
|
+
}
|
|
16170
|
+
|
|
15890
16171
|
static void _upb_Decoder_MungeInt32(wireval* val) {
|
|
15891
16172
|
if (!upb_IsLittleEndian()) {
|
|
15892
16173
|
/* The next stage will memcpy(dst, &val, 4) */
|
|
@@ -15924,7 +16205,7 @@ static upb_Message* _upb_Decoder_NewSubMessage2(upb_Decoder* d,
|
|
|
15924
16205
|
upb_Message** target) {
|
|
15925
16206
|
UPB_ASSERT(subl);
|
|
15926
16207
|
upb_Message* msg = _upb_Message_New(subl, &d->arena);
|
|
15927
|
-
if (!msg) upb_ErrorHandler_ThrowError(
|
|
16208
|
+
if (!msg) upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
15928
16209
|
|
|
15929
16210
|
*target = msg;
|
|
15930
16211
|
return msg;
|
|
@@ -15941,7 +16222,7 @@ static const char* _upb_Decoder_ReadString2(upb_Decoder* d, const char* ptr,
|
|
|
15941
16222
|
int size, upb_StringView* str,
|
|
15942
16223
|
bool validate_utf8) {
|
|
15943
16224
|
if (!_upb_Decoder_ReadString(d, &ptr, size, str, validate_utf8)) {
|
|
15944
|
-
upb_ErrorHandler_ThrowError(
|
|
16225
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
15945
16226
|
}
|
|
15946
16227
|
return ptr;
|
|
15947
16228
|
}
|
|
@@ -15952,12 +16233,12 @@ const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d, const char* ptr,
|
|
|
15952
16233
|
const upb_MiniTable* subl,
|
|
15953
16234
|
uint32_t expected_end_group) {
|
|
15954
16235
|
if (--d->depth < 0) {
|
|
15955
|
-
upb_ErrorHandler_ThrowError(
|
|
16236
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_MaxDepthExceeded);
|
|
15956
16237
|
}
|
|
15957
16238
|
ptr = _upb_Decoder_DecodeMessage(d, ptr, submsg, subl);
|
|
15958
16239
|
d->depth++;
|
|
15959
16240
|
if (d->end_group != expected_end_group) {
|
|
15960
|
-
upb_ErrorHandler_ThrowError(
|
|
16241
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
15961
16242
|
}
|
|
15962
16243
|
return ptr;
|
|
15963
16244
|
}
|
|
@@ -15981,7 +16262,7 @@ const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
|
|
|
15981
16262
|
const upb_MiniTable* subl,
|
|
15982
16263
|
uint32_t number) {
|
|
15983
16264
|
if (upb_EpsCopyInputStream_IsDone(EPS(d), &ptr)) {
|
|
15984
|
-
upb_ErrorHandler_ThrowError(
|
|
16265
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
15985
16266
|
}
|
|
15986
16267
|
ptr = _upb_Decoder_RecurseSubMessage(d, ptr, submsg, subl, number);
|
|
15987
16268
|
d->end_group = DECODE_NOGROUP;
|
|
@@ -15998,40 +16279,6 @@ const char* _upb_Decoder_DecodeKnownGroup(upb_Decoder* d, const char* ptr,
|
|
|
15998
16279
|
field->UPB_PRIVATE(number));
|
|
15999
16280
|
}
|
|
16000
16281
|
|
|
16001
|
-
#define kUpb_Decoder_EncodeVarint32MaxSize 5
|
|
16002
|
-
static char* upb_Decoder_EncodeVarint32(uint32_t val, char* ptr) {
|
|
16003
|
-
do {
|
|
16004
|
-
uint8_t byte = val & 0x7fU;
|
|
16005
|
-
val >>= 7;
|
|
16006
|
-
if (val) byte |= 0x80U;
|
|
16007
|
-
*(ptr++) = byte;
|
|
16008
|
-
} while (val);
|
|
16009
|
-
return ptr;
|
|
16010
|
-
}
|
|
16011
|
-
|
|
16012
|
-
UPB_FORCEINLINE
|
|
16013
|
-
void _upb_Decoder_AddEnumValueToUnknown(upb_Decoder* d, upb_Message* msg,
|
|
16014
|
-
const upb_MiniTableField* field,
|
|
16015
|
-
wireval* val) {
|
|
16016
|
-
// Unrecognized enum goes into unknown fields.
|
|
16017
|
-
// For packed fields the tag could be arbitrarily far in the past,
|
|
16018
|
-
// so we just re-encode the tag and value here.
|
|
16019
|
-
const uint32_t tag =
|
|
16020
|
-
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint;
|
|
16021
|
-
upb_Message* unknown_msg =
|
|
16022
|
-
field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension ? d->original_msg
|
|
16023
|
-
: msg;
|
|
16024
|
-
char buf[2 * kUpb_Decoder_EncodeVarint32MaxSize];
|
|
16025
|
-
char* end = buf;
|
|
16026
|
-
end = upb_Decoder_EncodeVarint32(tag, end);
|
|
16027
|
-
end = upb_Decoder_EncodeVarint32(val->uint64_val, end);
|
|
16028
|
-
|
|
16029
|
-
if (!UPB_PRIVATE(_upb_Message_AddUnknown)(unknown_msg, buf, end - buf,
|
|
16030
|
-
&d->arena, kUpb_AddUnknown_Copy)) {
|
|
16031
|
-
upb_ErrorHandler_ThrowError(&d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16032
|
-
}
|
|
16033
|
-
}
|
|
16034
|
-
|
|
16035
16282
|
UPB_FORCEINLINE
|
|
16036
16283
|
const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr,
|
|
16037
16284
|
upb_Array* arr, wireval* val,
|
|
@@ -16040,10 +16287,10 @@ const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr,
|
|
|
16040
16287
|
upb_StringView sv;
|
|
16041
16288
|
ptr = upb_EpsCopyInputStream_ReadStringEphemeral(&d->input, ptr, val->size,
|
|
16042
16289
|
&sv);
|
|
16043
|
-
if (!ptr) upb_ErrorHandler_ThrowError(
|
|
16290
|
+
if (!ptr) upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16044
16291
|
int mask = (1 << lg2) - 1;
|
|
16045
16292
|
if (UPB_UNLIKELY((val->size & mask) != 0 || ptr == NULL)) {
|
|
16046
|
-
upb_ErrorHandler_ThrowError(
|
|
16293
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16047
16294
|
}
|
|
16048
16295
|
size_t count = val->size >> lg2;
|
|
16049
16296
|
if (count == 0) return ptr;
|
|
@@ -16115,9 +16362,17 @@ static const char* _upb_Decoder_DecodeEnumPacked(
|
|
|
16115
16362
|
wireval elem;
|
|
16116
16363
|
ptr = upb_WireReader_ReadVarint(ptr, &elem.uint64_val, EPS(d));
|
|
16117
16364
|
if (!upb_MiniTableEnum_CheckValue(e, elem.uint64_val)) {
|
|
16118
|
-
|
|
16365
|
+
upb_Message* unknown_msg =
|
|
16366
|
+
field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension
|
|
16367
|
+
? d->original_msg
|
|
16368
|
+
: msg;
|
|
16369
|
+
if (!_upb_Encoder_AddEnumValueToUnknown(unknown_msg, field,
|
|
16370
|
+
elem.uint64_val, &d->arena)) {
|
|
16371
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16372
|
+
}
|
|
16119
16373
|
continue;
|
|
16120
16374
|
}
|
|
16375
|
+
_upb_Decoder_MungeInt32(&elem);
|
|
16121
16376
|
if (_upb_Decoder_Reserve(d, arr, 1)) {
|
|
16122
16377
|
out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr),
|
|
16123
16378
|
arr->UPB_PRIVATE(size) * 4, void);
|
|
@@ -16134,11 +16389,15 @@ static upb_Array* _upb_Decoder_CreateArray(upb_Decoder* d,
|
|
|
16134
16389
|
const upb_MiniTableField* field) {
|
|
16135
16390
|
const upb_FieldType field_type = field->UPB_PRIVATE(descriptortype);
|
|
16136
16391
|
const size_t lg2 = UPB_PRIVATE(_upb_FieldType_SizeLg2)(field_type);
|
|
16137
|
-
upb_Array* ret = UPB_PRIVATE(_upb_Array_New)(
|
|
16138
|
-
|
|
16392
|
+
upb_Array* ret = UPB_PRIVATE(_upb_Array_New)(
|
|
16393
|
+
&d->arena, _UPB_ARRAY_DEFAULT_INITIAL_SIZE, lg2);
|
|
16394
|
+
if (!ret) upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16139
16395
|
return ret;
|
|
16140
16396
|
}
|
|
16141
16397
|
|
|
16398
|
+
#if UPB_FASTTABLE
|
|
16399
|
+
UPB_PRESERVE_NONE
|
|
16400
|
+
#endif
|
|
16142
16401
|
static const char* _upb_Decoder_DecodeToArray(upb_Decoder* d, const char* ptr,
|
|
16143
16402
|
upb_Message* msg,
|
|
16144
16403
|
const upb_MiniTableField* field,
|
|
@@ -16244,36 +16503,13 @@ static upb_Map* _upb_Decoder_CreateMap(upb_Decoder* d,
|
|
|
16244
16503
|
UPB_ASSERT(key_field->UPB_PRIVATE(offset) == offsetof(upb_MapEntry, k));
|
|
16245
16504
|
UPB_ASSERT(val_field->UPB_PRIVATE(offset) == offsetof(upb_MapEntry, v));
|
|
16246
16505
|
upb_Map* ret = _upb_Map_New(&d->arena, key_size, val_size);
|
|
16247
|
-
if (!ret) upb_ErrorHandler_ThrowError(
|
|
16506
|
+
if (!ret) upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16248
16507
|
return ret;
|
|
16249
16508
|
}
|
|
16250
16509
|
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
char* buf;
|
|
16255
|
-
size_t size;
|
|
16256
|
-
upb_EncodeStatus status =
|
|
16257
|
-
upb_Encode(ent_msg, entry, 0, &d->arena, &buf, &size);
|
|
16258
|
-
if (status != kUpb_EncodeStatus_Ok) {
|
|
16259
|
-
upb_ErrorHandler_ThrowError(&d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16260
|
-
}
|
|
16261
|
-
char delim_buf[2 * kUpb_Decoder_EncodeVarint32MaxSize];
|
|
16262
|
-
char* delim_end = delim_buf;
|
|
16263
|
-
uint32_t tag =
|
|
16264
|
-
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Delimited;
|
|
16265
|
-
delim_end = upb_Decoder_EncodeVarint32(tag, delim_end);
|
|
16266
|
-
delim_end = upb_Decoder_EncodeVarint32(size, delim_end);
|
|
16267
|
-
upb_StringView unknown[] = {
|
|
16268
|
-
{delim_buf, delim_end - delim_buf},
|
|
16269
|
-
{buf, size},
|
|
16270
|
-
};
|
|
16271
|
-
|
|
16272
|
-
if (!UPB_PRIVATE(_upb_Message_AddUnknownV)(msg, &d->arena, unknown, 2)) {
|
|
16273
|
-
upb_ErrorHandler_ThrowError(&d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16274
|
-
}
|
|
16275
|
-
}
|
|
16276
|
-
|
|
16510
|
+
#if UPB_FASTTABLE
|
|
16511
|
+
UPB_PRESERVE_NONE
|
|
16512
|
+
#endif
|
|
16277
16513
|
static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
|
|
16278
16514
|
upb_Message* msg,
|
|
16279
16515
|
const upb_MiniTableField* field,
|
|
@@ -16324,16 +16560,22 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
|
|
|
16324
16560
|
}
|
|
16325
16561
|
|
|
16326
16562
|
if (upb_Message_HasUnknown(&ent.message)) {
|
|
16327
|
-
|
|
16563
|
+
if (!_upb_Encoder_AddMapEntryUnknown(msg, field, &ent.message, entry,
|
|
16564
|
+
&d->arena)) {
|
|
16565
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16566
|
+
}
|
|
16328
16567
|
} else {
|
|
16329
16568
|
if (_upb_Map_Insert(map, &ent.k, map->key_size, &ent.v, map->val_size,
|
|
16330
16569
|
&d->arena) == kUpb_MapInsertStatus_OutOfMemory) {
|
|
16331
|
-
upb_ErrorHandler_ThrowError(
|
|
16570
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16332
16571
|
}
|
|
16333
16572
|
}
|
|
16334
16573
|
return ptr;
|
|
16335
16574
|
}
|
|
16336
16575
|
|
|
16576
|
+
#if UPB_FASTTABLE
|
|
16577
|
+
UPB_PRESERVE_NONE
|
|
16578
|
+
#endif
|
|
16337
16579
|
static const char* _upb_Decoder_DecodeToSubMessage(
|
|
16338
16580
|
upb_Decoder* d, const char* ptr, upb_Message* msg,
|
|
16339
16581
|
const upb_MiniTableField* field, wireval* val, int op) {
|
|
@@ -16401,7 +16643,7 @@ static void upb_Decoder_AddKnownMessageSetItem(
|
|
|
16401
16643
|
upb_Extension* ext =
|
|
16402
16644
|
UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(msg, item_mt, &d->arena);
|
|
16403
16645
|
if (UPB_UNLIKELY(!ext)) {
|
|
16404
|
-
upb_ErrorHandler_ThrowError(
|
|
16646
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16405
16647
|
}
|
|
16406
16648
|
upb_Message** submsgp = (upb_Message**)&ext->data.msg_val;
|
|
16407
16649
|
upb_Message* submsg = _upb_Decoder_NewSubMessage2(
|
|
@@ -16409,13 +16651,13 @@ static void upb_Decoder_AddKnownMessageSetItem(
|
|
|
16409
16651
|
&ext->ext->UPB_PRIVATE(field), submsgp);
|
|
16410
16652
|
// upb_Decode_LimitDepth() takes uint32_t, d->depth - 1 can not be negative.
|
|
16411
16653
|
if (d->depth <= 1) {
|
|
16412
|
-
upb_ErrorHandler_ThrowError(
|
|
16654
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_MaxDepthExceeded);
|
|
16413
16655
|
}
|
|
16414
16656
|
upb_DecodeStatus status = upb_Decode(
|
|
16415
16657
|
data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt),
|
|
16416
16658
|
d->extreg, upb_Decode_LimitDepth(d->options, d->depth - 1), &d->arena);
|
|
16417
16659
|
if (status != kUpb_DecodeStatus_Ok) {
|
|
16418
|
-
upb_ErrorHandler_ThrowError(
|
|
16660
|
+
upb_ErrorHandler_ThrowError(d->err, status);
|
|
16419
16661
|
}
|
|
16420
16662
|
}
|
|
16421
16663
|
|
|
@@ -16424,16 +16666,16 @@ static void upb_Decoder_AddUnknownMessageSetItem(upb_Decoder* d,
|
|
|
16424
16666
|
uint32_t type_id,
|
|
16425
16667
|
const char* message_data,
|
|
16426
16668
|
uint32_t message_size) {
|
|
16427
|
-
char buf[6 *
|
|
16669
|
+
char buf[6 * kUpb_Encoder_EncodeVarint32MaxSize];
|
|
16428
16670
|
char* ptr = buf;
|
|
16429
|
-
ptr =
|
|
16430
|
-
ptr =
|
|
16431
|
-
ptr =
|
|
16432
|
-
ptr =
|
|
16433
|
-
ptr =
|
|
16671
|
+
ptr = upb_Encoder_EncodeVarint32(kStartItemTag, ptr);
|
|
16672
|
+
ptr = upb_Encoder_EncodeVarint32(kTypeIdTag, ptr);
|
|
16673
|
+
ptr = upb_Encoder_EncodeVarint32(type_id, ptr);
|
|
16674
|
+
ptr = upb_Encoder_EncodeVarint32(kMessageTag, ptr);
|
|
16675
|
+
ptr = upb_Encoder_EncodeVarint32(message_size, ptr);
|
|
16434
16676
|
char* split = ptr;
|
|
16435
16677
|
|
|
16436
|
-
ptr =
|
|
16678
|
+
ptr = upb_Encoder_EncodeVarint32(kEndItemTag, ptr);
|
|
16437
16679
|
char* end = ptr;
|
|
16438
16680
|
upb_StringView unknown[] = {
|
|
16439
16681
|
{buf, split - buf},
|
|
@@ -16441,7 +16683,7 @@ static void upb_Decoder_AddUnknownMessageSetItem(upb_Decoder* d,
|
|
|
16441
16683
|
{split, end - split},
|
|
16442
16684
|
};
|
|
16443
16685
|
if (!UPB_PRIVATE(_upb_Message_AddUnknownV)(msg, &d->arena, unknown, 3)) {
|
|
16444
|
-
upb_ErrorHandler_ThrowError(
|
|
16686
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16445
16687
|
}
|
|
16446
16688
|
}
|
|
16447
16689
|
|
|
@@ -16493,7 +16735,7 @@ static const char* upb_Decoder_DecodeMessageSetItem(
|
|
|
16493
16735
|
ptr = upb_EpsCopyInputStream_ReadStringAlwaysAlias(&d->input, ptr, size,
|
|
16494
16736
|
&sv);
|
|
16495
16737
|
if (!ptr) {
|
|
16496
|
-
upb_ErrorHandler_ThrowError(
|
|
16738
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16497
16739
|
}
|
|
16498
16740
|
if (state_mask & kUpb_HavePayload) break; // Ignore dup.
|
|
16499
16741
|
state_mask |= kUpb_HavePayload;
|
|
@@ -16512,7 +16754,7 @@ static const char* upb_Decoder_DecodeMessageSetItem(
|
|
|
16512
16754
|
break;
|
|
16513
16755
|
}
|
|
16514
16756
|
}
|
|
16515
|
-
upb_ErrorHandler_ThrowError(
|
|
16757
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16516
16758
|
}
|
|
16517
16759
|
|
|
16518
16760
|
static upb_MiniTableField upb_Decoder_FieldNotFoundField = {
|
|
@@ -16549,9 +16791,10 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d,
|
|
|
16549
16791
|
upb_MiniTable_FindFieldByNumber(t, field_number);
|
|
16550
16792
|
if (field) return field;
|
|
16551
16793
|
|
|
16552
|
-
if (d->extreg &&
|
|
16553
|
-
return _upb_Decoder_FindExtensionField(
|
|
16554
|
-
|
|
16794
|
+
if (d->extreg && UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(t)) {
|
|
16795
|
+
return _upb_Decoder_FindExtensionField(
|
|
16796
|
+
d, t, field_number, UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(t),
|
|
16797
|
+
wire_type);
|
|
16555
16798
|
}
|
|
16556
16799
|
|
|
16557
16800
|
return &upb_Decoder_FieldNotFoundField; // Unknown field.
|
|
@@ -16591,18 +16834,7 @@ void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
|
|
|
16591
16834
|
if (field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension) return;
|
|
16592
16835
|
const upb_MiniTable* mt_sub = upb_MiniTable_GetSubMessageTable(field);
|
|
16593
16836
|
if (mt_sub != NULL) return; // Normal case, sub-message is linked.
|
|
16594
|
-
|
|
16595
|
-
const upb_MiniTableField* oneof = upb_MiniTable_GetOneof(mt, field);
|
|
16596
|
-
if (oneof) {
|
|
16597
|
-
// All other members of the oneof must be message fields that are also
|
|
16598
|
-
// unlinked.
|
|
16599
|
-
do {
|
|
16600
|
-
UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message);
|
|
16601
|
-
const upb_MiniTable* oneof_sub = upb_MiniTable_GetSubMessageTable(oneof);
|
|
16602
|
-
UPB_ASSERT(!oneof_sub);
|
|
16603
|
-
} while (upb_MiniTable_NextOneofField(mt, &oneof));
|
|
16604
|
-
}
|
|
16605
|
-
#endif // NDEBUG
|
|
16837
|
+
_upb_Decoder_VerifyOneofUnlinked(mt, field);
|
|
16606
16838
|
*op = kUpb_DecodeOp_UnknownField;
|
|
16607
16839
|
}
|
|
16608
16840
|
|
|
@@ -16652,7 +16884,7 @@ static int _upb_Decoder_GetDelimitedOp(upb_Decoder* d, const upb_MiniTable* mt,
|
|
|
16652
16884
|
[kRepeatedBase + kUpb_FieldType_Fixed32] = OP_FIXPCK_LG2(2),
|
|
16653
16885
|
[kRepeatedBase + kUpb_FieldType_Bool] = OP_VARPCK_LG2(0),
|
|
16654
16886
|
[kRepeatedBase + kUpb_FieldType_String] = kUpb_DecodeOp_String,
|
|
16655
|
-
[kRepeatedBase + kUpb_FieldType_Group] =
|
|
16887
|
+
[kRepeatedBase + kUpb_FieldType_Group] = kUpb_DecodeOp_UnknownField,
|
|
16656
16888
|
[kRepeatedBase + kUpb_FieldType_Message] = kUpb_DecodeOp_SubMessage,
|
|
16657
16889
|
[kRepeatedBase + kUpb_FieldType_Bytes] = kUpb_DecodeOp_Bytes,
|
|
16658
16890
|
[kRepeatedBase + kUpb_FieldType_UInt32] = OP_VARPCK_LG2(2),
|
|
@@ -16738,7 +16970,7 @@ const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
|
|
|
16738
16970
|
default:
|
|
16739
16971
|
break;
|
|
16740
16972
|
}
|
|
16741
|
-
upb_ErrorHandler_ThrowError(
|
|
16973
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16742
16974
|
}
|
|
16743
16975
|
|
|
16744
16976
|
UPB_FORCEINLINE
|
|
@@ -16754,7 +16986,7 @@ const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
|
|
|
16754
16986
|
upb_Extension* ext = UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
16755
16987
|
msg, ext_layout, &d->arena);
|
|
16756
16988
|
if (UPB_UNLIKELY(!ext)) {
|
|
16757
|
-
upb_ErrorHandler_ThrowError(
|
|
16989
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
16758
16990
|
}
|
|
16759
16991
|
d->original_msg = msg;
|
|
16760
16992
|
msg = &ext->data.UPB_PRIVATE(ext_msg_val);
|
|
@@ -16772,42 +17004,116 @@ const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
|
|
|
16772
17004
|
}
|
|
16773
17005
|
}
|
|
16774
17006
|
|
|
16775
|
-
|
|
16776
|
-
|
|
16777
|
-
|
|
17007
|
+
UPB_FORCEINLINE
|
|
17008
|
+
bool _upb_Decoder_CanSkipUnknownField(upb_Decoder* d, uint32_t next_field_num,
|
|
17009
|
+
uint32_t next_wire_type,
|
|
17010
|
+
const upb_MiniTable* mt, uint32_t* gap_lo,
|
|
17011
|
+
uint32_t* gap_hi, bool is_extendable) {
|
|
17012
|
+
if (next_wire_type == kUpb_WireType_EndGroup) {
|
|
17013
|
+
return false;
|
|
17014
|
+
}
|
|
17015
|
+
|
|
17016
|
+
if (UPB_UNLIKELY(upb_MiniTable_IsMessageSet(mt))) {
|
|
17017
|
+
if (next_field_num == kUpb_MsgSet_Item) {
|
|
17018
|
+
return false;
|
|
17019
|
+
}
|
|
17020
|
+
}
|
|
17021
|
+
|
|
17022
|
+
if (next_field_num <= *gap_lo || next_field_num >= *gap_hi) {
|
|
17023
|
+
if (UPB_LIKELY(next_field_num == *gap_hi)) {
|
|
17024
|
+
// Common case of fields in ascending order encountering a known
|
|
17025
|
+
// field
|
|
17026
|
+
return false;
|
|
17027
|
+
}
|
|
17028
|
+
if (UPB_UNLIKELY(next_field_num == 0)) {
|
|
17029
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
17030
|
+
}
|
|
17031
|
+
if (next_field_num == *gap_lo) {
|
|
17032
|
+
return false;
|
|
17033
|
+
}
|
|
17034
|
+
if (!UPB_PRIVATE(_upb_MiniTable_FindUnknownGap)(mt, next_field_num, gap_lo,
|
|
17035
|
+
gap_hi)) {
|
|
17036
|
+
return false;
|
|
17037
|
+
}
|
|
17038
|
+
}
|
|
17039
|
+
|
|
17040
|
+
if (is_extendable) {
|
|
17041
|
+
if (upb_ExtensionRegistry_Lookup(d->extreg, mt, next_field_num)) {
|
|
17042
|
+
return false;
|
|
17043
|
+
}
|
|
17044
|
+
}
|
|
17045
|
+
|
|
17046
|
+
return true;
|
|
17047
|
+
}
|
|
17048
|
+
|
|
17049
|
+
UPB_NOINLINE
|
|
17050
|
+
static const char* _upb_Decoder_DecodeUnknowns(
|
|
17051
|
+
upb_Decoder* d, const char* ptr, upb_Message* msg, const upb_MiniTable* mt,
|
|
17052
|
+
uint32_t field_number, uint32_t wire_type, wireval val, const char* start) {
|
|
16778
17053
|
if (field_number == 0) {
|
|
16779
|
-
upb_ErrorHandler_ThrowError(
|
|
17054
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_Malformed);
|
|
16780
17055
|
}
|
|
16781
17056
|
|
|
16782
|
-
|
|
17057
|
+
upb_EpsCopyCapture capture;
|
|
17058
|
+
upb_EpsCopyCapture_Start(&capture, &d->input, start);
|
|
16783
17059
|
|
|
17060
|
+
// We have already parsed the tag and "value" (or size) of the first unknown
|
|
17061
|
+
// field. ptr is currently:
|
|
17062
|
+
// - after value for Varint, 32Bit, 64Bit.
|
|
17063
|
+
// - after size for Delimited.
|
|
17064
|
+
// - after tag for StartGroup.
|
|
17065
|
+
|
|
17066
|
+
// We need to finish skipping the first field.
|
|
16784
17067
|
if (wire_type == kUpb_WireType_Delimited) {
|
|
16785
17068
|
upb_StringView sv;
|
|
16786
17069
|
ptr = upb_EpsCopyInputStream_ReadStringEphemeral(&d->input, ptr, val.size,
|
|
16787
17070
|
&sv);
|
|
16788
|
-
if (!ptr) upb_ErrorHandler_ThrowError(&d->err, kUpb_DecodeStatus_Malformed);
|
|
16789
17071
|
} else if (wire_type == kUpb_WireType_StartGroup) {
|
|
16790
17072
|
ptr = UPB_PRIVATE(_upb_WireReader_SkipGroup)(ptr, field_number << 3,
|
|
16791
17073
|
d->depth, &d->input);
|
|
16792
17074
|
}
|
|
16793
17075
|
|
|
16794
|
-
|
|
16795
|
-
|
|
17076
|
+
// Fast check if next fields are also unknown, based on the gap between known
|
|
17077
|
+
// fields our first unknown falls between.
|
|
16796
17078
|
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
|
|
17079
|
+
uint32_t gap_lo = 0;
|
|
17080
|
+
uint32_t gap_hi = 0;
|
|
17081
|
+
bool has_gap = UPB_PRIVATE(_upb_MiniTable_FindUnknownGap)(mt, field_number,
|
|
17082
|
+
&gap_lo, &gap_hi);
|
|
17083
|
+
|
|
17084
|
+
if (has_gap) {
|
|
17085
|
+
bool is_extendable =
|
|
17086
|
+
(UPB_UNLIKELY(UPB_PRIVATE(_upb_MiniTable_IsExtendable)(mt)) ||
|
|
17087
|
+
UPB_UNLIKELY(upb_MiniTable_IsMessageSet(mt))) &&
|
|
17088
|
+
d->extreg;
|
|
17089
|
+
while (!upb_EpsCopyInputStream_IsDone(EPS(d), &ptr)) {
|
|
17090
|
+
const char* start_ptr = ptr;
|
|
17091
|
+
uint32_t tag;
|
|
17092
|
+
ptr = upb_WireReader_ReadTag(ptr, &tag, EPS(d));
|
|
17093
|
+
|
|
17094
|
+
uint32_t next_field_num = tag >> 3;
|
|
17095
|
+
uint32_t next_wire_type = tag & 7;
|
|
17096
|
+
|
|
17097
|
+
if (_upb_Decoder_CanSkipUnknownField(d, next_field_num, next_wire_type,
|
|
17098
|
+
mt, &gap_lo, &gap_hi,
|
|
17099
|
+
is_extendable)) {
|
|
17100
|
+
ptr = _upb_WireReader_SkipValueForceInline(ptr, tag, d->depth, EPS(d));
|
|
17101
|
+
} else {
|
|
17102
|
+
ptr = start_ptr;
|
|
17103
|
+
break;
|
|
17104
|
+
}
|
|
16805
17105
|
}
|
|
16806
17106
|
}
|
|
16807
17107
|
|
|
16808
|
-
|
|
16809
|
-
|
|
16810
|
-
|
|
17108
|
+
upb_StringView sv;
|
|
17109
|
+
upb_EpsCopyCapture_End(&capture, &d->input, ptr, &sv);
|
|
17110
|
+
|
|
17111
|
+
if (UPB_LIKELY(sv.size > 0)) {
|
|
17112
|
+
if (!UPB_PRIVATE(_upb_Message_AddUnknown)(
|
|
17113
|
+
msg, sv.data, sv.size, &d->arena,
|
|
17114
|
+
_upb_Decoder_GetAddUnknownMode(d, sv.data))) {
|
|
17115
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
17116
|
+
}
|
|
16811
17117
|
}
|
|
16812
17118
|
|
|
16813
17119
|
return ptr;
|
|
@@ -16841,8 +17147,8 @@ const char* _upb_Decoder_DecodeFieldData(
|
|
|
16841
17147
|
} else {
|
|
16842
17148
|
switch (op) {
|
|
16843
17149
|
case kUpb_DecodeOp_UnknownField:
|
|
16844
|
-
return
|
|
16845
|
-
|
|
17150
|
+
return _upb_Decoder_DecodeUnknowns(d, ptr, msg, mt, field_number,
|
|
17151
|
+
wire_type, val, start);
|
|
16846
17152
|
case kUpb_DecodeOp_MessageSetItem:
|
|
16847
17153
|
return upb_Decoder_DecodeMessageSetItem(d, ptr, msg, mt);
|
|
16848
17154
|
default:
|
|
@@ -16883,18 +17189,21 @@ bool _upb_Decoder_TryDecodeMessageFast(upb_Decoder* d, const char** ptr,
|
|
|
16883
17189
|
const upb_MiniTable* mt,
|
|
16884
17190
|
uint64_t last_field_index,
|
|
16885
17191
|
uint64_t data) {
|
|
16886
|
-
#
|
|
17192
|
+
#if UPB_FASTTABLE
|
|
16887
17193
|
if (mt->UPB_PRIVATE(table_mask) == (unsigned char)-1 ||
|
|
16888
17194
|
(d->options & kUpb_DecodeOption_DisableFastTable)) {
|
|
16889
17195
|
// Fast table is unavailable or disabled.
|
|
16890
17196
|
return false;
|
|
16891
17197
|
}
|
|
16892
17198
|
|
|
16893
|
-
|
|
16894
|
-
const char* start =
|
|
17199
|
+
uint64_t data2 = upb_DecodeFastData2_PackMask(mt->UPB_PRIVATE(table_mask));
|
|
17200
|
+
const char* start =
|
|
17201
|
+
UPB_PRIVATE(upb_EpsCopyInputStream_GetInputPtr)(&d->input, *ptr);
|
|
16895
17202
|
char* trace_next = _upb_Decoder_TraceNext(d);
|
|
16896
17203
|
|
|
16897
|
-
|
|
17204
|
+
upb_FastDecoder_Return ret =
|
|
17205
|
+
upb_DecodeFast_Dispatch(d, *ptr, msg, mt, 0, 0, data2);
|
|
17206
|
+
*ptr = ret.ptr;
|
|
16898
17207
|
|
|
16899
17208
|
if (d->message_is_done) {
|
|
16900
17209
|
// The entire message was successfully parsed fast.
|
|
@@ -16909,7 +17218,10 @@ bool _upb_Decoder_TryDecodeMessageFast(upb_Decoder* d, const char** ptr,
|
|
|
16909
17218
|
// If the fast decoder consumed any data, it must have emitted at least
|
|
16910
17219
|
// one 'F' event into the trace buffer (in addition to the 'D' event
|
|
16911
17220
|
// that is always emitted).
|
|
16912
|
-
|
|
17221
|
+
const char* end =
|
|
17222
|
+
UPB_PRIVATE(upb_EpsCopyInputStream_GetInputPtr)(&d->input, *ptr);
|
|
17223
|
+
char* trace_end = _upb_Decoder_TracePtr(d);
|
|
17224
|
+
UPB_ASSERT(trace_end == NULL || trace_end != trace_next || end == start);
|
|
16913
17225
|
_upb_Decoder_Trace(d, '<');
|
|
16914
17226
|
#endif
|
|
16915
17227
|
return false;
|
|
@@ -16929,6 +17241,56 @@ const char* _upb_Decoder_DecodeField(upb_Decoder* d, const char* ptr,
|
|
|
16929
17241
|
return _upb_Decoder_DecodeFieldNoFast(d, ptr, msg, mt);
|
|
16930
17242
|
}
|
|
16931
17243
|
|
|
17244
|
+
UPB_NOINLINE
|
|
17245
|
+
static const char* _upb_Decoder_DecodeEmptyMessage(upb_Decoder* d,
|
|
17246
|
+
const char* ptr,
|
|
17247
|
+
upb_Message* msg) {
|
|
17248
|
+
if (upb_EpsCopyInputStream_IsDone(EPS(d), &ptr)) {
|
|
17249
|
+
return ptr;
|
|
17250
|
+
}
|
|
17251
|
+
|
|
17252
|
+
const char* start = ptr;
|
|
17253
|
+
const char* capture_end = ptr;
|
|
17254
|
+
upb_EpsCopyCapture capture;
|
|
17255
|
+
upb_EpsCopyCapture_Start(&capture, &d->input, start);
|
|
17256
|
+
while (!upb_EpsCopyInputStream_IsDone(EPS(d), &ptr)) {
|
|
17257
|
+
uint32_t tag;
|
|
17258
|
+
capture_end = ptr;
|
|
17259
|
+
ptr = upb_WireReader_ReadTag(ptr, &tag, EPS(d));
|
|
17260
|
+
if ((tag & 7) == kUpb_WireType_EndGroup) {
|
|
17261
|
+
d->end_group = tag >> 3;
|
|
17262
|
+
break;
|
|
17263
|
+
}
|
|
17264
|
+
ptr = _upb_WireReader_SkipValueForceInline(ptr, tag, d->depth, EPS(d));
|
|
17265
|
+
capture_end = ptr;
|
|
17266
|
+
}
|
|
17267
|
+
upb_StringView sv;
|
|
17268
|
+
upb_EpsCopyCapture_End(&capture, EPS(d), capture_end, &sv);
|
|
17269
|
+
|
|
17270
|
+
if (sv.size > 0) {
|
|
17271
|
+
if (!UPB_PRIVATE(_upb_Message_AddUnknown)(
|
|
17272
|
+
msg, sv.data, sv.size, &d->arena,
|
|
17273
|
+
_upb_Decoder_GetAddUnknownMode(d, sv.data))) {
|
|
17274
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
17275
|
+
}
|
|
17276
|
+
}
|
|
17277
|
+
return ptr;
|
|
17278
|
+
}
|
|
17279
|
+
|
|
17280
|
+
// When fasttable is enabled, _upb_Decoder_DecodeMessage possibly calls a
|
|
17281
|
+
// preserve_none function, which forces a spill of all callee-save registers
|
|
17282
|
+
// registers to the stack in its prologue and restoration in its epilogue, due
|
|
17283
|
+
// to mismatched calling conventions - the fast decoder (preserve_none) calls
|
|
17284
|
+
// _upb_Decoder_DecodeMessage (normal) which calls the fast decoder
|
|
17285
|
+
// (preserve_none). Arm has a lot of callee-save registers in its normal calling
|
|
17286
|
+
// convention, including a bunch of simd&fp registers that our preserve_none
|
|
17287
|
+
// caller is probably not actually using. To avoid this cost, all functions in
|
|
17288
|
+
// the call stack (excluding force-inlined) between the fast decoder's decode
|
|
17289
|
+
// message function and a recursive call to the fast decoder should use the fast
|
|
17290
|
+
// decoder's calling convention.
|
|
17291
|
+
#if UPB_FASTTABLE
|
|
17292
|
+
UPB_PRESERVE_NONE
|
|
17293
|
+
#endif
|
|
16932
17294
|
UPB_NOINLINE
|
|
16933
17295
|
const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
|
|
16934
17296
|
upb_Message* msg,
|
|
@@ -16936,6 +17298,12 @@ const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
|
|
|
16936
17298
|
UPB_ASSERT(mt);
|
|
16937
17299
|
UPB_ASSERT(d->message_is_done == false);
|
|
16938
17300
|
|
|
17301
|
+
if (UPB_UNLIKELY(upb_MiniTable_FieldCount(mt) == 0 &&
|
|
17302
|
+
UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(mt) ==
|
|
17303
|
+
kUpb_ExtMode_NonExtendable)) {
|
|
17304
|
+
return _upb_Decoder_DecodeEmptyMessage(d, ptr, msg);
|
|
17305
|
+
}
|
|
17306
|
+
|
|
16939
17307
|
do {
|
|
16940
17308
|
ptr = _upb_Decoder_DecodeField(d, ptr, msg, mt, 0, 0);
|
|
16941
17309
|
} while (!d->message_is_done);
|
|
@@ -16961,10 +17329,10 @@ static upb_DecodeStatus upb_Decoder_Decode(upb_Decoder* const decoder,
|
|
|
16961
17329
|
upb_Message* const msg,
|
|
16962
17330
|
const upb_MiniTable* const m,
|
|
16963
17331
|
upb_Arena* const arena) {
|
|
16964
|
-
if (UPB_SETJMP(decoder->err
|
|
16965
|
-
decoder->err
|
|
17332
|
+
if (UPB_SETJMP(decoder->err->buf) == 0) {
|
|
17333
|
+
decoder->err->code = _upb_Decoder_DecodeTop(decoder, buf, msg, m);
|
|
16966
17334
|
} else {
|
|
16967
|
-
UPB_ASSERT(decoder->err
|
|
17335
|
+
UPB_ASSERT(decoder->err->code != kUpb_DecodeStatus_Ok);
|
|
16968
17336
|
}
|
|
16969
17337
|
|
|
16970
17338
|
return upb_Decoder_Destroy(decoder, arena);
|
|
@@ -16985,7 +17353,10 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
|
|
|
16985
17353
|
upb_Arena* arena) {
|
|
16986
17354
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
16987
17355
|
upb_Decoder decoder;
|
|
16988
|
-
|
|
17356
|
+
upb_ErrorHandler err;
|
|
17357
|
+
upb_ErrorHandler_Init(&err);
|
|
17358
|
+
buf = upb_Decoder_Init(&decoder, buf, size, extreg, options, arena, &err,
|
|
17359
|
+
NULL, 0);
|
|
16989
17360
|
|
|
16990
17361
|
return upb_Decoder_Decode(&decoder, buf, msg, mt, arena);
|
|
16991
17362
|
}
|
|
@@ -16997,8 +17368,10 @@ upb_DecodeStatus upb_DecodeWithTrace(const char* buf, size_t size,
|
|
|
16997
17368
|
char* trace_buf, size_t trace_size) {
|
|
16998
17369
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
16999
17370
|
upb_Decoder decoder;
|
|
17000
|
-
|
|
17001
|
-
|
|
17371
|
+
upb_ErrorHandler err;
|
|
17372
|
+
upb_ErrorHandler_Init(&err);
|
|
17373
|
+
buf = upb_Decoder_Init(&decoder, buf, size, extreg, options, arena, &err,
|
|
17374
|
+
trace_buf, trace_size);
|
|
17002
17375
|
|
|
17003
17376
|
return upb_Decoder_Decode(&decoder, buf, msg, mt, arena);
|
|
17004
17377
|
}
|
|
@@ -17063,7 +17436,6 @@ const char* upb_DecodeStatus_String(upb_DecodeStatus status) {
|
|
|
17063
17436
|
// We encode backwards, to avoid pre-computing lengths (one-pass encode).
|
|
17064
17437
|
|
|
17065
17438
|
|
|
17066
|
-
#include <setjmp.h>
|
|
17067
17439
|
#include <stdbool.h>
|
|
17068
17440
|
#include <stdint.h>
|
|
17069
17441
|
#include <stdlib.h>
|
|
@@ -17072,6 +17444,186 @@ const char* upb_DecodeStatus_String(upb_DecodeStatus status) {
|
|
|
17072
17444
|
|
|
17073
17445
|
// Must be last.
|
|
17074
17446
|
|
|
17447
|
+
upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
|
17448
|
+
int options, upb_Arena* arena, char** buf,
|
|
17449
|
+
size_t* size) {
|
|
17450
|
+
return _upb_Encode(msg, l, options, arena, buf, size, false);
|
|
17451
|
+
}
|
|
17452
|
+
|
|
17453
|
+
upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
|
|
17454
|
+
const upb_MiniTable* l, int options,
|
|
17455
|
+
upb_Arena* arena, char** buf,
|
|
17456
|
+
size_t* size) {
|
|
17457
|
+
return _upb_Encode(msg, l, options, arena, buf, size, true);
|
|
17458
|
+
}
|
|
17459
|
+
|
|
17460
|
+
const char* upb_EncodeStatus_String(upb_EncodeStatus status) {
|
|
17461
|
+
switch (status) {
|
|
17462
|
+
case kUpb_EncodeStatus_Ok:
|
|
17463
|
+
return "Ok";
|
|
17464
|
+
case kUpb_EncodeStatus_MissingRequired:
|
|
17465
|
+
return "Missing required field";
|
|
17466
|
+
case kUpb_EncodeStatus_MaxDepthExceeded:
|
|
17467
|
+
return "Max depth exceeded";
|
|
17468
|
+
case kUpb_EncodeStatus_OutOfMemory:
|
|
17469
|
+
return "Arena alloc failed";
|
|
17470
|
+
default:
|
|
17471
|
+
return "Unknown encode status";
|
|
17472
|
+
}
|
|
17473
|
+
}
|
|
17474
|
+
|
|
17475
|
+
|
|
17476
|
+
#include <stddef.h>
|
|
17477
|
+
#include <stdint.h>
|
|
17478
|
+
#include <string.h>
|
|
17479
|
+
|
|
17480
|
+
|
|
17481
|
+
// Must be last.
|
|
17482
|
+
|
|
17483
|
+
char upb_BackAlloc_sentinel;
|
|
17484
|
+
|
|
17485
|
+
static size_t upb_BackAlloc_CalcBlockSize(upb_BackAlloc* a, size_t required,
|
|
17486
|
+
bool* one_off) {
|
|
17487
|
+
#if UPB_HWASAN
|
|
17488
|
+
required = UPB_ALIGN_UP(required, UPB_MALLOC_ALIGN);
|
|
17489
|
+
#endif
|
|
17490
|
+
size_t organic_block_size =
|
|
17491
|
+
UPB_PRIVATE(_upb_Arena_NextBlockSize)(a->arena, required, one_off);
|
|
17492
|
+
|
|
17493
|
+
// We want to offer amortized linear time, which means we must grow block
|
|
17494
|
+
// sizes exponentially. However, merely allocating a power of 2 is
|
|
17495
|
+
// pathological for allocators that use a header with mmap for large
|
|
17496
|
+
// contiguous allocations. Instead, we want to allocate based on a power of
|
|
17497
|
+
// 2, but request slightly less to leave room for backing allocator
|
|
17498
|
+
// metadata. If we had universal size feedback this would not be necessary.
|
|
17499
|
+
size_t scaled_block_size = upb_RoundUpToPowerOfTwo(required);
|
|
17500
|
+
|
|
17501
|
+
// Estimated value such that 128 bytes of possible overhead is not
|
|
17502
|
+
// significant. 128 bytes should be enough for whatever metadata is needed.
|
|
17503
|
+
if (scaled_block_size >= 4096 * 4) {
|
|
17504
|
+
scaled_block_size = upb_RoundUpToPowerOfTwo(required + 128) - 128;
|
|
17505
|
+
}
|
|
17506
|
+
|
|
17507
|
+
// Scaled block size calculations could overflow, but that's OK as it's
|
|
17508
|
+
// unsigned and won't be used if it's less than the organic block size
|
|
17509
|
+
if (scaled_block_size > organic_block_size) {
|
|
17510
|
+
return UPB_PRIVATE(_upb_Arena_NextBlockSize)(a->arena, scaled_block_size,
|
|
17511
|
+
one_off);
|
|
17512
|
+
}
|
|
17513
|
+
|
|
17514
|
+
return organic_block_size;
|
|
17515
|
+
}
|
|
17516
|
+
|
|
17517
|
+
static char* upb_BackAlloc_Realloc(upb_BackAlloc* a, char* ptr, size_t n) {
|
|
17518
|
+
size_t copy = a->limit - ptr;
|
|
17519
|
+
if (SIZE_MAX - copy < n) {
|
|
17520
|
+
return NULL;
|
|
17521
|
+
}
|
|
17522
|
+
|
|
17523
|
+
bool one_off = false;
|
|
17524
|
+
size_t required_block_size = copy + n;
|
|
17525
|
+
size_t size = upb_BackAlloc_CalcBlockSize(a, required_block_size, &one_off);
|
|
17526
|
+
|
|
17527
|
+
char* block = UPB_PRIVATE(_upb_Arena_AllocBlock)(a->arena, &size);
|
|
17528
|
+
|
|
17529
|
+
if (!block) {
|
|
17530
|
+
return NULL;
|
|
17531
|
+
}
|
|
17532
|
+
|
|
17533
|
+
UPB_PRIVATE(_upb_Arena_UpdateGrowthState)(a->arena, required_block_size, size,
|
|
17534
|
+
one_off);
|
|
17535
|
+
|
|
17536
|
+
char* dst = block + size - copy;
|
|
17537
|
+
memcpy(dst, ptr, copy);
|
|
17538
|
+
|
|
17539
|
+
if (a->limit != a->buf) {
|
|
17540
|
+
// Dispose of the old block.
|
|
17541
|
+
if (a->standalone) {
|
|
17542
|
+
// Note: while it would technically be possible to give this block to the
|
|
17543
|
+
// arena to use for allocations, this could lead to a lot of garbage
|
|
17544
|
+
// blocks that never get used.
|
|
17545
|
+
UPB_PRIVATE(_upb_Arena_FreeBlock)(a->arena, a->buf);
|
|
17546
|
+
} else {
|
|
17547
|
+
UPB_PRIVATE(_upb_Arena_UseBlock)(a->arena, a->buf, a->limit - a->buf);
|
|
17548
|
+
}
|
|
17549
|
+
}
|
|
17550
|
+
|
|
17551
|
+
a->buf = block;
|
|
17552
|
+
a->limit = block + size;
|
|
17553
|
+
a->standalone = true;
|
|
17554
|
+
return dst - n;
|
|
17555
|
+
}
|
|
17556
|
+
|
|
17557
|
+
char* upb_BackAlloc_Grow(upb_BackAlloc* a, char* ptr, size_t n) {
|
|
17558
|
+
if (a->limit == a->buf) {
|
|
17559
|
+
// First allocation: try to steal a block.
|
|
17560
|
+
size_t size = n;
|
|
17561
|
+
char* block = UPB_PRIVATE(_upb_Arena_Steal)(a->arena, &size);
|
|
17562
|
+
if (block) {
|
|
17563
|
+
UPB_ASSERT(size >= n);
|
|
17564
|
+
UPB_ASSERT(a->standalone == false);
|
|
17565
|
+
a->buf = block;
|
|
17566
|
+
a->limit = block + size;
|
|
17567
|
+
return a->limit - n;
|
|
17568
|
+
}
|
|
17569
|
+
}
|
|
17570
|
+
|
|
17571
|
+
return upb_BackAlloc_Realloc(a, ptr, n);
|
|
17572
|
+
}
|
|
17573
|
+
|
|
17574
|
+
|
|
17575
|
+
|
|
17576
|
+
|
|
17577
|
+
// Must be last.
|
|
17578
|
+
|
|
17579
|
+
UPB_NOINLINE
|
|
17580
|
+
const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
|
|
17581
|
+
const upb_Message* msg,
|
|
17582
|
+
const upb_MiniTable* m) {
|
|
17583
|
+
UPB_ASSERT(m->UPB_PRIVATE(required_count));
|
|
17584
|
+
if (UPB_UNLIKELY(d->options & kUpb_DecodeOption_CheckRequired)) {
|
|
17585
|
+
d->missing_required =
|
|
17586
|
+
d->missing_required ||
|
|
17587
|
+
!UPB_PRIVATE(_upb_Message_IsInitializedShallow)(msg, m);
|
|
17588
|
+
}
|
|
17589
|
+
return ptr;
|
|
17590
|
+
}
|
|
17591
|
+
|
|
17592
|
+
// We encode backwards, to avoid pre-computing lengths (one-pass encode).
|
|
17593
|
+
|
|
17594
|
+
|
|
17595
|
+
#include <setjmp.h>
|
|
17596
|
+
#include <stddef.h>
|
|
17597
|
+
#include <stdint.h>
|
|
17598
|
+
#include <string.h>
|
|
17599
|
+
|
|
17600
|
+
|
|
17601
|
+
// Must be last.
|
|
17602
|
+
|
|
17603
|
+
UPB_NOINLINE bool _upb_Encoder_AddMapEntryUnknown(
|
|
17604
|
+
upb_Message* msg, const upb_MiniTableField* field, upb_Message* ent_msg,
|
|
17605
|
+
const upb_MiniTable* entry, upb_Arena* arena) {
|
|
17606
|
+
char* buf;
|
|
17607
|
+
size_t size;
|
|
17608
|
+
upb_EncodeStatus status =
|
|
17609
|
+
_upb_Encode(ent_msg, entry, 0, arena, &buf, &size, false);
|
|
17610
|
+
if (status != kUpb_EncodeStatus_Ok) {
|
|
17611
|
+
return false;
|
|
17612
|
+
}
|
|
17613
|
+
char delim_buf[2 * kUpb_Encoder_EncodeVarint32MaxSize];
|
|
17614
|
+
char* delim_end = delim_buf;
|
|
17615
|
+
uint32_t tag =
|
|
17616
|
+
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Delimited;
|
|
17617
|
+
delim_end = upb_Encoder_EncodeVarint32(tag, delim_end);
|
|
17618
|
+
delim_end = upb_Encoder_EncodeVarint32(size, delim_end);
|
|
17619
|
+
upb_StringView unknown[] = {
|
|
17620
|
+
{delim_buf, delim_end - delim_buf},
|
|
17621
|
+
{buf, size},
|
|
17622
|
+
};
|
|
17623
|
+
|
|
17624
|
+
return UPB_PRIVATE(_upb_Message_AddUnknownV)(msg, arena, unknown, 2);
|
|
17625
|
+
}
|
|
17626
|
+
|
|
17075
17627
|
static uint32_t encode_zz32(int32_t n) {
|
|
17076
17628
|
return ((uint32_t)n << 1) ^ (n >> 31);
|
|
17077
17629
|
}
|
|
@@ -17079,62 +17631,29 @@ static uint64_t encode_zz64(int64_t n) {
|
|
|
17079
17631
|
return ((uint64_t)n << 1) ^ (n >> 63);
|
|
17080
17632
|
}
|
|
17081
17633
|
|
|
17082
|
-
typedef struct {
|
|
17083
|
-
upb_EncodeStatus status;
|
|
17084
|
-
jmp_buf err;
|
|
17085
|
-
upb_Arena* arena;
|
|
17086
|
-
// These should only be used for arithmetic and reallocation to allow full
|
|
17087
|
-
// aliasing analysis on the ptr argument.
|
|
17088
|
-
const char UPB_NODEREF *buf, *limit;
|
|
17089
|
-
int options;
|
|
17090
|
-
int depth;
|
|
17091
|
-
_upb_mapsorter sorter;
|
|
17092
|
-
} upb_encstate;
|
|
17093
|
-
|
|
17094
17634
|
UPB_NORETURN static void encode_err(upb_encstate* e, upb_EncodeStatus s) {
|
|
17095
17635
|
UPB_ASSERT(s != kUpb_EncodeStatus_Ok);
|
|
17096
17636
|
e->status = s;
|
|
17097
|
-
UPB_LONGJMP(e->err, 1);
|
|
17637
|
+
UPB_LONGJMP(*e->err, 1);
|
|
17098
17638
|
}
|
|
17099
17639
|
|
|
17100
|
-
// Subtraction is used for bounds checks, and the C standard says that pointer
|
|
17101
|
-
// subtraction is UB if the pointers aren't part of the same array or one past
|
|
17102
|
-
// the end, so we must avoid NULL - NULL. C++ defines it though.
|
|
17103
|
-
static char initial_buf_sentinel;
|
|
17104
|
-
|
|
17105
17640
|
UPB_NOINLINE static char* encode_growbuffer(char* ptr, upb_encstate* e,
|
|
17106
17641
|
size_t bytes) {
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
size_t new_size = upb_RoundUpToPowerOfTwo(UPB_MAX(128, needed_size));
|
|
17111
|
-
if (new_size == old_size) encode_err(e, kUpb_EncodeStatus_OutOfMemory);
|
|
17112
|
-
void* old_buf = e->buf == &initial_buf_sentinel ? NULL : (void*)e->buf;
|
|
17113
|
-
char* new_buf = upb_Arena_Realloc(e->arena, old_buf, old_size, new_size);
|
|
17114
|
-
|
|
17115
|
-
if (!new_buf) encode_err(e, kUpb_EncodeStatus_OutOfMemory);
|
|
17116
|
-
|
|
17117
|
-
// We want previous data at the end, realloc() put it at the beginning.
|
|
17118
|
-
// TODO: This is somewhat inefficient since we are copying twice.
|
|
17119
|
-
// Maybe create a realloc() that copies to the end of the new buffer?
|
|
17120
|
-
if (old_size > 0) {
|
|
17121
|
-
memmove(new_buf + new_size - old_size, new_buf, old_size);
|
|
17642
|
+
ptr = upb_BackAlloc_Grow(&e->alloc, ptr, bytes);
|
|
17643
|
+
if (ptr == NULL) {
|
|
17644
|
+
encode_err(e, kUpb_EncodeStatus_OutOfMemory);
|
|
17122
17645
|
}
|
|
17123
|
-
|
|
17124
|
-
e->buf = new_buf;
|
|
17125
|
-
e->limit = new_buf + new_size;
|
|
17126
|
-
return new_buf + new_size - needed_size;
|
|
17646
|
+
return ptr;
|
|
17127
17647
|
}
|
|
17128
17648
|
|
|
17129
|
-
|
|
17130
|
-
|
|
17649
|
+
// Call to ensure that at least `bytes` bytes are available for writing at
|
|
17650
|
+
// ptr.
|
|
17131
17651
|
UPB_FORCEINLINE
|
|
17132
17652
|
char* encode_reserve(char* ptr, upb_encstate* e, size_t bytes) {
|
|
17133
|
-
if ((
|
|
17134
|
-
return
|
|
17653
|
+
if (upb_BackAlloc_HasBytes(&e->alloc, ptr, bytes)) {
|
|
17654
|
+
return ptr - bytes;
|
|
17135
17655
|
}
|
|
17136
|
-
|
|
17137
|
-
return ptr - bytes;
|
|
17656
|
+
return encode_growbuffer(ptr, e, bytes);
|
|
17138
17657
|
}
|
|
17139
17658
|
|
|
17140
17659
|
static char* encode_bytes_unchecked(char* ptr, upb_encstate* e,
|
|
@@ -17306,7 +17825,7 @@ char* encode_varint_unchecked(char* ptr, upb_encstate* e, uint64_t val) {
|
|
|
17306
17825
|
}
|
|
17307
17826
|
UPB_FORCEINLINE
|
|
17308
17827
|
char* encode_varint(char* ptr, upb_encstate* e, uint64_t val) {
|
|
17309
|
-
if (val < 128 && ptr
|
|
17828
|
+
if (val < 128 && upb_BackAlloc_HasBytes(&e->alloc, ptr, 1)) {
|
|
17310
17829
|
--ptr;
|
|
17311
17830
|
*ptr = val;
|
|
17312
17831
|
return ptr;
|
|
@@ -17325,7 +17844,7 @@ char* encode_longlength(char* ptr, upb_encstate* e, uint64_t val) {
|
|
|
17325
17844
|
|
|
17326
17845
|
UPB_FORCEINLINE
|
|
17327
17846
|
char* encode_length(char* ptr, upb_encstate* e, uint64_t val) {
|
|
17328
|
-
if (val < 128 && ptr
|
|
17847
|
+
if (val < 128 && upb_BackAlloc_HasBytes(&e->alloc, ptr, 1)) {
|
|
17329
17848
|
--ptr;
|
|
17330
17849
|
*ptr = val;
|
|
17331
17850
|
return ptr;
|
|
@@ -17402,9 +17921,6 @@ static char* encode_fixedarray(char* ptr, upb_encstate* e, const upb_Array* arr,
|
|
|
17402
17921
|
}
|
|
17403
17922
|
}
|
|
17404
17923
|
|
|
17405
|
-
static char* encode_message(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
17406
|
-
const upb_MiniTable* m, size_t* size);
|
|
17407
|
-
|
|
17408
17924
|
static char* encode_scalar(char* ptr, upb_encstate* e, const void* field_mem,
|
|
17409
17925
|
const upb_MiniTableField* f) {
|
|
17410
17926
|
// Max size is tag + 10 bytes for max varint or 8 for largest fixed size
|
|
@@ -17497,26 +18013,30 @@ static char* encode_array(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
|
17497
18013
|
const upb_MiniTableField* f) {
|
|
17498
18014
|
const upb_Array* arr = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), upb_Array*);
|
|
17499
18015
|
bool packed = upb_MiniTableField_IsPacked(f);
|
|
17500
|
-
size_t pre_len = e->
|
|
18016
|
+
size_t pre_len = upb_BackAlloc_Size(&e->alloc, ptr);
|
|
17501
18017
|
|
|
17502
18018
|
if (arr == NULL || upb_Array_Size(arr) == 0) {
|
|
17503
18019
|
return ptr;
|
|
17504
18020
|
}
|
|
17505
18021
|
|
|
17506
|
-
#define VARINT_CASE(ctype, encode)
|
|
17507
|
-
{
|
|
17508
|
-
const ctype* start = upb_Array_DataPtr(arr);
|
|
17509
|
-
const ctype* arr_ptr = start + upb_Array_Size(arr);
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
18022
|
+
#define VARINT_CASE(ctype, encode) \
|
|
18023
|
+
{ \
|
|
18024
|
+
const ctype* start = upb_Array_DataPtr(arr); \
|
|
18025
|
+
const ctype* arr_ptr = start + upb_Array_Size(arr); \
|
|
18026
|
+
if (packed) { \
|
|
18027
|
+
do { \
|
|
18028
|
+
arr_ptr--; \
|
|
18029
|
+
ptr = encode_varint(ptr, e, encode); \
|
|
18030
|
+
} while (arr_ptr != start); \
|
|
18031
|
+
} else { \
|
|
18032
|
+
uint32_t number = upb_MiniTableField_Number(f); \
|
|
18033
|
+
do { \
|
|
18034
|
+
arr_ptr--; \
|
|
18035
|
+
ptr = encode_varint(ptr, e, encode); \
|
|
18036
|
+
ptr = encode_tag(ptr, e, number, kUpb_WireType_Varint); \
|
|
18037
|
+
} while (arr_ptr != start); \
|
|
18038
|
+
} \
|
|
18039
|
+
} \
|
|
17520
18040
|
break;
|
|
17521
18041
|
|
|
17522
18042
|
#define TAG(wire_type) (packed ? 0 : (f->UPB_PRIVATE(number) << 3 | wire_type))
|
|
@@ -17604,7 +18124,7 @@ static char* encode_array(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
|
17604
18124
|
#undef VARINT_CASE
|
|
17605
18125
|
|
|
17606
18126
|
if (packed) {
|
|
17607
|
-
ptr = encode_length(ptr, e, e->
|
|
18127
|
+
ptr = encode_length(ptr, e, upb_BackAlloc_Size(&e->alloc, ptr) - pre_len);
|
|
17608
18128
|
ptr = encode_tag(ptr, e, upb_MiniTableField_Number(f),
|
|
17609
18129
|
kUpb_WireType_Delimited);
|
|
17610
18130
|
}
|
|
@@ -17616,11 +18136,11 @@ static char* encode_mapentry(char* ptr, upb_encstate* e, uint32_t number,
|
|
|
17616
18136
|
const upb_MapEntry* ent) {
|
|
17617
18137
|
const upb_MiniTableField* key_field = upb_MiniTable_MapKey(layout);
|
|
17618
18138
|
const upb_MiniTableField* val_field = upb_MiniTable_MapValue(layout);
|
|
17619
|
-
size_t pre_len = e->
|
|
18139
|
+
size_t pre_len = upb_BackAlloc_Size(&e->alloc, ptr);
|
|
17620
18140
|
size_t size;
|
|
17621
18141
|
ptr = encode_scalar(ptr, e, &ent->v, val_field);
|
|
17622
18142
|
ptr = encode_scalar(ptr, e, &ent->k, key_field);
|
|
17623
|
-
size = (e->
|
|
18143
|
+
size = upb_BackAlloc_Size(&e->alloc, ptr) - pre_len;
|
|
17624
18144
|
ptr = encode_length(ptr, e, size);
|
|
17625
18145
|
ptr = encode_tag(ptr, e, number, kUpb_WireType_Delimited);
|
|
17626
18146
|
return ptr;
|
|
@@ -17635,20 +18155,6 @@ static char* encode_map(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
|
17635
18155
|
if (!map || !upb_Map_Size(map)) return ptr;
|
|
17636
18156
|
|
|
17637
18157
|
if (e->options & kUpb_EncodeOption_Deterministic) {
|
|
17638
|
-
if (!map->UPB_PRIVATE(is_strtable)) {
|
|
17639
|
-
// For inttable, first encode the array part, then sort the table entries.
|
|
17640
|
-
intptr_t iter = UPB_INTTABLE_BEGIN;
|
|
17641
|
-
while ((size_t)++iter < map->t.inttable.array_size) {
|
|
17642
|
-
upb_value value = map->t.inttable.array[iter];
|
|
17643
|
-
if (upb_inttable_arrhas(&map->t.inttable, iter)) {
|
|
17644
|
-
upb_MapEntry ent;
|
|
17645
|
-
memcpy(&ent.k, &iter, sizeof(iter));
|
|
17646
|
-
_upb_map_fromvalue(value, &ent.v, map->val_size);
|
|
17647
|
-
ptr = encode_mapentry(ptr, e, upb_MiniTableField_Number(f), layout,
|
|
17648
|
-
&ent);
|
|
17649
|
-
}
|
|
17650
|
-
}
|
|
17651
|
-
}
|
|
17652
18158
|
_upb_sortedmap sorted;
|
|
17653
18159
|
_upb_mapsorter_pushmap(
|
|
17654
18160
|
&e->sorter, layout->UPB_PRIVATE(fields)[0].UPB_PRIVATE(descriptortype),
|
|
@@ -17767,7 +18273,8 @@ static char* encode_ext(char* ptr, upb_encstate* e,
|
|
|
17767
18273
|
|
|
17768
18274
|
static char* encode_exts(char* ptr, upb_encstate* e, const upb_MiniTable* m,
|
|
17769
18275
|
const upb_Message* msg) {
|
|
17770
|
-
if (
|
|
18276
|
+
if (UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(m) == kUpb_ExtMode_NonExtendable)
|
|
18277
|
+
return ptr;
|
|
17771
18278
|
|
|
17772
18279
|
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
17773
18280
|
if (!in) return ptr;
|
|
@@ -17792,7 +18299,8 @@ static char* encode_exts(char* ptr, upb_encstate* e, const upb_MiniTable* m,
|
|
|
17792
18299
|
const upb_Extension* ext;
|
|
17793
18300
|
while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) {
|
|
17794
18301
|
ptr = encode_ext(ptr, e, ext->ext, ext->data,
|
|
17795
|
-
|
|
18302
|
+
UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(m) ==
|
|
18303
|
+
kUpb_ExtMode_IsMessageSet);
|
|
17796
18304
|
}
|
|
17797
18305
|
_upb_mapsorter_popmap(&e->sorter, &sorted);
|
|
17798
18306
|
} else {
|
|
@@ -17805,9 +18313,9 @@ static char* encode_exts(char* ptr, upb_encstate* e, const upb_MiniTable* m,
|
|
|
17805
18313
|
return ptr;
|
|
17806
18314
|
}
|
|
17807
18315
|
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
size_t pre_len = e->
|
|
18316
|
+
char* encode_message(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
18317
|
+
const upb_MiniTable* m, size_t* size) {
|
|
18318
|
+
size_t pre_len = upb_BackAlloc_Size(&e->alloc, ptr);
|
|
17811
18319
|
|
|
17812
18320
|
if (e->options & kUpb_EncodeOption_CheckRequired) {
|
|
17813
18321
|
if (m->UPB_PRIVATE(required_count)) {
|
|
@@ -17851,7 +18359,7 @@ static char* encode_message(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
|
17851
18359
|
}
|
|
17852
18360
|
}
|
|
17853
18361
|
|
|
17854
|
-
*size = (e->
|
|
18362
|
+
*size = upb_BackAlloc_Size(&e->alloc, ptr) - pre_len;
|
|
17855
18363
|
return ptr;
|
|
17856
18364
|
}
|
|
17857
18365
|
|
|
@@ -17865,100 +18373,67 @@ static upb_EncodeStatus upb_Encoder_Encode(char* ptr,
|
|
|
17865
18373
|
// code paths which blindly copy the returned pointer without bothering to
|
|
17866
18374
|
// check for errors until much later (b/235839510). So we still set *buf to
|
|
17867
18375
|
// NULL on error and we still set it to non-NULL on a successful empty result.
|
|
17868
|
-
if (UPB_SETJMP(encoder->err) == 0) {
|
|
18376
|
+
if (UPB_SETJMP(*encoder->err) == 0) {
|
|
17869
18377
|
size_t encoded_msg_size;
|
|
17870
18378
|
ptr = encode_message(ptr, encoder, msg, l, &encoded_msg_size);
|
|
17871
18379
|
if (prepend_len) {
|
|
17872
18380
|
ptr = encode_length(ptr, encoder, encoded_msg_size);
|
|
17873
18381
|
}
|
|
17874
|
-
*size = encoder->
|
|
17875
|
-
|
|
17876
|
-
static char ch;
|
|
17877
|
-
*buf = &ch;
|
|
17878
|
-
} else {
|
|
17879
|
-
UPB_ASSERT(ptr);
|
|
17880
|
-
*buf = ptr;
|
|
17881
|
-
}
|
|
18382
|
+
*size = upb_BackAlloc_Finish(&encoder->alloc, ptr);
|
|
18383
|
+
*buf = ptr;
|
|
17882
18384
|
} else {
|
|
17883
18385
|
UPB_ASSERT(encoder->status != kUpb_EncodeStatus_Ok);
|
|
18386
|
+
upb_BackAlloc_Abort(&encoder->alloc);
|
|
17884
18387
|
*buf = NULL;
|
|
17885
18388
|
*size = 0;
|
|
17886
18389
|
}
|
|
17887
|
-
|
|
17888
|
-
_upb_mapsorter_destroy(&encoder->sorter);
|
|
18390
|
+
UPB_PRIVATE(_upb_encstate_destroy)(encoder);
|
|
17889
18391
|
return encoder->status;
|
|
17890
18392
|
}
|
|
17891
18393
|
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options) {
|
|
17897
|
-
uint16_t max_depth = upb_EncodeOptions_GetMaxDepth(options);
|
|
17898
|
-
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
|
|
17899
|
-
}
|
|
17900
|
-
|
|
17901
|
-
static upb_EncodeStatus _upb_Encode(const upb_Message* msg,
|
|
17902
|
-
const upb_MiniTable* l, int options,
|
|
17903
|
-
upb_Arena* arena, char** buf, size_t* size,
|
|
17904
|
-
bool prepend_len) {
|
|
18394
|
+
upb_EncodeStatus _upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
|
18395
|
+
int options, upb_Arena* arena, char** buf,
|
|
18396
|
+
size_t* size, bool prepend_len) {
|
|
17905
18397
|
upb_encstate e;
|
|
18398
|
+
jmp_buf err;
|
|
17906
18399
|
|
|
17907
18400
|
e.status = kUpb_EncodeStatus_Ok;
|
|
17908
|
-
e.
|
|
17909
|
-
|
|
17910
|
-
e.limit = &initial_buf_sentinel;
|
|
18401
|
+
e.err = &err;
|
|
18402
|
+
char* ptr = upb_BackAlloc_Init(&e.alloc, arena);
|
|
17911
18403
|
e.depth = upb_EncodeOptions_GetEffectiveMaxDepth(options);
|
|
17912
18404
|
e.options = options;
|
|
17913
18405
|
_upb_mapsorter_init(&e.sorter);
|
|
17914
18406
|
|
|
17915
|
-
return upb_Encoder_Encode(
|
|
17916
|
-
prepend_len);
|
|
17917
|
-
}
|
|
17918
|
-
|
|
17919
|
-
upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
|
17920
|
-
int options, upb_Arena* arena, char** buf,
|
|
17921
|
-
size_t* size) {
|
|
17922
|
-
return _upb_Encode(msg, l, options, arena, buf, size, false);
|
|
17923
|
-
}
|
|
17924
|
-
|
|
17925
|
-
upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
|
|
17926
|
-
const upb_MiniTable* l, int options,
|
|
17927
|
-
upb_Arena* arena, char** buf,
|
|
17928
|
-
size_t* size) {
|
|
17929
|
-
return _upb_Encode(msg, l, options, arena, buf, size, true);
|
|
17930
|
-
}
|
|
17931
|
-
|
|
17932
|
-
const char* upb_EncodeStatus_String(upb_EncodeStatus status) {
|
|
17933
|
-
switch (status) {
|
|
17934
|
-
case kUpb_EncodeStatus_Ok:
|
|
17935
|
-
return "Ok";
|
|
17936
|
-
case kUpb_EncodeStatus_MissingRequired:
|
|
17937
|
-
return "Missing required field";
|
|
17938
|
-
case kUpb_EncodeStatus_MaxDepthExceeded:
|
|
17939
|
-
return "Max depth exceeded";
|
|
17940
|
-
case kUpb_EncodeStatus_OutOfMemory:
|
|
17941
|
-
return "Arena alloc failed";
|
|
17942
|
-
default:
|
|
17943
|
-
return "Unknown encode status";
|
|
17944
|
-
}
|
|
18407
|
+
return upb_Encoder_Encode(ptr, &e, msg, l, buf, size, prepend_len);
|
|
17945
18408
|
}
|
|
17946
18409
|
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
18410
|
+
upb_EncodeStatus UPB_PRIVATE(_upb_Encode_Field)(upb_encstate* e,
|
|
18411
|
+
const upb_Message* msg,
|
|
18412
|
+
const upb_MiniTableField* field,
|
|
18413
|
+
char** buf, size_t* size,
|
|
18414
|
+
int options) {
|
|
18415
|
+
e->options = options;
|
|
18416
|
+
e->depth = upb_EncodeOptions_GetEffectiveMaxDepth(options);
|
|
18417
|
+
char* ptr = *buf;
|
|
18418
|
+
if (encode_shouldencode(msg, field)) {
|
|
18419
|
+
ptr = encode_field(ptr, e, msg, field);
|
|
18420
|
+
}
|
|
18421
|
+
*size = upb_BackAlloc_Finish(&e->alloc, ptr);
|
|
18422
|
+
*buf = ptr;
|
|
18423
|
+
return e->status;
|
|
18424
|
+
}
|
|
18425
|
+
|
|
18426
|
+
upb_EncodeStatus UPB_PRIVATE(_upb_Encode_Extension)(
|
|
18427
|
+
upb_encstate* e, const upb_MiniTableExtension* ext,
|
|
18428
|
+
upb_MessageValue ext_val, bool is_message_set, char** buf, size_t* size,
|
|
18429
|
+
int options) {
|
|
18430
|
+
e->options = options;
|
|
18431
|
+
e->depth = upb_EncodeOptions_GetEffectiveMaxDepth(options);
|
|
18432
|
+
char* ptr = *buf;
|
|
18433
|
+
ptr = encode_ext(ptr, e, ext, ext_val, is_message_set);
|
|
18434
|
+
*size = upb_BackAlloc_Finish(&e->alloc, ptr);
|
|
18435
|
+
*buf = ptr;
|
|
18436
|
+
return e->status;
|
|
17962
18437
|
}
|
|
17963
18438
|
|
|
17964
18439
|
|
|
@@ -17968,11 +18443,10 @@ const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
|
|
|
17968
18443
|
|
|
17969
18444
|
// Must be last.
|
|
17970
18445
|
|
|
17971
|
-
|
|
17972
|
-
upb_EpsCopyInputStream* e) {
|
|
18446
|
+
UPB_NORETURN UPB_NOINLINE void UPB_PRIVATE(
|
|
18447
|
+
upb_EpsCopyInputStream_ThrowMalformed)(upb_EpsCopyInputStream* e) {
|
|
17973
18448
|
e->error = true;
|
|
17974
|
-
|
|
17975
|
-
return NULL;
|
|
18449
|
+
upb_ErrorHandler_ThrowError(e->err, kUpb_ErrorCode_Malformed);
|
|
17976
18450
|
}
|
|
17977
18451
|
|
|
17978
18452
|
const char* UPB_PRIVATE(upb_EpsCopyInputStream_IsDoneFallback)(
|
|
@@ -18098,12 +18572,15 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)(
|
|
|
18098
18572
|
#undef UPB_NORETURN
|
|
18099
18573
|
#undef UPB_PRINTF
|
|
18100
18574
|
#undef UPB_NODEREF
|
|
18575
|
+
#undef UPB_NODISCARD
|
|
18101
18576
|
#undef UPB_MAX
|
|
18102
18577
|
#undef UPB_MIN
|
|
18103
18578
|
#undef UPB_UNUSED
|
|
18104
18579
|
#undef UPB_ASSUME
|
|
18105
18580
|
#undef UPB_ASSERT
|
|
18106
18581
|
#undef UPB_UNREACHABLE
|
|
18582
|
+
#undef UPB_UNREACHABLE_FAILURE
|
|
18583
|
+
#undef UPB_PRETTY_FUNCTION
|
|
18107
18584
|
#undef UPB_DEFAULT_MAX_BLOCK_SIZE
|
|
18108
18585
|
#undef UPB_SETJMP
|
|
18109
18586
|
#undef UPB_LONGJMP
|
|
@@ -18137,7 +18614,6 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)(
|
|
|
18137
18614
|
#undef UPB_LINKARR_APPEND
|
|
18138
18615
|
#undef UPB_LINKARR_START
|
|
18139
18616
|
#undef UPB_LINKARR_STOP
|
|
18140
|
-
#undef UPB_FUTURE_BREAKING_CHANGES
|
|
18141
18617
|
#undef UPB_HAS_ATTRIBUTE
|
|
18142
18618
|
#undef UPB_HAS_CPP_ATTRIBUTE
|
|
18143
18619
|
#undef UPB_HAS_BUILTIN
|