cpp

Coverage Report

Created: 2023-11-29 23:45

/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_slab.h"
13
14
// GlobalList is layout-compatible with List (unit tests assert this), and it
15
// can be a true C global (incurs zero startup time)
16
17
template <typename T, int N>
18
class GlobalList {
19
 public:
20
  int len_;
21
  int capacity_;
22
  GlobalSlab<T, N>* slab_;
23
};
24
25
#define GLOBAL_LIST(name, T, N, array)                                         \
26
  GcGlobal<GlobalSlab<T, N>> _slab_##name = {ObjHeader::Global(TypeTag::Slab), \
27
                                             {.items_ = array}};               \
28
  GcGlobal<GlobalList<T, N>> _list_##name = {                                  \
29
      ObjHeader::Global(TypeTag::List),                                        \
30
      {.len_ = N, .capacity_ = N, .slab_ = &_slab_##name.obj}};                \
31
  List<T>* name = reinterpret_cast<List<T>*>(&_list_##name.obj);
32
33
template <typename T>
34
class List {
35
 public:
36
949
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
949
  }
_ZN4ListIP6BigStrEC2Ev
Line
Count
Source
36
170
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
170
  }
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEEC2Ev
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEEC2Ev
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEEC2Ev
_ZN4ListIiEC2Ev
Line
Count
Source
36
683
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
683
  }
_ZN4ListIP6Tuple2IiP6BigStrEEC2Ev
Line
Count
Source
36
9
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
9
  }
_ZN4ListIP6Tuple2IP6BigStriEEC2Ev
Line
Count
Source
36
1
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
1
  }
_ZN4ListIPN10hnode_asdl5FieldEEC2Ev
Line
Count
Source
36
37
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
37
  }
_ZN4ListIPN10hnode_asdl7hnode_tEEC2Ev
Line
Count
Source
36
37
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
37
  }
_ZN4ListIbEC2Ev
Line
Count
Source
36
3
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
3
  }
_ZN4ListIP6Tuple2IiiEEC2Ev
Line
Count
Source
36
4
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
4
  }
_ZN4ListIPiEC2Ev
Line
Count
Source
36
2
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
2
  }
_ZN4ListIdEC2Ev
Line
Count
Source
36
2
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
2
  }
_ZN4ListIPN4pyos11PasswdEntryEEC2Ev
Line
Count
Source
36
1
  List() : len_(0), capacity_(0), slab_(nullptr) {
37
1
  }
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEEC2Ev
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEEC2Ev
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEEC2Ev
38
39
  // Implements L[i]
40
  T at(int i);
41
42
  // returns index of the element
43
  int index(T element);
44
45
  // Implements L[i] = item
46
  void set(int i, T item);
47
48
  // L[begin:]
49
  List* slice(int begin);
50
51
  // L[begin:end]
52
  List* slice(int begin, int end);
53
54
  // L[begin:end:step]
55
  List* slice(int begin, int end, int step);
56
57
  // Should we have a separate API that doesn't return it?
58
  // https://stackoverflow.com/questions/12600330/pop-back-return-value
59
  T pop();
60
61
  // Used in osh/word_parse.py to remove from front
62
  T pop(int i);
63
64
  // Remove the first occourence of x from the list.
65
  void remove(T x);
66
67
  void clear();
68
69
  // Used in osh/string_ops.py
70
  void reverse();
71
72
  // Templated function
73
  void sort();
74
75
  // Ensure that there's space for at LEAST this many items
76
  void reserve(int num_desired);
77
78
  // Append a single element to this list.
79
  void append(T item);
80
81
  // Extend this list with multiple elements.
82
  void extend(List<T>* other);
83
84
934
  static constexpr ObjHeader obj_header() {
85
934
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
934
  }
_ZN4ListIP6BigStrE10obj_headerEv
Line
Count
Source
84
170
  static constexpr ObjHeader obj_header() {
85
170
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
170
  }
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEE10obj_headerEv
_ZN4ListIiE10obj_headerEv
Line
Count
Source
84
672
  static constexpr ObjHeader obj_header() {
85
672
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
672
  }
_ZN4ListIP6Tuple2IP6BigStriEE10obj_headerEv
Line
Count
Source
84
1
  static constexpr ObjHeader obj_header() {
85
1
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
1
  }
_ZN4ListIP6Tuple2IiP6BigStrEE10obj_headerEv
Line
Count
Source
84
5
  static constexpr ObjHeader obj_header() {
85
5
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
5
  }
_ZN4ListIPN10hnode_asdl5FieldEE10obj_headerEv
Line
Count
Source
84
37
  static constexpr ObjHeader obj_header() {
85
37
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
37
  }
_ZN4ListIPN10hnode_asdl7hnode_tEE10obj_headerEv
Line
Count
Source
84
37
  static constexpr ObjHeader obj_header() {
85
37
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
37
  }
_ZN4ListIbE10obj_headerEv
Line
Count
Source
84
3
  static constexpr ObjHeader obj_header() {
85
3
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
3
  }
_ZN4ListIP6Tuple2IiiEE10obj_headerEv
Line
Count
Source
84
4
  static constexpr ObjHeader obj_header() {
85
4
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
4
  }
_ZN4ListIPiE10obj_headerEv
Line
Count
Source
84
2
  static constexpr ObjHeader obj_header() {
85
2
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
2
  }
_ZN4ListIdE10obj_headerEv
Line
Count
Source
84
2
  static constexpr ObjHeader obj_header() {
85
2
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
2
  }
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9AssocPairEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10obj_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_asdl7EnvPairEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5RedirEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10AssignPairEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10obj_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_asdl5ParamEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10SourceLineEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10obj_headerEv
_ZN4ListIPN4pyos11PasswdEntryEE10obj_headerEv
Line
Count
Source
84
1
  static constexpr ObjHeader obj_header() {
85
1
    return ObjHeader::ClassFixed(field_mask(), sizeof(List<T>));
86
1
  }
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10obj_headerEv
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10obj_headerEv
87
88
  int len_;       // number of entries
89
  int capacity_;  // max entries before resizing
90
91
  // The container may be resized, so this field isn't in-line.
92
  Slab<T>* slab_;
93
94
  // A list has one Slab pointer which we need to follow.
95
936
  static constexpr uint32_t field_mask() {
96
936
    return maskbit(offsetof(List, slab_));
97
936
  }
_ZN4ListIP6BigStrE10field_maskEv
Line
Count
Source
95
170
  static constexpr uint32_t field_mask() {
96
170
    return maskbit(offsetof(List, slab_));
97
170
  }
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEE10field_maskEv
_ZN4ListIiE10field_maskEv
Line
Count
Source
95
674
  static constexpr uint32_t field_mask() {
96
674
    return maskbit(offsetof(List, slab_));
97
674
  }
_ZN4ListIP6Tuple2IP6BigStriEE10field_maskEv
Line
Count
Source
95
1
  static constexpr uint32_t field_mask() {
96
1
    return maskbit(offsetof(List, slab_));
97
1
  }
_ZN4ListIP6Tuple2IiP6BigStrEE10field_maskEv
Line
Count
Source
95
5
  static constexpr uint32_t field_mask() {
96
5
    return maskbit(offsetof(List, slab_));
97
5
  }
