/src/sentencepiece/third_party/protobuf-lite/google/protobuf/arena.h
Line | Count | Source |
1 | | // Protocol Buffers - Google's data interchange format |
2 | | // Copyright 2008 Google Inc. All rights reserved. |
3 | | // https://developers.google.com/protocol-buffers/ |
4 | | // |
5 | | // Redistribution and use in source and binary forms, with or without |
6 | | // modification, are permitted provided that the following conditions are |
7 | | // met: |
8 | | // |
9 | | // * Redistributions of source code must retain the above copyright |
10 | | // notice, this list of conditions and the following disclaimer. |
11 | | // * Redistributions in binary form must reproduce the above |
12 | | // copyright notice, this list of conditions and the following disclaimer |
13 | | // in the documentation and/or other materials provided with the |
14 | | // distribution. |
15 | | // * Neither the name of Google Inc. nor the names of its |
16 | | // contributors may be used to endorse or promote products derived from |
17 | | // this software without specific prior written permission. |
18 | | // |
19 | | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
20 | | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
21 | | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
22 | | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
23 | | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 | | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 | | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 | | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 | | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | | |
31 | | // This file defines an Arena allocator for better allocation performance. |
32 | | |
33 | | #ifndef GOOGLE_PROTOBUF_ARENA_H__ |
34 | | #define GOOGLE_PROTOBUF_ARENA_H__ |
35 | | |
36 | | |
37 | | #include <limits> |
38 | | #include <type_traits> |
39 | | #include <utility> |
40 | | #ifdef max |
41 | | #undef max // Visual Studio defines this macro |
42 | | #endif |
43 | | #if defined(_MSC_VER) && !defined(_LIBCPP_STD_VER) && !_HAS_EXCEPTIONS |
44 | | // Work around bugs in MSVC <typeinfo> header when _HAS_EXCEPTIONS=0. |
45 | | #include <exception> |
46 | | #include <typeinfo> |
47 | | namespace std { |
48 | | using type_info = ::type_info; |
49 | | } |
50 | | #else |
51 | | #include <typeinfo> |
52 | | #endif |
53 | | |
54 | | #include <type_traits> |
55 | | #include <google/protobuf/arena_impl.h> |
56 | | #include <google/protobuf/port.h> |
57 | | |
58 | | #include <google/protobuf/port_def.inc> |
59 | | |
60 | | #ifdef SWIG |
61 | | #error "You cannot SWIG proto headers" |
62 | | #endif |
63 | | |
64 | | namespace google { |
65 | | namespace protobuf { |
66 | | |
67 | | struct ArenaOptions; // defined below |
68 | | |
69 | | } // namespace protobuf |
70 | | } // namespace google |
71 | | |
72 | | namespace google { |
73 | | namespace protobuf { |
74 | | |
75 | | class Arena; // defined below |
76 | | class Message; // defined in message.h |
77 | | class MessageLite; |
78 | | template <typename Key, typename T> |
79 | | class Map; |
80 | | |
81 | | namespace arena_metrics { |
82 | | |
83 | | void EnableArenaMetrics(ArenaOptions* options); |
84 | | |
85 | | } // namespace arena_metrics |
86 | | |
87 | | namespace internal { |
88 | | |
89 | | struct ArenaStringPtr; // defined in arenastring.h |
90 | | class LazyField; // defined in lazy_field.h |
91 | | class EpsCopyInputStream; // defined in parse_context.h |
92 | | |
93 | | template <typename Type> |
94 | | class GenericTypeHandler; // defined in repeated_field.h |
95 | | |
96 | | // Templated cleanup methods. |
97 | | template <typename T> |
98 | 0 | void arena_destruct_object(void* object) { |
99 | 0 | reinterpret_cast<T*>(object)->~T(); |
100 | 0 | } Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::internal::ImplicitWeakMessage>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::SentencePieceText_SentencePiece>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::SentencePieceText>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::NBestSentencePieceText>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::TrainerSpec>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::NormalizerSpec>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::SelfTestData_Sample>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::SelfTestData>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::ModelProto_SentencePiece>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<sentencepiece::ModelProto>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<int> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<long> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<unsigned int> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<unsigned long> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<float> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<double> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedField<bool> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite> >(void*) Unexecuted instantiation: void google::protobuf::internal::arena_destruct_object<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > > >(void*) |
101 | | template <typename T> |
102 | 0 | void arena_delete_object(void* object) { |
103 | 0 | delete reinterpret_cast<T*>(object); |
104 | 0 | } Unexecuted instantiation: void google::protobuf::internal::arena_delete_object<google::protobuf::MessageLite>(void*) Unexecuted instantiation: void google::protobuf::internal::arena_delete_object<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(void*) |
105 | | } // namespace internal |
106 | | |
107 | | // ArenaOptions provides optional additional parameters to arena construction |
108 | | // that control its block-allocation behavior. |
109 | | struct ArenaOptions { |
110 | | // This defines the size of the first block requested from the system malloc. |
111 | | // Subsequent block sizes will increase in a geometric series up to a maximum. |
112 | | size_t start_block_size; |
113 | | |
114 | | // This defines the maximum block size requested from system malloc (unless an |
115 | | // individual arena allocation request occurs with a size larger than this |
116 | | // maximum). Requested block sizes increase up to this value, then remain |
117 | | // here. |
118 | | size_t max_block_size; |
119 | | |
120 | | // An initial block of memory for the arena to use, or NULL for none. If |
121 | | // provided, the block must live at least as long as the arena itself. The |
122 | | // creator of the Arena retains ownership of the block after the Arena is |
123 | | // destroyed. |
124 | | char* initial_block; |
125 | | |
126 | | // The size of the initial block, if provided. |
127 | | size_t initial_block_size; |
128 | | |
129 | | // A function pointer to an alloc method that returns memory blocks of size |
130 | | // requested. By default, it contains a ptr to the malloc function. |
131 | | // |
132 | | // NOTE: block_alloc and dealloc functions are expected to behave like |
133 | | // malloc and free, including Asan poisoning. |
134 | | void* (*block_alloc)(size_t); |
135 | | // A function pointer to a dealloc method that takes ownership of the blocks |
136 | | // from the arena. By default, it contains a ptr to a wrapper function that |
137 | | // calls free. |
138 | | void (*block_dealloc)(void*, size_t); |
139 | | |
140 | | ArenaOptions() |
141 | | : start_block_size(kDefaultStartBlockSize), |
142 | | max_block_size(kDefaultMaxBlockSize), |
143 | | initial_block(NULL), |
144 | | initial_block_size(0), |
145 | | block_alloc(kDefaultBlockAlloc), |
146 | | block_dealloc(&internal::ArenaFree), |
147 | 0 | make_metrics_collector(nullptr) {} |
148 | | |
149 | | PROTOBUF_EXPORT static void* (*const kDefaultBlockAlloc)(size_t); |
150 | | |
151 | | private: |
152 | | // If make_metrics_collector is not nullptr, it will be called at Arena init |
153 | | // time. It may return a pointer to a collector instance that will be notified |
154 | | // of interesting events related to the arena. |
155 | | internal::ArenaMetricsCollector* (*make_metrics_collector)(); |
156 | | |
157 | | // Constants define default starting block size and max block size for |
158 | | // arena allocator behavior -- see descriptions above. |
159 | | static const size_t kDefaultStartBlockSize = |
160 | | internal::ArenaImpl::kDefaultStartBlockSize; |
161 | | static const size_t kDefaultMaxBlockSize = |
162 | | internal::ArenaImpl::kDefaultMaxBlockSize; |
163 | | |
164 | | friend void arena_metrics::EnableArenaMetrics(ArenaOptions*); |
165 | | |
166 | | friend class Arena; |
167 | | friend class ArenaOptionsTestFriend; |
168 | | friend class internal::ArenaImpl; |
169 | | }; |
170 | | |
171 | | // Support for non-RTTI environments. (The metrics hooks API uses type |
172 | | // information.) |
173 | | #if PROTOBUF_RTTI |
174 | 0 | #define RTTI_TYPE_ID(type) (&typeid(type)) |
175 | | #else |
176 | | #define RTTI_TYPE_ID(type) (NULL) |
177 | | #endif |
178 | | |
179 | | // Arena allocator. Arena allocation replaces ordinary (heap-based) allocation |
180 | | // with new/delete, and improves performance by aggregating allocations into |
181 | | // larger blocks and freeing allocations all at once. Protocol messages are |
182 | | // allocated on an arena by using Arena::CreateMessage<T>(Arena*), below, and |
183 | | // are automatically freed when the arena is destroyed. |
184 | | // |
185 | | // This is a thread-safe implementation: multiple threads may allocate from the |
186 | | // arena concurrently. Destruction is not thread-safe and the destructing |
187 | | // thread must synchronize with users of the arena first. |
188 | | // |
189 | | // An arena provides two allocation interfaces: CreateMessage<T>, which works |
190 | | // for arena-enabled proto2 message types as well as other types that satisfy |
191 | | // the appropriate protocol (described below), and Create<T>, which works for |
192 | | // any arbitrary type T. CreateMessage<T> is better when the type T supports it, |
193 | | // because this interface (i) passes the arena pointer to the created object so |
194 | | // that its sub-objects and internal allocations can use the arena too, and (ii) |
195 | | // elides the object's destructor call when possible. Create<T> does not place |
196 | | // any special requirements on the type T, and will invoke the object's |
197 | | // destructor when the arena is destroyed. |
198 | | // |
199 | | // The arena message allocation protocol, required by |
200 | | // CreateMessage<T>(Arena* arena, Args&&... args), is as follows: |
201 | | // |
202 | | // - The type T must have (at least) two constructors: a constructor callable |
203 | | // with `args` (without `arena`), called when a T is allocated on the heap; |
204 | | // and a constructor callable with `Arena* arena, Args&&... args`, called when |
205 | | // a T is allocated on an arena. If the second constructor is called with a |
206 | | // NULL arena pointer, it must be equivalent to invoking the first |
207 | | // (`args`-only) constructor. |
208 | | // |
209 | | // - The type T must have a particular type trait: a nested type |
210 | | // |InternalArenaConstructable_|. This is usually a typedef to |void|. If no |
211 | | // such type trait exists, then the instantiation CreateMessage<T> will fail |
212 | | // to compile. |
213 | | // |
214 | | // - The type T *may* have the type trait |DestructorSkippable_|. If this type |
215 | | // trait is present in the type, then its destructor will not be called if and |
216 | | // only if it was passed a non-NULL arena pointer. If this type trait is not |
217 | | // present on the type, then its destructor is always called when the |
218 | | // containing arena is destroyed. |
219 | | // |
220 | | // This protocol is implemented by all arena-enabled proto2 message classes as |
221 | | // well as protobuf container types like RepeatedPtrField and Map. The protocol |
222 | | // is internal to protobuf and is not guaranteed to be stable. Non-proto types |
223 | | // should not rely on this protocol. |
224 | | class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { |
225 | | public: |
226 | | // Default constructor with sensible default options, tuned for average |
227 | | // use-cases. |
228 | 0 | inline Arena() : impl_() {} |
229 | | |
230 | | // Construct an arena with default options, except for the supplied |
231 | | // initial block. It is more efficient to use this constructor |
232 | | // instead of passing ArenaOptions if the only configuration needed |
233 | | // by the caller is supplying an initial block. |
234 | | inline Arena(char* initial_block, size_t initial_block_size) |
235 | 0 | : impl_(initial_block, initial_block_size) {} |
236 | | |
237 | | // Arena constructor taking custom options. See ArenaOptions above for |
238 | | // descriptions of the options available. |
239 | 0 | explicit Arena(const ArenaOptions& options) : impl_(options) {} |
240 | | |
241 | | // Block overhead. Use this as a guide for how much to over-allocate the |
242 | | // initial block if you want an allocation of size N to fit inside it. |
243 | | // |
244 | | // WARNING: if you allocate multiple objects, it is difficult to guarantee |
245 | | // that a series of allocations will fit in the initial block, especially if |
246 | | // Arena changes its alignment guarantees in the future! |
247 | | static const size_t kBlockOverhead = internal::ArenaImpl::kBlockHeaderSize + |
248 | | internal::ArenaImpl::kSerialArenaSize; |
249 | | |
250 | 0 | inline ~Arena() {} |
251 | | |
252 | | // TODO(protobuf-team): Fix callers to use constructor and delete this method. |
253 | 0 | void Init(const ArenaOptions&) {} |
254 | | |
255 | | // API to create proto2 message objects on the arena. If the arena passed in |
256 | | // is NULL, then a heap allocated object is returned. Type T must be a message |
257 | | // defined in a .proto file with cc_enable_arenas set to true, otherwise a |
258 | | // compilation error will occur. |
259 | | // |
260 | | // RepeatedField and RepeatedPtrField may also be instantiated directly on an |
261 | | // arena with this method. |
262 | | // |
263 | | // This function also accepts any type T that satisfies the arena message |
264 | | // allocation protocol, documented above. |
265 | | template <typename T, typename... Args> |
266 | 0 | PROTOBUF_ALWAYS_INLINE static T* CreateMessage(Arena* arena, Args&&... args) { |
267 | 0 | static_assert( |
268 | 0 | InternalHelper<T>::is_arena_constructable::value, |
269 | 0 | "CreateMessage can only construct types that are ArenaConstructable"); |
270 | | // We must delegate to CreateMaybeMessage() and NOT CreateMessageInternal() |
271 | | // because protobuf generated classes specialize CreateMaybeMessage() and we |
272 | | // need to use that specialization for code size reasons. |
273 | 0 | return Arena::CreateMaybeMessage<T>(arena, std::forward<Args>(args)...); |
274 | 0 | } Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::CreateMessage<google::protobuf::internal::ImplicitWeakMessage>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<int>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<long>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<unsigned int>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<unsigned long>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<float>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<double>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedField<bool>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::CreateMessage<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>>(google::protobuf::Arena*) |
275 | | |
276 | | // API to create any objects on the arena. Note that only the object will |
277 | | // be created on the arena; the underlying ptrs (in case of a proto2 message) |
278 | | // will be still heap allocated. Proto messages should usually be allocated |
279 | | // with CreateMessage<T>() instead. |
280 | | // |
281 | | // Note that even if T satisfies the arena message construction protocol |
282 | | // (InternalArenaConstructable_ trait and optional DestructorSkippable_ |
283 | | // trait), as described above, this function does not follow the protocol; |
284 | | // instead, it treats T as a black-box type, just as if it did not have these |
285 | | // traits. Specifically, T's constructor arguments will always be only those |
286 | | // passed to Create<T>() -- no additional arena pointer is implicitly added. |
287 | | // Furthermore, the destructor will always be called at arena destruction time |
288 | | // (unless the destructor is trivial). Hence, from T's point of view, it is as |
289 | | // if the object were allocated on the heap (except that the underlying memory |
290 | | // is obtained from the arena). |
291 | | template <typename T, typename... Args> |
292 | 0 | PROTOBUF_ALWAYS_INLINE static T* Create(Arena* arena, Args&&... args) { |
293 | 0 | return CreateNoMessage<T>(arena, is_arena_constructable<T>(), |
294 | 0 | std::forward<Args>(args)...); |
295 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::Create<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::Create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::Create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::Create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::Create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::Create<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(google::protobuf::Arena*) |
296 | | |
297 | | // Create an array of object type T on the arena *without* invoking the |
298 | | // constructor of T. If `arena` is null, then the return value should be freed |
299 | | // with `delete[] x;` (or `::operator delete[](x);`). |
300 | | // To ensure safe uses, this function checks at compile time |
301 | | // (when compiled as C++11) that T is trivially default-constructible and |
302 | | // trivially destructible. |
303 | | template <typename T> |
304 | | PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena, |
305 | 0 | size_t num_elements) { |
306 | 0 | static_assert(std::is_pod<T>::value, |
307 | 0 | "CreateArray requires a trivially constructible type"); |
308 | 0 | static_assert(std::is_trivially_destructible<T>::value, |
309 | 0 | "CreateArray requires a trivially destructible type"); |
310 | 0 | GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T)) |
311 | 0 | << "Requested size is too large to fit into size_t."; |
312 | 0 | if (arena == NULL) { |
313 | 0 | return static_cast<T*>(::operator new[](num_elements * sizeof(T))); |
314 | 0 | } else { |
315 | 0 | return arena->CreateInternalRawArray<T>(num_elements); |
316 | 0 | } |
317 | 0 | } Unexecuted instantiation: char* google::protobuf::Arena::CreateArray<char>(google::protobuf::Arena*, unsigned long) Unexecuted instantiation: google::protobuf::internal::ExtensionSet::KeyValue* google::protobuf::Arena::CreateArray<google::protobuf::internal::ExtensionSet::KeyValue>(google::protobuf::Arena*, unsigned long) |
318 | | |
319 | | // Returns the total space allocated by the arena, which is the sum of the |
320 | | // sizes of the underlying blocks. This method is relatively fast; a counter |
321 | | // is kept as blocks are allocated. |
322 | 0 | uint64 SpaceAllocated() const { return impl_.SpaceAllocated(); } |
323 | | // Returns the total space used by the arena. Similar to SpaceAllocated but |
324 | | // does not include free space and block overhead. The total space returned |
325 | | // may not include space used by other threads executing concurrently with |
326 | | // the call to this method. |
327 | 0 | uint64 SpaceUsed() const { return impl_.SpaceUsed(); } |
328 | | |
329 | | // Frees all storage allocated by this arena after calling destructors |
330 | | // registered with OwnDestructor() and freeing objects registered with Own(). |
331 | | // Any objects allocated on this arena are unusable after this call. It also |
332 | | // returns the total space used by the arena which is the sums of the sizes |
333 | | // of the allocated blocks. This method is not thread-safe. |
334 | 0 | uint64 Reset() { return impl_.Reset(); } |
335 | | |
336 | | // Adds |object| to a list of heap-allocated objects to be freed with |delete| |
337 | | // when the arena is destroyed or reset. |
338 | | template <typename T> |
339 | 0 | PROTOBUF_NOINLINE void Own(T* object) { |
340 | 0 | OwnInternal(object, std::is_convertible<T*, Message*>()); |
341 | 0 | } Unexecuted instantiation: void google::protobuf::Arena::Own<google::protobuf::MessageLite>(google::protobuf::MessageLite*) Unexecuted instantiation: void google::protobuf::Arena::Own<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) |
342 | | |
343 | | // Adds |object| to a list of objects whose destructors will be manually |
344 | | // called when the arena is destroyed or reset. This differs from Own() in |
345 | | // that it does not free the underlying memory with |delete|; hence, it is |
346 | | // normally only used for objects that are placement-newed into |
347 | | // arena-allocated memory. |
348 | | template <typename T> |
349 | 0 | PROTOBUF_NOINLINE void OwnDestructor(T* object) { |
350 | 0 | if (object != NULL) { |
351 | 0 | impl_.AddCleanup(object, &internal::arena_destruct_object<T>); |
352 | 0 | } |
353 | 0 | } |
354 | | |
355 | | // Adds a custom member function on an object to the list of destructors that |
356 | | // will be manually called when the arena is destroyed or reset. This differs |
357 | | // from OwnDestructor() in that any member function may be specified, not only |
358 | | // the class destructor. |
359 | | PROTOBUF_NOINLINE void OwnCustomDestructor(void* object, |
360 | 0 | void (*destruct)(void*)) { |
361 | 0 | impl_.AddCleanup(object, destruct); |
362 | 0 | } |
363 | | |
364 | | // Retrieves the arena associated with |value| if |value| is an arena-capable |
365 | | // message, or NULL otherwise. If possible, the call resolves at compile time. |
366 | | // Note that we can often devirtualize calls to `value->GetArena()` so usually |
367 | | // calling this method is unnecessary. |
368 | | template <typename T> |
369 | 0 | PROTOBUF_ALWAYS_INLINE static Arena* GetArena(const T* value) { |
370 | 0 | return GetArenaInternal(value); |
371 | 0 | } Unexecuted instantiation: google::protobuf::Arena* google::protobuf::Arena::GetArena<sentencepiece::TrainerSpec>(sentencepiece::TrainerSpec const*) Unexecuted instantiation: google::protobuf::Arena* google::protobuf::Arena::GetArena<sentencepiece::NormalizerSpec>(sentencepiece::NormalizerSpec const*) Unexecuted instantiation: google::protobuf::Arena* google::protobuf::Arena::GetArena<sentencepiece::SelfTestData>(sentencepiece::SelfTestData const*) |
372 | | |
373 | | template <typename T> |
374 | | class InternalHelper { |
375 | | template <typename U> |
376 | | static char DestructorSkippable(const typename U::DestructorSkippable_*); |
377 | | template <typename U> |
378 | | static double DestructorSkippable(...); |
379 | | |
380 | | typedef std::integral_constant< |
381 | | bool, sizeof(DestructorSkippable<T>(static_cast<const T*>(0))) == |
382 | | sizeof(char) || |
383 | | std::is_trivially_destructible<T>::value> |
384 | | is_destructor_skippable; |
385 | | |
386 | | template <typename U> |
387 | | static char ArenaConstructable( |
388 | | const typename U::InternalArenaConstructable_*); |
389 | | template <typename U> |
390 | | static double ArenaConstructable(...); |
391 | | |
392 | | typedef std::integral_constant<bool, sizeof(ArenaConstructable<T>( |
393 | | static_cast<const T*>(0))) == |
394 | | sizeof(char)> |
395 | | is_arena_constructable; |
396 | | |
397 | | template <typename U, |
398 | | typename std::enable_if< |
399 | | std::is_same<Arena*, decltype(std::declval<const U>() |
400 | | .GetArena())>::value, |
401 | | int>::type = 0> |
402 | | static char HasGetArena(decltype(&U::GetArena)); |
403 | | template <typename U> |
404 | | static double HasGetArena(...); |
405 | | |
406 | | typedef std::integral_constant<bool, sizeof(HasGetArena<T>(nullptr)) == |
407 | | sizeof(char)> |
408 | | has_get_arena; |
409 | | |
410 | | template <typename... Args> |
411 | 0 | static T* Construct(void* ptr, Args&&... args) { |
412 | 0 | return new (ptr) T(std::forward<Args>(args)...); |
413 | 0 | } Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::InternalHelper<google::protobuf::internal::ImplicitWeakMessage>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::SentencePieceText_SentencePiece* google::protobuf::Arena::InternalHelper<sentencepiece::SentencePieceText_SentencePiece>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::SentencePieceText* google::protobuf::Arena::InternalHelper<sentencepiece::SentencePieceText>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::NBestSentencePieceText* google::protobuf::Arena::InternalHelper<sentencepiece::NBestSentencePieceText>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::TrainerSpec* google::protobuf::Arena::InternalHelper<sentencepiece::TrainerSpec>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::NormalizerSpec* google::protobuf::Arena::InternalHelper<sentencepiece::NormalizerSpec>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::SelfTestData_Sample* google::protobuf::Arena::InternalHelper<sentencepiece::SelfTestData_Sample>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::SelfTestData* google::protobuf::Arena::InternalHelper<sentencepiece::SelfTestData>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::ModelProto_SentencePiece* google::protobuf::Arena::InternalHelper<sentencepiece::ModelProto_SentencePiece>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: sentencepiece::ModelProto* google::protobuf::Arena::InternalHelper<sentencepiece::ModelProto>::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<int> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<long> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<unsigned int> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<unsigned long> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<float> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<double> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedField<bool> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::InternalHelper<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite> >::Construct<google::protobuf::Arena*>(void*, google::protobuf::Arena*&&) |
414 | | |
415 | 0 | static Arena* GetArena(const T* p) { return p->GetArena(); }Unexecuted instantiation: google::protobuf::Arena::InternalHelper<sentencepiece::TrainerSpec>::GetArena(sentencepiece::TrainerSpec const*) Unexecuted instantiation: google::protobuf::Arena::InternalHelper<sentencepiece::NormalizerSpec>::GetArena(sentencepiece::NormalizerSpec const*) Unexecuted instantiation: google::protobuf::Arena::InternalHelper<sentencepiece::SelfTestData>::GetArena(sentencepiece::SelfTestData const*) |
416 | | |
417 | | friend class Arena; |
418 | | }; |
419 | | |
420 | | // Helper typetraits that indicates support for arenas in a type T at compile |
421 | | // time. This is public only to allow construction of higher-level templated |
422 | | // utilities. |
423 | | // |
424 | | // is_arena_constructable<T>::value is true if the message type T has arena |
425 | | // support enabled, and false otherwise. |
426 | | // |
427 | | // is_destructor_skippable<T>::value is true if the message type T has told |
428 | | // the arena that it is safe to skip the destructor, and false otherwise. |
429 | | // |
430 | | // This is inside Arena because only Arena has the friend relationships |
431 | | // necessary to see the underlying generated code traits. |
432 | | template <typename T> |
433 | | struct is_arena_constructable : InternalHelper<T>::is_arena_constructable {}; |
434 | | template <typename T> |
435 | | struct is_destructor_skippable : InternalHelper<T>::is_destructor_skippable { |
436 | | }; |
437 | | |
438 | | private: |
439 | | template <typename T> |
440 | | struct has_get_arena : InternalHelper<T>::has_get_arena {}; |
441 | | |
442 | | template <typename T, typename... Args> |
443 | | PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena, |
444 | | Args&&... args) { |
445 | | static_assert( |
446 | | InternalHelper<T>::is_arena_constructable::value, |
447 | | "CreateMessage can only construct types that are ArenaConstructable"); |
448 | | if (arena == NULL) { |
449 | | return new T(nullptr, std::forward<Args>(args)...); |
450 | | } else { |
451 | | return arena->DoCreateMessage<T>(std::forward<Args>(args)...); |
452 | | } |
453 | | } |
454 | | |
455 | | // This specialization for no arguments is necessary, because its behavior is |
456 | | // slightly different. When the arena pointer is nullptr, it calls T() |
457 | | // instead of T(nullptr). |
458 | | template <typename T> |
459 | 0 | PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena) { |
460 | 0 | static_assert( |
461 | 0 | InternalHelper<T>::is_arena_constructable::value, |
462 | 0 | "CreateMessage can only construct types that are ArenaConstructable"); |
463 | 0 | if (arena == NULL) { |
464 | 0 | return new T(); |
465 | 0 | } else { |
466 | 0 | return arena->DoCreateMessage<T>(); |
467 | 0 | } |
468 | 0 | } Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::CreateMessageInternal<google::protobuf::internal::ImplicitWeakMessage>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::SentencePieceText_SentencePiece* google::protobuf::Arena::CreateMessageInternal<sentencepiece::SentencePieceText_SentencePiece>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::SentencePieceText* google::protobuf::Arena::CreateMessageInternal<sentencepiece::SentencePieceText>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::NBestSentencePieceText* google::protobuf::Arena::CreateMessageInternal<sentencepiece::NBestSentencePieceText>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::TrainerSpec* google::protobuf::Arena::CreateMessageInternal<sentencepiece::TrainerSpec>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::NormalizerSpec* google::protobuf::Arena::CreateMessageInternal<sentencepiece::NormalizerSpec>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::SelfTestData_Sample* google::protobuf::Arena::CreateMessageInternal<sentencepiece::SelfTestData_Sample>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::SelfTestData* google::protobuf::Arena::CreateMessageInternal<sentencepiece::SelfTestData>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::ModelProto_SentencePiece* google::protobuf::Arena::CreateMessageInternal<sentencepiece::ModelProto_SentencePiece>(google::protobuf::Arena*) Unexecuted instantiation: sentencepiece::ModelProto* google::protobuf::Arena::CreateMessageInternal<sentencepiece::ModelProto>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<int> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<long> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<unsigned int> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<unsigned long> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<float> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<double> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedField<bool> >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::CreateMessageInternal<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite> >(google::protobuf::Arena*) |
469 | | |
470 | | template <typename T, typename... Args> |
471 | | PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena, |
472 | 0 | Args&&... args) { |
473 | 0 | if (arena == NULL) { |
474 | 0 | return new T(std::forward<Args>(args)...); |
475 | 0 | } else { |
476 | 0 | return arena->DoCreate<T>(std::is_trivially_destructible<T>::value, |
477 | 0 | std::forward<Args>(args)...); |
478 | 0 | } |
479 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateInternal<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::CreateInternal<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(google::protobuf::Arena*) |
480 | | |
481 | 0 | inline void AllocHook(const std::type_info* allocated_type, size_t n) const { |
482 | 0 | impl_.RecordAlloc(allocated_type, n); |
483 | 0 | } |
484 | | |
485 | | // Allocate and also optionally call collector with the allocated type info |
486 | | // when allocation recording is enabled. |
487 | | template <typename T> |
488 | 0 | PROTOBUF_ALWAYS_INLINE void* AllocateInternal(bool skip_explicit_ownership) { |
489 | 0 | const size_t n = internal::AlignUpTo8(sizeof(T)); |
490 | | // Monitor allocation if needed. |
491 | 0 | impl_.RecordAlloc(RTTI_TYPE_ID(T), n); |
492 | 0 | if (skip_explicit_ownership) { |
493 | 0 | return AllocateAlignedTo<alignof(T)>(sizeof(T)); |
494 | 0 | } else { |
495 | 0 | if (alignof(T) <= 8) { |
496 | 0 | return impl_.AllocateAlignedAndAddCleanup( |
497 | 0 | n, &internal::arena_destruct_object<T>); |
498 | 0 | } else { |
499 | 0 | auto ptr = |
500 | 0 | reinterpret_cast<uintptr_t>(impl_.AllocateAlignedAndAddCleanup( |
501 | 0 | sizeof(T) + alignof(T) - 8, |
502 | 0 | &internal::arena_destruct_object<T>)); |
503 | 0 | return reinterpret_cast<void*>((ptr + alignof(T) - 8) & |
504 | 0 | (~alignof(T) + 1)); |
505 | 0 | } |
506 | 0 | } |
507 | 0 | } Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::internal::ImplicitWeakMessage>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::SentencePieceText_SentencePiece>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::SentencePieceText>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::NBestSentencePieceText>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::TrainerSpec>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::NormalizerSpec>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::SelfTestData_Sample>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::SelfTestData>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::ModelProto_SentencePiece>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<sentencepiece::ModelProto>(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<int> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<long> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<unsigned int> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<unsigned long> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<float> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<double> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedField<bool> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite> >(bool) Unexecuted instantiation: void* google::protobuf::Arena::AllocateInternal<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > > >(bool) |
508 | | |
509 | | // CreateMessage<T> requires that T supports arenas, but this private method |
510 | | // works whether or not T supports arenas. These are not exposed to user code |
511 | | // as it can cause confusing API usages, and end up having double free in |
512 | | // user code. These are used only internally from LazyField and Repeated |
513 | | // fields, since they are designed to work in all mode combinations. |
514 | | template <typename Msg, typename... Args> |
515 | | PROTOBUF_ALWAYS_INLINE static Msg* DoCreateMaybeMessage(Arena* arena, |
516 | | std::true_type, |
517 | 0 | Args&&... args) { |
518 | 0 | return CreateMessageInternal<Msg>(arena, std::forward<Args>(args)...); |
519 | 0 | } Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::internal::ImplicitWeakMessage>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<int>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<long>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<unsigned int>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<unsigned long>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<float>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<double>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedField<bool>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>>(google::protobuf::Arena*, std::__1::integral_constant<bool, true>) |
520 | | |
521 | | template <typename T, typename... Args> |
522 | | PROTOBUF_ALWAYS_INLINE static T* DoCreateMaybeMessage(Arena* arena, |
523 | | std::false_type, |
524 | 0 | Args&&... args) { |
525 | 0 | return CreateInternal<T>(arena, std::forward<Args>(args)...); |
526 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::DoCreateMaybeMessage<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::DoCreateMaybeMessage<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) |
527 | | |
528 | | template <typename T, typename... Args> |
529 | | PROTOBUF_ALWAYS_INLINE static T* CreateMaybeMessage(Arena* arena, |
530 | 0 | Args&&... args) { |
531 | 0 | return DoCreateMaybeMessage<T>(arena, is_arena_constructable<T>(), |
532 | 0 | std::forward<Args>(args)...); |
533 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::internal::ImplicitWeakMessage>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateMaybeMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(google::protobuf::Arena*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<int>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<long>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<unsigned int>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<unsigned long>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<float>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<double>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedField<bool>>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*) Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>>(google::protobuf::Arena*) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::CreateMaybeMessage<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(google::protobuf::Arena*) |
534 | | |
535 | | template <typename T, typename... Args> |
536 | | PROTOBUF_ALWAYS_INLINE static T* CreateNoMessage(Arena* arena, std::true_type, |
537 | | Args&&... args) { |
538 | | // User is constructing with Create() despite the fact that T supports arena |
539 | | // construction. In this case we have to delegate to CreateInternal(), and |
540 | | // we can't use any CreateMaybeMessage() specialization that may be defined. |
541 | | return CreateInternal<T>(arena, std::forward<Args>(args)...); |
542 | | } |
543 | | |
544 | | template <typename T, typename... Args> |
545 | | PROTOBUF_ALWAYS_INLINE static T* CreateNoMessage(Arena* arena, |
546 | | std::false_type, |
547 | 0 | Args&&... args) { |
548 | | // User is constructing with Create() and the type does not support arena |
549 | | // construction. In this case we can delegate to CreateMaybeMessage() and |
550 | | // use any specialization that may be available for that. |
551 | 0 | return CreateMaybeMessage<T>(arena, std::forward<Args>(args)...); |
552 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::CreateNoMessage<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateNoMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateNoMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateNoMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::CreateNoMessage<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::CreateNoMessage<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(google::protobuf::Arena*, std::__1::integral_constant<bool, false>) |
553 | | |
554 | | // Just allocate the required size for the given type assuming the |
555 | | // type has a trivial constructor. |
556 | | template <typename T> |
557 | 0 | PROTOBUF_ALWAYS_INLINE T* CreateInternalRawArray(size_t num_elements) { |
558 | 0 | GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T)) |
559 | 0 | << "Requested size is too large to fit into size_t."; |
560 | | // We count on compiler to realize that if sizeof(T) is a multiple of |
561 | | // 8 AlignUpTo can be elided. |
562 | 0 | const size_t n = internal::AlignUpTo8(sizeof(T) * num_elements); |
563 | | // Monitor allocation if needed. |
564 | 0 | impl_.RecordAlloc(RTTI_TYPE_ID(T), n); |
565 | 0 | return static_cast<T*>(AllocateAlignedTo<alignof(T)>(n)); |
566 | 0 | } Unexecuted instantiation: char* google::protobuf::Arena::CreateInternalRawArray<char>(unsigned long) Unexecuted instantiation: google::protobuf::internal::ExtensionSet::KeyValue* google::protobuf::Arena::CreateInternalRawArray<google::protobuf::internal::ExtensionSet::KeyValue>(unsigned long) |
567 | | |
568 | | template <typename T, typename... Args> |
569 | | PROTOBUF_ALWAYS_INLINE T* DoCreate(bool skip_explicit_ownership, |
570 | 0 | Args&&... args) { |
571 | 0 | return new (AllocateInternal<T>(skip_explicit_ownership)) |
572 | 0 | T(std::forward<Args>(args)...); |
573 | 0 | } Unexecuted instantiation: google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::DoCreate<google::protobuf::internal::InternalMetadata::Container<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>(bool) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreate<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(bool) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreate<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreate<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::protobuf::Arena::DoCreate<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >* google::protobuf::Arena::DoCreate<std::__1::map<int, google::protobuf::internal::ExtensionSet::Extension, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, google::protobuf::internal::ExtensionSet::Extension> > >>(bool) |
574 | | template <typename T, typename... Args> |
575 | 0 | PROTOBUF_ALWAYS_INLINE T* DoCreateMessage(Args&&... args) { |
576 | 0 | return InternalHelper<T>::Construct( |
577 | 0 | AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value), |
578 | 0 | this, std::forward<Args>(args)...); |
579 | 0 | } Unexecuted instantiation: google::protobuf::internal::ImplicitWeakMessage* google::protobuf::Arena::DoCreateMessage<google::protobuf::internal::ImplicitWeakMessage>() Unexecuted instantiation: sentencepiece::SentencePieceText_SentencePiece* google::protobuf::Arena::DoCreateMessage<sentencepiece::SentencePieceText_SentencePiece>() Unexecuted instantiation: sentencepiece::SentencePieceText* google::protobuf::Arena::DoCreateMessage<sentencepiece::SentencePieceText>() Unexecuted instantiation: sentencepiece::NBestSentencePieceText* google::protobuf::Arena::DoCreateMessage<sentencepiece::NBestSentencePieceText>() Unexecuted instantiation: sentencepiece::TrainerSpec* google::protobuf::Arena::DoCreateMessage<sentencepiece::TrainerSpec>() Unexecuted instantiation: sentencepiece::NormalizerSpec* google::protobuf::Arena::DoCreateMessage<sentencepiece::NormalizerSpec>() Unexecuted instantiation: sentencepiece::SelfTestData_Sample* google::protobuf::Arena::DoCreateMessage<sentencepiece::SelfTestData_Sample>() Unexecuted instantiation: sentencepiece::SelfTestData* google::protobuf::Arena::DoCreateMessage<sentencepiece::SelfTestData>() Unexecuted instantiation: sentencepiece::ModelProto_SentencePiece* google::protobuf::Arena::DoCreateMessage<sentencepiece::ModelProto_SentencePiece>() Unexecuted instantiation: sentencepiece::ModelProto* google::protobuf::Arena::DoCreateMessage<sentencepiece::ModelProto>() Unexecuted instantiation: google::protobuf::RepeatedField<int>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<int>>() Unexecuted instantiation: google::protobuf::RepeatedField<long>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<long>>() Unexecuted instantiation: google::protobuf::RepeatedField<unsigned int>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<unsigned int>>() Unexecuted instantiation: google::protobuf::RepeatedField<unsigned long>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<unsigned long>>() Unexecuted instantiation: google::protobuf::RepeatedField<float>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<float>>() Unexecuted instantiation: google::protobuf::RepeatedField<double>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<double>>() Unexecuted instantiation: google::protobuf::RepeatedField<bool>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedField<bool>>() Unexecuted instantiation: google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >>() Unexecuted instantiation: google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>* google::protobuf::Arena::DoCreateMessage<google::protobuf::RepeatedPtrField<google::protobuf::MessageLite>>() |
580 | | |
581 | | // CreateInArenaStorage is used to implement map field. Without it, |
582 | | // Map need to call generated message's protected arena constructor, |
583 | | // which needs to declare Map as friend of generated message. |
584 | | template <typename T, typename... Args> |
585 | | static void CreateInArenaStorage(T* ptr, Arena* arena, Args&&... args) { |
586 | | CreateInArenaStorageInternal(ptr, arena, |
587 | | typename is_arena_constructable<T>::type(), |
588 | | std::forward<Args>(args)...); |
589 | | RegisterDestructorInternal( |
590 | | ptr, arena, |
591 | | typename InternalHelper<T>::is_destructor_skippable::type()); |
592 | | } |
593 | | |
594 | | template <typename T, typename... Args> |
595 | | static void CreateInArenaStorageInternal(T* ptr, Arena* arena, |
596 | | std::true_type, Args&&... args) { |
597 | | InternalHelper<T>::Construct(ptr, arena, std::forward<Args>(args)...); |
598 | | } |
599 | | template <typename T, typename... Args> |
600 | | static void CreateInArenaStorageInternal(T* ptr, Arena* /* arena */, |
601 | | std::false_type, Args&&... args) { |
602 | | new (ptr) T(std::forward<Args>(args)...); |
603 | | } |
604 | | |
605 | | template <typename T> |
606 | | static void RegisterDestructorInternal(T* /* ptr */, Arena* /* arena */, |
607 | | std::true_type) {} |
608 | | template <typename T> |
609 | | static void RegisterDestructorInternal(T* ptr, Arena* arena, |
610 | | std::false_type) { |
611 | | arena->OwnDestructor(ptr); |
612 | | } |
613 | | |
614 | | // These implement Own(), which registers an object for deletion (destructor |
615 | | // call and operator delete()). The second parameter has type 'true_type' if T |
616 | | // is a subtype of Message and 'false_type' otherwise. Collapsing |
617 | | // all template instantiations to one for generic Message reduces code size, |
618 | | // using the virtual destructor instead. |
619 | | template <typename T> |
620 | | PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::true_type) { |
621 | | if (object != NULL) { |
622 | | impl_.AddCleanup(object, &internal::arena_delete_object<Message>); |
623 | | } |
624 | | } |
625 | | template <typename T> |
626 | 0 | PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::false_type) { |
627 | 0 | if (object != NULL) { |
628 | 0 | impl_.AddCleanup(object, &internal::arena_delete_object<T>); |
629 | 0 | } |
630 | 0 | } Unexecuted instantiation: void google::protobuf::Arena::OwnInternal<google::protobuf::MessageLite>(google::protobuf::MessageLite*, std::__1::integral_constant<bool, false>) Unexecuted instantiation: void google::protobuf::Arena::OwnInternal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::integral_constant<bool, false>) |
631 | | |
632 | | // Implementation for GetArena(). Only message objects with |
633 | | // InternalArenaConstructable_ tags can be associated with an arena, and such |
634 | | // objects must implement a GetArena() method. |
635 | | template <typename T, typename std::enable_if< |
636 | | is_arena_constructable<T>::value, int>::type = 0> |
637 | 0 | PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) { |
638 | 0 | return InternalHelper<T>::GetArena(value); |
639 | 0 | } Unexecuted instantiation: _ZN6google8protobuf5Arena16GetArenaInternalIN13sentencepiece11TrainerSpecETnNSt3__19enable_ifIXsr22is_arena_constructableIT_EE5valueEiE4typeELi0EEEPS1_PKS7_ Unexecuted instantiation: _ZN6google8protobuf5Arena16GetArenaInternalIN13sentencepiece14NormalizerSpecETnNSt3__19enable_ifIXsr22is_arena_constructableIT_EE5valueEiE4typeELi0EEEPS1_PKS7_ Unexecuted instantiation: _ZN6google8protobuf5Arena16GetArenaInternalIN13sentencepiece12SelfTestDataETnNSt3__19enable_ifIXsr22is_arena_constructableIT_EE5valueEiE4typeELi0EEEPS1_PKS7_ |
640 | | template <typename T, |
641 | | typename std::enable_if<!is_arena_constructable<T>::value && |
642 | | has_get_arena<T>::value, |
643 | | int>::type = 0> |
644 | | PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) { |
645 | | return value->GetArena(); |
646 | | } |
647 | | template <typename T, |
648 | | typename std::enable_if<!is_arena_constructable<T>::value && |
649 | | !has_get_arena<T>::value, |
650 | | int>::type = 0> |
651 | | PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) { |
652 | | (void)value; |
653 | | return nullptr; |
654 | | } |
655 | | |
656 | | // For friends of arena. |
657 | 0 | void* AllocateAligned(size_t n) { |
658 | 0 | return AllocateAlignedNoHook(internal::AlignUpTo8(n)); |
659 | 0 | } |
660 | | template<size_t Align> |
661 | 0 | void* AllocateAlignedTo(size_t n) { |
662 | 0 | static_assert(Align > 0, "Alignment must be greater than 0"); |
663 | 0 | static_assert((Align & (Align - 1)) == 0, "Alignment must be power of two"); |
664 | 0 | if (Align <= 8) return AllocateAligned(n); |
665 | | // TODO(b/151247138): if the pointer would have been aligned already, |
666 | | // this is wasting space. We should pass the alignment down. |
667 | 0 | uintptr_t ptr = reinterpret_cast<uintptr_t>(AllocateAligned(n + Align - 8)); |
668 | 0 | ptr = (ptr + Align - 1) & (~Align + 1); |
669 | 0 | return reinterpret_cast<void*>(ptr); |
670 | 0 | } Unexecuted instantiation: void* google::protobuf::Arena::AllocateAlignedTo<8ul>(unsigned long) Unexecuted instantiation: void* google::protobuf::Arena::AllocateAlignedTo<1ul>(unsigned long) |
671 | | |
672 | | void* AllocateAlignedNoHook(size_t n); |
673 | | |
674 | | internal::ArenaImpl impl_; |
675 | | |
676 | | template <typename Type> |
677 | | friend class internal::GenericTypeHandler; |
678 | | friend struct internal::ArenaStringPtr; // For AllocateAligned. |
679 | | friend class internal::LazyField; // For CreateMaybeMessage. |
680 | | friend class internal::EpsCopyInputStream; // For parser performance |
681 | | friend class MessageLite; |
682 | | template <typename Key, typename T> |
683 | | friend class Map; |
684 | | }; |
685 | | |
686 | | // Defined above for supporting environments without RTTI. |
687 | | #undef RTTI_TYPE_ID |
688 | | |
689 | | } // namespace protobuf |
690 | | } // namespace google |
691 | | |
692 | | #include <google/protobuf/port_undef.inc> |
693 | | |
694 | | #endif // GOOGLE_PROTOBUF_ARENA_H__ |