Commit graph

96 commits

Author SHA1 Message Date
Protobuf Team Bot
0eafd3c3e4 Internal change.
PiperOrigin-RevId: 964172133
2026-08-13 10:53:40 -07:00
Protobuf Team Bot
a5412936c7 Annotate extension names in hpb generator for Kythe metadata.
PiperOrigin-RevId: 957381097
2026-07-31 16:16:26 -07:00
Protobuf Team Bot
e0fd1807a7 Emit Kythe metadata pragma in generated HPB headers
PiperOrigin-RevId: 933756732
2026-06-17 09:07:57 -07:00
Protobuf Team Bot
c5a405c0b7 Add Kythe indexing support to HPB proto in C++
PiperOrigin-RevId: 929969615
2026-06-10 11:24:41 -07:00
Hong Shin
09a8d9a5e5 hpb: update null_enum.proto to edition 2024
PiperOrigin-RevId: 885178675
2026-03-17 13:24:30 -07:00
Protobuf Team Bot
a4dd212110 hpb: escape NULL enum values and types to NULL_
This change ensures that enums and enum values named NULL are correctly escaped to NULL_ in the generated C++ code,
avoiding conflicts with the NULL macro. Added a regression test case to verify the fix.

PiperOrigin-RevId: 861526129
2026-01-26 22:46:59 -08:00
Joshua Haberman
3a3560bb87 Removed the third_party/upb/upb/bazel directory.
We are absorbing its contents into other directories. This will reduce the 3:1 merge to `upb/bazel` in GitHub to 2:1 (soon to be 1:1).

PiperOrigin-RevId: 860299666
2026-01-23 16:35:18 -08:00
Protobuf Team Bot
7e1188d3cd Automated rollback of commit 733abfd86d.
PiperOrigin-RevId: 846799221
2025-12-19 11:07:59 -08:00
Hong Shin
733abfd86d hpb/cpp: [mk3] wrap proto2 messages so that they're invocable in terra hpb, starting with simple scalars (bools)
PiperOrigin-RevId: 846266989
2025-12-18 07:55:53 -08:00
Protobuf Team Bot
0327bd62cc Automated rollback of commit e7e1adc4d5.
PiperOrigin-RevId: 843334457
2025-12-11 12:49:45 -08:00
Hong Shin
e7e1adc4d5 hpb/cpp: wrap proto2 messages so that they're invocable in terra hpb, starting with simple scalars (bools)
PiperOrigin-RevId: 843217783
2025-12-11 07:45:34 -08:00
Joshua Haberman
af91d2a2fc Rolling forward after fixing the weak symbol linking for optimized iOS builds.
The previous CL's approach of using `__attribute__((weakref()))` was not actually behaving as expected, and the unit tests were not sufficient to catch this.

We now use inline assembly to achieve the functionality that we thought we were getting with `__attribute__((weakref()))`.  From assembly, we can create a weak symbol whose value is the same as another "stub" symbol in the same file.

Unfortunately we cannot have all of our weak symbols reference a single placeholder "empty" message, due to a bug I discovered in the LLVM linker and reported in https://github.com/llvm/llvm-project/issues/167262

If and when that bug is fixed, we should be able to get optimal tree shaking behavior, even on iOS.

PiperOrigin-RevId: 831396179
2025-11-12 08:21:20 -08:00
Joshua Haberman
f79742a2dc Automated jj rollback of changelist 829022414
*** Reason for rollback ***

Breaking tests.

PiperOrigin-RevId: 829158111
2025-11-06 16:46:00 -08:00
Joshua Haberman
1a54fdb2c3 Removed indirection for sub-messages.
To do this, we use `__attribute__((weakref()))` to weakly reference a placeholder definition for tree shaken sub-messages.  This provides the same tree shaking behavior we had before, but without needing an extra indirection.  If we had discovered this technique before, we would have had no reason to add the indirection in cl/640369522.

This will reduce the code size and memory overhead of any MiniTables with sub-messages in them, because we no longer need an extra `void*` per sub-message field to store the extra indirect pointer.

It also should improve efficiency a bit since there is one fewer indirection when recursing into a sub-message field.