_ZN4ListIPN10hnode_asdl5FieldEE10field_maskEv
Line
Count
Source
95
37
  static constexpr uint32_t field_mask() {
96
37
    return maskbit(offsetof(List, slab_));
97
37
  }
_ZN4ListIPN10hnode_asdl7hnode_tEE10field_maskEv
Line
Count
Source
95
37
  static constexpr uint32_t field_mask() {
96
37
    return maskbit(offsetof(List, slab_));
97
37
  }
_ZN4ListIbE10field_maskEv
Line
Count
Source
95
3
  static constexpr uint32_t field_mask() {
96
3
    return maskbit(offsetof(List, slab_));
97
3
  }
_ZN4ListIP6Tuple2IiiEE10field_maskEv
Line
Count
Source
95
4
  static constexpr uint32_t field_mask() {
96
4
    return maskbit(offsetof(List, slab_));
97
4
  }
_ZN4ListIPiE10field_maskEv
Line
Count
Source
95
2
  static constexpr uint32_t field_mask() {
96
2
    return maskbit(offsetof(List, slab_));
97
2
  }
_ZN4ListIdE10field_maskEv
Line
Count
Source
95
2
  static constexpr uint32_t field_mask() {
96
2
    return maskbit(offsetof(List, slab_));
97
2
  }
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl9AssocPairEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE10field_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_asdl7EnvPairEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5RedirEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10AssignPairEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl5TokenEE10field_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_asdl5ParamEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl10SourceLineEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl8TypeExprEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN12runtime_asdl9AssignArgEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN12runtime_asdl12part_value_tEE10field_maskEv
Unexecuted instantiation: _ZN4ListIPN10value_asdl7value_tEE10field_maskEv
_ZN4ListIPN4pyos11PasswdEntryEE10field_maskEv
Line
Count
Source
95
1
  static constexpr uint32_t field_mask() {
96
1
    return maskbit(offsetof(List, slab_));
97
1
  }
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE10field_maskEv
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE10field_maskEv
98
99
  DISALLOW_COPY_AND_ASSIGN(List)
100
101
  static_assert(sizeof(ObjHeader) % sizeof(T) == 0,
102
                "ObjHeader size should be multiple of item size");
103
  static constexpr int kHeaderFudge = sizeof(ObjHeader) / sizeof(T);
104
105
#if 0
106
  // 24-byte pool comes from very common List header, and Token
107
  static constexpr int kPoolBytes1 = 24 - sizeof(ObjHeader);
108
  static_assert(kPoolBytes1 % sizeof(T) == 0,
109
                "An integral number of items should fit in first pool");
110
  static constexpr int kNumItems1 = kPoolBytes1 / sizeof(T);
111
#endif
112
113
  // Matches mark_sweep_heap.h
114
  static constexpr int kPoolBytes2 = 48 - sizeof(ObjHeader);
115
  static_assert(kPoolBytes2 % sizeof(T) == 0,
116
                "An integral number of items should fit in second pool");
117
  static constexpr int kNumItems2 = kPoolBytes2 / sizeof(T);
118
119
#if 0
120
  static constexpr int kMinBytes2 = 128 - sizeof(ObjHeader);
121
  static_assert(kMinBytes2 % sizeof(T) == 0,
122
                "An integral number of items should fit");
123
  static constexpr int kMinItems2 = kMinBytes2 / sizeof(T);
124
#endif
125
126
  // Given the number of items desired, return the number items we should
127
  // reserve room for, according to our growth policy.
128
941
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
941
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
876
      return kNumItems2;
138
876
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
65
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
941
  }
_ZN4ListIP6BigStrE12HowManyItemsEi
Line
Count
Source
128
181
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
181
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
151
      return kNumItems2;
138
151
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
30
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
181
  }
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEE12HowManyItemsEi
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEE12HowManyItemsEi
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEE12HowManyItemsEi
_ZN4ListIiE12HowManyItemsEi
Line
Count
Source
128
700
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
700
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
670
      return kNumItems2;
138
670
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
30
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
700
  }
_ZN4ListIP6Tuple2IiP6BigStrEE12HowManyItemsEi
Line
Count
Source
128
7
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
7
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
7
      return kNumItems2;
138
7
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
7
  }
_ZN4ListIP6Tuple2IP6BigStriEE12HowManyItemsEi
Line
Count
Source
128
1
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
1
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
1
      return kNumItems2;
138
1
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
1
  }
_ZN4ListIPN10hnode_asdl5FieldEE12HowManyItemsEi
Line
Count
Source
128
37
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
37
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
37
      return kNumItems2;
138
37
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
37
  }
_ZN4ListIbE12HowManyItemsEi
Line
Count
Source
128
3
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
3
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
3
      return kNumItems2;
138
3
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
3
  }
_ZN4ListIP6Tuple2IiiEE12HowManyItemsEi
Line
Count
Source
128
4
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
4
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
4
      return kNumItems2;
138
4
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
4
  }
_ZN4ListIdE12HowManyItemsEi
Line
Count
Source
128
2
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
2
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
2
      return kNumItems2;
