Sha256: 11feff71f997e70f45552f9534a8fbe163c0c9f239c434dddf0cea5580d4be47

Contents?: true

Size: 1.86 KB

Versions: 12

Compression:

Stored size: 1.86 KB

Contents

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
#define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_

#include <array>

#include "cppgc/internal/api-constants.h"
#include "cppgc/internal/logging.h"
#include "cppgc/platform.h"
#include "v8config.h"  // NOLINT(build/include_directory)

namespace cppgc {
namespace internal {

class HeapBase;

#if defined(CPPGC_YOUNG_GENERATION)

// AgeTable contains entries that correspond to 4KB memory regions. Each entry
// can be in one of three states: kOld, kYoung or kUnknown.
class AgeTable final {
  static constexpr size_t kGranularityBits = 12;  // 4KiB per byte.

 public:
  enum class Age : uint8_t { kOld, kYoung, kUnknown };

  static constexpr size_t kEntrySizeInBytes = 1 << kGranularityBits;

  Age& operator[](uintptr_t offset) { return table_[entry(offset)]; }
  Age operator[](uintptr_t offset) const { return table_[entry(offset)]; }

  void Reset(PageAllocator* allocator);

 private:
  static constexpr size_t kAgeTableSize =
      api_constants::kCagedHeapReservationSize >> kGranularityBits;

  size_t entry(uintptr_t offset) const {
    const size_t entry = offset >> kGranularityBits;
    CPPGC_DCHECK(table_.size() > entry);
    return entry;
  }

  std::array<Age, kAgeTableSize> table_;
};

static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
              "Size of AgeTable is 1MB");

#endif  // CPPGC_YOUNG_GENERATION

struct CagedHeapLocalData final {
  CagedHeapLocalData(HeapBase&, PageAllocator&);

  bool is_incremental_marking_in_progress = false;
  HeapBase& heap_base;
#if defined(CPPGC_YOUNG_GENERATION)
  AgeTable age_table;
#endif
};

}  // namespace internal
}  // namespace cppgc

#endif  // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
libv8-node-17.9.1.1-x86_64-linux vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.1-x86_64-linux-musl vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.1-x86_64-darwin vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.1-arm64-darwin vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.1-aarch64-linux vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.1-aarch64-linux-musl vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-aarch64-linux-musl vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-aarch64-linux vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-arm64-darwin vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-x86_64-linux-musl vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-x86_64-linux vendor/v8/include/cppgc/internal/caged-heap-local-data.h
libv8-node-17.9.1.0-x86_64-darwin vendor/v8/include/cppgc/internal/caged-heap-local-data.h