/home/andy/git/oilshell/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 | 935 | List() : len_(0), capacity_(0), slab_(nullptr) { |
38 | 935 | } Line | Count | Source | 37 | 147 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 147 | } |
Line | Count | Source | 37 | 692 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 692 | } |
_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 | } |
_ZN4ListIPN10hnode_asdl5FieldEEC2Ev Line | Count | Source | 37 | 37 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 37 | } |
_ZN4ListIPN10hnode_asdl7hnode_tEEC2Ev Line | Count | Source | 37 | 37 | List() : len_(0), capacity_(0), slab_(nullptr) { | 38 | 37 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEEC2Ev 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 | | // Implements L[i] |
41 | | T at(int i); |
42 | | |
43 | | // returns index of the element |
44 | | int index(T element); |
45 | | |
46 | | // Implements L[i] = item |
47 | | void set(int i, T item); |
48 | | |
49 | | // L[begin:] |
50 | | List* slice(int begin); |
51 | | |
52 | | // L[begin:end] |
53 | | List* slice(int begin, int end); |
54 | | |
55 | | // Should we have a separate API that doesn't return it? |
56 | | // https://stackoverflow.com/questions/12600330/pop-back-return-value |
57 | | T pop(); |
58 | | |
59 | | // Used in osh/word_parse.py to remove from front |
60 | | T pop(int i); |
61 | | |
62 | | // Remove the first occourence of x from the list. |
63 | | void remove(T x); |
64 | | |
65 | | void clear(); |
66 | | |
67 | | // Used in osh/string_ops.py |
68 | | void reverse(); |
69 | | |
70 | | // Templated function |
71 | | void sort(); |
72 | | |
73 | | // Ensure that there's space for at LEAST this many items |
74 | | void reserve(int num_desired); |
75 | | |
76 | | // Append a single element to this list. |
77 | | void append(T item); |
78 | | |
79 | | // Extend this list with multiple elements. |
80 | | void extend(List<T>* other); |
81 | | |
82 | 920 | static constexpr ObjHeader obj_header() { |
83 | 920 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); |
84 | 920 | } _ZN4ListIP6BigStrE10obj_headerEv Line | Count | Source | 82 | 147 | static constexpr ObjHeader obj_header() { | 83 | 147 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 147 | } |
_ZN4ListIiE10obj_headerEv Line | Count | Source | 82 | 681 | static constexpr ObjHeader obj_header() { | 83 | 681 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 681 | } |
_ZN4ListIP6Tuple2IP6BigStriEE10obj_headerEv Line | Count | Source | 82 | 1 | static constexpr ObjHeader obj_header() { | 83 | 1 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE10obj_headerEv Line | Count | Source | 82 | 5 | static constexpr ObjHeader obj_header() { | 83 | 5 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 5 | } |
_ZN4ListIPN10hnode_asdl5FieldEE10obj_headerEv Line | Count | Source | 82 | 37 | static constexpr ObjHeader obj_header() { | 83 | 37 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 37 | } |
_ZN4ListIPN10hnode_asdl7hnode_tEE10obj_headerEv Line | Count | Source | 82 | 37 | static constexpr ObjHeader obj_header() { | 83 | 37 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 37 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11MeasuredDocEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9AssocPairEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl11word_part_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9command_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_asdl5IfArmEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7CaseArmEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8NameTypeEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7y_lhs_tEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10place_op_tEE10obj_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_asdl10SourceLineEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10obj_headerEv _ZN4ListIbE10obj_headerEv Line | Count | Source | 82 | 3 | static constexpr ObjHeader obj_header() { | 83 | 3 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE10obj_headerEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE10obj_headerEv _ZN4ListIlE10obj_headerEv Line | Count | Source | 82 | 2 | static constexpr ObjHeader obj_header() { | 83 | 2 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 2 | } |
_ZN4ListIP6Tuple2IiiEE10obj_headerEv Line | Count | Source | 82 | 4 | static constexpr ObjHeader obj_header() { | 83 | 4 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 4 | } |
_ZN4ListIPiE10obj_headerEv Line | Count | Source | 82 | 2 | static constexpr ObjHeader obj_header() { | 83 | 2 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 2 | } |
_ZN4ListIPN4pyos11PasswdEntryEE10obj_headerEv Line | Count | Source | 82 | 1 | static constexpr ObjHeader obj_header() { | 83 | 1 | return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>)); | 84 | 1 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10obj_headerEv Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10obj_headerEv |
85 | | |
86 | | int len_; // number of entries |
87 | | int capacity_; // max entries before resizing |
88 | | |
89 | | // The container may be resized, so this field isn't in-line. |
90 | | Slab<T>* slab_; |
91 | | |
92 | | // A list has one Slab pointer which we need to follow. |
93 | 922 | static constexpr uint32_t field_mask() { |
94 | 922 | return maskbit(offsetof(List, slab_)); |
95 | 922 | } _ZN4ListIP6BigStrE10field_maskEv Line | Count | Source | 93 | 147 | static constexpr uint32_t field_mask() { | 94 | 147 | return maskbit(offsetof(List, slab_)); | 95 | 147 | } |
_ZN4ListIiE10field_maskEv Line | Count | Source | 93 | 683 | static constexpr uint32_t field_mask() { | 94 | 683 | return maskbit(offsetof(List, slab_)); | 95 | 683 | } |
_ZN4ListIP6Tuple2IP6BigStriEE10field_maskEv Line | Count | Source | 93 | 1 | static constexpr uint32_t field_mask() { | 94 | 1 | return maskbit(offsetof(List, slab_)); | 95 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE10field_maskEv Line | Count | Source | 93 | 5 | static constexpr uint32_t field_mask() { | 94 | 5 | return maskbit(offsetof(List, slab_)); | 95 | 5 | } |
_ZN4ListIPN10hnode_asdl5FieldEE10field_maskEv Line | Count | Source | 93 | 37 | static constexpr uint32_t field_mask() { | 94 | 37 | return maskbit(offsetof(List, slab_)); | 95 | 37 | } |
_ZN4ListIPN10hnode_asdl7hnode_tEE10field_maskEv Line | Count | Source | 93 | 37 | static constexpr uint32_t field_mask() { | 94 | 37 | return maskbit(offsetof(List, slab_)); | 95 | 37 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11MeasuredDocEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9AssocPairEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl11word_part_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9command_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_asdl8NameTypeEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl7y_lhs_tEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10place_op_tEE10field_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_asdl10SourceLineEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10field_maskEv _ZN4ListIbE10field_maskEv Line | Count | Source | 93 | 3 | static constexpr uint32_t field_mask() { | 94 | 3 | return maskbit(offsetof(List, slab_)); | 95 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE10field_maskEv Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE10field_maskEv _ZN4ListIlE10field_maskEv Line | Count | Source | 93 | 2 | static constexpr uint32_t field_mask() { | 94 | 2 | return maskbit(offsetof(List, slab_)); | 95 | 2 | } |
_ZN4ListIP6Tuple2IiiEE10field_maskEv Line | Count | Source | 93 | 4 | static constexpr uint32_t field_mask() { | 94 | 4 | return maskbit(offsetof(List, slab_)); | 95 | 4 | } |
_ZN4ListIPiE10field_maskEv Line | Count | Source | 93 | 2 | static constexpr uint32_t field_mask() { | 94 | 2 | return maskbit(offsetof(List, slab_)); | 95 | 2 | } |
_ZN4ListIPN4pyos11PasswdEntryEE10field_maskEv Line | Count | Source | 93 | 1 | static constexpr uint32_t field_mask() { | 94 | 1 | return maskbit(offsetof(List, slab_)); | 95 | 1 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10field_maskEv Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10field_maskEv |
96 | | |
97 | | DISALLOW_COPY_AND_ASSIGN(List) |
98 | | |
99 | | static_assert(sizeof(ObjHeader) % sizeof(T) == 0, |
100 | | "ObjHeader size should be multiple of item size"); |
101 | | static constexpr int kHeaderFudge = sizeof(ObjHeader) / sizeof(T); |
102 | | |
103 | | #if 0 |
104 | | // 24-byte pool comes from very common List header, and Token |
105 | | static constexpr int kPoolBytes1 = 24 - sizeof(ObjHeader); |
106 | | static_assert(kPoolBytes1 % sizeof(T) == 0, |
107 | | "An integral number of items should fit in first pool"); |
108 | | static constexpr int kNumItems1 = kPoolBytes1 / sizeof(T); |
109 | | #endif |
110 | | |
111 | | // Matches mark_sweep_heap.h |
112 | | static constexpr int kPoolBytes2 = 48 - sizeof(ObjHeader); |
113 | | static_assert(kPoolBytes2 % sizeof(T) == 0, |
114 | | "An integral number of items should fit in second pool"); |
115 | | static constexpr int kNumItems2 = kPoolBytes2 / sizeof(T); |
116 | | |
117 | | #if 0 |
118 | | static constexpr int kMinBytes2 = 128 - sizeof(ObjHeader); |
119 | | static_assert(kMinBytes2 % sizeof(T) == 0, |
120 | | "An integral number of items should fit"); |
121 | | static constexpr int kMinItems2 = kMinBytes2 / sizeof(T); |
122 | | #endif |
123 | | |
124 | | // Given the number of items desired, return the number items we should |
125 | | // reserve room for, according to our growth policy. |
126 | 946 | int HowManyItems(int num_desired) { |
127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So |
128 | | // just use the larger 48 byte pool. |
129 | | #if 0 |
130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 |
131 | | return kNumItems1; |
132 | | } |
133 | | #endif |
134 | 946 | if (num_desired <= kNumItems2) { // use full cell in pool 2 |
135 | 863 | return kNumItems2; |
136 | 863 | } |
137 | | #if 0 |
138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 |
139 | | return kMinItems2; |
140 | | } |
141 | | #endif |
142 | | |
143 | | // Make sure the total allocation is a power of 2. TODO: consider using |
144 | | // slightly less than power of 2, to account for malloc() headers, and |
145 | | // reduce fragmentation. |
146 | | // Example: |
147 | | // - ask for 11 integers |
148 | | // - round up 11+2 == 13 up to 16 items |
149 | | // - return 14 items |
150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. |
151 | 83 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; |
152 | 946 | } _ZN4ListIP6BigStrE12HowManyItemsEi Line | Count | Source | 126 | 168 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 168 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 129 | return kNumItems2; | 136 | 129 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 39 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 168 | } |
_ZN4ListIiE12HowManyItemsEi Line | Count | Source | 126 | 719 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 719 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 679 | return kNumItems2; | 136 | 679 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 40 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 719 | } |
_ZN4ListIP6Tuple2IP6BigStriEE12HowManyItemsEi Line | Count | Source | 126 | 1 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 1 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 1 | return kNumItems2; | 136 | 1 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE12HowManyItemsEi Line | Count | Source | 126 | 7 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 7 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 7 | return kNumItems2; | 136 | 7 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 7 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE12HowManyItemsEi _ZN4ListIPN10hnode_asdl5FieldEE12HowManyItemsEi Line | Count | Source | 126 | 37 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 37 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 37 | return kNumItems2; | 136 | 37 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 37 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE12HowManyItemsEi _ZN4ListIbE12HowManyItemsEi Line | Count | Source | 126 | 3 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 3 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 3 | return kNumItems2; | 136 | 3 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE12HowManyItemsEi _ZN4ListIlE12HowManyItemsEi Line | Count | Source | 126 | 2 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 2 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 2 | return kNumItems2; | 136 | 2 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 2 | } |
_ZN4ListIP6Tuple2IiiEE12HowManyItemsEi Line | Count | Source | 126 | 4 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 4 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 4 | return kNumItems2; | 136 | 4 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 0 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 4 | } |
_ZN4ListIPN4pyos11PasswdEntryEE12HowManyItemsEi Line | Count | Source | 126 | 5 | int HowManyItems(int num_desired) { | 127 | | // Using the 24-byte pool leads to too much GC of tiny slab objects! So | 128 | | // just use the larger 48 byte pool. | 129 | | #if 0 | 130 | | if (num_desired <= kNumItems1) { // use full cell in pool 1 | 131 | | return kNumItems1; | 132 | | } | 133 | | #endif | 134 | 5 | if (num_desired <= kNumItems2) { // use full cell in pool 2 | 135 | 1 | return kNumItems2; | 136 | 1 | } | 137 | | #if 0 | 138 | | if (num_desired <= kMinItems2) { // 48 -> 128, not 48 -> 64 | 139 | | return kMinItems2; | 140 | | } | 141 | | #endif | 142 | | | 143 | | // Make sure the total allocation is a power of 2. TODO: consider using | 144 | | // slightly less than power of 2, to account for malloc() headers, and | 145 | | // reduce fragmentation. | 146 | | // Example: | 147 | | // - ask for 11 integers | 148 | | // - round up 11+2 == 13 up to 16 items | 149 | | // - return 14 items | 150 | | // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc. | 151 | 4 | return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge; | 152 | 5 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE12HowManyItemsEi Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE12HowManyItemsEi |
153 | | }; |
154 | | |
155 | | // "Constructors" as free functions since we can't allocate within a |
156 | | // constructor. Allocation may cause garbage collection, which interferes with |
157 | | // placement new. |
158 | | |
159 | | // This is not really necessary, only syntactic sugar. |
160 | | template <typename T> |
161 | 665 | List<T>* NewList() { |
162 | 665 | return Alloc<List<T>>(); |
163 | 665 | } _Z7NewListIP6BigStrEP4ListIT_Ev Line | Count | Source | 161 | 28 | List<T>* NewList() { | 162 | 28 | return Alloc<List<T>>(); | 163 | 28 | } |
Line | Count | Source | 161 | 631 | List<T>* NewList() { | 162 | 631 | return Alloc<List<T>>(); | 163 | 631 | } |
_Z7NewListIPiEP4ListIT_Ev Line | Count | Source | 161 | 2 | List<T>* NewList() { | 162 | 2 | return Alloc<List<T>>(); | 163 | 2 | } |
_Z7NewListIPN4pyos11PasswdEntryEEP4ListIT_Ev Line | Count | Source | 161 | 1 | List<T>* NewList() { | 162 | 1 | return Alloc<List<T>>(); | 163 | 1 | } |
Unexecuted instantiation: _Z7NewListIPN11syntax_asdl12CompoundWordEEP4ListIT_Ev _Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_Ev Line | Count | Source | 161 | 3 | List<T>* NewList() { | 162 | 3 | return Alloc<List<T>>(); | 163 | 3 | } |
|
164 | | |
165 | | // Literal ['foo', 'bar'] |
166 | | // This seems to allow better template argument type deduction than a |
167 | | // constructor. |
168 | | template <typename T> |
169 | 103 | List<T>* NewList(std::initializer_list<T> init) { |
170 | 103 | auto self = Alloc<List<T>>(); |
171 | | |
172 | 103 | int n = init.size(); |
173 | 103 | self->reserve(n); |
174 | | |
175 | 103 | int i = 0; |
176 | 214 | for (auto item : init) { |
177 | 214 | self->set(i, item); |
178 | 214 | ++i; |
179 | 214 | } |
180 | 103 | self->len_ = n; |
181 | 103 | return self; |
182 | 103 | } _Z7NewListIP6BigStrEP4ListIT_ESt16initializer_listIS3_E Line | Count | Source | 169 | 70 | List<T>* NewList(std::initializer_list<T> init) { | 170 | 70 | auto self = Alloc<List<T>>(); | 171 | | | 172 | 70 | int n = init.size(); | 173 | 70 | self->reserve(n); | 174 | | | 175 | 70 | int i = 0; | 176 | 89 | for (auto item : init) { | 177 | 89 | self->set(i, item); | 178 | 89 | ++i; | 179 | 89 | } | 180 | 70 | self->len_ = n; | 181 | 70 | return self; | 182 | 70 | } |
_Z7NewListIiEP4ListIT_ESt16initializer_listIS1_E Line | Count | Source | 169 | 30 | List<T>* NewList(std::initializer_list<T> init) { | 170 | 30 | auto self = Alloc<List<T>>(); | 171 | | | 172 | 30 | int n = init.size(); | 173 | 30 | self->reserve(n); | 174 | | | 175 | 30 | int i = 0; | 176 | 119 | for (auto item : init) { | 177 | 119 | self->set(i, item); | 178 | 119 | ++i; | 179 | 119 | } | 180 | 30 | self->len_ = n; | 181 | 30 | return self; | 182 | 30 | } |
_Z7NewListIP6Tuple2IP6BigStriEEP4ListIT_ESt16initializer_listIS6_E Line | Count | Source | 169 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 170 | 1 | auto self = Alloc<List<T>>(); | 171 | | | 172 | 1 | int n = init.size(); | 173 | 1 | self->reserve(n); | 174 | | | 175 | 1 | int i = 0; | 176 | 2 | for (auto item : init) { | 177 | 2 | self->set(i, item); | 178 | 2 | ++i; | 179 | 2 | } | 180 | 1 | self->len_ = n; | 181 | 1 | return self; | 182 | 1 | } |
_Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_ESt16initializer_listIS6_E Line | Count | Source | 169 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 170 | 1 | auto self = Alloc<List<T>>(); | 171 | | | 172 | 1 | int n = init.size(); | 173 | 1 | self->reserve(n); | 174 | | | 175 | 1 | int i = 0; | 176 | 2 | for (auto item : init) { | 177 | 2 | self->set(i, item); | 178 | 2 | ++i; | 179 | 2 | } | 180 | 1 | self->len_ = n; | 181 | 1 | return self; | 182 | 1 | } |
Unexecuted instantiation: _Z7NewListIPN11pretty_asdl11DocFragmentEEP4ListIT_ESt16initializer_listIS4_E Unexecuted instantiation: _Z7NewListIPN10hnode_asdl7hnode_tEEP4ListIT_ESt16initializer_listIS4_E _Z7NewListIbEP4ListIT_ESt16initializer_listIS1_E Line | Count | Source | 169 | 1 | List<T>* NewList(std::initializer_list<T> init) { | 170 | 1 | auto self = Alloc<List<T>>(); | 171 | | | 172 | 1 | int n = init.size(); | 173 | 1 | self->reserve(n); | 174 | | | 175 | 1 | int i = 0; | 176 | 2 | for (auto item : init) { | 177 | 2 | self->set(i, item); | 178 | 2 | ++i; | 179 | 2 | } | 180 | 1 | self->len_ = n; | 181 | 1 | return self; | 182 | 1 | } |
Unexecuted instantiation: _Z7NewListIP6Tuple2IiiEEP4ListIT_ESt16initializer_listIS4_E |
183 | | |
184 | | // ['foo'] * 3 |
185 | | template <typename T> |
186 | 9 | List<T>* NewList(T item, int times) { |
187 | 9 | auto self = Alloc<List<T>>(); |
188 | | |
189 | 9 | self->reserve(times); |
190 | 9 | self->len_ = times; |
191 | 36 | for (int i = 0; i < times; ++i) { |
192 | 27 | self->set(i, item); |
193 | 27 | } |
194 | 9 | return self; |
195 | 9 | } _Z7NewListIP6BigStrEP4ListIT_ES3_i Line | Count | Source | 186 | 3 | List<T>* NewList(T item, int times) { | 187 | 3 | auto self = Alloc<List<T>>(); | 188 | | | 189 | 3 | self->reserve(times); | 190 | 3 | self->len_ = times; | 191 | 12 | for (int i = 0; i < times; ++i) { | 192 | 9 | self->set(i, item); | 193 | 9 | } | 194 | 3 | return self; | 195 | 3 | } |
_Z7NewListIbEP4ListIT_ES1_i Line | Count | Source | 186 | 2 | List<T>* NewList(T item, int times) { | 187 | 2 | auto self = Alloc<List<T>>(); | 188 | | | 189 | 2 | self->reserve(times); | 190 | 2 | self->len_ = times; | 191 | 8 | for (int i = 0; i < times; ++i) { | 192 | 6 | self->set(i, item); | 193 | 6 | } | 194 | 2 | return self; | 195 | 2 | } |
_Z7NewListIiEP4ListIT_ES1_i Line | Count | Source | 186 | 4 | List<T>* NewList(T item, int times) { | 187 | 4 | auto self = Alloc<List<T>>(); | 188 | | | 189 | 4 | self->reserve(times); | 190 | 4 | self->len_ = times; | 191 | 16 | for (int i = 0; i < times; ++i) { | 192 | 12 | self->set(i, item); | 193 | 12 | } | 194 | 4 | return self; | 195 | 4 | } |
|
196 | | |
197 | | template <typename T> |
198 | 4.86k | void List<T>::append(T item) { |
199 | 4.86k | reserve(len_ + 1); |
200 | 4.86k | slab_->items_[len_] = item; |
201 | 4.86k | ++len_; |
202 | 4.86k | } _ZN4ListIP6BigStrE6appendES1_ Line | Count | Source | 198 | 627 | void List<T>::append(T item) { | 199 | 627 | reserve(len_ + 1); | 200 | 627 | slab_->items_[len_] = item; | 201 | 627 | ++len_; | 202 | 627 | } |
Line | Count | Source | 198 | 4.10k | void List<T>::append(T item) { | 199 | 4.10k | reserve(len_ + 1); | 200 | 4.10k | slab_->items_[len_] = item; | 201 | 4.10k | ++len_; | 202 | 4.10k | } |
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStriEE6appendES4_ Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE6appendES2_ _ZN4ListIPN10hnode_asdl5FieldEE6appendES2_ Line | Count | Source | 198 | 65 | void List<T>::append(T item) { | 199 | 65 | reserve(len_ + 1); | 200 | 65 | slab_->items_[len_] = item; | 201 | 65 | ++len_; | 202 | 65 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE6appendES2_ Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE6appendES2_ _ZN4ListIP6Tuple2IiP6BigStrEE6appendES4_ Line | Count | Source | 198 | 20 | void List<T>::append(T item) { | 199 | 20 | reserve(len_ + 1); | 200 | 20 | slab_->items_[len_] = item; | 201 | 20 | ++len_; | 202 | 20 | } |
Line | Count | Source | 198 | 4 | void List<T>::append(T item) { | 199 | 4 | reserve(len_ + 1); | 200 | 4 | slab_->items_[len_] = item; | 201 | 4 | ++len_; | 202 | 4 | } |
_ZN4ListIP6Tuple2IiiEE6appendES2_ Line | Count | Source | 198 | 8 | void List<T>::append(T item) { | 199 | 8 | reserve(len_ + 1); | 200 | 8 | slab_->items_[len_] = item; | 201 | 8 | ++len_; | 202 | 8 | } |
_ZN4ListIPN4pyos11PasswdEntryEE6appendES2_ Line | Count | Source | 198 | 36 | void List<T>::append(T item) { | 199 | 36 | reserve(len_ + 1); | 200 | 36 | slab_->items_[len_] = item; | 201 | 36 | ++len_; | 202 | 36 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE6appendES4_ Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE6appendES4_ |
203 | | |
204 | | template <typename T> |
205 | 4.19k | int len(const List<T>* L) { |
206 | 4.19k | return L->len_; |
207 | 4.19k | } Line | Count | Source | 205 | 3.97k | int len(const List<T>* L) { | 206 | 3.97k | return L->len_; | 207 | 3.97k | } |
_Z3lenIP6BigStrEiPK4ListIT_E Line | Count | Source | 205 | 200 | int len(const List<T>* L) { | 206 | 200 | return L->len_; | 207 | 200 | } |
Unexecuted instantiation: _Z3lenIPN11pretty_asdl11DocFragmentEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN15test_classes_gc10OpaqueBaseEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN15test_classes_gc12PointersBaseEEiPK4ListIT_E Unexecuted instantiation: _Z3lenIPN15test_classes_gc14BaseWithMethodEEiPK4ListIT_E _Z3lenIP6Tuple2IiP6BigStrEEiPK4ListIT_E Line | Count | Source | 205 | 7 | int len(const List<T>* L) { | 206 | 7 | return L->len_; | 207 | 7 | } |
Line | Count | Source | 205 | 2 | int len(const List<T>* L) { | 206 | 2 | return L->len_; | 207 | 2 | } |
_Z3lenIP6Tuple2IiiEEiPK4ListIT_E Line | Count | Source | 205 | 4 | int len(const List<T>* L) { | 206 | 4 | return L->len_; | 207 | 4 | } |
Line | Count | Source | 205 | 2 | int len(const List<T>* L) { | 206 | 2 | return L->len_; | 207 | 2 | } |
_Z3lenIPN4pyos11PasswdEntryEEiPK4ListIT_E Line | Count | Source | 205 | 1 | int len(const List<T>* L) { | 206 | 1 | return L->len_; | 207 | 1 | } |
|
208 | | |
209 | | template <typename T> |
210 | | List<T>* list_repeat(T item, int times); |
211 | | |
212 | | template <typename T> |
213 | | inline bool list_contains(List<T>* haystack, T needle); |
214 | | |
215 | | template <typename K, typename V> |
216 | | class Dict; // forward decl |
217 | | |
218 | | template <typename V> |
219 | | List<BigStr*>* sorted(Dict<BigStr*, V>* d); |
220 | | |
221 | | template <typename T> |
222 | | List<T>* sorted(List<T>* l); |
223 | | |
224 | | // L[begin:] |
225 | | template <typename T> |
226 | 606 | List<T>* List<T>::slice(int begin) { |
227 | 606 | return slice(begin, len_); |
228 | 606 | } _ZN4ListIP6BigStrE5sliceEi Line | Count | Source | 226 | 3 | List<T>* List<T>::slice(int begin) { | 227 | 3 | return slice(begin, len_); | 228 | 3 | } |
Line | Count | Source | 226 | 603 | List<T>* List<T>::slice(int begin) { | 227 | 603 | return slice(begin, len_); | 228 | 603 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE5sliceEi |
229 | | |
230 | | // L[begin:end] |
231 | | template <typename T> |
232 | 611 | List<T>* List<T>::slice(int begin, int end) { |
233 | 611 | SLICE_ADJUST(begin, end, len_); |
234 | | |
235 | 611 | DCHECK(0 <= begin && begin <= len_); |
236 | 611 | DCHECK(0 <= end && end <= len_); |
237 | | |
238 | 0 | int new_len = end - begin; |
239 | 611 | DCHECK(0 <= new_len && new_len <= len_); |
240 | | |
241 | 0 | List<T>* result = NewList<T>(); |
242 | 611 | result->reserve(new_len); |
243 | | |
244 | | // Faster than append() in a loop |
245 | 611 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); |
246 | 611 | result->len_ = new_len; |
247 | | |
248 | 611 | return result; |
249 | 611 | } _ZN4ListIP6BigStrE5sliceEii Line | Count | Source | 232 | 3 | List<T>* List<T>::slice(int begin, int end) { | 233 | 3 | SLICE_ADJUST(begin, end, len_); | 234 | | | 235 | 3 | DCHECK(0 <= begin && begin <= len_); | 236 | 3 | DCHECK(0 <= end && end <= len_); | 237 | | | 238 | 0 | int new_len = end - begin; | 239 | 3 | DCHECK(0 <= new_len && new_len <= len_); | 240 | | | 241 | 0 | List<T>* result = NewList<T>(); | 242 | 3 | result->reserve(new_len); | 243 | | | 244 | | // Faster than append() in a loop | 245 | 3 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); | 246 | 3 | result->len_ = new_len; | 247 | | | 248 | 3 | return result; | 249 | 3 | } |
Line | Count | Source | 232 | 608 | List<T>* List<T>::slice(int begin, int end) { | 233 | 608 | SLICE_ADJUST(begin, end, len_); | 234 | | | 235 | 608 | DCHECK(0 <= begin && begin <= len_); | 236 | 608 | DCHECK(0 <= end && end <= len_); | 237 | | | 238 | 0 | int new_len = end - begin; | 239 | 608 | DCHECK(0 <= new_len && new_len <= len_); | 240 | | | 241 | 0 | List<T>* result = NewList<T>(); | 242 | 608 | result->reserve(new_len); | 243 | | | 244 | | // Faster than append() in a loop | 245 | 608 | memcpy(result->slab_->items_, slab_->items_ + begin, new_len * sizeof(T)); | 246 | 608 | result->len_ = new_len; | 247 | | | 248 | 608 | return result; | 249 | 608 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE5sliceEii |
250 | | |
251 | | // Ensure that there's space for a number of items |
252 | | template <typename T> |
253 | 5.62k | void List<T>::reserve(int num_desired) { |
254 | | // log("reserve capacity = %d, n = %d", capacity_, n); |
255 | | |
256 | | // Don't do anything if there's already enough space. |
257 | 5.62k | if (capacity_ >= num_desired) { |
258 | 4.68k | return; |
259 | 4.68k | } |
260 | | |
261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of |
262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for |
263 | | // List<int>. |
264 | | // |
265 | | // Example: the user reserves space for 3 integers. The minimum number of |
266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, |
267 | | // which leads to 8 + 6*4 = 32 byte Slab. |
268 | | |
269 | 946 | capacity_ = HowManyItems(num_desired); |
270 | 946 | auto new_slab = NewSlab<T>(capacity_); |
271 | | |
272 | 946 | if (len_ > 0) { |
273 | | // log("Copying %d bytes", len_ * sizeof(T)); |
274 | 70 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); |
275 | 70 | } |
276 | 946 | slab_ = new_slab; |
277 | 946 | } _ZN4ListIP6BigStrE7reserveEi Line | Count | Source | 253 | 717 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 717 | if (capacity_ >= num_desired) { | 258 | 549 | return; | 259 | 549 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 168 | capacity_ = HowManyItems(num_desired); | 270 | 168 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 168 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 36 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 36 | } | 276 | 168 | slab_ = new_slab; | 277 | 168 | } |
Line | Count | Source | 253 | 4.77k | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 4.77k | if (capacity_ >= num_desired) { | 258 | 4.05k | return; | 259 | 4.05k | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 719 | capacity_ = HowManyItems(num_desired); | 270 | 719 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 719 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 30 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 30 | } | 276 | 719 | slab_ = new_slab; | 277 | 719 | } |
_ZN4ListIP6Tuple2IP6BigStriEE7reserveEi Line | Count | Source | 253 | 1 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 1 | if (capacity_ >= num_desired) { | 258 | 0 | return; | 259 | 0 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 1 | capacity_ = HowManyItems(num_desired); | 270 | 1 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 1 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 1 | slab_ = new_slab; | 277 | 1 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE7reserveEi Line | Count | Source | 253 | 21 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 21 | if (capacity_ >= num_desired) { | 258 | 14 | return; | 259 | 14 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 7 | capacity_ = HowManyItems(num_desired); | 270 | 7 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 7 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 7 | slab_ = new_slab; | 277 | 7 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE7reserveEi _ZN4ListIPN10hnode_asdl5FieldEE7reserveEi Line | Count | Source | 253 | 65 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 65 | if (capacity_ >= num_desired) { | 258 | 28 | return; | 259 | 28 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 37 | capacity_ = HowManyItems(num_desired); | 270 | 37 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 37 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 37 | slab_ = new_slab; | 277 | 37 | } |
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE7reserveEi Line | Count | Source | 253 | 3 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 3 | if (capacity_ >= num_desired) { | 258 | 0 | return; | 259 | 0 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 3 | capacity_ = HowManyItems(num_desired); | 270 | 3 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 3 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 3 | slab_ = new_slab; | 277 | 3 | } |
Unexecuted instantiation: _ZN4ListIPN15test_classes_gc10OpaqueBaseEE7reserveEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc12PointersBaseEE7reserveEi Unexecuted instantiation: _ZN4ListIPN15test_classes_gc14BaseWithMethodEE7reserveEi Line | Count | Source | 253 | 4 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 4 | if (capacity_ >= num_desired) { | 258 | 2 | return; | 259 | 2 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 2 | capacity_ = HowManyItems(num_desired); | 270 | 2 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 2 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 2 | slab_ = new_slab; | 277 | 2 | } |
_ZN4ListIP6Tuple2IiiEE7reserveEi Line | Count | Source | 253 | 8 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 8 | if (capacity_ >= num_desired) { | 258 | 4 | return; | 259 | 4 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 4 | capacity_ = HowManyItems(num_desired); | 270 | 4 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 4 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 0 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 0 | } | 276 | 4 | slab_ = new_slab; | 277 | 4 | } |
_ZN4ListIPN4pyos11PasswdEntryEE7reserveEi Line | Count | Source | 253 | 36 | void List<T>::reserve(int num_desired) { | 254 | | // log("reserve capacity = %d, n = %d", capacity_, n); | 255 | | | 256 | | // Don't do anything if there's already enough space. | 257 | 36 | if (capacity_ >= num_desired) { | 258 | 31 | return; | 259 | 31 | } | 260 | | | 261 | | // Slabs should be a total of 2^N bytes. kCapacityAdjust is the number of | 262 | | // items that the 8 byte header takes up: 1 for List<T*>, and 2 for | 263 | | // List<int>. | 264 | | // | 265 | | // Example: the user reserves space for 3 integers. The minimum number of | 266 | | // items would be 5, which is rounded up to 8. Subtract 2 again, giving 6, | 267 | | // which leads to 8 + 6*4 = 32 byte Slab. | 268 | | | 269 | 5 | capacity_ = HowManyItems(num_desired); | 270 | 5 | auto new_slab = NewSlab<T>(capacity_); | 271 | | | 272 | 5 | if (len_ > 0) { | 273 | | // log("Copying %d bytes", len_ * sizeof(T)); | 274 | 4 | memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T)); | 275 | 4 | } | 276 | 5 | slab_ = new_slab; | 277 | 5 | } |
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE7reserveEi Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE7reserveEi Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE7reserveEi |
278 | | |
279 | | // Implements L[i] = item |
280 | | template <typename T> |
281 | 293 | void List<T>::set(int i, T item) { |
282 | 293 | if (i < 0) { |
283 | 0 | i = len_ + i; |
284 | 0 | } |
285 | | |
286 | 293 | DCHECK(i >= 0); |
287 | 293 | DCHECK(i < capacity_); |
288 | | |
289 | 0 | slab_->items_[i] = item; |
290 | 293 | } _ZN4ListIP6BigStrE3setEiS1_ Line | Count | Source | 281 | 110 | void List<T>::set(int i, T item) { | 282 | 110 | if (i < 0) { | 283 | 0 | i = len_ + i; | 284 | 0 | } | 285 | | | 286 | 110 | DCHECK(i >= 0); | 287 | 110 | DCHECK(i < capacity_); | 288 | | | 289 | 0 | slab_->items_[i] = item; | 290 | 110 | } |
Line | Count | Source | 281 | 171 | void List<T>::set(int i, T item) { | 282 | 171 | if (i < 0) { | 283 | 0 | i = len_ + i; | 284 | 0 | } | 285 | | | 286 | 171 | DCHECK(i >= 0); | 287 | 171 | DCHECK(i < capacity_); | 288 | | | 289 | 0 | slab_->items_[i] = item; | 290 | 171 | } |
_ZN4ListIP6Tuple2IP6BigStriEE3setEiS4_ Line | Count | Source | 281 | 2 | void List<T>::set(int i, T item) { | 282 | 2 | if (i < 0) { | 283 | 0 | i = len_ + i; | 284 | 0 | } | 285 | | | 286 | 2 | DCHECK(i >= 0); | 287 | 2 | DCHECK(i < capacity_); | 288 | | | 289 | 0 | slab_->items_[i] = item; | 290 | 2 | } |
_ZN4ListIP6Tuple2IiP6BigStrEE3setEiS4_ Line | Count | Source | 281 | 2 | void List<T>::set(int i, T item) { | 282 | 2 | if (i < 0) { | 283 | 0 | i = len_ + i; | 284 | 0 | } | 285 | | | 286 | 2 | DCHECK(i >= 0); | 287 | 2 | DCHECK(i < capacity_); | 288 | | | 289 | 0 | slab_->items_[i] = item; | 290 | 2 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE3setEiS2_ Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE3setEiS2_ Line | Count | Source | 281 | 8 | void List<T>::set(int i, T item) { | 282 | 8 | if (i < 0) { | 283 | 0 | i = len_ + i; | 284 | 0 | } | 285 | | | 286 | 8 | DCHECK(i >= 0); | 287 | 8 | DCHECK(i < capacity_); | 288 | | | 289 | 0 | slab_->items_[i] = item; | 290 | 8 | } |
Unexecuted instantiation: _ZN4ListIP6Tuple2IiiEE3setEiS2_ |
291 | | |
292 | | // Implements L[i] |
293 | | template <typename T> |
294 | 1.70k | T List<T>::at(int i) { |
295 | 1.70k | if (i < 0) { |
296 | 4 | int j = len_ + i; |
297 | 4 | if (j >= len_ || j < 0) { |
298 | 0 | throw Alloc<IndexError>(); |
299 | 0 | } |
300 | 4 | return slab_->items_[j]; |
301 | 4 | } |
302 | | |
303 | 1.70k | if (i >= len_ || i < 0) { |
304 | 0 | throw Alloc<IndexError>(); |
305 | 0 | } |
306 | 1.70k | return slab_->items_[i]; |
307 | 1.70k | } Line | Count | Source | 294 | 562 | T List<T>::at(int i) { | 295 | 562 | if (i < 0) { | 296 | 1 | int j = len_ + i; | 297 | 1 | if (j >= len_ || j < 0) { | 298 | 0 | throw Alloc<IndexError>(); | 299 | 0 | } | 300 | 1 | return slab_->items_[j]; | 301 | 1 | } | 302 | | | 303 | 561 | if (i >= len_ || i < 0) { | 304 | 0 | throw Alloc<IndexError>(); | 305 | 0 | } | 306 | 561 | return slab_->items_[i]; | 307 | 561 | } |
Line | Count | Source | 294 | 1.13k | T List<T>::at(int i) { | 295 | 1.13k | if (i < 0) { | 296 | 3 | int j = len_ + i; | 297 | 3 | if (j >= len_ || j < 0) { | 298 | 0 | throw Alloc<IndexError>(); | 299 | 0 | } | 300 | 3 | return slab_->items_[j]; | 301 | 3 | } | 302 | | | 303 | 1.12k | if (i >= len_ || i < 0) { | 304 | 0 | throw Alloc<IndexError>(); | 305 | 0 | } | 306 | 1.12k | return slab_->items_[i]; | 307 | 1.12k | } |
Line | Count | Source | 294 | 4 | T List<T>::at(int i) { | 295 | 4 | if (i < 0) { | 296 | 0 | int j = len_ + i; | 297 | 0 | if (j >= len_ || j < 0) { | 298 | 0 | throw Alloc<IndexError>(); | 299 | 0 | } | 300 | 0 | return slab_->items_[j]; | 301 | 0 | } | 302 | | | 303 | 4 | if (i >= len_ || i < 0) { | 304 | 0 | throw Alloc<IndexError>(); | 305 | 0 | } | 306 | 4 | return slab_->items_[i]; | 307 | 4 | } |
Line | Count | Source | 294 | 4 | T List<T>::at(int i) { | 295 | 4 | if (i < 0) { | 296 | 0 | int j = len_ + i; | 297 | 0 | if (j >= len_ || j < 0) { | 298 | 0 | throw Alloc<IndexError>(); | 299 | 0 | } | 300 | 0 | return slab_->items_[j]; | 301 | 0 | } | 302 | | | 303 | 4 | if (i >= len_ || i < 0) { | 304 | 0 | throw Alloc<IndexError>(); | 305 | 0 | } | 306 | 4 | return slab_->items_[i]; | 307 | 4 | } |
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE2atEi _ZN4ListIP6Tuple2IiP6BigStrEE2atEi Line | Count | Source | 294 | 5 | T List<T>::at(int i) { | 295 | 5 | if (i < 0) { | 296 | 0 | int j = len_ + i; | 297 | 0 | if (j >= len_ || j < 0) { | 298 | 0 | throw Alloc<IndexError>(); | 299 | 0 | } | 300 | 0 | return slab_->items_[j]; | 301 | 0 | } | 302 | | | 303 | 5 | if (i >= len_ || i < 0) { | 304 | 0 | throw Alloc<IndexError>(); | 305 | 0 | } | 306 | 5 | return slab_->items_[i]; | 307 | 5 | } |
|
308 | | |
309 | | // L.index(i) -- Python method |
310 | | template <typename T> |
311 | 8 | int List<T>::index(T value) { |
312 | 8 | int element_count = len(this); |
313 | 18 | for (int i = 0; i < element_count; i++) { |
314 | 16 | if (items_equal(slab_->items_[i], value)) { |
315 | 6 | return i; |
316 | 6 | } |
317 | 16 | } |
318 | 2 | throw Alloc<ValueError>(); |
319 | 8 | } |
320 | | |
321 | | // Should we have a separate API that doesn't return it? |
322 | | // https://stackoverflow.com/questions/12600330/pop-back-return-value |
323 | | template <typename T> |
324 | 9 | T List<T>::pop() { |
325 | 9 | if (len_ == 0) { |
326 | 0 | throw Alloc<IndexError>(); |
327 | 0 | } |
328 | 9 | len_--; |
329 | 9 | T result = slab_->items_[len_]; |
330 | 9 | slab_->items_[len_] = 0; // zero for GC scan |
331 | 9 | return result; |
332 | 9 | } Line | Count | Source | 324 | 7 | T List<T>::pop() { | 325 | 7 | if (len_ == 0) { | 326 | 0 | throw Alloc<IndexError>(); | 327 | 0 | } | 328 | 7 | len_--; | 329 | 7 | T result = slab_->items_[len_]; | 330 | 7 | slab_->items_[len_] = 0; // zero for GC scan | 331 | 7 | return result; | 332 | 7 | } |
Unexecuted instantiation: _ZN4ListIPN11pretty_asdl11DocFragmentEE3popEv Line | Count | Source | 324 | 2 | T List<T>::pop() { | 325 | 2 | if (len_ == 0) { | 326 | 0 | throw Alloc<IndexError>(); | 327 | 0 | } | 328 | 2 | len_--; | 329 | 2 | T result = slab_->items_[len_]; | 330 | 2 | slab_->items_[len_] = 0; // zero for GC scan | 331 | 2 | return result; | 332 | 2 | } |
|
333 | | |
334 | | // Used in osh/word_parse.py to remove from front |
335 | | template <typename T> |
336 | 12 | T List<T>::pop(int i) { |
337 | 12 | if (len_ < i) { |
338 | 0 | throw Alloc<IndexError>(); |
339 | 0 | } |
340 | | |
341 | 12 | T result = at(i); |
342 | 12 | len_--; |
343 | | |
344 | | // Shift everything by one |
345 | 12 | memmove(slab_->items_ + i, slab_->items_ + (i + 1), (len_ - i) * sizeof(T)); |
346 | | |
347 | | /* |
348 | | for (int j = 0; j < len_; j++) { |
349 | | slab_->items_[j] = slab_->items_[j+1]; |
350 | | } |
351 | | */ |
352 | | |
353 | 12 | slab_->items_[len_] = 0; // zero for GC scan |
354 | 12 | return result; |
355 | 12 | } |
356 | | |
357 | | template <typename T> |
358 | 6 | void List<T>::remove(T x) { |
359 | 6 | int idx = this->index(x); |
360 | 6 | this->pop(idx); // unused |
361 | 6 | } |
362 | | |
363 | | template <typename T> |
364 | 7 | void List<T>::clear() { |
365 | 7 | if (slab_) { |
366 | 4 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan |
367 | 4 | } |
368 | 7 | len_ = 0; |
369 | 7 | } Line | Count | Source | 364 | 4 | void List<T>::clear() { | 365 | 4 | if (slab_) { | 366 | 4 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 367 | 4 | } | 368 | 4 | len_ = 0; | 369 | 4 | } |
_ZN4ListIP6BigStrE5clearEv Line | Count | Source | 364 | 1 | void List<T>::clear() { | 365 | 1 | if (slab_) { | 366 | 0 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 367 | 0 | } | 368 | 1 | len_ = 0; | 369 | 1 | } |
Line | Count | Source | 364 | 2 | void List<T>::clear() { | 365 | 2 | if (slab_) { | 366 | 0 | memset(slab_->items_, 0, len_ * sizeof(T)); // zero for GC scan | 367 | 0 | } | 368 | 2 | len_ = 0; | 369 | 2 | } |
|
370 | | |
371 | | // Used in osh/string_ops.py |
372 | | template <typename T> |
373 | 8 | void List<T>::reverse() { |
374 | 16 | for (int i = 0; i < len_ / 2; ++i) { |
375 | | // log("swapping %d and %d", i, n-i); |
376 | 8 | T tmp = slab_->items_[i]; |
377 | 8 | int j = len_ - 1 - i; |
378 | 8 | slab_->items_[i] = slab_->items_[j]; |
379 | 8 | slab_->items_[j] = tmp; |
380 | 8 | } |
381 | 8 | } Unexecuted instantiation: _ZN4ListIP6BigStrE7reverseEv Line | Count | Source | 373 | 8 | void List<T>::reverse() { | 374 | 16 | for (int i = 0; i < len_ / 2; ++i) { | 375 | | // log("swapping %d and %d", i, n-i); | 376 | 8 | T tmp = slab_->items_[i]; | 377 | 8 | int j = len_ - 1 - i; | 378 | 8 | slab_->items_[i] = slab_->items_[j]; | 379 | 8 | slab_->items_[j] = tmp; | 380 | 8 | } | 381 | 8 | } |
|
382 | | |
383 | | // Extend this list with multiple elements. |
384 | | template <typename T> |
385 | 13 | void List<T>::extend(List<T>* other) { |
386 | 13 | int n = other->len_; |
387 | 13 | int new_len = len_ + n; |
388 | 13 | reserve(new_len); |
389 | | |
390 | 54 | for (int i = 0; i < n; ++i) { |
391 | 41 | set(len_ + i, other->slab_->items_[i]); |
392 | 41 | } |
393 | 13 | len_ = new_len; |
394 | 13 | } _ZN4ListIP6BigStrE6extendEPS2_ Line | Count | Source | 385 | 2 | void List<T>::extend(List<T>* other) { | 386 | 2 | int n = other->len_; | 387 | 2 | int new_len = len_ + n; | 388 | 2 | reserve(new_len); | 389 | | | 390 | 8 | for (int i = 0; i < n; ++i) { | 391 | 6 | set(len_ + i, other->slab_->items_[i]); | 392 | 6 | } | 393 | 2 | len_ = new_len; | 394 | 2 | } |
Line | Count | Source | 385 | 11 | void List<T>::extend(List<T>* other) { | 386 | 11 | int n = other->len_; | 387 | 11 | int new_len = len_ + n; | 388 | 11 | reserve(new_len); | 389 | | | 390 | 46 | for (int i = 0; i < n; ++i) { | 391 | 35 | set(len_ + i, other->slab_->items_[i]); | 392 | 35 | } | 393 | 11 | len_ = new_len; | 394 | 11 | } |
|
395 | | |
396 | 34 | inline bool CompareBigStr(BigStr* a, BigStr* b) { |
397 | 34 | return mylib::str_cmp(a, b) < 0; |
398 | 34 | } |
399 | | |
400 | | template <> |
401 | 8 | inline void List<BigStr*>::sort() { |
402 | 8 | std::sort(slab_->items_, slab_->items_ + len_, CompareBigStr); |
403 | 8 | } |
404 | | |
405 | 0 | inline bool CompareBigInt(mops::BigInt a, mops::BigInt b) { |
406 | 0 | return a < b; |
407 | 0 | } |
408 | | |
409 | | template <> |
410 | 0 | inline void List<mops::BigInt>::sort() { |
411 | 0 | std::sort(slab_->items_, slab_->items_ + len_, CompareBigInt); |
412 | 0 | } |
413 | | |
414 | | // TODO: mycpp can just generate the constructor instead? |
415 | | // e.g. [None] * 3 |
416 | | template <typename T> |
417 | 5 | List<T>* list_repeat(T item, int times) { |
418 | 5 | return NewList<T>(item, times); |
419 | 5 | } _Z11list_repeatIP6BigStrEP4ListIT_ES3_i Line | Count | Source | 417 | 3 | List<T>* list_repeat(T item, int times) { | 418 | 3 | return NewList<T>(item, times); | 419 | 3 | } |
_Z11list_repeatIbEP4ListIT_ES1_i Line | Count | Source | 417 | 2 | List<T>* list_repeat(T item, int times) { | 418 | 2 | return NewList<T>(item, times); | 419 | 2 | } |
|
420 | | |
421 | | // e.g. 'a' in ['a', 'b', 'c'] |
422 | | template <typename T> |
423 | 24 | inline bool list_contains(List<T>* haystack, T needle) { |
424 | 24 | int n = len(haystack); |
425 | 59 | for (int i = 0; i < n; ++i) { |
426 | 47 | if (items_equal(haystack->at(i), needle)) { |
427 | 12 | return true; |
428 | 12 | } |
429 | 47 | } |
430 | 12 | return false; |
431 | 24 | } _Z13list_containsIiEbP4ListIT_ES1_ Line | Count | Source | 423 | 10 | inline bool list_contains(List<T>* haystack, T needle) { | 424 | 10 | int n = len(haystack); | 425 | 25 | for (int i = 0; i < n; ++i) { | 426 | 20 | if (items_equal(haystack->at(i), needle)) { | 427 | 5 | return true; | 428 | 5 | } | 429 | 20 | } | 430 | 5 | return false; | 431 | 10 | } |
_Z13list_containsIP6BigStrEbP4ListIT_ES3_ Line | Count | Source | 423 | 12 | inline bool list_contains(List<T>* haystack, T needle) { | 424 | 12 | int n = len(haystack); | 425 | 28 | for (int i = 0; i < n; ++i) { | 426 | 23 | if (items_equal(haystack->at(i), needle)) { | 427 | 7 | return true; | 428 | 7 | } | 429 | 23 | } | 430 | 5 | return false; | 431 | 12 | } |
_Z13list_containsIlEbP4ListIT_ES1_ Line | Count | Source | 423 | 2 | inline bool list_contains(List<T>* haystack, T needle) { | 424 | 2 | int n = len(haystack); | 425 | 6 | for (int i = 0; i < n; ++i) { | 426 | 4 | if (items_equal(haystack->at(i), needle)) { | 427 | 0 | return true; | 428 | 0 | } | 429 | 4 | } | 430 | 2 | return false; | 431 | 2 | } |
|
432 | | |
433 | | template <typename V> |
434 | 2 | List<BigStr*>* sorted(Dict<BigStr*, V>* d) { |
435 | 2 | auto keys = d->keys(); |
436 | 2 | keys->sort(); |
437 | 2 | return keys; |
438 | 2 | } |
439 | | |
440 | | template <typename T> |
441 | 2 | List<T>* sorted(List<T>* l) { |
442 | 2 | auto ret = list(l); |
443 | 2 | ret->sort(); |
444 | 2 | return ret; |
445 | 2 | } |
446 | | |
447 | | // list(L) copies the list |
448 | | template <typename T> |
449 | 7 | List<T>* list(List<T>* other) { |
450 | 7 | auto result = NewList<T>(); |
451 | 7 | result->extend(other); |
452 | 7 | return result; |
453 | 7 | } Line | Count | Source | 449 | 5 | List<T>* list(List<T>* other) { | 450 | 5 | auto result = NewList<T>(); | 451 | 5 | result->extend(other); | 452 | 5 | return result; | 453 | 5 | } |
_Z4listIP6BigStrEP4ListIT_ES5_ Line | Count | Source | 449 | 2 | List<T>* list(List<T>* other) { | 450 | 2 | auto result = NewList<T>(); | 451 | 2 | result->extend(other); | 452 | 2 | return result; | 453 | 2 | } |
|
454 | | |
455 | | template <class T> |
456 | | class ListIter { |
457 | | public: |
458 | 167 | explicit ListIter(List<T>* L) : L_(L), i_(0) { |
459 | | // Cheney only: L_ could be moved during iteration. |
460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); |
461 | 167 | } _ZN8ListIterIP6BigStrEC2EP4ListIS1_E Line | Count | Source | 458 | 50 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 50 | } |
_ZN8ListIterIiEC2EP4ListIiE Line | Count | Source | 458 | 22 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 22 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEEC2EP4ListIS4_E Line | Count | Source | 458 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 1 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E Line | Count | Source | 458 | 6 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 6 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEEC2EP4ListIS2_E _ZN8ListIterIPN10hnode_asdl5FieldEEC2EP4ListIS2_E Line | Count | Source | 458 | 82 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 82 | } |
Unexecuted instantiation: _ZN8ListIterIPN11pretty_asdl11MeasuredDocEEC2EP4ListIS2_E 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_asdl11word_part_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9AssocPairEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEEC2EP4ListIS2_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_asdl8NameTypeEEC2EP4ListIS2_E Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEEC2EP4ListIS2_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 | 458 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 1 | } |
_ZN8ListIterIP6Tuple2IiiEEC2EP4ListIS2_E Line | Count | Source | 458 | 4 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 4 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEEC2EP4ListIS2_E Line | Count | Source | 458 | 1 | explicit ListIter(List<T>* L) : L_(L), i_(0) { | 459 | | // Cheney only: L_ could be moved during iteration. | 460 | | // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_)); | 461 | 1 | } |
|
462 | | |
463 | 170 | ~ListIter() { |
464 | | // gHeap.PopRoot(); |
465 | 170 | } _ZN8ListIterIP6BigStrED2Ev Line | Count | Source | 463 | 50 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 50 | } |
Line | Count | Source | 463 | 25 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 25 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEED2Ev Line | Count | Source | 463 | 1 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 1 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEED2Ev Line | Count | Source | 463 | 6 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 6 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEED2Ev _ZN8ListIterIPN10hnode_asdl5FieldEED2Ev Line | Count | Source | 463 | 82 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 82 | } |
Unexecuted instantiation: _ZN8ListIterIPN11pretty_asdl11MeasuredDocEED2Ev 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_asdl11word_part_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9AssocPairEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEED2Ev Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEED2Ev 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 | 463 | 1 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 1 | } |
_ZN8ListIterIP6Tuple2IiiEED2Ev Line | Count | Source | 463 | 4 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 4 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEED2Ev Line | Count | Source | 463 | 1 | ~ListIter() { | 464 | | // gHeap.PopRoot(); | 465 | 1 | } |
|
466 | 445 | void Next() { |
467 | 445 | i_++; |
468 | 445 | } _ZN8ListIterIP6BigStrE4NextEv Line | Count | Source | 466 | 173 | void Next() { | 467 | 173 | i_++; | 468 | 173 | } |
Line | Count | Source | 466 | 85 | void Next() { | 467 | 85 | i_++; | 468 | 85 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE4NextEv Line | Count | Source | 466 | 2 | void Next() { | 467 | 2 | i_++; | 468 | 2 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE4NextEv Line | Count | Source | 466 | 18 | void Next() { | 467 | 18 | i_++; | 468 | 18 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4NextEv _ZN8ListIterIPN10hnode_asdl5FieldEE4NextEv Line | Count | Source | 466 | 123 | void Next() { | 467 | 123 | i_++; | 468 | 123 | } |
Unexecuted instantiation: _ZN8ListIterIPN11pretty_asdl11MeasuredDocEE4NextEv 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_asdl11word_part_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9AssocPairEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE4NextEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE4NextEv 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 | 466 | 2 | void Next() { | 467 | 2 | i_++; | 468 | 2 | } |
_ZN8ListIterIP6Tuple2IiiEE4NextEv Line | Count | Source | 466 | 8 | void Next() { | 467 | 8 | i_++; | 468 | 8 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE4NextEv Line | Count | Source | 466 | 34 | void Next() { | 467 | 34 | i_++; | 468 | 34 | } |
|
469 | 609 | bool Done() { |
470 | | // "unsigned size_t was a mistake" |
471 | 609 | return i_ >= static_cast<int>(L_->len_); |
472 | 609 | } _ZN8ListIterIP6BigStrE4DoneEv Line | Count | Source | 469 | 223 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 223 | return i_ >= static_cast<int>(L_->len_); | 472 | 223 | } |
Line | Count | Source | 469 | 104 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 104 | return i_ >= static_cast<int>(L_->len_); | 472 | 104 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE4DoneEv Line | Count | Source | 469 | 3 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 3 | return i_ >= static_cast<int>(L_->len_); | 472 | 3 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE4DoneEv Line | Count | Source | 469 | 24 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 24 | return i_ >= static_cast<int>(L_->len_); | 472 | 24 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4DoneEv _ZN8ListIterIPN10hnode_asdl5FieldEE4DoneEv Line | Count | Source | 469 | 205 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 205 | return i_ >= static_cast<int>(L_->len_); | 472 | 205 | } |
Unexecuted instantiation: _ZN8ListIterIPN11pretty_asdl11MeasuredDocEE4DoneEv 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_asdl11word_part_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9AssocPairEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE4DoneEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE4DoneEv 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 | 469 | 3 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 3 | return i_ >= static_cast<int>(L_->len_); | 472 | 3 | } |
_ZN8ListIterIP6Tuple2IiiEE4DoneEv Line | Count | Source | 469 | 12 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 12 | return i_ >= static_cast<int>(L_->len_); | 472 | 12 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE4DoneEv Line | Count | Source | 469 | 35 | bool Done() { | 470 | | // "unsigned size_t was a mistake" | 471 | 35 | return i_ >= static_cast<int>(L_->len_); | 472 | 35 | } |
|
473 | 465 | T Value() { |
474 | 465 | return L_->slab_->items_[i_]; |
475 | 465 | } _ZN8ListIterIP6BigStrE5ValueEv Line | Count | Source | 473 | 174 | T Value() { | 474 | 174 | return L_->slab_->items_[i_]; | 475 | 174 | } |
Line | Count | Source | 473 | 80 | T Value() { | 474 | 80 | return L_->slab_->items_[i_]; | 475 | 80 | } |
_ZN8ListIterIP6Tuple2IP6BigStriEE5ValueEv Line | Count | Source | 473 | 2 | T Value() { | 474 | 2 | return L_->slab_->items_[i_]; | 475 | 2 | } |
_ZN8ListIterIP6Tuple2IiP6BigStrEE5ValueEv Line | Count | Source | 473 | 10 | T Value() { | 474 | 10 | return L_->slab_->items_[i_]; | 475 | 10 | } |
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE5ValueEv _ZN8ListIterIPN10hnode_asdl5FieldEE5ValueEv Line | Count | Source | 473 | 146 | T Value() { | 474 | 146 | return L_->slab_->items_[i_]; | 475 | 146 | } |
Unexecuted instantiation: _ZN8ListIterIPN11pretty_asdl11MeasuredDocEE5ValueEv 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_asdl11word_part_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6word_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl6expr_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NamedArgEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9AssocPairEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9command_tEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl9EggexFlagEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5RedirEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7EnvPairEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10AssignPairEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5IfArmEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7CaseArmEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl8NameTypeEE5ValueEv Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl7y_lhs_tEE5ValueEv 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 | 473 | 2 | T Value() { | 474 | 2 | return L_->slab_->items_[i_]; | 475 | 2 | } |
_ZN8ListIterIP6Tuple2IiiEE5ValueEv Line | Count | Source | 473 | 16 | T Value() { | 474 | 16 | return L_->slab_->items_[i_]; | 475 | 16 | } |
_ZN8ListIterIPN4pyos11PasswdEntryEE5ValueEv Line | Count | Source | 473 | 35 | T Value() { | 474 | 35 | return L_->slab_->items_[i_]; | 475 | 35 | } |
|
476 | 16 | T iterNext() { |
477 | 16 | if (Done()) { |
478 | 3 | throw Alloc<StopIteration>(); |
479 | 3 | } |
480 | 13 | T ret = L_->slab_->items_[i_]; |
481 | 13 | Next(); |
482 | 13 | return ret; |
483 | 16 | } _ZN8ListIterIP6Tuple2IiP6BigStrEE8iterNextEv Line | Count | Source | 476 | 10 | T iterNext() { | 477 | 10 | if (Done()) { | 478 | 2 | throw Alloc<StopIteration>(); | 479 | 2 | } | 480 | 8 | T ret = L_->slab_->items_[i_]; | 481 | 8 | Next(); | 482 | 8 | return ret; | 483 | 10 | } |
_ZN8ListIterIiE8iterNextEv Line | Count | Source | 476 | 6 | T iterNext() { | 477 | 6 | if (Done()) { | 478 | 1 | throw Alloc<StopIteration>(); | 479 | 1 | } | 480 | 5 | T ret = L_->slab_->items_[i_]; | 481 | 5 | Next(); | 482 | 5 | return ret; | 483 | 6 | } |
|
484 | | |
485 | | // only for use with generators |
486 | 3 | List<T>* GetList() { |
487 | 3 | return L_; |
488 | 3 | } |
489 | | |
490 | | private: |
491 | | List<T>* L_; |
492 | | int i_; |
493 | | }; |
494 | | |
495 | | // list(it) returns the iterator's backing list |
496 | | template <typename T> |
497 | 3 | List<T>* list(ListIter<T> it) { |
498 | 3 | return list(it.GetList()); |
499 | 3 | } |
500 | | |
501 | | // TODO: Does using pointers rather than indices make this more efficient? |
502 | | template <class T> |
503 | | class ReverseListIter { |
504 | | public: |
505 | 4 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { |
506 | 4 | } _ZN15ReverseListIterIP6BigStrEC2EP4ListIS1_E Line | Count | Source | 505 | 1 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 506 | 1 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E Line | Count | Source | 505 | 1 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 506 | 1 | } |
Unexecuted instantiation: _ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEEC2EP4ListIS2_E _ZN15ReverseListIterIiEC2EP4ListIiE Line | Count | Source | 505 | 2 | explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) { | 506 | 2 | } |
|
507 | 10 | void Next() { |
508 | 10 | i_--; |
509 | 10 | } _ZN15ReverseListIterIP6BigStrE4NextEv Line | Count | Source | 507 | 2 | void Next() { | 508 | 2 | i_--; | 509 | 2 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4NextEv Line | Count | Source | 507 | 2 | void Next() { | 508 | 2 | i_--; | 509 | 2 | } |
Unexecuted instantiation: _ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE4NextEv _ZN15ReverseListIterIiE4NextEv Line | Count | Source | 507 | 6 | void Next() { | 508 | 6 | i_--; | 509 | 6 | } |
|
510 | 14 | bool Done() { |
511 | 14 | return i_ < 0; |
512 | 14 | } _ZN15ReverseListIterIP6BigStrE4DoneEv Line | Count | Source | 510 | 3 | bool Done() { | 511 | 3 | return i_ < 0; | 512 | 3 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4DoneEv Line | Count | Source | 510 | 3 | bool Done() { | 511 | 3 | return i_ < 0; | 512 | 3 | } |
Unexecuted instantiation: _ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE4DoneEv _ZN15ReverseListIterIiE4DoneEv Line | Count | Source | 510 | 8 | bool Done() { | 511 | 8 | return i_ < 0; | 512 | 8 | } |
|
513 | 10 | T Value() { |
514 | 10 | return L_->slab_->items_[i_]; |
515 | 10 | } _ZN15ReverseListIterIP6BigStrE5ValueEv Line | Count | Source | 513 | 2 | T Value() { | 514 | 2 | return L_->slab_->items_[i_]; | 515 | 2 | } |
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE5ValueEv Line | Count | Source | 513 | 2 | T Value() { | 514 | 2 | return L_->slab_->items_[i_]; | 515 | 2 | } |
Unexecuted instantiation: _ZN15ReverseListIterIPN11pretty_asdl11MeasuredDocEE5ValueEv _ZN15ReverseListIterIiE5ValueEv Line | Count | Source | 513 | 6 | T Value() { | 514 | 6 | return L_->slab_->items_[i_]; | 515 | 6 | } |
|
516 | | |
517 | | private: |
518 | | List<T>* L_; |
519 | | int i_; |
520 | | }; |
521 | | |
522 | | int max(List<int>* elems); |
523 | | |
524 | | #endif // MYCPP_GC_LIST_H |