138
2
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
0
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
2
  }
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE12HowManyItemsEi
_ZN4ListIPN4pyos11PasswdEntryEE12HowManyItemsEi
Line
Count
Source
128
6
  int HowManyItems(int num_desired) {
129
    // Using the 24-byte pool leads to too much GC of tiny slab objects!  So
130
    // just use the larger 48 byte pool.
131
#if 0
132
    if (num_desired <= kNumItems1) {  // use full cell in pool 1
133
      return kNumItems1;
134
    }
135
#endif
136
6
    if (num_desired <= kNumItems2) {  // use full cell in pool 2
137
1
      return kNumItems2;
138
1
    }
139
#if 0
140
    if (num_desired <= kMinItems2) {  // 48 -> 128, not 48 -> 64
141
      return kMinItems2;
142
    }
143
#endif
144
145
    // Make sure the total allocation is a power of 2.  TODO: consider using
146
    // slightly less than power of 2, to account for malloc() headers, and
147
    // reduce fragmentation.
148
    // Example:
149
    // - ask for 11 integers
150
    // - round up 11+2 == 13 up to 16 items
151
    // - return 14 items
152
    // - 14 integers is 56 bytes, plus 8 byte GC header => 64 byte alloc.
153
5
    return RoundUp(num_desired + kHeaderFudge) - kHeaderFudge;
154
6
  }
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE12HowManyItemsEi
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE12HowManyItemsEi
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE12HowManyItemsEi
155
};
156
157
// "Constructors" as free functions since we can't allocate within a
158
// constructor.  Allocation may cause garbage collection, which interferes with
159
// placement new.
160
161
// This is not really necessary, only syntactic sugar.
162
template <typename T>
163
660
List<T>* NewList() {
164
660
  return Alloc<List<T>>();
165
660
}
_Z7NewListIP6BigStrEP4ListIT_Ev
Line
Count
Source
163
28
List<T>* NewList() {
164
28
  return Alloc<List<T>>();
165
28
}
_Z7NewListIiEP4ListIT_Ev
Line
Count
Source
163
626
List<T>* NewList() {
164
626
  return Alloc<List<T>>();
165
626
}
_Z7NewListIPiEP4ListIT_Ev
Line
Count
Source
163
2
List<T>* NewList() {
164
2
  return Alloc<List<T>>();
165
2
}
_Z7NewListIPN4pyos11PasswdEntryEEP4ListIT_Ev
Line
Count
Source
163
1
List<T>* NewList() {
164
1
  return Alloc<List<T>>();
165
1
}
Unexecuted instantiation: _Z7NewListIPN11syntax_asdl12CompoundWordEEP4ListIT_Ev
_Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_Ev
Line
Count
Source
163
3
List<T>* NewList() {
164
3
  return Alloc<List<T>>();
165
3
}
166
167
// Literal ['foo', 'bar']
168
// This seems to allow better template argument type deduction than a
169
// constructor.
170
template <typename T>
171
96
List<T>* NewList(std::initializer_list<T> init) {
172
96
  auto self = Alloc<List<T>>();
173
174
96
  int n = init.size();
175
96
  self->reserve(n);
176
177
96
  int i = 0;
178
200
  for (auto item : init) {
179
200
    self->set(i, item);
180
200
    ++i;
181
200
  }
182
96
  self->len_ = n;
183
96
  return self;
184
96
}
_Z7NewListIP6BigStrEP4ListIT_ESt16initializer_listIS3_E
Line
Count
Source
171
61
List<T>* NewList(std::initializer_list<T> init) {
172
61
  auto self = Alloc<List<T>>();
173
174
61
  int n = init.size();
175
61
  self->reserve(n);
176
177
61
  int i = 0;
178
69
  for (auto item : init) {
179
69
    self->set(i, item);
180
69
    ++i;
181
69
  }
182
61
  self->len_ = n;
183
61
  return self;
184
61
}
_Z7NewListIiEP4ListIT_ESt16initializer_listIS1_E
Line
Count
Source
171
30
List<T>* NewList(std::initializer_list<T> init) {
172
30
  auto self = Alloc<List<T>>();
173
174
30
  int n = init.size();
175
30
  self->reserve(n);
176
177
30
  int i = 0;
178
119
  for (auto item : init) {
179
119
    self->set(i, item);
180
119
    ++i;
181
119
  }
182
30
  self->len_ = n;
183
30
  return self;
184
30
}
_Z7NewListIP6Tuple2IP6BigStriEEP4ListIT_ESt16initializer_listIS6_E
Line
Count
Source
171
1
List<T>* NewList(std::initializer_list<T> init) {
172
1
  auto self = Alloc<List<T>>();
173
174
1
  int n = init.size();
175
1
  self->reserve(n);
176
177
1
  int i = 0;
178
2
  for (auto item : init) {
179
2
    self->set(i, item);
180
2
    ++i;
181
2
  }
182
1
  self->len_ = n;
183
1
  return self;
184
1
}
_Z7NewListIP6Tuple2IiP6BigStrEEP4ListIT_ESt16initializer_listIS6_E
Line
Count
Source
171
1
List<T>* NewList(std::initializer_list<T> init) {
172
1
  auto self = Alloc<List<T>>();
173
174
1
  int n = init.size();
175
1
  self->reserve(n);
176
177
1
  int i = 0;
178
2
  for (auto item : init) {
179
2
    self->set(i, item);
180
2
    ++i;
181
2
  }
182
1
  self->len_ = n;
183
1
  return self;
184
1
}
_Z7NewListIbEP4ListIT_ESt16initializer_listIS1_E
Line
Count
Source
171
1
List<T>* NewList(std::initializer_list<T> init) {
172
1
  auto self = Alloc<List<T>>();
173
174
1
  int n = init.size();
175
1
  self->reserve(n);
176
177
1
  int i = 0;
178
2
  for (auto item : init) {
179
2
    self->set(i, item);
180
2
    ++i;
181
2
  }
182
1
  self->len_ = n;
183
1
  return self;
184
1
}
_Z7NewListIdEP4ListIT_ESt16initializer_listIS1_E
Line
Count
Source
171
2
List<T>* NewList(std::initializer_list<T> init) {
172
2
  auto self = Alloc<List<T>>();
173
174
2
  int n = init.size();
175
2
  self->reserve(n);
176
177
2
  int i = 0;
178
6
  for (auto item : init) {
179
6
    self->set(i, item);
180
6
    ++i;
181
6
  }
182
2
  self->len_ = n;
183
2
  return self;
184
2
}
Unexecuted instantiation: _Z7NewListIPN10hnode_asdl7hnode_tEEP4ListIT_ESt16initializer_listIS4_E
Unexecuted instantiation: _Z7NewListIP6Tuple2IiiEEP4ListIT_ESt16initializer_listIS4_E
185
186
// ['foo'] * 3
187
template <typename T>
188
9
List<T>* NewList(T item, int times) {
189
9
  auto self = Alloc<List<T>>();
190
191
9
  self->reserve(times);
192
9
  self->len_ = times;
193
36
  for (int i = 0; i < times; ++i) {
194
27
    self->set(i, item);
195
27
  }
196
9
  return self;
197
9
}
_Z7NewListIP6BigStrEP4ListIT_ES3_i
Line
Count
Source
188
3
List<T>* NewList(T item, int times) {
189
3
  auto self = Alloc<List<T>>();
190
191
3
  self->reserve(times);
192
3
  self->len_ = times;
193
12
  for (int i = 0; i < times; ++i) {
194
9
    self->set(i, item);
195
9
  }
196
3
  return self;
197
3
}
_Z7NewListIbEP4ListIT_ES1_i
Line
Count
Source
188
2
List<T>* NewList(T item, int times) {
189
2
  auto self = Alloc<List<T>>();
190
191
2
  self->reserve(times);
192
2
  self->len_ = times;
193
8
  for (int i = 0; i < times; ++i) {
194
6
    self->set(i, item);
195
6
  }
196
2
  return self;
197
2
}
_Z7NewListIiEP4ListIT_ES1_i
Line
Count
Source
188
4
List<T>* NewList(T item, int times) {
189
4
  auto self = Alloc<List<T>>();
190
191
4
  self->reserve(times);
192
4
  self->len_ = times;
193
16
  for (int i = 0; i < times; ++i) {
194
12
    self->set(i, item);
195
12
  }
196
4
  return self;
197
4
}
198
199
template <typename T>
200
6.86k
void List<T>::append(T item) {
201
6.86k
  reserve(len_ + 1);
202
6.86k
  slab_->items_[len_] = item;
203
6.86k
  ++len_;
204
6.86k
}
_ZN4ListIP6BigStrE6appendES1_
Line
Count
Source
200
475
void List<T>::append(T item) {
201
475
  reserve(len_ + 1);
202
475
  slab_->items_[len_] = item;
203
475
  ++len_;
204
475
}
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEE6appendES2_
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEE6appendES2_
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEE6appendES2_
_ZN4ListIiE6appendEi
Line
Count
Source
200
6.22k
void List<T>::append(T item) {
201
6.22k
  reserve(len_ + 1);
202
6.22k
  slab_->items_[len_] = item;
203
6.22k
  ++len_;
204
6.22k
}
_ZN4ListIP6Tuple2IiP6BigStrEE6appendES4_
Line
Count
Source
200
20
void List<T>::append(T item) {
201
20
  reserve(len_ + 1);
202
20
  slab_->items_[len_] = item;
203
20
  ++len_;
204
20
}
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStriEE6appendES4_
_ZN4ListIPN10hnode_asdl5FieldEE6appendES2_
Line
Count
Source
200
65
void List<T>::append(T item) {
201
65
  reserve(len_ + 1);
202
65
  slab_->items_[len_] = item;
203
65
  ++len_;
204
65
}
_ZN4ListIP6Tuple2IiiEE6appendES2_
Line
Count
Source
200
8
void List<T>::append(T item) {
201
8
  reserve(len_ + 1);
202
8
  slab_->items_[len_] = item;
203
8
  ++len_;
204
8
}
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE6appendES2_
_ZN4ListIPN4pyos11PasswdEntryEE6appendES2_
Line
Count
Source
200
76
void List<T>::append(T item) {
201
76
  reserve(len_ + 1);
202
76
  slab_->items_[len_] = item;
203
76
  ++len_;
204
76
}
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE6appendES4_
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE6appendES2_
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE6appendES4_
205
206
template <typename T>
207
4.21k
int len(const List<T>* L) {
208
4.21k
  return L->len_;
209
4.21k
}
_Z3lenIiEiPK4ListIT_E
Line
Count
Source
207
3.97k
int len(const List<T>* L) {
208
3.97k
  return L->len_;
209
3.97k
}
_Z3lenIP6BigStrEiPK4ListIT_E
Line
Count
Source
207
231
int len(const List<T>* L) {
208
231
  return L->len_;
209
231
}
Unexecuted instantiation: _Z3lenIPN10classes_gc10OpaqueBaseEEiPK4ListIT_E
Unexecuted instantiation: _Z3lenIPN10classes_gc12PointersBaseEEiPK4ListIT_E
Unexecuted instantiation: _Z3lenIPN10classes_gc14BaseWithMethodEEiPK4ListIT_E
_Z3lenIP6Tuple2IiP6BigStrEEiPK4ListIT_E
Line
Count
Source
207
7
int len(const List<T>* L) {
208
7
  return L->len_;
209
7
}
_Z3lenIP6Tuple2IiiEEiPK4ListIT_E
Line
Count
Source
207
4
int len(const List<T>* L) {
208
4
  return L->len_;
209
4
}
_Z3lenIbEiPK4ListIT_E
Line
Count
Source
207
2
int len(const List<T>* L) {
208
2
  return L->len_;
209
2
}
_Z3lenIdEiPK4ListIT_E
Line
Count
Source
207
4
int len(const List<T>* L) {
208
4
  return L->len_;
209
4
}
210
211
template <typename T>
212
List<T>* list_repeat(T item, int times);
213
214
template <typename T>
215
inline bool list_contains(List<T>* haystack, T needle);
216
217
template <typename K, typename V>
218
class Dict;  // forward decl
219
220
template <typename V>
221
List<BigStr*>* sorted(Dict<BigStr*, V>* d);
222
223
template <typename T>
224
List<T>* sorted(List<T>* l);
225
226
// L[begin:]
227
// TODO: Implement this in terms of slice(begin, end)
228
template <typename T>
229
606
List<T>* List<T>::slice(int begin) {
230
606
  if (begin < 0) {
231
0
    begin = len_ + begin;
232
0
  }
233
234
606
  DCHECK(begin >= 0);
235
236
0
  List<T>* result = nullptr;
237
606
  result = NewList<T>();
238
239
3.02k
  for (int i = begin; i < len_; i++) {
240
2.41k
    result->append(slab_->items_[i]);
241
2.41k
  }
242
243
606
  return result;
244
606
}
_ZN4ListIP6BigStrE5sliceEi
Line
Count
Source
229
3
List<T>* List<T>::slice(int begin) {
230
3
  if (begin < 0) {
231
0
    begin = len_ + begin;
232
0
  }
233
234
3
  DCHECK(begin >= 0);
235
236
0
  List<T>* result = nullptr;
237
3
  result = NewList<T>();
238
239
9
  for (int i = begin; i < len_; i++) {
240
6
    result->append(slab_->items_[i]);
241
6
  }
242
243
3
  return result;
244
3
}
_ZN4ListIiE5sliceEi
Line
Count
Source
229
603
List<T>* List<T>::slice(int begin) {
230
603
  if (begin < 0) {
231
0
    begin = len_ + begin;
232
0
  }
233
234
603
  DCHECK(begin >= 0);
235
236
0
  List<T>* result = nullptr;
237
603
  result = NewList<T>();
238
239
3.01k
  for (int i = begin; i < len_; i++) {
240
2.40k
    result->append(slab_->items_[i]);
241
2.40k
  }
242
243
603
  return result;
244
603
}
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE5sliceEi
245
246
// L[begin:end]
247
template <typename T>
248
3
List<T>* List<T>::slice(int begin, int end) {
249
3
  return slice(begin, end, 1);
250
3
}
251
252
// L[begin:end:step]
253
template <typename T>
254
6
List<T>* List<T>::slice(int begin, int end, int step) {
255
6
  if (begin < 0) {
256
2
    begin = len_ + begin;
257
2
  }
258
6
  if (end < 0) {
259
3
    end = len_ + end;
260
3
  }
261
262
6
  DCHECK(end <= len_);
263
6
  DCHECK(begin >= 0);
264
6
  DCHECK(end >= 0);
265
266
0
  List<T>* result = NewList<T>();
267
  // step might be negative
268
18
  for (int i = begin; begin <= i && i < end; i += step) {
269
12
    result->append(slab_->items_[i]);
270
12
  }
271
272
6
  return result;
273
6
}
274
275
// Ensure that there's space for a number of items
276
template <typename T>
277
7.00k
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
7.00k
  if (capacity_ >= num_desired) {
282
6.06k
    return;
283
6.06k
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
941
  capacity_ = HowManyItems(num_desired);
294
941
  auto new_slab = NewSlab<T>(capacity_);
295
296
941
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
52
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
52
  }
