@@ -168,93 +168,6 @@ class MachOPlatformRuntimeState {
168
168
169
169
using AtExitsVector = std::vector<AtExitEntry>;
170
170
171
- // / Used to manage sections of fixed-sized metadata records (e.g. pointer
172
- // / sections, selector refs, etc.)
173
- template <typename RecordElement> class RecordSectionsTracker {
174
- public:
175
- // / Add a section to the "new" list.
176
- void add (span<RecordElement> Sec) { New.push_back (std::move (Sec)); }
177
-
178
- // / Returns true if there are new sections to process.
179
- bool hasNewSections () const { return !New.empty (); }
180
-
181
- // / Returns the number of new sections to process.
182
- size_t numNewSections () const { return New.size (); }
183
-
184
- // / Process all new sections.
185
- template <typename ProcessSectionFunc>
186
- std::enable_if_t <std::is_void_v<
187
- std::invoke_result_t <ProcessSectionFunc, span<RecordElement>>>>
188
- processNewSections (ProcessSectionFunc &&ProcessSection) {
189
- for (auto &Sec : New)
190
- ProcessSection (Sec);
191
- moveNewToProcessed ();
192
- }
193
-
194
- // / Proces all new sections with a fallible handler.
195
- // /
196
- // / Successfully handled sections will be moved to the Processed
197
- // / list.
198
- template <typename ProcessSectionFunc>
199
- std::enable_if_t <
200
- std::is_same_v<Error, std::invoke_result_t <ProcessSectionFunc,
201
- span<RecordElement>>>,
202
- Error>
203
- processNewSections (ProcessSectionFunc &&ProcessSection) {
204
- for (size_t I = 0 ; I != New.size (); ++I) {
205
- if (auto Err = ProcessSection (New[I])) {
206
- for (size_t J = 0 ; J != I; ++J)
207
- Processed.push_back (New[J]);
208
- New.erase (New.begin (), New.begin () + I);
209
- return Err;
210
- }
211
- }
212
- moveNewToProcessed ();
213
- return Error::success ();
214
- }
215
-
216
- // / Move all sections back to New for reprocessing.
217
- void reset () {
218
- moveNewToProcessed ();
219
- New = std::move (Processed);
220
- }
221
-
222
- // / Remove the section with the given range.
223
- bool removeIfPresent (ExecutorAddrRange R) {
224
- if (removeIfPresent (New, R))
225
- return true ;
226
- return removeIfPresent (Processed, R);
227
- }
228
-
229
- private:
230
- void moveNewToProcessed () {
231
- if (Processed.empty ())
232
- Processed = std::move (New);
233
- else {
234
- Processed.reserve (Processed.size () + New.size ());
235
- std::copy (New.begin (), New.end (), std::back_inserter (Processed));
236
- New.clear ();
237
- }
238
- }
239
-
240
- bool removeIfPresent (std::vector<span<RecordElement>> &V,
241
- ExecutorAddrRange R) {
242
- auto RI = std::find_if (
243
- V.rbegin (), V.rend (),
244
- [RS = R.toSpan <RecordElement>()](const span<RecordElement> &E) {
245
- return E.data () == RS.data ();
246
- });
247
- if (RI != V.rend ()) {
248
- V.erase (std::next (RI).base ());
249
- return true ;
250
- }
251
- return false ;
252
- }
253
-
254
- std::vector<span<RecordElement>> Processed;
255
- std::vector<span<RecordElement>> New;
256
- };
257
-
258
171
struct UnwindSections {
259
172
UnwindSections (const UnwindSectionInfo &USI)
260
173
: DwarfSection(USI.DwarfSection.toSpan<char >()),
0 commit comments