Coverage Report

Created: 2025-12-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hermes/lib/BCGen/HBC/StringKind.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#include "hermes/BCGen/HBC/StringKind.h"
9
10
namespace hermes {
11
12
StringKind::Entry::Entry(StringKind::Kind kind, uint32_t count)
13
213
    : datum_{kind | count} {
14
213
  assert((kind & MaxCount) == 0 && "kind overlapping with count storage.");
15
213
  assert(1 <= count && count <= MaxCount && "Count out of bounds");
16
213
}
17
18
7.75k
StringKind::Entry &StringKind::Entry::operator++() {
19
7.75k
  assert(count() < MaxCount && "Count Overflow");
20
7.75k
  datum_++;
21
7.75k
  return *this;
22
7.75k
}
23
24
7.97k
void StringKind::Accumulator::push_back(Kind k) {
25
7.97k
  if (LLVM_UNLIKELY(entries_.empty())) {
26
147
    entries_.emplace_back(k);
27
147
    return;
28
147
  }
29
30
7.82k
  auto &back = entries_.back();
31
7.82k
  if (back.kind() != k || LLVM_UNLIKELY(back.count() >= MaxCount)) {
32
66
    entries_.emplace_back(k);
33
7.75k
  } else {
34
7.75k
    ++back;
35
7.75k
  }
36
7.82k
}
37
38
} // namespace hermes