300
941
  slab_ = new_slab;
301
941
}
_ZN4ListIP6BigStrE7reserveEi
Line
Count
Source
277
553
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
553
  if (capacity_ >= num_desired) {
282
372
    return;
283
372
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
181
  capacity_ = HowManyItems(num_desired);
294
181
  auto new_slab = NewSlab<T>(capacity_);
295
296
181
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
27
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
27
  }
300
181
  slab_ = new_slab;
301
181
}
Unexecuted instantiation: _ZN4ListIPN10classes_gc10OpaqueBaseEE7reserveEi
Unexecuted instantiation: _ZN4ListIPN10classes_gc12PointersBaseEE7reserveEi
Unexecuted instantiation: _ZN4ListIPN10classes_gc14BaseWithMethodEE7reserveEi
_ZN4ListIiE7reserveEi
Line
Count
Source
277
6.27k
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
6.27k
  if (capacity_ >= num_desired) {
282
5.57k
    return;
283
5.57k
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
700
  capacity_ = HowManyItems(num_desired);
294
700
  auto new_slab = NewSlab<T>(capacity_);
295
296
700
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
20
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
20
  }
300
700
  slab_ = new_slab;
301
700
}
_ZN4ListIP6Tuple2IiP6BigStrEE7reserveEi
Line
Count
Source
277
21
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
21
  if (capacity_ >= num_desired) {
282
14
    return;
283
14
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
7
  capacity_ = HowManyItems(num_desired);
294
7
  auto new_slab = NewSlab<T>(capacity_);
295
296
7
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
7
  slab_ = new_slab;
301
7
}
_ZN4ListIP6Tuple2IP6BigStriEE7reserveEi
Line
Count
Source
277
1
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
1
  if (capacity_ >= num_desired) {
282
0
    return;
283
0
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
1
  capacity_ = HowManyItems(num_desired);
294
1
  auto new_slab = NewSlab<T>(capacity_);
295
296
1
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
1
  slab_ = new_slab;
301
1
}
_ZN4ListIPN10hnode_asdl5FieldEE7reserveEi
Line
Count
Source
277
65
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
65
  if (capacity_ >= num_desired) {
282
28
    return;
283
28
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
37
  capacity_ = HowManyItems(num_desired);
294
37
  auto new_slab = NewSlab<T>(capacity_);
295
296
37
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
37
  slab_ = new_slab;
301
37
}
_ZN4ListIbE7reserveEi
Line
Count
Source
277
3
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
3
  if (capacity_ >= num_desired) {
282
0
    return;
283
0
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
3
  capacity_ = HowManyItems(num_desired);
294
3
  auto new_slab = NewSlab<T>(capacity_);
295
296
3
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
3
  slab_ = new_slab;
301
3
}
_ZN4ListIP6Tuple2IiiEE7reserveEi
Line
Count
Source
277
8
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
8
  if (capacity_ >= num_desired) {
282
4
    return;
283
4
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
4
  capacity_ = HowManyItems(num_desired);
294
4
  auto new_slab = NewSlab<T>(capacity_);
295
296
4
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
4
  slab_ = new_slab;
301
4
}
_ZN4ListIdE7reserveEi
Line
Count
Source
277
2
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
2
  if (capacity_ >= num_desired) {
282
0
    return;
283
0
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
2
  capacity_ = HowManyItems(num_desired);
294
2
  auto new_slab = NewSlab<T>(capacity_);
295
296
2
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
0
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
0
  }