PiperOrigin-RevId: 829022414
2025-11-06 10:55:15 -08:00
Hong Shin
f8b4a29c50 hpb: update options ParseOptionsDefault -> DefaultParseOptions
PiperOrigin-RevId: 816214632
2025-10-07 08:19:35 -07:00
Hong Shin
ecf96a8a0e hpb: update test_generated and message_lock_test to use hpb::Parse<T> -> hpb::StatusOr<T>
PiperOrigin-RevId: 815820145
2025-10-06 11:48:29 -07:00
Hong Shin
64b8b12cc3 hpb: update extension_test to use hpb::Parse -> hpb::StatusOr<T>
PiperOrigin-RevId: 811021098
2025-09-24 13:55:43 -07:00
Hong Shin
2516dcfb9d hpb: add arena check for set_alias + maps
PiperOrigin-RevId: 810537103
2025-09-23 12:25:27 -07:00
Hong Shin
68a2efb987 hpb: introduce hpb::StatusOr<T> parse that takes in hpb::ParseOptions
This CL deprecates the hpb::Parse overload that returns absl::StatusOr<T>. Instead, prefer hpb::Parse -> hpb::StatusOr<T>.

String aliasing via upb is allow plumbed through with this CL.

PiperOrigin-RevId: 808732870
2025-09-18 14:20:54 -07:00
Hong Shin
73a75ff992 hpb/oss: replace trigraph test with escaped string test
This allows us to remove trigraph enabling in hpb ci as well :)

PiperOrigin-RevId: 808144179
2025-09-17 07:28:38 -07:00
Hong Shin
6a2009e976 hpb/oss: correct IsOkayAndHolds using for oss
PiperOrigin-RevId: 804524664
2025-09-08 11:51:47 -07:00
Joshua Haberman
75e8d668b0 Factored out logic for undefing/restoring OS macros so it can be reused by hpb.
PiperOrigin-RevId: 804513731
2025-09-08 11:24:11 -07:00
Hong Shin
c9c7c43f1f hpb/oss: add missing dep: status matchers for extension_test
PiperOrigin-RevId: 804452526
2025-09-08 08:57:48 -07:00
Hong Shin
9d1b8d5e98 hpb/oss: remove obsolete UPB_DEFAULT_COPTS from hpb_generator/tests/BUILD
PiperOrigin-RevId: 803141569
2025-09-04 13:04:13 -07:00
Protobuf Team Bot
2bbd96ceab hpb: Check array is not nullptr before dereferencing it.
If a repeated field is empty, upb_Array is nullptr.

Repeated string and message fields already have similar checks. This bug only
affects empty repeated scalar fields.

