dart-sdk/runtime/vm/virtual_memory_compressed.h
Siva Annamalai be8e94162e Revert "[vm, gc] Assert the whole object is in to-space, not just its beginning."
This reverts commit c870932e45.

Reason for revert: We have a build failure on arm64c
../../third_party/dart/runtime/vm/virtual_memory_compressed.cc:143:35: error: out-of-line definition of 'Contains' does not match any declaration in 'dart::VirtualMemoryCompressedHeap'

TEST=ci

Original change's description:
> [vm, gc] Assert the whole object is in to-space, not just its beginning.
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/50564
> Change-Id: I60e7637600a1a7a99d546e8c674901175a119ba5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272863
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I62c83c8e8fa5b263bdc53d2afcf27b1fdd07c087
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/50564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273060
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-12-01 01:35:26 +00:00

72 lines
2.3 KiB
C++

// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_VIRTUAL_MEMORY_COMPRESSED_H_
#define RUNTIME_VM_VIRTUAL_MEMORY_COMPRESSED_H_
#include "vm/globals.h"
#include "vm/heap/pages.h"
#include "vm/memory_region.h"
namespace dart {
#if defined(DART_COMPRESSED_POINTERS)
static constexpr intptr_t kCompressedHeapSize = 4 * GB;
static constexpr intptr_t kCompressedHeapAlignment = 4 * GB;
static constexpr intptr_t kCompressedPageSize = kPageSize;
static constexpr intptr_t kCompressedHeapNumPages =
kCompressedHeapSize / kPageSize;
static constexpr intptr_t kCompressedHeapBitmapSize =
kCompressedHeapNumPages / 8;
#if !defined(DART_HOST_OS_FUCHSIA)
#define DART_COMPRESSED_HEAP
#endif // !defined(DART_HOST_OS_FUCHSIA)
#endif // defined(DART_COMPRESSED_POINTERS)
#if defined(DART_COMPRESSED_HEAP)
// Utilities for allocating memory within a contiguous region of memory, for use
// with compressed pointers.
class VirtualMemoryCompressedHeap : public AllStatic {
public:
// Initializes the compressed heap. The callee must allocate a region of
// kCompressedHeapSize bytes, aligned to kCompressedHeapSize.
static void Init(void* compressed_heap_region, size_t size);
// Cleans up the compressed heap. The callee is responsible for freeing the
// region's memory.
static void Cleanup();
// Allocates a segment of the compressed heap with the given size. Returns a
// heap memory region if a large enough free segment can't be found.
static MemoryRegion Allocate(intptr_t size, intptr_t alignment);
// Frees a segment.
static void Free(void* address, intptr_t size);
// Returns whether the address is within the compressed heap.
static bool Contains(void* address);
// Returns a pointer to the compressed heap region.
static void* GetRegion();
private:
static bool IsPageUsed(uword page_id);
static void SetPageUsed(uword page_id);
static void ClearPageUsed(uword page_id);
static uword base_;
static uword size_;
static uint8_t* pages_;
static uword minimum_free_page_id_;
static Mutex* mutex_;
};
#endif // defined(DART_COMPRESSED_HEAP)
} // namespace dart
#endif // RUNTIME_VM_VIRTUAL_MEMORY_COMPRESSED_H_