300
2
  slab_ = new_slab;
301
2
}
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE7reserveEi
_ZN4ListIPN4pyos11PasswdEntryEE7reserveEi
Line
Count
Source
277
76
void List<T>::reserve(int num_desired) {
278
  // log("reserve capacity = %d, n = %d", capacity_, n);
279
280
  // Don't do anything if there's already enough space.
281
76
  if (capacity_ >= num_desired) {
282
70
    return;
283
70
  }
284
285
  // Slabs should be a total of 2^N bytes.  kCapacityAdjust is the number of
286
  // items that the 8 byte header takes up: 1 for List<T*>, and 2 for
287
  // List<int>.
288
  //
289
  // Example: the user reserves space for 3 integers.  The minimum number of
290
  // items would be 5, which is rounded up to 8.  Subtract 2 again, giving 6,
291
  // which leads to 8 + 6*4 = 32 byte Slab.
292
293
6
  capacity_ = HowManyItems(num_desired);
294
6
  auto new_slab = NewSlab<T>(capacity_);
295
296
6
  if (len_ > 0) {
297
    // log("Copying %d bytes", len_ * sizeof(T));
298
5
    memcpy(new_slab->items_, slab_->items_, len_ * sizeof(T));
299
5
  }
300
6
  slab_ = new_slab;
301
6
}
Unexecuted instantiation: _ZN4ListIPS_IP6Tuple2IiiEEE7reserveEi
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE7reserveEi
Unexecuted instantiation: _ZN4ListIP6Tuple2IP6BigStrbEE7reserveEi
302
303
// Implements L[i] = item
304
template <typename T>
305
279
void List<T>::set(int i, T item) {
306
279
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
279
  DCHECK(i >= 0);
311
279
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
279
}
_ZN4ListIP6BigStrE3setEiS1_
Line
Count
Source
305
90
void List<T>::set(int i, T item) {
306
90
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
90
  DCHECK(i >= 0);
311
90
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
90
}
_ZN4ListIiE3setEii
Line
Count
Source
305
171
void List<T>::set(int i, T item) {
306
171
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
171
  DCHECK(i >= 0);
311
171
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
171
}
_ZN4ListIP6Tuple2IP6BigStriEE3setEiS4_
Line
Count
Source
305
2
void List<T>::set(int i, T item) {
306
2
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
2
  DCHECK(i >= 0);
311
2
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
2
}
_ZN4ListIP6Tuple2IiP6BigStrEE3setEiS4_
Line
Count
Source
305
2
void List<T>::set(int i, T item) {
306
2
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
2
  DCHECK(i >= 0);
311
2
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
2
}
_ZN4ListIbE3setEib
Line
Count
Source
305
8
void List<T>::set(int i, T item) {
306
8
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
8
  DCHECK(i >= 0);
311
8
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
8
}
_ZN4ListIdE3setEid
Line
Count
Source
305
6
void List<T>::set(int i, T item) {
306
6
  if (i < 0) {
307
0
    i = len_ + i;
308
0
  }
309
310
6
  DCHECK(i >= 0);
311
6
  DCHECK(i < capacity_);
312
313
0
  slab_->items_[i] = item;
314
6
}
Unexecuted instantiation: _ZN4ListIPN10hnode_asdl7hnode_tEE3setEiS2_
Unexecuted instantiation: _ZN4ListIP6Tuple2IiiEE3setEiS2_
315
316
// Implements L[i]
317
template <typename T>
318
977
T List<T>::at(int i) {
319
977
  if (i < 0) {
320
4
    int j = len_ + i;
321
4
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
4
    return slab_->items_[j];
325
4
  }
326
327
973
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
973
  return slab_->items_[i];
331
973
}
_ZN4ListIiE2atEi
Line
Count
Source
318
284
T List<T>::at(int i) {
319
284
  if (i < 0) {
320
1
    int j = len_ + i;
321
1
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
1
    return slab_->items_[j];
325
1
  }
326
327
283
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
283
  return slab_->items_[i];
331
283
}
_ZN4ListIP6BigStrE2atEi
Line
Count
Source
318
676
T List<T>::at(int i) {
319
676
  if (i < 0) {
320
3
    int j = len_ + i;
321
3
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
3
    return slab_->items_[j];
325
3
  }
326
327
673
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
673
  return slab_->items_[i];
331
673
}
_ZN4ListIbE2atEi
Line
Count
Source
318
4
T List<T>::at(int i) {
319
4
  if (i < 0) {
320
0
    int j = len_ + i;
321
0
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
0
    return slab_->items_[j];
325
0
  }
326
327
4
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
4
  return slab_->items_[i];
331
4
}
_ZN4ListIdE2atEi
Line
Count
Source
318
8
T List<T>::at(int i) {
319
8
  if (i < 0) {
320
0
    int j = len_ + i;
321
0
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
0
    return slab_->items_[j];
325
0
  }
326
327
8
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
8
  return slab_->items_[i];
331
8
}
Unexecuted instantiation: _ZN4ListIPN11syntax_asdl12CompoundWordEE2atEi
_ZN4ListIP6Tuple2IiP6BigStrEE2atEi
Line
Count
Source
318
5
T List<T>::at(int i) {
319
5
  if (i < 0) {
320
0
    int j = len_ + i;
321
0
    if (j >= len_ || j < 0) {
322
0
      throw Alloc<IndexError>();
323
0
    }
324
0
    return slab_->items_[j];
325
0
  }
326
327
5
  if (i >= len_ || i < 0) {
328
0
    throw Alloc<IndexError>();
329
0
  }
330
5
  return slab_->items_[i];
331
5
}
332
333
// L.index(i) -- Python method
334
template <typename T>
335
8
int List<T>::index(T value) {
336
8
  int element_count = len(this);
337
18
  for (int i = 0; i < element_count; i++) {
338
16
    if (are_equal(slab_->items_[i], value)) {
339
6
      return i;
340
6
    }
341
16
  }
342
2
  throw Alloc<ValueError>();
343
8
}
344
345
// Should we have a separate API that doesn't return it?
346
// https://stackoverflow.com/questions/12600330/pop-back-return-value
347
template <typename T>
348
7
T List<T>::pop() {
349
7
  if (len_ == 0) {
350
0
    throw Alloc<IndexError>();
351
0
  }
352
7
  len_--;
353
7
  T result = slab_->items_[len_];
354
7
  slab_->items_[len_] = 0;  // zero for GC scan
355
7
  return result;
356
7
}
_ZN4ListIP6BigStrE3popEv
Line
Count
Source
348
5
T List<T>::pop() {
349
5
  if (len_ == 0) {
350
0
    throw Alloc<IndexError>();
351
0
  }
352
5
  len_--;
353
5
  T result = slab_->items_[len_];
354
5
  slab_->items_[len_] = 0;  // zero for GC scan
355
5
  return result;
356
5
}
_ZN4ListIiE3popEv
Line
Count
Source
348
2
T List<T>::pop() {
349
2
  if (len_ == 0) {
350
0
    throw Alloc<IndexError>();
351
0
  }
352
2
  len_--;
353
2
  T result = slab_->items_[len_];
354
2
  slab_->items_[len_] = 0;  // zero for GC scan
355
2
  return result;
356
2
}
357
358
// Used in osh/word_parse.py to remove from front
359
template <typename T>
360
10
T List<T>::pop(int i) {
361
10
  if (len_ < i) {
362
0
    throw Alloc<IndexError>();
363
0
  }
364
365
10
  T result = at(i);
366
10
  len_--;
367
368
  // Shift everything by one
369
10
  memmove(slab_->items_ + i, slab_->items_ + (i + 1), len_ * sizeof(T));
370
371
  /*
372
  for (int j = 0; j < len_; j++) {
373
    slab_->items_[j] = slab_->items_[j+1];
374
  }
375
  */
376
377
10
  slab_->items_[len_] = 0;  // zero for GC scan
378
10
  return result;
379
10
}
380
381
template <typename T>
382
6
void List<T>::remove(T x) {
383
6
  int idx = this->index(x);
384
6
  this->pop(idx);  // unused
385
6
}
386
387
template <typename T>
388
7
void List<T>::clear() {
389
7
  if (slab_) {
390
4
    memset(slab_->items_, 0, len_ * sizeof(T));  // zero for GC scan
391
4
  }
392
7
  len_ = 0;
393
7
}
_ZN4ListIiE5clearEv
Line
Count
Source
388
4
void List<T>::clear() {
389
4
  if (slab_) {
390
4
    memset(slab_->items_, 0, len_ * sizeof(T));  // zero for GC scan
391
4
  }
392
4
  len_ = 0;
393
4
}
_ZN4ListIP6BigStrE5clearEv
Line
Count
Source
388
1
void List<T>::clear() {
389
1
  if (slab_) {
390
0
    memset(slab_->items_, 0, len_ * sizeof(T));  // zero for GC scan
391
0
  }
392
1
  len_ = 0;
393
1
}
_ZN4ListIPiE5clearEv
Line
Count
Source
388
2
void List<T>::clear() {
389
2
  if (slab_) {
390
0
    memset(slab_->items_, 0, len_ * sizeof(T));  // zero for GC scan
391
0
  }
392
2
  len_ = 0;
393
2
}
394
395
// Used in osh/string_ops.py
396
template <typename T>
397
8
void List<T>::reverse() {
398
16
  for (int i = 0; i < len_ / 2; ++i) {
399
    // log("swapping %d and %d", i, n-i);
400
8
    T tmp = slab_->items_[i];
401
8
    int j = len_ - 1 - i;
402
8
    slab_->items_[i] = slab_->items_[j];
403
8
    slab_->items_[j] = tmp;
404
8
  }
405
8
}
Unexecuted instantiation: _ZN4ListIP6BigStrE7reverseEv
_ZN4ListIiE7reverseEv
Line
Count
Source
397
8
void List<T>::reverse() {
398
16
  for (int i = 0; i < len_ / 2; ++i) {
399
    // log("swapping %d and %d", i, n-i);
400
8
    T tmp = slab_->items_[i];
401
8
    int j = len_ - 1 - i;
402
8
    slab_->items_[i] = slab_->items_[j];
403
8
    slab_->items_[j] = tmp;
404
8
  }
405
8
}
406
407
// Extend this list with multiple elements.
408
template <typename T>
409
13
void List<T>::extend(List<T>* other) {
410
13
  int n = other->len_;
411
13
  int new_len = len_ + n;
412
13
  reserve(new_len);
413
414
54
  for (int i = 0; i < n; ++i) {
415
41
    set(len_ + i, other->slab_->items_[i]);
416
41
  }
417
13
  len_ = new_len;
418
13
}
_ZN4ListIiE6extendEPS0_
Line
Count
Source
409
11
void List<T>::extend(List<T>* other) {
410
11
  int n = other->len_;
411
11
  int new_len = len_ + n;
412
11
  reserve(new_len);
413
414
46
  for (int i = 0; i < n; ++i) {
415
35
    set(len_ + i, other->slab_->items_[i]);
416
35
  }
417
11
  len_ = new_len;
418
11
}
_ZN4ListIP6BigStrE6extendEPS2_
Line
Count
Source
409
2
void List<T>::extend(List<T>* other) {
410
2
  int n = other->len_;
411
2
  int new_len = len_ + n;
412
2
  reserve(new_len);
413
414
8
  for (int i = 0; i < n; ++i) {
415
6
    set(len_ + i, other->slab_->items_[i]);
416
6
  }
417
2
  len_ = new_len;
418
2
}
419
420
34
inline bool _cmp(BigStr* a, BigStr* b) {
421
34
  return mylib::str_cmp(a, b) < 0;
422
34
}
423
424
template <typename T>
425
8
void List<T>::sort() {
426
8
  std::sort(slab_->items_, slab_->items_ + len_, _cmp);
427
8
}
428
429
// TODO: mycpp can just generate the constructor instead?
430
// e.g. [None] * 3
431
template <typename T>
432
5
List<T>* list_repeat(T item, int times) {
433
5
  return NewList<T>(item, times);
434
5
}
_Z11list_repeatIP6BigStrEP4ListIT_ES3_i
Line
Count
Source
432
3
List<T>* list_repeat(T item, int times) {
433
3
  return NewList<T>(item, times);
434
3
}
_Z11list_repeatIbEP4ListIT_ES1_i
Line
Count
Source
432
2
List<T>* list_repeat(T item, int times) {
433
2
  return NewList<T>(item, times);
434
2
}
435
436
// e.g. 'a' in ['a', 'b', 'c']
437
template <typename T>
438
24
inline bool list_contains(List<T>* haystack, T needle) {
439
24
  int n = len(haystack);
440
57
  for (int i = 0; i < n; ++i) {
441
47
    if (are_equal(haystack->at(i), needle)) {
442
14
      return true;
443
14
    }
444
47
  }
445
10
  return false;
446
24
}
_Z13list_containsIiEbP4ListIT_ES1_
Line
Count
Source
438
8
inline bool list_contains(List<T>* haystack, T needle) {
439
8
  int n = len(haystack);
440
19
  for (int i = 0; i < n; ++i) {
441
16
    if (are_equal(haystack->at(i), needle)) {
442
5
      return true;
443
5
    }
444
16
  }
445
3
  return false;
446
8
}
_Z13list_containsIP6BigStrEbP4ListIT_ES3_
Line
Count
Source
438
12
inline bool list_contains(List<T>* haystack, T needle) {
439
12
  int n = len(haystack);
440
28
  for (int i = 0; i < n; ++i) {
441
23
    if (are_equal(haystack->at(i), needle)) {
442
7
      return true;
443
7
    }
444
23
  }
445
5
  return false;
446
12
}
_Z13list_containsIdEbP4ListIT_ES1_
Line
Count
Source
438
4
inline bool list_contains(List<T>* haystack, T needle) {
439
4
  int n = len(haystack);
440
10
  for (int i = 0; i < n; ++i) {
441
8
    if (are_equal(haystack->at(i), needle)) {
442
2
      return true;
443
2
    }
444
8
  }
445
2
  return false;
446
4
}
447
448
template <typename V>
449
2
List<BigStr*>* sorted(Dict<BigStr*, V>* d) {
450
2
  auto keys = d->keys();
451
2
  keys->sort();
452
2
  return keys;
453
2
}
454
455
template <typename T>
456
2
List<T>* sorted(List<T>* l) {
457
2
  auto ret = list(l);
458
2
  ret->sort();
459
2
  return ret;
460
2
}
461
462
// list(L) copies the list
463
template <typename T>
464
7
List<T>* list(List<T>* other) {
465
7
  auto result = NewList<T>();
466
7
  result->extend(other);
467
7
  return result;
468
7
}
_Z4listIiEP4ListIT_ES3_
Line
Count
Source
464
5
List<T>* list(List<T>* other) {
465
5
  auto result = NewList<T>();
466
5
  result->extend(other);
467
5
  return result;
468
5
}
_Z4listIP6BigStrEP4ListIT_ES5_
Line
Count
Source
464
2
List<T>* list(List<T>* other) {
465
2
  auto result = NewList<T>();
466
2
  result->extend(other);
467
2
  return result;
468
2
}
469
470
template <class T>
471
class ListIter {
472
 public:
473
158
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
158
  }