PiperOrigin-RevId: 800474430
2025-08-28 08:25:59 -07:00
Protobuf Team Bot
93643810a9 Add arena ownership APIs
PiperOrigin-RevId: 799699199
2025-08-26 13:51:58 -07:00
Hong Shin
735621f7d7 hpb/oss: update hpb .proto include paths to hpb_generator/...
PiperOrigin-RevId: 785863458
2025-07-22 08:32:22 -07:00
Hong Shin
27c7c508fb hpb/oss: restore all targets in hpb_generator/tests/BUILD
PiperOrigin-RevId: 784229166
2025-07-17 10:26:33 -07:00
Hong Shin
0f0feeab28 hpb/oss: tweak copybara hpbgencode path to point to toplvl hpb_generator.
PiperOrigin-RevId: 783856451
2025-07-16 12:48:12 -07:00
Hong Shin
1d6a5b6ef9 hpb: Add support for initial block sizes when initting an hpb::arena. This allows us to re-enable the extension_test that disallows fusing.
PiperOrigin-RevId: 783406087
2025-07-15 11:26:57 -07:00
Protobuf Team Bot
8af5fadbea Automated Code Change
PiperOrigin-RevId: 783038271
2025-07-14 14:18:30 -07:00
Hong Shin
dd96fcdb8b hpb: Introduce canonical hpb::Arena
During our migration, we merely aliased `hpb::Arena` to `upb::Arena` (upb's C++ RAII wrapper for `upb_Arena`).

The alias has served us well, but it's now time to transition to a class that'll support our multibackend goals. Henceforth, `hpb::Arena` shall contain an arena based on the SELECTED backend (upb, cpp).

If the underlying upb arena needs to be accessed, `arena.ptr()` will no longer work; one must go through `hpb::interop::upb::UnwrapArena`.

If the backend is upb, the arena also has support for `.Fuse` and `.IsFused`.

PiperOrigin-RevId: 774808755
2025-06-23 09:26:37 -07:00
Hong Shin
90d75c58ba hpb: temporarily disable SetExtensionFusingFailureShouldCopy while we refactor hpb::Arena
hpb::Arena can't take init blocks right now, but soon should be able to, since both backends {upb, cpp} support it. We'll re-enable then.
PiperOrigin-RevId: 772593594
2025-06-17 13:20:55 -07:00
Craig Tiller
ed930a5433 Adjust hpb include paths
PiperOrigin-RevId: 771259798
2025-06-13 16:15:38 -07:00
Craig Tiller
5b710becb4 Automated rollback of commit 7620bbf3c6.
PiperOrigin-RevId: 770733506
2025-06-12 11:25:36 -07:00
Hong Shin
9b766a185d hpb: update internal tests upb::arena -> hpb::arena
PiperOrigin-RevId: 759255007
2025-05-15 12:34:41 -07:00
Hong Shin
6b52343311 hpb: [multibackend] in this CL, we elide the generation of upb gencode if backend=cpp is detected. In that case, generator.cc will now generate a hpb(cpp) impl with message stubs.
Note that the old runtime's code (proto2::cpp) is not wrapped just yet.

PiperOrigin-RevId: 758164686
2025-05-13 04:56:12 -07:00
Hong Shin
eabe78e032 hpb: obliterate .upb.proto.h in favor of .hpb.h - bye! 👋
PiperOrigin-RevId: 748001080
2025-04-15 13:34:23 -07:00
Protobuf Team Bot
56daa37fa1 Automated Code Change
PiperOrigin-RevId: 745030509
2025-04-08 01:31:11 -07:00
Hong Shin
e439961617 hpb: emit both .upb.proto.h and .hpb.h - temporary while we fully transition to .hpb.h
PiperOrigin-RevId: 743583013
2025-04-03 09:03:00 -07:00
Protobuf Team Bot
8c51540cb5 Update hpb generator to include full containing-type prefix for enums
PiperOrigin-RevId: 740802587
2025-03-26 09:47:57 -07:00
Hong Shin
751d6bb8e0 hpb: make ExtensionNumber inside ExtensionIdentifier accessible in a constexpr context
We expunge the emission of the ExtensionIdentifier in the cc and `inline constexpr` it in the .h.

The extension number is fed into the constexpr ExtensionIdentifier ctor and now the id can be requested at compile time (e.g. constexpr auto extension_number = hpb::ExtensionNumber(your_extension_name_here)).

PiperOrigin-RevId: 740749472
2025-03-26 06:57:10 -07:00
Hong Shin
f587cf5663 hpb: Add support for string extensions
We introduce a UpbExtensionTrait specialization for absl::string_view.

PiperOrigin-RevId: 734232249
2025-03-06 11:58:54 -08:00
Protobuf Team Bot
ab83b8d444 hpb: Add support for setting extensions as aliases
PiperOrigin-RevId: 725747180
2025-02-11 13:27:26 -08:00
Hong Shin
178f8db655 hpb: Introduce CloneMessage with hpb::Arena + Deprecate CloneMessage w/ upb_arena*
PiperOrigin-RevId: 712906220
2025-01-07 07:38:39 -08:00
Hong Shin
cac05fe0d1 hpb: Introduce UPB_EXT_PRIMITIVE to flesh out all remaining scalars for extensions
In this CL, we add the macro UPB_EXT_PRIMITIVE.
The template specializations are practically identical sans the CppType and UpbFunc called, so we now consolidate via this macro.

Added support for uint32/64, float/double, and bool.
Getting and setting exts of ^ in hpb should all work, and fetch the proper default value as well (if provided in the .proto).

PiperOrigin-RevId: 707897721
2024-12-19 06:56:15 -08:00
Hong Shin
758b1fb871 hpb: support hpb::RepeatedField<T> inside extensions (GetExtension)
Before this change, hpb had no way of returning repeated fields (that are extensions) -- they were incorrectly treated as pure scalars (int32 vs repeated<int32>).

We rectify this hole and now return RepeatedField<T> for a given T.

This CL also cleans up the `if constexpr` special casing we were performing inside GetExtension and delegates that to the UpbExtensionTrait.

PiperOrigin-RevId: 706789273
2024-12-16 12:13:03 -08:00
Hong Shin
74cbd3126f hpb: refactor repeated tests to repeated_test.cc
PiperOrigin-RevId: 698015352
2024-11-19 07:54:46 -08:00
Hong Shin
8549d0ae47 hpb: refactor extension_test.cc into its own file
PiperOrigin-RevId: 697739629
2024-11-18 13:35:31 -08:00
Hong Shin
f72b1034b4 hpb: impl GlobalExtensionRegistry
We introduce hpb::ExtensionRegistry::generated_registry. In the future, Parse calls will default to this being the default registry, while still being able to supply their own (if needed).

PiperOrigin-RevId: 697690765
2024-11-18 11:07:56 -08:00