/home/uke/oil/mycpp/gc_list.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef MYCPP_GC_LIST_H |
2 | | #define MYCPP_GC_LIST_H |
3 | | |
4 | | #include <string.h> // memcpy |
5 | | |
6 | | #include <algorithm> // sort() is templated |
7 | | |
8 | | #include "mycpp/common.h" // DCHECK |
9 | | #include "mycpp/comparators.h" |
10 | | #include "mycpp/gc_alloc.h" // Alloc |
11 | | #include "mycpp/gc_builtins.h" // ValueError |
12 | | #include "mycpp/gc_mops.h" // BigInt |
13 | | #include "mycpp/gc_slab.h" |
14 | | |
15 | | // GlobalList is layout-compatible with List (unit tests assert this), and it |
16 | | // can be a true C global (incurs zero startup time) |
17 | | |
18 | | template <typename T, int N> |
19 | | class GlobalList { |
20 | | public: |
21 | | int len_; |
22 | | int capacity_; |
23 | | GlobalSlab<T, N>* slab_; |
24 | | }; |
25 | | |
26 | | #define GLOBAL_LIST(name, T, N, array) \ |
27 | | GcGlobal<GlobalSlab<T, N>> _slab_##name = {ObjHeader::Global(TypeTag::Slab), \ |
28 | | {.items_ = array}}; \ |
29 | | GcGlobal<GlobalList<T, N>> _list_##name = { \ |
30 | | ObjHeader::Global(TypeTag::List), \ |
31 | | {.len_ = N, .capacity_ = N, .slab_ = &_slab_##name.obj}}; \ |
32 | | List<T>* name = reinterpret_cast<List<T>*>(&_list_##name.obj); |
33 | | |
34 | | template <typename T> |
35 | | class List { |
36 | | public: |
37 | 1.56k | List() : len_(0), capacity_(0), slab_(nullptr) { |
38 | 1.56k | } Line | Count | Source | 37 | 701 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 701 | } |
Line | Count | Source | 37 | 153 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 153 | } |
_ZN4ListIP6Tuple2IP6BigStriEEC2Ev Line | Count | Source | 37 | 1 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEEC2Ev Line | Count | Source | 37 | 9 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 9 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEEC2Ev Line | Count | Source | 37 | 609 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 609 | } |
_ZN4ListIPN10hnode_asdl5FieldEEC2Ev Line | Count | Source | 37 | 57 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 57 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEEC2Ev Line | Count | Source | 37 | 19 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 19 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEEC2Ev Line | Count | Source | 37 | 3 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEEC2Ev Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEEC2Ev Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEEC2Ev Line | Count | Source | 37 | 2 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 2 | } |
_ZN4ListIP6Tuple2IiiEEC2Ev Line | Count | Source | 37 | 4 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 4 | } |
Line | Count | Source | 37 | 2 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 2 | } |
_ZN4ListIPN4pyos11PasswdEntryEEC2Ev Line | Count | Source | 37 | 1 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 1 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEEC2Ev Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEEC2Ev Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEEC2Ev |
39 | | |
40 | | protected: |
41 | | // Used for ASDL subtypes with <. NOT even a shallow copy - it ALIASES thes |
42 | | // slab. |
43 | | explicit List(List* other) |
44 | 1 | : len_(other->len_), capacity_(other->capacity_), slab_(other->slab_) { |
45 | 1 | } |
46 | | |
47 | | public: |
48 | | // Implements L[i] |
49 | | T at(int i); |
50 | | |
51 | | // returns index of the element |
52 | | int index(T element); |
53 | | |
54 | | // Implements L[i] = item |
55 | | void set(int i, T item); |
56 | | |
57 | | // L[begin:] |
58 | | List* slice(int begin); |
59 | | |
60 | | // L[begin:end] |
61 | | List* slice(int begin, int end); |
62 | | |
63 | | // Should we have a separate API that doesn't return it? |
64 | | // https://stackoverflow.com/questions/12600330/pop-back-return-value |
65 | | T pop(); |
66 | | |
67 | | // Used in osh/word_parse.py to remove from front |
68 | | T pop(int i); |
69 | | |
70 | | // Remove the first occurence of x from the list. |
71 | | void remove(T x); |
72 | | |
73 | | void clear(); |
74 | | |
75 | | // Used in osh/string_ops.py |
76 | | void reverse(); |
77 | | |
78 | | // Templated function |
79 | | void sort(); |
80 | | |
81 | | // Ensure that there's space for at LEAST this many items |
82 | | void reserve(int num_desired); |
83 | | |
84 | | // Append a single element to this list. |
85 | | void append(T item); |
86 | | |
87 | | // Extend this list with multiple elements. |
88 | | void extend(List<T>* other); |
89 | | |
90 | 1.26k | static constexpr ObjHeader obj_header() { |
91 | 1.26k | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); |
92 | 1.26k | } _ZN4ListIiE10obj_headerEv Line | Count | Source | 90 | 690 | static constexpr ObjHeader obj_header() { | 91 | 690 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 690 | } |
_ZN4ListIP6BigStrE10obj_headerEv Line | Count | Source | 90 | 152 | static constexpr ObjHeader obj_header() { | 91 | 152 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 152 | } |
_ZN4ListIP6Tuple2IP6BigStriEE10obj_headerEv Line | Count | Source | 90 | 1 | static constexpr ObjHeader obj_header() { | 91 | 1 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE10obj_headerEv Line | Count | Source | 90 | 5 | static constexpr ObjHeader obj_header() { | 91 | 5 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 5 | } |
_ZN4ListIPN10hnode_asdl5FieldEE10obj_headerEv Line | Count | Source | 90 | 57 | static constexpr ObjHeader obj_header() { | 91 | 57 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 57 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEE10obj_headerEv Line | Count | Source | 90 | 333 | static constexpr ObjHeader obj_header() { | 91 | 333 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 333 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE10obj_headerEv Line | Count | Source | 90 | 19 | static constexpr ObjHeader obj_header() { | 91 | 19 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 19 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN10value_asdl16InitializerValueEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10SourceLineEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl17InitializerWord_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl11word_part_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl6word_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl6expr_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5RedirEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7EnvPairEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10AssignPairEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9command_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5IfArmEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7CaseArmEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10place_op_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8NameTypeEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl13ComprehensionEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl20class_literal_term_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl17char_class_term_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl4re_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8NamedArgEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9EggexFlagEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5ParamEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7y_lhs_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10obj_headerEv _ZN4ListIbE10obj_headerEv Line | Count | Source | 90 | 3 | static constexpr ObjHeader obj_header() { | 91 | 3 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE10obj_headerEv _ZN4ListIlE10obj_headerEv Line | Count | Source | 90 | 2 | static constexpr ObjHeader obj_header() { | 91 | 2 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 2 | } |
_ZN4ListIP6Tuple2IiiEE10obj_headerEv Line | Count | Source | 90 | 4 | static constexpr ObjHeader obj_header() { | 91 | 4 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 4 | } |
_ZN4ListIPiE10obj_headerEv Line | Count | Source | 90 | 2 | static constexpr ObjHeader obj_header() { | 91 | 2 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 2 | } |
_ZN4ListIPN4pyos11PasswdEntryEE10obj_headerEv Line | Count | Source | 90 | 1 | static constexpr ObjHeader obj_header() { | 91 | 1 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 92 | 1 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10obj_headerEv Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10obj_headerEv |
93 | | |
94 | | // Used by ASDL |
95 | | void SetTaken(); |
96 | | |
97 | | int len_; // number of entries |
98 | | int capacity_; // max entries before resizing |
99 | | |
100 | | // The container may be resized, so this field isn't in-line. |
101 | | Slab<T>* slab_; |
102 | | |
103 | | // A list has one Slab pointer which we need to follow. |
104 | 1.54k | static constexpr uint32_t field_mask() { |
105 | 1.54k | return maskbit(offsetof(List, slab_)); |
106 | 1.54k | } _ZN4ListIiE10field_maskEv Line | Count | Source | 104 | 692 | static constexpr uint32_t field_mask() { | 105 | 692 | return maskbit(offsetof(List, slab_)); | 106 | 692 | } |
_ZN4ListIP6BigStrE10field_maskEv Line | Count | Source | 104 | 154 | static constexpr uint32_t field_mask() { | 105 | 154 | return maskbit(offsetof(List, slab_)); | 106 | 154 | } |
_ZN4ListIP6Tuple2IP6BigStriEE10field_maskEv Line | Count | Source | 104 | 1 | static constexpr uint32_t field_mask() { | 105 | 1 | return maskbit(offsetof(List, slab_)); | 106 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE10field_maskEv Line | Count | Source | 104 | 5 | static constexpr uint32_t field_mask() { | 105 | 5 | return maskbit(offsetof(List, slab_)); | 106 | 5 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEE10field_maskEv Line | Count | Source | 104 | 609 | static constexpr uint32_t field_mask() { | 105 | 609 | return maskbit(offsetof(List, slab_)); | 106 | 609 | } |
_ZN4ListIPN10hnode_asdl5FieldEE10field_maskEv Line | Count | Source | 104 | 57 | static constexpr uint32_t field_mask() { | 105 | 57 | return maskbit(offsetof(List, slab_)); | 106 | 57 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE10field_maskEv Line | Count | Source | 104 | 19 | static constexpr uint32_t field_mask() { | 105 | 19 | return maskbit(offsetof(List, slab_)); | 106 | 19 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN10value_asdl16InitializerValueEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10SourceLineEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9command_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl17InitializerWord_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl11word_part_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl6word_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl6expr_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5RedirEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7EnvPairEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10AssignPairEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5IfArmEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7CaseArmEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10place_op_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8NameTypeEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl13ComprehensionEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl20class_literal_term_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl17char_class_term_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl4re_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8NamedArgEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9EggexFlagEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5ParamEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7y_lhs_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10field_maskEv _ZN4ListIbE10field_maskEv Line | Count | Source | 104 | 3 | static constexpr uint32_t field_mask() { | 105 | 3 | return maskbit(offsetof(List, slab_)); | 106 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE10field_maskEv _ZN4ListIlE10field_maskEv Line | Count | Source | 104 | 2 | static constexpr uint32_t field_mask() { | 105 | 2 | return maskbit(offsetof(List, slab_)); | 106 | 2 | } |
_ZN4ListIP6Tuple2IiiEE10field_maskEv Line | Count | Source | 104 | 4 | static constexpr uint32_t field_mask() { | 105 | 4 | return maskbit(offsetof(List, slab_)); | 106 | 4 | } |
_ZN4ListIPiE10field_maskEv Line | Count | Source | 104 | 2 | static constexpr uint32_t field_mask() { | 105 | 2 | return maskbit(offsetof(List, slab_)); | 106 | 2 | } |
_ZN4ListIPN4pyos11PasswdEntryEE10field_maskEv Line | Count | Source | 104 | 1 | static constexpr uint32_t field_mask() { | 105 | 1 | return maskbit(offsetof(List, slab_)); | 106 | 1 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10field_maskEv Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10field_maskEv |
107 | | |
108 | | DISALLOW_COPY_AND_ASSIGN(List) |
109 | | |
110 | | static_assert(sizeof(ObjHeader) % sizeof(T) == 0, |
111 | | "ObjHeader size should be multiple of item size"); |
112 | | static constexpr int kHeaderFudge = sizeof(ObjHeader) / sizeof(T); |
113 | | |
114 | | #if 0 |
115 | | // 24-byte pool comes from very common List header, and Token |
116 | | static constexpr int kPoolBytes1 = 24 - sizeof(ObjHeader); |
117 | | static_assert(kPoolBytes1 % sizeof(T) == 0, |
118 | | "An integral number of items should fit in first pool"); |
119 | | static constexpr int kNumItems1 = kPoolBytes1 / sizeof(T); |
120 | | #endif |
121 | | |
122 | | // Matches mark_sweep_heap.h |
123 | | static constexpr int kPoolBytes2 = 48 - sizeof(ObjHeader); |
124 | | static_assert(kPoolBytes2 % sizeof(T) == 0, |
125 | | "An integral number of items should fit in second pool"); |
126 | | static constexpr int kNumItems2 = kPoolBytes2 / sizeof(T); |
127 | | |
128 | | #if 0 |
129 | | static constexpr int kMinBytes2 = 128 - sizeof(ObjHeader); |
130 | | static_assert(kMinBytes2 % sizeof(T) == 0, |
131 | | "An integral number of items should fit"); |
132 | | static constexpr int kMinItems2 = kMinBytes2 / sizeof(T); |
133 | | #endif |
134 | | |
135 | | // Given the number of items desired, return the number items we should |
136 | | // reserve room for, according to our growth policy. |
137 | 1.75k | int HowManyItems(int num_desired) { |
138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So |
139 | | // just use the larger 48 byte pool. |
140 | | #if 0 |
141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 |
142 | | return kNumItems1; |
143 | | } |
144 | | #endif |
145 | 1.75k | if (num_desired <= kNumItems2) { // use full cell in pool 2 |
146 | 1.51k | return kNumItems2; |
147 | 1.51k | } |
148 | | #if 0 |
149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 |
150 | | return kMinItems2; |
151 | | } |
152 | | #endif |
153 | | |
154 | | // Make sure the total allocation is a power of 2. TODO: consider using |
155 | | // slightly less than power of 2, to account for malloc() headers, and |
156 | | // reduce fragmentation. |
157 | | // Example: |
158 | | // - ask for 11 integers |
159 | | // - round up 11+2 == 13 up to 16 items |
160 | | // - return 14 items |
161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. |
162 | 233 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; |
163 | 1.75k | } _ZN4ListIiE12HowManyItemsEi Line | Count | Source | 137 | 726 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 726 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 682 | return kNumItems2; | 147 | 682 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 44 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 726 | } |
_ZN4ListIP6BigStrE12HowManyItemsEi Line | Count | Source | 137 | 172 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 172 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 134 | return kNumItems2; | 147 | 134 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 38 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 172 | } |
_ZN4ListIP6Tuple2IP6BigStriEE12HowManyItemsEi Line | Count | Source | 137 | 1 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 1 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 1 | return kNumItems2; | 147 | 1 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE12HowManyItemsEi Line | Count | Source | 137 | 7 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 7 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 7 | return kNumItems2; | 147 | 7 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 7 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEE12HowManyItemsEi Line | Count | Source | 137 | 719 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 719 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 609 | return kNumItems2; | 147 | 609 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 110 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 719 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE12HowManyItemsEi Line | Count | Source | 137 | 57 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 57 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 19 | return kNumItems2; | 147 | 19 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 38 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 57 | } |
_ZN4ListIPN10hnode_asdl5FieldEE12HowManyItemsEi Line | Count | Source | 137 | 57 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 57 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 57 | return kNumItems2; | 147 | 57 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 57 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE12HowManyItemsEi _ZN4ListIbE12HowManyItemsEi Line | Count | Source | 137 | 3 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 3 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 3 | return kNumItems2; | 147 | 3 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE12HowManyItemsEi _ZN4ListIlE12HowManyItemsEi Line | Count | Source | 137 | 2 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 2 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 2 | return kNumItems2; | 147 | 2 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 2 | } |
_ZN4ListIP6Tuple2IiiEE12HowManyItemsEi Line | Count | Source | 137 | 4 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 4 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 4 | return kNumItems2; | 147 | 4 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 4 | } |
_ZN4ListIPN4pyos11PasswdEntryEE12HowManyItemsEi Line | Count | Source | 137 | 4 | int HowManyItems(int num_desired) { | 138 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 139 | | // just use the larger 48 byte pool. | 140 | | #if 0 | 141 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 142 | | return kNumItems1; | 143 | | } | 144 | | #endif | 145 | 4 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 146 | 1 | return kNumItems2; | 147 | 1 | } | 148 | | #if 0 | 149 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 150 | | return kMinItems2; | 151 | | } | 152 | | #endif | 153 | | | 154 | | // Make sure the total allocation is a power of 2. TODO: consider using | 155 | | // slightly less than power of 2, to account for malloc() headers, and | 156 | | // reduce fragmentation. | 157 | | // Example: | 158 | | // - ask for 11 integers | 159 | | // - round up 11+2 == 13 up to 16 items | 160 | | // - return 14 items | 161 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 162 | 3 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 163 | 4 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE12HowManyItemsEi |
164 | | }; |
165 | | |
166 | | // "Constructors" as free functions since we can't allocate within a |
167 | | // constructor. Allocation may cause garbage collection, which interferes with |
168 | | // placement new. |
169 | | |
170 | | // This is not really necessary, only syntactic sugar. |
171 | | template <typename T> |
172 | 671 | List<T>* NewList() { |
173 | 671 | return Alloc<List<T>>(); |
174 | 671 | } Line | Count | Source | 172 | 635 | List<T>* NewList() { | 173 | 635 | return Alloc<List<T>>(); | 174 | 635 | } |
_Z7NewListIP6BigStrEP4ListIT_Ev Line | Count | Source | 172 | 30 | List<T>* NewList() { | 173 | 30 | return Alloc<List<T>>(); | 174 | 30 | } |
Unexecuted instantiation: _Z7NewListIPN10hnode_asdl7hnode_tEEP4ListIT_Ev Unexecuted instantiation: _Z7NewListIPN10hnode_asdl5FieldEEP4ListIT_Ev _Z7NewListIPiEP4ListIT_Ev Line | Count | Source | 172 | 2 | List<T>* NewList() { | 173 | 2 | return Alloc<List<T>>(); | 174 | 2 | } |
_Z7NewListIPN4pyos11PasswdEntryEEP4ListIT_Ev Line | Count | Source | 172 | 1 | List<T>* NewList() { | 173 | 1 | return Alloc<List<T>>(); | 174 | 1 | } |
Unexecuted instantiation: _Z7NewListIPN11syntax_asdl12CompoundWordEEP4ListIT_Ev _Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_Ev Line | Count | Source | 172 | 3 | List<T>* NewList() { | 173 | 3 | return Alloc<List<T>>(); | 174 | 3 | } |
|
175 | | |
176 | | // Literal ['foo', 'bar'] |
177 | | // This seems to allow better template argument type deduction than a |
178 | | // constructor. |
179 | | template <typename T> |
180 | 345 | List<T>* NewList(std::initializer_list<T> init) { |
181 | 345 | auto self = Alloc<List<T>>(); |
182 | | |
183 | 345 | int n = init.size(); |
184 | 345 | self->reserve(n); |
185 | | |
186 | 345 | int i = 0; |
187 | 855 | for (auto item : init) { |
188 | 855 | self->slab_->items_[i] = item; |
189 | 855 | ++i; |
190 | 855 | } |
191 | 345 | self->len_ = n; |
192 | 345 | return self; |
193 | 345 | } _Z7NewListIP6BigStrEP4ListIT_ESt16initializer_listIS3_E Line | Count | Source | 180 | 71 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 71 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 71 | int n = init.size(); | 184 | 71 | self->reserve(n); | 185 | | | 186 | 71 | int i = 0; | 187 | 93 | for (auto item : init) { | 188 | 93 | self->slab_->items_[i] = item; | 189 | 93 | ++i; | 190 | 93 | } | 191 | 71 | self->len_ = n; | 192 | 71 | return self; | 193 | 71 | } |
_Z7NewListIiEP4ListIT_ESt16initializer_listIS1_E Line | Count | Source | 180 | 33 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 33 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 33 | int n = init.size(); | 184 | 33 | self->reserve(n); | 185 | | | 186 | 33 | int i = 0; | 187 | 128 | for (auto item : init) { | 188 | 128 | self->slab_->items_[i] = item; | 189 | 128 | ++i; | 190 | 128 | } | 191 | 33 | self->len_ = n; | 192 | 33 | return self; | 193 | 33 | } |
_Z7NewListIP6Tuple2IP6BigStriEEP4ListIT_ESt16initializer_listIS6_E Line | Count | Source | 180 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 1 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 1 | int n = init.size(); | 184 | 1 | self->reserve(n); | 185 | | | 186 | 1 | int i = 0; | 187 | 2 | for (auto item : init) { | 188 | 2 | self->slab_->items_[i] = item; | 189 | 2 | ++i; | 190 | 2 | } | 191 | 1 | self->len_ = n; | 192 | 1 | return self; | 193 | 1 | } |
_Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_ESt16initializer_listIS6_E Line | Count | Source | 180 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 1 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 1 | int n = init.size(); | 184 | 1 | self->reserve(n); | 185 | | | 186 | 1 | int i = 0; | 187 | 2 | for (auto item : init) { | 188 | 2 | self->slab_->items_[i] = item; | 189 | 2 | ++i; | 190 | 2 | } | 191 | 1 | self->len_ = n; | 192 | 1 | return self; | 193 | 1 | } |
_Z7NewListIPN11pretty_asdl11MeasuredDocEEP4ListIT_ESt16initializer_listIS4_E Line | Count | Source | 180 | 219 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 219 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 219 | int n = init.size(); | 184 | 219 | self->reserve(n); | 185 | | | 186 | 219 | int i = 0; | 187 | 609 | for (auto item : init) { | 188 | 609 | self->slab_->items_[i] = item; | 189 | 609 | ++i; | 190 | 609 | } | 191 | 219 | self->len_ = n; | 192 | 219 | return self; | 193 | 219 | } |
_Z7NewListIPN11pretty_asdl11DocFragmentEEP4ListIT_ESt16initializer_listIS4_E Line | Count | Source | 180 | 19 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 19 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 19 | int n = init.size(); | 184 | 19 | self->reserve(n); | 185 | | | 186 | 19 | int i = 0; | 187 | 19 | for (auto item : init) { | 188 | 19 | self->slab_->items_[i] = item; | 189 | 19 | ++i; | 190 | 19 | } | 191 | 19 | self->len_ = n; | 192 | 19 | return self; | 193 | 19 | } |
_Z7NewListIbEP4ListIT_ESt16initializer_listIS1_E Line | Count | Source | 180 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 181 | 1 | auto self = Alloc<List<T>>(); | 182 | | | 183 | 1 | int n = init.size(); | 184 | 1 | self->reserve(n); | 185 | | | 186 | 1 | int i = 0; | 187 | 2 | for (auto item : init) { | 188 | 2 | self->slab_->items_[i] = item; | 189 | 2 | ++i; | 190 | 2 | } | 191 | 1 | self->len_ = n; | 192 | 1 | return self; | 193 | 1 | } |
Unexecuted instantiation: _Z7NewListIP6Tuple2IiiEEP4ListIT_ESt16initializer_listIS4_E |
194 | | |
195 | | // ['foo'] * 3 |
196 | | template <typename T> |
197 | 9 | List<T>* NewList(T item, int times) { |
198 | 9 | auto self = Alloc<List<T>>(); |
199 | | |
200 | 9 | self->reserve(times); |
201 | 9 | self->len_ = times; |
202 | 36 | for (int i = 0; i < times; ++i) { |
203 | 27 | self->set(i, item); |
204 | 27 | } |
205 | 9 | return self; |
206 | 9 | } _Z7NewListIP6BigStrEP4ListIT_ES3_i Line | Count | Source | 197 | 3 | List<T>* NewList(T item, int times) { | 198 | 3 | auto self = Alloc<List<T>>(); | 199 | | | 200 | 3 | self->reserve(times); | 201 | 3 | self->len_ = times; | 202 | 12 | for (int i = 0; i < times; ++i) { | 203 | 9 | self->set(i, item); | 204 | 9 | } | 205 | 3 | return self; | 206 | 3 | } |
_Z7NewListIbEP4ListIT_ES1_i Line | Count | Source | 197 | 2 | List<T>* NewList(T item, int times) { | 198 | 2 | auto self = Alloc<List<T>>(); | 199 | | | 200 | 2 | self->reserve(times); | 201 | 2 | self->len_ = times; | 202 | 8 | for (int i = 0; i < times; ++i) { | 203 | 6 | self->set(i, item); | 204 | 6 | } | 205 | 2 | return self; | 206 | 2 | } |
_Z7NewListIiEP4ListIT_ES1_i Line | Count | Source | 197 | 4 | List<T>* NewList(T item, int times) { | 198 | 4 | auto self = Alloc<List<T>>(); | 199 | | | 200 | 4 | self->reserve(times); | 201 | 4 | self->len_ = times; | 202 | 16 | for (int i = 0; i < times; ++i) { | 203 | 12 | self->set(i, item); | 204 | 12 | } | 205 | 4 | return self; | 206 | 4 | } |
|
207 | | |
208 | | template <typename T> |
209 | 8.16k | void List<T>::append(T item) { |
210 | 8.16k | reserve(len_ + 1); |
211 | 8.16k | slab_->items_[len_] = item; |
212 | 8.16k | ++len_; |
213 | 8.16k | } Line | Count | Source | 209 | 5.13k | void List<T>::append(T item) { | 210 | 5.13k | reserve(len_ + 1); | 211 | 5.13k | slab_->items_[len_] = item; | 212 | 5.13k | ++len_; | 213 | 5.13k | } |
_ZN4ListIP6BigStrE6appendES1_ Line | Count | Source | 209 | 625 | void List<T>::append(T item) { | 210 | 625 | reserve(len_ + 1); | 211 | 625 | slab_->items_[len_] = item; | 212 | 625 | ++len_; | 213 | 625 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEE6appendES2_ Line | Count | Source | 209 | 1.47k | void List<T>::append(T item) { | 210 | 1.47k | reserve(len_ + 1); | 211 | 1.47k | slab_->items_[len_] = item; | 212 | 1.47k | ++len_; | 213 | 1.47k | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE6appendES2_ Line | Count | Source | 209 | 781 | void List<T>::append(T item) { | 210 | 781 | reserve(len_ + 1); | 211 | 781 | slab_->items_[len_] = item; | 212 | 781 | ++len_; | 213 | 781 | } |
_ZN4ListIPN10hnode_asdl5FieldEE6appendES2_ Line | Count | Source | 209 | 105 | void List<T>::append(T item) { | 210 | 105 | reserve(len_ + 1); | 211 | 105 | slab_->items_[len_] = item; | 212 | 105 | ++len_; | 213 | 105 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE6appendES2_ _ZN4ListIP6Tuple2IiP6BigStrEE6appendES4_ Line | Count | Source | 209 | 20 | void List<T>::append(T item) { | 210 | 20 | reserve(len_ + 1); | 211 | 20 | slab_->items_[len_] = item; | 212 | 20 | ++len_; | 213 | 20 | } |
Line | Count | Source | 209 | 4 | void List<T>::append(T item) { | 210 | 4 | reserve(len_ + 1); | 211 | 4 | slab_->items_[len_] = item; | 212 | 4 | ++len_; | 213 | 4 | } |
_ZN4ListIP6Tuple2IiiEE6appendES2_ Line | Count | Source | 209 | 8 | void List<T>::append(T item) { | 210 | 8 | reserve(len_ + 1); | 211 | 8 | slab_->items_[len_] = item; | 212 | 8 | ++len_; | 213 | 8 | } |
_ZN4ListIPN4pyos11PasswdEntryEE6appendES2_ Line | Count | Source | 209 | 19 | void List<T>::append(T item) { | 210 | 19 | reserve(len_ + 1); | 211 | 19 | slab_->items_[len_] = item; | 212 | 19 | ++len_; | 213 | 19 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE6appendES4_ Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE6appendES4_ |
214 | | |
215 | | template <typename T> |
216 | 5.90k | int len(const List<T>* L) { |
217 | 5.90k | return L->len_; |
218 | 5.90k | } Line | Count | Source | 216 | 3.98k | int len(const List<T>* L) { | 217 | 3.98k | return L->len_; | 218 | 3.98k | } |
_Z3lenIP6BigStrEiPK4ListIT_E Line | Count | Source | 216 | 212 | int len(const List<T>* L) { | 217 | 212 | return L->len_; | 218 | 212 | } |
Unexecuted instantiation: _Z3lenIPN11pretty_asdl11MeasuredDocEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN10hnode_asdl7hnode_tEEiPK4ListIT_E _Z3lenIPN10hnode_asdl5FieldEEiPK4ListIT_E Line | Count | Source | 216 | 57 | int len(const List<T>* L) { | 217 | 57 | return L->len_; | 218 | 57 | } |
_Z3lenIPN11pretty_asdl11DocFragmentEEiPK4ListIT_E Line | Count | Source | 216 | 1.63k | int len(const List<T>* L) { | 217 | 1.63k | return L->len_; | 218 | 1.63k | } |
Unexecuted instantiation: _Z3lenIPN15test_classes_gc10OpaqueBaseEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN15test_classes_gc12PointersBaseEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN15test_classes_gc14BaseWithMethodEEiPK4ListIT_E _Z3lenIP6Tuple2IiP6BigStrEEiPK4ListIT_E Line | Count | Source | 216 | 7 | int len(const List<T>* L) { | 217 | 7 | return L->len_; | 218 | 7 | } |
Line | Count | Source | 216 | 2 | int len(const List<T>* L) { | 217 | 2 | return L->len_; | 218 | 2 | } |
_Z3lenIP6Tuple2IiiEEiPK4ListIT_E Line | Count | Source | 216 | 4 | int len(const List<T>* L) { | 217 | 4 | return L->len_; | 218 | 4 | } |
Line | Count | Source | 216 | 2 | int len(const List<T>* L) { | 217 | 2 | return L->len_; | 218 | 2 | } |
_Z3lenIPN4pyos11PasswdEntryEEiPK4ListIT_E Line | Count | Source | 216 | 1 | int len(const List<T>* L) { | 217 | 1 | return L->len_; | 218 | 1 | } |
|
219 | | |
220 | | template <typename T> |
221 | | List<T>* list_repeat(T item, int times); |
222 | | |
223 | | template <typename T> |
224 | | inline bool list_contains(List<T>* haystack, T needle); |
225 | | |
226 | | template <typename K, typename V> |
227 | | class Dict; // forward decl |
228 | | |
229 | | template <typename V> |
230 | | List<BigStr*>* sorted(Dict<BigStr*, V>* d); |
231 | | |
232 | | template <typename T> |
233 | | List<T>* sorted(List<T>* l); |
234 | | |
235 | | // L[begin:] |
236 | | template <typename T> |
237 | 606 | List<T>* List<T>::slice(int begin) { |
238 | 606 | return slice(begin, len_); |
239 | 606 | } _ZN4ListIP6BigStrE5sliceEi Line | Count | Source | 237 | 3 | List<T>* List<T>::slice(int begin) { | 238 | 3 | return slice(begin, len_); | 239 | 3 | } |
Line | Count | Source | 237 | 603 | List<T>* List<T>::slice(int begin) { | 238 | 603 | return slice(begin, len_); | 239 | 603 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE5sliceEi |
240 | | |
241 | | // L[begin:end] |
242 | | template <typename T> |
243 | 613 | List<T>* List<T>::slice(int begin, int end) { |
244 | 613 | SLICE_ADJUST(begin, end, len_); |
245 | | |
246 | 613 | DCHECK(0 <= begin && begin <= len_); |
247 | 613 | DCHECK(0 <= end && end <= len_); |
248 | | |
249 | 0 | int new_len = end - begin; |
250 | 613 | DCHECK(0 <= new_len && new_len <= len_); |
251 | | |
252 | 0 | List<T>* result = NewList<T>(); |
253 | 613 | if (new_len == 0) { // empty slice |
254 | 2 | return result; |
255 | 2 | } |
256 | | |
257 | 611 | result->reserve(new_len); |
258 | 611 | DCHECK(result->slab_); |
259 | | // Faster than append() in a loop |
260 | 0 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); |
261 | 611 | result->len_ = new_len; |
262 | | |
263 | 611 | return result; |
264 | 613 | } _ZN4ListIP6BigStrE5sliceEii Line | Count | Source | 243 | 5 | List<T>* List<T>::slice(int begin, int end) { | 244 | 5 | SLICE_ADJUST(begin, end, len_); | 245 | | | 246 | 5 | DCHECK(0 <= begin && begin <= len_); | 247 | 5 | DCHECK(0 <= end && end <= len_); | 248 | | | 249 | 0 | int new_len = end - begin; | 250 | 5 | DCHECK(0 <= new_len && new_len <= len_); | 251 | | | 252 | 0 | List<T>* result = NewList<T>(); | 253 | 5 | if (new_len == 0) { // empty slice | 254 | 2 | return result; | 255 | 2 | } | 256 | | | 257 | 3 | result->reserve(new_len); | 258 | 3 | DCHECK(result->slab_); | 259 | | // Faster than append() in a loop | 260 | 0 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); | 261 | 3 | result->len_ = new_len; | 262 | | | 263 | 3 | return result; | 264 | 5 | } |
Line | Count | Source | 243 | 608 | List<T>* List<T>::slice(int begin, int end) { | 244 | 608 | SLICE_ADJUST(begin, end, len_); | 245 | | | 246 | 608 | DCHECK(0 <= begin && begin <= len_); | 247 | 608 | DCHECK(0 <= end && end <= len_); | 248 | | | 249 | 0 | int new_len = end - begin; | 250 | 608 | DCHECK(0 <= new_len && new_len <= len_); | 251 | | | 252 | 0 | List<T>* result = NewList<T>(); | 253 | 608 | if (new_len == 0) { // empty slice | 254 | 0 | return result; | 255 | 0 | } | 256 | | | 257 | 608 | result->reserve(new_len); | 258 | 608 | DCHECK(result->slab_); | 259 | | // Faster than append() in a loop | 260 | 0 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); | 261 | 608 | result->len_ = new_len; | 262 | | | 263 | 608 | return result; | 264 | 608 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE5sliceEii |
265 | | |
266 | | // Ensure that there's space for a number of items |
267 | | template <typename T> |
268 | 9.17k | void List<T>::reserve(int num_desired) { |
269 | | // log("reserve capacity = %d, n = %d", capacity_, n); |
270 | | |
271 | | // Don't do anything if there's already enough space. |
272 | 9.17k | if (capacity_ >= num_desired) { |
273 | 7.42k | return; |
274 | 7.42k | } |
275 | | |
276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of |
277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for |
278 | | // List<int>. |
279 | | // |
280 | | // Example: the user reserves space for 3 integers. The minimum number of |
281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, |
282 | | // which leads to 8 + 6*4 = 32 byte Slab. |
283 | | |
284 | 1.75k | capacity_ = HowManyItems(num_desired); |
285 | 1.75k | auto new_slab = NewSlab<T>(capacity_); |
286 | | |
287 | 1.75k | if (len_ > 0) { |
288 | | // log("Copying %d bytes", len_ * sizeof(T)); |
289 | 216 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); |
290 | 216 | } |
291 | 1.75k | slab_ = new_slab; |
292 | 1.75k | } Line | Count | Source | 268 | 5.80k | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 5.80k | if (capacity_ >= num_desired) { | 273 | 5.08k | return; | 274 | 5.08k | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 726 | capacity_ = HowManyItems(num_desired); | 285 | 726 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 726 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 30 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 30 | } | 291 | 726 | slab_ = new_slab; | 292 | 726 | } |
_ZN4ListIP6BigStrE7reserveEi Line | Count | Source | 268 | 718 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 718 | if (capacity_ >= num_desired) { | 273 | 546 | return; | 274 | 546 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 172 | capacity_ = HowManyItems(num_desired); | 285 | 172 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 172 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 35 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 35 | } | 291 | 172 | slab_ = new_slab; | 292 | 172 | } |
_ZN4ListIP6Tuple2IP6BigStriEE7reserveEi Line | Count | Source | 268 | 1 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 1 | if (capacity_ >= num_desired) { | 273 | 0 | return; | 274 | 0 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 1 | capacity_ = HowManyItems(num_desired); | 285 | 1 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 1 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 1 | slab_ = new_slab; | 292 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE7reserveEi Line | Count | Source | 268 | 21 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 21 | if (capacity_ >= num_desired) { | 273 | 14 | return; | 274 | 14 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 7 | capacity_ = HowManyItems(num_desired); | 285 | 7 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 7 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 7 | slab_ = new_slab; | 292 | 7 | } |
_ZN4ListIPN11pretty_asdl11MeasuredDocEE7reserveEi Line | Count | Source | 268 | 1.68k | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 1.68k | if (capacity_ >= num_desired) { | 273 | 970 | return; | 274 | 970 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 719 | capacity_ = HowManyItems(num_desired); | 285 | 719 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 719 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 110 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 110 | } | 291 | 719 | slab_ = new_slab; | 292 | 719 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE7reserveEi Line | Count | Source | 268 | 800 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 800 | if (capacity_ >= num_desired) { | 273 | 743 | return; | 274 | 743 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 57 | capacity_ = HowManyItems(num_desired); | 285 | 57 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 57 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 38 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 38 | } | 291 | 57 | slab_ = new_slab; | 292 | 57 | } |
_ZN4ListIPN10hnode_asdl5FieldEE7reserveEi Line | Count | Source | 268 | 105 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 105 | if (capacity_ >= num_desired) { | 273 | 48 | return; | 274 | 48 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 57 | capacity_ = HowManyItems(num_desired); | 285 | 57 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 57 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 57 | slab_ = new_slab; | 292 | 57 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE7reserveEi Line | Count | Source | 268 | 3 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 3 | if (capacity_ >= num_desired) { | 273 | 0 | return; | 274 | 0 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 3 | capacity_ = HowManyItems(num_desired); | 285 | 3 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 3 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 3 | slab_ = new_slab; | 292 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE7reserveEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE7reserveEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE7reserveEi Line | Count | Source | 268 | 4 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 4 | if (capacity_ >= num_desired) { | 273 | 2 | return; | 274 | 2 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 2 | capacity_ = HowManyItems(num_desired); | 285 | 2 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 2 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 2 | slab_ = new_slab; | 292 | 2 | } |
_ZN4ListIP6Tuple2IiiEE7reserveEi Line | Count | Source | 268 | 8 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 8 | if (capacity_ >= num_desired) { | 273 | 4 | return; | 274 | 4 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 4 | capacity_ = HowManyItems(num_desired); | 285 | 4 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 4 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 0 | } | 291 | 4 | slab_ = new_slab; | 292 | 4 | } |
_ZN4ListIPN4pyos11PasswdEntryEE7reserveEi Line | Count | Source | 268 | 19 | void List<T>::reserve(int num_desired) { | 269 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 270 | | | 271 | | // Don't do anything if there's already enough space. | 272 | 19 | if (capacity_ >= num_desired) { | 273 | 15 | return; | 274 | 15 | } | 275 | | | 276 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 277 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 278 | | // List<int>. | 279 | | // | 280 | | // Example: the user reserves space for 3 integers. The minimum number of | 281 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 282 | | // which leads to 8 + 6*4 = 32 byte Slab. | 283 | | | 284 | 4 | capacity_ = HowManyItems(num_desired); | 285 | 4 | auto new_slab = NewSlab<T>(capacity_); | 286 | | | 287 | 4 | if (len_ > 0) { | 288 | | // log("Copying %d bytes", len_ * sizeof(T)); | 289 | 3 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 290 | 3 | } | 291 | 4 | slab_ = new_slab; | 292 | 4 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE7reserveEi Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE7reserveEi Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE7reserveEi |
293 | | |
294 | | // Implements L[i] = item |
295 | | template <typename T> |
296 | 47 | void List<T>::set(int i, T item) { |
297 | 47 | if (i < 0) { |
298 | 4 | i = len_ + i; |
299 | 4 | } |
300 | | |
301 | 47 | if (0 > i || i >= len_) { |
302 | 4 | throw Alloc<IndexError>(); |
303 | 4 | } |
304 | | |
305 | 43 | slab_->items_[i] = item; |
306 | 43 | } Line | Count | Source | 296 | 25 | void List<T>::set(int i, T item) { | 297 | 25 | if (i < 0) { | 298 | 4 | i = len_ + i; | 299 | 4 | } | 300 | | | 301 | 25 | if (0 > i || i >= len_) { | 302 | 4 | throw Alloc<IndexError>(); | 303 | 4 | } | 304 | | | 305 | 21 | slab_->items_[i] = item; | 306 | 21 | } |
_ZN4ListIP6BigStrE3setEiS1_ Line | Count | Source | 296 | 16 | void List<T>::set(int i, T item) { | 297 | 16 | if (i < 0) { | 298 | 0 | i = len_ + i; | 299 | 0 | } | 300 | | | 301 | 16 | if (0 > i || i >= len_) { | 302 | 0 | throw Alloc<IndexError>(); | 303 | 0 | } | 304 | | | 305 | 16 | slab_->items_[i] = item; | 306 | 16 | } |
Line | Count | Source | 296 | 6 | void List<T>::set(int i, T item) { | 297 | 6 | if (i < 0) { | 298 | 0 | i = len_ + i; | 299 | 0 | } | 300 | | | 301 | 6 | if (0 > i || i >= len_) { | 302 | 0 | throw Alloc<IndexError>(); | 303 | 0 | } | 304 | | | 305 | 6 | slab_->items_[i] = item; | 306 | 6 | } |
|
307 | | |
308 | | // Implements L[i] |
309 | | template <typename T> |
310 | 1.72k | T List<T>::at(int i) { |
311 | 1.72k | if (i < 0) { |
312 | 10 | i = len_ + i; |
313 | 10 | } |
314 | | |
315 | 1.72k | if (0 > i || i >= len_) { |
316 | 4 | throw Alloc<IndexError>(); |
317 | 4 | } |
318 | 1.72k | return slab_->items_[i]; |
319 | 1.72k | } Line | Count | Source | 310 | 578 | T List<T>::at(int i) { | 311 | 578 | if (i < 0) { | 312 | 7 | i = len_ + i; | 313 | 7 | } | 314 | | | 315 | 578 | if (0 > i || i >= len_) { | 316 | 4 | throw Alloc<IndexError>(); | 317 | 4 | } | 318 | 574 | return slab_->items_[i]; | 319 | 578 | } |
Line | Count | Source | 310 | 1.13k | T List<T>::at(int i) { | 311 | 1.13k | if (i < 0) { | 312 | 3 | i = len_ + i; | 313 | 3 | } | 314 | | | 315 | 1.13k | if (0 > i || i >= len_) { | 316 | 0 | throw Alloc<IndexError>(); | 317 | 0 | } | 318 | 1.13k | return slab_->items_[i]; | 319 | 1.13k | } |
Line | Count | Source | 310 | 4 | T List<T>::at(int i) { | 311 | 4 | if (i < 0) { | 312 | 0 | i = len_ + i; | 313 | 0 | } | 314 | | | 315 | 4 | if (0 > i || i >= len_) { | 316 | 0 | throw Alloc<IndexError>(); | 317 | 0 | } | 318 | 4 | return slab_->items_[i]; | 319 | 4 | } |
Line | Count | Source | 310 | 4 | T List<T>::at(int i) { | 311 | 4 | if (i < 0) { | 312 | 0 | i = len_ + i; | 313 | 0 | } | 314 | | | 315 | 4 | if (0 > i || i >= len_) { | 316 | 0 | throw Alloc<IndexError>(); | 317 | 0 | } | 318 | 4 | return slab_->items_[i]; | 319 | 4 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE2atEi _ZN4ListIP6Tuple2IiP6BigStrEE2atEi Line | Count | Source | 310 | 5 | T List<T>::at(int i) { | 311 | 5 | if (i < 0) { | 312 | 0 | i = len_ + i; | 313 | 0 | } | 314 | | | 315 | 5 | if (0 > i || i >= len_) { | 316 | 0 | throw Alloc<IndexError>(); | 317 | 0 | } | 318 | 5 | return slab_->items_[i]; | 319 | 5 | } |
|
320 | | |
321 | | // L.index(i) -- Python method |
322 | | template <typename T> |
323 | 8 | int List<T>::index(T value) { |
324 | 8 | int element_count = len(this); |
325 | 18 | for (int i = 0; i < element_count; i++) { |
326 | 16 | if (items_equal(slab_->items_[i], value)) { |
327 | 6 | return i; |
328 | 6 | } |
329 | 16 | } |
330 | 2 | throw Alloc<ValueError>(); |
331 | 8 | } |
332 | | |
333 | | // Should we have a separate API that doesn't return it? |
334 | | // https://stackoverflow.com/questions/12600330/pop-back-return-value |
335 | | template <typename T> |
336 | 809 | T List<T>::pop() { |
337 | 809 | if (len_ == 0) { |
338 | 0 | throw Alloc<IndexError>(); |
339 | 0 | } |
340 | 809 | len_--; |
341 | 809 | T result = slab_->items_[len_]; |
342 | 809 | slab_->items_[len_] = 0; // zero for GC scan |
343 | 809 | return result; |
344 | 809 | } Line | Count | Source | 336 | 7 | T List<T>::pop() { | 337 | 7 | if (len_ == 0) { | 338 | 0 | throw Alloc<IndexError>(); | 339 | 0 | } | 340 | 7 | len_--; | 341 | 7 | T result = slab_->items_[len_]; | 342 | 7 | slab_->items_[len_] = 0; // zero for GC scan | 343 | 7 | return result; | 344 | 7 | } |
_ZN4ListIPN11pretty_asdl11DocFragmentEE3popEv Line | Count | Source | 336 | 800 | T List<T>::pop() { | 337 | 800 | if (len_ == 0) { | 338 | 0 | throw Alloc<IndexError>(); | 339 | 0 | } | 340 | 800 | len_--; | 341 | 800 | T result = slab_->items_[len_]; | 342 | 800 | slab_->items_[len_] = 0; // zero for GC scan | 343 | 800 | return result; | 344 | 800 | } |
Line | Count | Source | 336 | 2 | T List<T>::pop() { | 337 | 2 | if (len_ == 0) { | 338 | 0 | throw Alloc<IndexError>(); | 339 | 0 | } | 340 | 2 | len_--; | 341 | 2 | T result = slab_->items_[len_]; | 342 | 2 | slab_->items_[len_] = 0; // zero for GC scan | 343 | 2 | return result; | 344 | 2 | } |
|
345 | | |
346 | | // Used in osh/word_parse.py to remove from front |
347 | | template <typename T> |
348 | 14 | T List<T>::pop(int i) { |
349 | 14 | if (len_ < i) { |
350 | 0 | throw Alloc<IndexError>(); |
351 | 0 | } |
352 | | |
353 | 14 | T result = at(i); |
354 | 14 | len_--; |
355 | | |
356 | | // Shift everything by one |
357 | 14 | memmove(slab_->items_ + i, slab_->items_ + (i + 1), (len_ - i) * sizeof(T)); |
358 | | |
359 | | /* |
360 | | for (int j = 0; j < len_; j++) { |
361 | | slab_->items_[j] = slab_->items_[j+1]; |
362 | | } |
363 | | */ |
364 | | |
365 | 14 | slab_->items_[len_] = 0; // zero for GC scan |
366 | 14 | return result; |
367 | 14 | } Line | Count | Source | 348 | 12 | T List<T>::pop(int i) { | 349 | 12 | if (len_ < i) { | 350 | 0 | throw Alloc<IndexError>(); | 351 | 0 | } | 352 | | | 353 | 12 | T result = at(i); | 354 | 12 | len_--; | 355 | | | 356 | | // Shift everything by one | 357 | 12 | memmove(slab_->items_ + i, slab_->items_ + (i + 1), (len_ - i) * sizeof(T)); | 358 | | | 359 | | /* | 360 | | for (int j = 0; j < len_; j++) { | 361 | | slab_->items_[j] = slab_->items_[j+1]; | 362 | | } | 363 | | */ | 364 | | | 365 | 12 | slab_->items_[len_] = 0; // zero for GC scan | 366 | 12 | return result; | 367 | 12 | } |
Line | Count | Source | 348 | 2 | T List<T>::pop(int i) { | 349 | 2 | if (len_ < i) { | 350 | 0 | throw Alloc<IndexError>(); | 351 | 0 | } | 352 | | | 353 | 2 | T result = at(i); | 354 | 2 | len_--; | 355 | | | 356 | | // Shift everything by one | 357 | 2 | memmove(slab_->items_ + i, slab_->items_ + (i + 1), (len_ - i) * sizeof(T)); | 358 | | | 359 | | /* | 360 | | for (int j = 0; j < len_; j++) { | 361 | | slab_->items_[j] = slab_->items_[j+1]; | 362 | | } | 363 | | */ | 364 | | | 365 | 2 | slab_->items_[len_] = 0; // zero for GC scan | 366 | 2 | return result; | 367 | 2 | } |
|
368 | | |
369 | | template <typename T> |
370 | 6 | void List<T>::remove(T x) { |
371 | 6 | int idx = this->index(x); |
372 | 6 | this->pop(idx); // unused |
373 | 6 | } |
374 | | |
375 | | template <typename T> |
376 | 8 | void List<T>::clear() { |
377 | 8 | if (slab_) { |
378 | 5 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan |
379 | 5 | } |
380 | 8 | len_ = 0; |
381 | 8 | } Line | Count | Source | 376 | 5 | void List<T>::clear() { | 377 | 5 | if (slab_) { | 378 | 5 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 379 | 5 | } | 380 | 5 | len_ = 0; | 381 | 5 | } |
_ZN4ListIP6BigStrE5clearEv Line | Count | Source | 376 | 1 | void List<T>::clear() { | 377 | 1 | if (slab_) { | 378 | 0 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 379 | 0 | } | 380 | 1 | len_ = 0; | 381 | 1 | } |
Line | Count | Source | 376 | 2 | void List<T>::clear() { | 377 | 2 | if (slab_) { | 378 | 0 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 379 | 0 | } | 380 | 2 | len_ = 0; | 381 | 2 | } |
|
382 | | |
383 | | // used by ASDL |
384 | | template <typename T> |
385 | 1 | void List<T>::SetTaken() { |
386 | 1 | slab_ = nullptr; |
387 | 1 | len_ = 0; |
388 | 1 | capacity_ = 0; |
389 | 1 | } _ZN4ListIP6BigStrE8SetTakenEv Line | Count | Source | 385 | 1 | void List<T>::SetTaken() { | 386 | 1 | slab_ = nullptr; | 387 | 1 | len_ = 0; | 388 | 1 | capacity_ = 0; | 389 | 1 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11MeasuredDocEE8SetTakenEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9command_tEE8SetTakenEv |
390 | | |
391 | | // Used in osh/string_ops.py |
392 | | template <typename T> |
393 | 8 | void List<T>::reverse() { |
394 | 16 | for (int i = 0; i < len_ / 2; ++i) { |
395 | | // log("swapping %d and %d", i, n-i); |
396 | 8 | T tmp = slab_->items_[i]; |
397 | 8 | int j = len_ - 1 - i; |
398 | 8 | slab_->items_[i] = slab_->items_[j]; |
399 | 8 | slab_->items_[j] = tmp; |
400 | 8 | } |
401 | 8 | } Unexecuted instantiation: _ZN4ListIP6BigStrE7reverseEv Line | Count | Source | 393 | 8 | void List<T>::reverse() { | 394 | 16 | for (int i = 0; i < len_ / 2; ++i) { | 395 | | // log("swapping %d and %d", i, n-i); | 396 | 8 | T tmp = slab_->items_[i]; | 397 | 8 | int j = len_ - 1 - i; | 398 | 8 | slab_->items_[i] = slab_->items_[j]; | 399 | 8 | slab_->items_[j] = tmp; | 400 | 8 | } | 401 | 8 | } |
|
402 | | |
403 | | // Extend this list with multiple elements. |
404 | | template <typename T> |
405 | 15 | void List<T>::extend(List<T>* other) { |
406 | 15 | int n = other->len_; |
407 | 15 | int new_len = len_ + n; |
408 | 15 | reserve(new_len); |
409 | | |
410 | 56 | for (int i = 0; i < n; ++i) { |
411 | 41 | slab_->items_[len_ + i] = other->slab_->items_[i]; |
412 | 41 | } |
413 | 15 | len_ = new_len; |
414 | 15 | } _ZN4ListIP6BigStrE6extendEPS2_ Line | Count | Source | 405 | 4 | void List<T>::extend(List<T>* other) { | 406 | 4 | int n = other->len_; | 407 | 4 | int new_len = len_ + n; | 408 | 4 | reserve(new_len); | 409 | | | 410 | 10 | for (int i = 0; i < n; ++i) { | 411 | 6 | slab_->items_[len_ + i] = other->slab_->items_[i]; | 412 | 6 | } | 413 | 4 | len_ = new_len; | 414 | 4 | } |
Line | Count | Source | 405 | 11 | void List<T>::extend(List<T>* other) { | 406 | 11 | int n = other->len_; | 407 | 11 | int new_len = len_ + n; | 408 | 11 | reserve(new_len); | 409 | | | 410 | 46 | for (int i = 0; i < n; ++i) { | 411 | 35 | slab_->items_[len_ + i] = other->slab_->items_[i]; | 412 | 35 | } | 413 | 11 | len_ = new_len; | 414 | 11 | } |
|
415 | | |
416 | 34 | inline bool CompareBigStr(BigStr* a, BigStr* b) { |
417 | 34 | return mylib::str_cmp(a, b) < 0; |
418 | 34 | } |
419 | | |
420 | | template <> |
421 | 10 | inline void List<BigStr*>::sort() { |
422 | 10 | if (slab_) { |
423 | 8 | std::sort(slab_->items_, slab_->items_ + len_, CompareBigStr); |
424 | 8 | } |
425 | 10 | } |
426 | | |
427 | 0 | inline bool CompareBigInt(mops::BigInt a, mops::BigInt b) { |
428 | 0 | return a < b; |
429 | 0 | } |
430 | | |
431 | | template <> |
432 | 0 | inline void List<mops::BigInt>::sort() { |
433 | 0 | std::sort(slab_->items_, slab_->items_ + len_, CompareBigInt); |
434 | 0 | } |
435 | | |
436 | | // TODO: mycpp can just generate the constructor instead? |
437 | | // e.g. [None] * 3 |
438 | | template <typename T> |
439 | 5 | List<T>* list_repeat(T item, int times) { |
440 | 5 | return NewList<T>(item, times); |
441 | 5 | } _Z11list_repeatIP6BigStrEP4ListIT_ES3_i Line | Count | Source | 439 | 3 | List<T>* list_repeat(T item, int times) { | 440 | 3 | return NewList<T>(item, times); | 441 | 3 | } |
_Z11list_repeatIbEP4ListIT_ES1_i Line | Count | Source | 439 | 2 | List<T>* list_repeat(T item, int times) { | 440 | 2 | return NewList<T>(item, times); | 441 | 2 | } |
|
442 | | |
443 | | // e.g. 'a' in ['a', 'b', 'c'] |
444 | | template <typename T> |
445 | 24 | inline bool list_contains(List<T>* haystack, T needle) { |
446 | 24 | int n = len(haystack); |
447 | 59 | for (int i = 0; i < n; ++i) { |
448 | 47 | if (items_equal(haystack->at(i), needle)) { |
449 | 12 | return true; |
450 | 12 | } |
451 | 47 | } |
452 | 12 | return false; |
453 | 24 | } _Z13list_containsIiEbP4ListIT_ES1_ Line | Count | Source | 445 | 10 | inline bool list_contains(List<T>* haystack, T needle) { | 446 | 10 | int n = len(haystack); | 447 | 25 | for (int i = 0; i < n; ++i) { | 448 | 20 | if (items_equal(haystack->at(i), needle)) { | 449 | 5 | return true; | 450 | 5 | } | 451 | 20 | } | 452 | 5 | return false; | 453 | 10 | } |
_Z13list_containsIP6BigStrEbP4ListIT_ES3_ Line | Count | Source | 445 | 12 | inline bool list_contains(List<T>* haystack, T needle) { | 446 | 12 | int n = len(haystack); | 447 | 28 | for (int i = 0; i < n; ++i) { | 448 | 23 | if (items_equal(haystack->at(i), needle)) { | 449 | 7 | return true; | 450 | 7 | } | 451 | 23 | } | 452 | 5 | return false; | 453 | 12 | } |
_Z13list_containsIlEbP4ListIT_ES1_ Line | Count | Source | 445 | 2 | inline bool list_contains(List<T>* haystack, T needle) { | 446 | 2 | int n = len(haystack); | 447 | 6 | for (int i = 0; i < n; ++i) { | 448 | 4 | if (items_equal(haystack->at(i), needle)) { | 449 | 0 | return true; | 450 | 0 | } | 451 | 4 | } | 452 | 2 | return false; | 453 | 2 | } |
|
454 | | |
455 | | template <typename V> |
456 | 2 | List<BigStr*>* sorted(Dict<BigStr*, V>* d) { |
457 | 2 | auto keys = d->keys(); |
458 | 2 | keys->sort(); |
459 | 2 | return keys; |
460 | 2 | } |
461 | | |
462 | | template <typename T> |
463 | 2 | List<T>* sorted(List<T>* l) { |
464 | 2 | auto ret = list(l); |
465 | 2 | ret->sort(); |
466 | 2 | return ret; |
467 | 2 | } |
468 | | |
469 | | // list(L) copies the list |
470 | | template <typename T> |
471 | 7 | List<T>* list(List<T>* other) { |
472 | 7 | auto result = NewList<T>(); |
473 | 7 | result->extend(other); |
474 | 7 | return result; |
475 | 7 | } Line | Count | Source | 471 | 5 | List<T>* list(List<T>* other) { | 472 | 5 | auto result = NewList<T>(); | 473 | 5 | result->extend(other); | 474 | 5 | return result; | 475 | 5 | } |
_Z4listIP6BigStrEP4ListIT_ES5_ Line | Count | Source | 471 | 2 | List<T>* list(List<T>* other) { | 472 | 2 | auto result = NewList<T>(); | 473 | 2 | result->extend(other); | 474 | 2 | return result; | 475 | 2 | } |
|
476 | | |
477 | | template <class T> |
478 | | class ListIter { |
479 | | public: |
480 | 639 | explicit ListIter(List<T>* L) : L_(L), i_(0) { |
481 | | // Cheney only: L_ could be moved during iteration. |
482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); |
483 | 639 | } _ZN8ListIterIP6BigStrEC2EP4ListIS1_E Line | Count | Source | 480 | 52 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 52 | } |
_ZN8ListIterIiEC2EP4ListIiE Line | Count | Source | 480 | 22 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 22 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEEC2EP4ListIS4_E Line | Count | Source | 480 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 1 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E Line | Count | Source | 480 | 6 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 6 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEEC2EP4ListIS2_E _ZN8ListIterIPN10hnode_asdl5FieldEEC2EP4ListIS2_E Line | Count | Source | 480 | 57 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 57 | } |
_ZN8ListIterIPN11pretty_asdl11MeasuredDocEEC2EP4ListIS2_E Line | Count | Source | 480 | 495 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 495 | } |
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN10value_asdl16InitializerValueEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17InitializerWord_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8TypeExprEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10place_op_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl13ComprehensionEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl20class_literal_term_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17char_class_term_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl4re_tEEC2EP4ListIS2_E _ZN8ListIterIbEC2EP4ListIbE Line | Count | Source | 480 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 1 | } |
_ZN8ListIterIP6Tuple2IiiEEC2EP4ListIS2_E Line | Count | Source | 480 | 4 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 4 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEEC2EP4ListIS2_E Line | Count | Source | 480 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 481 | | // Cheney only: L_ could be moved during iteration. | 482 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 483 | 1 | } |
|
484 | | |
485 | 642 | ~ListIter() { |
486 | | // gHeap.PopRoot(); |
487 | 642 | } _ZN8ListIterIP6BigStrED2Ev Line | Count | Source | 485 | 52 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 52 | } |
Line | Count | Source | 485 | 25 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 25 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEED2Ev Line | Count | Source | 485 | 1 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 1 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEED2Ev Line | Count | Source | 485 | 6 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 6 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEED2Ev _ZN8ListIterIPN10hnode_asdl5FieldEED2Ev Line | Count | Source | 485 | 57 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 57 | } |
_ZN8ListIterIPN11pretty_asdl11MeasuredDocEED2Ev Line | Count | Source | 485 | 495 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 495 | } |
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEED2Ev Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEED2Ev Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEED2Ev Unexecuted instantiation: _ZN8ListIterIPN10value_asdl16InitializerValueEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17InitializerWord_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8TypeExprEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10place_op_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl13ComprehensionEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl20class_literal_term_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17char_class_term_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl4re_tEED2Ev Line | Count | Source | 485 | 1 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 1 | } |
_ZN8ListIterIP6Tuple2IiiEED2Ev Line | Count | Source | 485 | 4 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 4 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEED2Ev Line | Count | Source | 485 | 1 | ~ListIter() { | 486 | | // gHeap.PopRoot(); | 487 | 1 | } |
|
488 | 1.84k | void Next() { |
489 | 1.84k | i_++; |
490 | 1.84k | } _ZN8ListIterIP6BigStrE4NextEv Line | Count | Source | 488 | 179 | void Next() { | 489 | 179 | i_++; | 490 | 179 | } |
Line | Count | Source | 488 | 85 | void Next() { | 489 | 85 | i_++; | 490 | 85 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE4NextEv Line | Count | Source | 488 | 2 | void Next() { | 489 | 2 | i_++; | 490 | 2 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE4NextEv Line | Count | Source | 488 | 18 | void Next() { | 489 | 18 | i_++; | 490 | 18 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4NextEv _ZN8ListIterIPN10hnode_asdl5FieldEE4NextEv Line | Count | Source | 488 | 105 | void Next() { | 489 | 105 | i_++; | 490 | 105 | } |
_ZN8ListIterIPN11pretty_asdl11MeasuredDocEE4NextEv Line | Count | Source | 488 | 1.43k | void Next() { | 489 | 1.43k | i_++; | 490 | 1.43k | } |
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN10value_asdl16InitializerValueEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17InitializerWord_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8TypeExprEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10place_op_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl13ComprehensionEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl20class_literal_term_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17char_class_term_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl4re_tEE4NextEv Line | Count | Source | 488 | 2 | void Next() { | 489 | 2 | i_++; | 490 | 2 | } |
_ZN8ListIterIP6Tuple2IiiEE4NextEv Line | Count | Source | 488 | 8 | void Next() { | 489 | 8 | i_++; | 490 | 8 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE4NextEv Line | Count | Source | 488 | 18 | void Next() { | 489 | 18 | i_++; | 490 | 18 | } |
|
491 | 2.48k | bool Done() { |
492 | | // "unsigned size_t was a mistake" |
493 | 2.48k | return i_ >= static_cast<int>(L_->len_); |
494 | 2.48k | } _ZN8ListIterIP6BigStrE4DoneEv Line | Count | Source | 491 | 231 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 231 | return i_ >= static_cast<int>(L_->len_); | 494 | 231 | } |
Line | Count | Source | 491 | 104 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 104 | return i_ >= static_cast<int>(L_->len_); | 494 | 104 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE4DoneEv Line | Count | Source | 491 | 3 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 3 | return i_ >= static_cast<int>(L_->len_); | 494 | 3 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE4DoneEv Line | Count | Source | 491 | 24 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 24 | return i_ >= static_cast<int>(L_->len_); | 494 | 24 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4DoneEv _ZN8ListIterIPN10hnode_asdl5FieldEE4DoneEv Line | Count | Source | 491 | 162 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 162 | return i_ >= static_cast<int>(L_->len_); | 494 | 162 | } |
_ZN8ListIterIPN11pretty_asdl11MeasuredDocEE4DoneEv Line | Count | Source | 491 | 1.92k | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 1.92k | return i_ >= static_cast<int>(L_->len_); | 494 | 1.92k | } |
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN10value_asdl16InitializerValueEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17InitializerWord_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8TypeExprEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10place_op_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl13ComprehensionEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl20class_literal_term_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17char_class_term_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl4re_tEE4DoneEv Line | Count | Source | 491 | 3 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 3 | return i_ >= static_cast<int>(L_->len_); | 494 | 3 | } |
_ZN8ListIterIP6Tuple2IiiEE4DoneEv Line | Count | Source | 491 | 12 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 12 | return i_ >= static_cast<int>(L_->len_); | 494 | 12 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE4DoneEv Line | Count | Source | 491 | 19 | bool Done() { | 492 | | // "unsigned size_t was a mistake" | 493 | 19 | return i_ >= static_cast<int>(L_->len_); | 494 | 19 | } |
|
495 | 1.84k | T Value() { |
496 | 1.84k | return L_->slab_->items_[i_]; |
497 | 1.84k | } _ZN8ListIterIP6BigStrE5ValueEv Line | Count | Source | 495 | 180 | T Value() { | 496 | 180 | return L_->slab_->items_[i_]; | 497 | 180 | } |
Line | Count | Source | 495 | 80 | T Value() { | 496 | 80 | return L_->slab_->items_[i_]; | 497 | 80 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE5ValueEv Line | Count | Source | 495 | 2 | T Value() { | 496 | 2 | return L_->slab_->items_[i_]; | 497 | 2 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE5ValueEv Line | Count | Source | 495 | 10 | T Value() { | 496 | 10 | return L_->slab_->items_[i_]; | 497 | 10 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE5ValueEv _ZN8ListIterIPN10hnode_asdl5FieldEE5ValueEv Line | Count | Source | 495 | 105 | T Value() { | 496 | 105 | return L_->slab_->items_[i_]; | 497 | 105 | } |
_ZN8ListIterIPN11pretty_asdl11MeasuredDocEE5ValueEv Line | Count | Source | 495 | 1.43k | T Value() { | 496 | 1.43k | return L_->slab_->items_[i_]; | 497 | 1.43k | } |
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN10value_asdl16InitializerValueEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17InitializerWord_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8TypeExprEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10place_op_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl13ComprehensionEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl20class_literal_term_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl17char_class_term_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl4re_tEE5ValueEv Line | Count | Source | 495 | 2 | T Value() { | 496 | 2 | return L_->slab_->items_[i_]; | 497 | 2 | } |
_ZN8ListIterIP6Tuple2IiiEE5ValueEv Line | Count | Source | 495 | 16 | T Value() { | 496 | 16 | return L_->slab_->items_[i_]; | 497 | 16 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE5ValueEv Line | Count | Source | 495 | 19 | T Value() { | 496 | 19 | return L_->slab_->items_[i_]; | 497 | 19 | } |
|
498 | 16 | T iterNext() { |
499 | 16 | if (Done()) { |
500 | 3 | throw Alloc<StopIteration>(); |
501 | 3 | } |
502 | 13 | T ret = L_->slab_->items_[i_]; |
503 | 13 | Next(); |
504 | 13 | return ret; |
505 | 16 | } _ZN8ListIterIP6Tuple2IiP6BigStrEE8iterNextEv Line | Count | Source | 498 | 10 | T iterNext() { | 499 | 10 | if (Done()) { | 500 | 2 | throw Alloc<StopIteration>(); | 501 | 2 | } | 502 | 8 | T ret = L_->slab_->items_[i_]; | 503 | 8 | Next(); | 504 | 8 | return ret; | 505 | 10 | } |
_ZN8ListIterIiE8iterNextEv Line | Count | Source | 498 | 6 | T iterNext() { | 499 | 6 | if (Done()) { | 500 | 1 | throw Alloc<StopIteration>(); | 501 | 1 | } | 502 | 5 | T ret = L_->slab_->items_[i_]; | 503 | 5 | Next(); | 504 | 5 | return ret; | 505 | 6 | } |
|
506 | | |
507 | | // only for use with generators |
508 | 3 | List<T>* GetList() { |
509 | 3 | return L_; |
510 | 3 | } |
511 | | |
512 | | private: |
513 | | List<T>* L_; |
514 | | int i_; |
515 | | }; |
516 | | |
517 | | // list(it) returns the iterator's backing list |
518 | | template <typename T> |
519 | 3 | List<T>* list(ListIter<T> it) { |
520 | 3 | return list(it.GetList()); |
521 | 3 | } |
522 | | |
523 | | // TODO: Does using pointers rather than indices make this more efficient? |
524 | | template <class T> |
525 | | class ReverseListIter { |
526 | | public: |
527 | 118 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { |
528 | 118 | } _ZN15ReverseListIterIP6BigStrEC2EP4ListIS1_E Line | Count | Source | 527 | 1 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 528 | 1 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E Line | Count | Source | 527 | 1 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 528 | 1 | } |
_ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEEC2EP4ListIS2_E Line | Count | Source | 527 | 114 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 528 | 114 | } |
_ZN15ReverseListIterIiEC2EP4ListIiE Line | Count | Source | 527 | 2 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 528 | 2 | } |
|
529 | 658 | void Next() { |
530 | 658 | i_--; |
531 | 658 | } _ZN15ReverseListIterIP6BigStrE4NextEv Line | Count | Source | 529 | 2 | void Next() { | 530 | 2 | i_--; | 531 | 2 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4NextEv Line | Count | Source | 529 | 2 | void Next() { | 530 | 2 | i_--; | 531 | 2 | } |
_ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE4NextEv Line | Count | Source | 529 | 648 | void Next() { | 530 | 648 | i_--; | 531 | 648 | } |
_ZN15ReverseListIterIiE4NextEv Line | Count | Source | 529 | 6 | void Next() { | 530 | 6 | i_--; | 531 | 6 | } |
|
532 | 776 | bool Done() { |
533 | 776 | return i_ < 0; |
534 | 776 | } _ZN15ReverseListIterIP6BigStrE4DoneEv Line | Count | Source | 532 | 3 | bool Done() { | 533 | 3 | return i_ < 0; | 534 | 3 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4DoneEv Line | Count | Source | 532 | 3 | bool Done() { | 533 | 3 | return i_ < 0; | 534 | 3 | } |
_ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE4DoneEv Line | Count | Source | 532 | 762 | bool Done() { | 533 | 762 | return i_ < 0; | 534 | 762 | } |
_ZN15ReverseListIterIiE4DoneEv Line | Count | Source | 532 | 8 | bool Done() { | 533 | 8 | return i_ < 0; | 534 | 8 | } |
|
535 | 658 | T Value() { |
536 | 658 | return L_->slab_->items_[i_]; |
537 | 658 | } _ZN15ReverseListIterIP6BigStrE5ValueEv Line | Count | Source | 535 | 2 | T Value() { | 536 | 2 | return L_->slab_->items_[i_]; | 537 | 2 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE5ValueEv Line | Count | Source | 535 | 2 | T Value() { | 536 | 2 | return L_->slab_->items_[i_]; | 537 | 2 | } |
_ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE5ValueEv Line | Count | Source | 535 | 648 | T Value() { | 536 | 648 | return L_->slab_->items_[i_]; | 537 | 648 | } |
_ZN15ReverseListIterIiE5ValueEv Line | Count | Source | 535 | 6 | T Value() { | 536 | 6 | return L_->slab_->items_[i_]; | 537 | 6 | } |
|
538 | | |
539 | | private: |
540 | | List<T>* L_; |
541 | | int i_; |
542 | | }; |
543 | | |
544 | | int max(List<int>* elems); |
545 | | |
546 | | #endif // MYCPP_GC_LIST_H |