_ZN8ListIterIP6BigStrEC2EP4ListIS1_E
Line
Count
Source
473
40
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
40
  }
_ZN8ListIterIiEC2EP4ListIiE
Line
Count
Source
473
23
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
23
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E
Line
Count
Source
473
6
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
6
  }
_ZN8ListIterIP6Tuple2IP6BigStriEEC2EP4ListIS4_E
Line
Count
Source
473
1
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
1
  }
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEEC2EP4ListIS2_E
_ZN8ListIterIPN10hnode_asdl5FieldEEC2EP4ListIS2_E
Line
Count
Source
473
82
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
82
  }
_ZN8ListIterIbEC2EP4ListIbE
Line
Count
Source
473
1
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
1
  }
_ZN8ListIterIP6Tuple2IiiEEC2EP4ListIS2_E
Line
Count
Source
473
4
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
4
  }
_ZN8ListIterIPN4pyos11PasswdEntryEEC2EP4ListIS2_E
Line
Count
Source
473
1
  explicit ListIter(List<T>* L) : L_(L), i_(0) {
474
    // Cheney only: L_ could be moved during iteration.
475
    // gHeap.PushRoot(reinterpret_cast<RawObject**>(&L_));
476
1
  }
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEEC2EP4ListIS2_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_asdl5RedirEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEEC2EP4ListIS2_E
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEEC2EP4ListIS2_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
477
478
161
  ~ListIter() {
479
    // gHeap.PopRoot();
480
161
  }
_ZN8ListIterIP6BigStrED2Ev
Line
Count
Source
478
40
  ~ListIter() {
479
    // gHeap.PopRoot();
480
40
  }
_ZN8ListIterIiED2Ev
Line
Count
Source
478
26
  ~ListIter() {
479
    // gHeap.PopRoot();
480
26
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEED2Ev
Line
Count
Source
478
6
  ~ListIter() {
479
    // gHeap.PopRoot();
480
6
  }
_ZN8ListIterIP6Tuple2IP6BigStriEED2Ev
Line
Count
Source
478
1
  ~ListIter() {
479
    // gHeap.PopRoot();
480
1
  }
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEED2Ev
_ZN8ListIterIPN10hnode_asdl5FieldEED2Ev
Line
Count
Source
478
82
  ~ListIter() {
479
    // gHeap.PopRoot();
480
82
  }
_ZN8ListIterIbED2Ev
Line
Count
Source
478
1
  ~ListIter() {
479
    // gHeap.PopRoot();
480
1
  }
_ZN8ListIterIP6Tuple2IiiEED2Ev
Line
Count
Source
478
4
  ~ListIter() {
479
    // gHeap.PopRoot();
480
4
  }
_ZN8ListIterIPN4pyos11PasswdEntryEED2Ev
Line
Count
Source
478
1
  ~ListIter() {
479
    // gHeap.PopRoot();
480
1
  }
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEED2Ev
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_asdl5RedirEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEED2Ev
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEED2Ev
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
481
428
  void Next() {
482
428
    i_++;
483
428
  }
_ZN8ListIterIP6BigStrE4NextEv
Line
Count
Source
481
148
  void Next() {
482
148
    i_++;
483
148
  }
_ZN8ListIterIiE4NextEv
Line
Count
Source
481
87
  void Next() {
482
87
    i_++;
483
87
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEE4NextEv
Line
Count
Source
481
18
  void Next() {
482
18
    i_++;
483
18
  }
_ZN8ListIterIP6Tuple2IP6BigStriEE4NextEv
Line
Count
Source
481
2
  void Next() {
482
2
    i_++;
483
2
  }
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4NextEv
_ZN8ListIterIPN10hnode_asdl5FieldEE4NextEv
Line
Count
Source
481
123
  void Next() {
482
123
    i_++;
483
123
  }
_ZN8ListIterIbE4NextEv
Line
Count
Source
481
2
  void Next() {
482
2
    i_++;
483
2
  }
_ZN8ListIterIP6Tuple2IiiEE4NextEv
Line
Count
Source
481
8
  void Next() {
482
8
    i_++;
483
8
  }
_ZN8ListIterIPN4pyos11PasswdEntryEE4NextEv
Line
Count
Source
481
40
  void Next() {
482
40
    i_++;
483
40
  }
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE4NextEv
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_asdl5RedirEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4NextEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4NextEv
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
484
583
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
583
    return i_ >= static_cast<int>(L_->len_);
487
583
  }
_ZN8ListIterIP6BigStrE4DoneEv
Line
Count
Source
484
188
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
188
    return i_ >= static_cast<int>(L_->len_);
487
188
  }
_ZN8ListIterIiE4DoneEv
Line
Count
Source
484
107
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
107
    return i_ >= static_cast<int>(L_->len_);
487
107
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEE4DoneEv
Line
Count
Source
484
24
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
24
    return i_ >= static_cast<int>(L_->len_);
487
24
  }
_ZN8ListIterIP6Tuple2IP6BigStriEE4DoneEv
Line
Count
Source
484
3
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
3
    return i_ >= static_cast<int>(L_->len_);
487
3
  }
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE4DoneEv
_ZN8ListIterIPN10hnode_asdl5FieldEE4DoneEv
Line
Count
Source
484
205
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
205
    return i_ >= static_cast<int>(L_->len_);
487
205
  }
_ZN8ListIterIbE4DoneEv
Line
Count
Source
484
3
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
3
    return i_ >= static_cast<int>(L_->len_);
487
3
  }
_ZN8ListIterIP6Tuple2IiiEE4DoneEv
Line
Count
Source
484
12
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
12
    return i_ >= static_cast<int>(L_->len_);
487
12
  }
_ZN8ListIterIPN4pyos11PasswdEntryEE4DoneEv
Line
Count
Source
484
41
  bool Done() {
485
    // "unsigned size_t was a mistake"
486
41
    return i_ >= static_cast<int>(L_->len_);
487
41
  }
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE4DoneEv
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_asdl5RedirEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE4DoneEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE4DoneEv
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
488
448
  T Value() {
489
448
    return L_->slab_->items_[i_];
490
448
  }
_ZN8ListIterIP6BigStrE5ValueEv
Line
Count
Source
488
149
  T Value() {
489
149
    return L_->slab_->items_[i_];
490
149
  }
_ZN8ListIterIiE5ValueEv
Line
Count
Source
488
82
  T Value() {
489
82
    return L_->slab_->items_[i_];
490
82
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEE5ValueEv
Line
Count
Source
488
10
  T Value() {
489
10
    return L_->slab_->items_[i_];
490
10
  }
_ZN8ListIterIP6Tuple2IP6BigStriEE5ValueEv
Line
Count
Source
488
2
  T Value() {
489
2
    return L_->slab_->items_[i_];
490
2
  }
Unexecuted instantiation: _ZN8ListIterIPN10hnode_asdl7hnode_tEE5ValueEv
_ZN8ListIterIPN10hnode_asdl5FieldEE5ValueEv
Line
Count
Source
488
146
  T Value() {
489
146
    return L_->slab_->items_[i_];
490
146
  }
_ZN8ListIterIbE5ValueEv
Line
Count
Source
488
2
  T Value() {
489
2
    return L_->slab_->items_[i_];
490
2
  }
_ZN8ListIterIP6Tuple2IiiEE5ValueEv
Line
Count
Source
488
16
  T Value() {
489
16
    return L_->slab_->items_[i_];
490
16
  }
_ZN8ListIterIPN4pyos11PasswdEntryEE5ValueEv
Line
Count
Source
488
41
  T Value() {
489
41
    return L_->slab_->items_[i_];
490
41
  }
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl12CompoundWordEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN10value_asdl7value_tEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl9AssignArgEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN12runtime_asdl12part_value_tEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5loc_tEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl11word_part_tEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5TokenEE5ValueEv
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_asdl5RedirEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl5ParamEE5ValueEv
Unexecuted instantiation: _ZN8ListIterIPN11syntax_asdl10SourceLineEE5ValueEv
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
491
16
  T iterNext() {
492
16
    if (Done()) {
493
3
      throw Alloc<StopIteration>();
494
3
    }
495
13
    T ret = L_->slab_->items_[i_];
496
13
    Next();
497
13
    return ret;
498
16
  }
_ZN8ListIterIP6Tuple2IiP6BigStrEE8iterNextEv
Line
Count
Source
491
10
  T iterNext() {
492
10
    if (Done()) {
493
2
      throw Alloc<StopIteration>();
494
2
    }
495
8
    T ret = L_->slab_->items_[i_];
496
8
    Next();
497
8
    return ret;
498
10
  }
_ZN8ListIterIiE8iterNextEv
Line
Count
Source
491
6
  T iterNext() {
492
6
    if (Done()) {
493
1
      throw Alloc<StopIteration>();
494
1
    }
495
5
    T ret = L_->slab_->items_[i_];
496
5
    Next();
497
5
    return ret;
498
6
  }
499
500
  // only for use with generators
501
3
  List<T>* GetList() {
502
3
    return L_;
503
3
  }
504
505
 private:
506
  List<T>* L_;
507
  int i_;
508
};
509
510
// list(it) returns the iterator's backing list
511
template <typename T>
512
3
List<T>* list(ListIter<T> it) {
513
3
  return list(it.GetList());
514
3
}
515
516
// TODO: Does using pointers rather than indices make this more efficient?
517
template <class T>
518
class ReverseListIter {
519
 public:
520
4
  explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) {
521
4
  }
_ZN15ReverseListIterIP6BigStrEC2EP4ListIS1_E
Line
Count
Source
520
1
  explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) {
521
1
  }
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEEC2EP4ListIS4_E
Line
Count
Source
520
1
  explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) {
521
1
  }
_ZN15ReverseListIterIiEC2EP4ListIiE
Line
Count
Source
520
2
  explicit ReverseListIter(List<T>* L) : L_(L), i_(L_->len_ - 1) {
521
2
  }
522
10
  void Next() {
523
10
    i_--;
524
10
  }
_ZN15ReverseListIterIP6BigStrE4NextEv
Line
Count
Source
522
2
  void Next() {
523
2
    i_--;
524
2
  }
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4NextEv
Line
Count
Source
522
2
  void Next() {
523
2
    i_--;
524
2
  }
_ZN15ReverseListIterIiE4NextEv
Line
Count
Source
522
6
  void Next() {
523
6
    i_--;
524
6
  }
525
14
  bool Done() {
526
14
    return i_ < 0;
527
14
  }
_ZN15ReverseListIterIP6BigStrE4DoneEv
Line
Count
Source
525
3
  bool Done() {
526
3
    return i_ < 0;
527
3
  }
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE4DoneEv
Line
Count
Source
525
3
  bool Done() {
526
3
    return i_ < 0;
527
3
  }
_ZN15ReverseListIterIiE4DoneEv
Line
Count
Source
525
8
  bool Done() {
526
8
    return i_ < 0;
527
8
  }
528
10
  T Value() {
529
10
    return L_->slab_->items_[i_];
530
10
  }
_ZN15ReverseListIterIP6BigStrE5ValueEv
Line
Count
Source
528
2
  T Value() {
529
2
    return L_->slab_->items_[i_];
530
2
  }
_ZN15ReverseListIterIP6Tuple2IiP6BigStrEE5ValueEv
Line
Count
Source
528
2
  T Value() {
529
2
    return L_->slab_->items_[i_];
530
2
  }
_ZN15ReverseListIterIiE5ValueEv
Line
Count
Source
528
6
  T Value() {
529
6
    return L_->slab_->items_[i_];
530
6
  }
531
532
 private:
533
  List<T>* L_;
534
  int i_;
535
};
536
537
int max(List<int>* elems);
538
539
#endif  // MYCPP_GC_LIST_H