[scudo][standalone] Add bytemap classes
Summary:
The bytemap classes will be used by the primary32 allocator to associate
classes with memory regions. It's similar to the sanitizer_common one
except for the fact that the base (level1) maps are mapped instead of
being static to reduce the memory footprint of an uninitialized allocator.
Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr
Reviewed By: vitalybuka, morehouse
Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D58723
llvm-svn: 355416
2019-03-06 01:36:11 +08:00
|
|
|
//===-- bytemap.h -----------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SCUDO_BYTEMAP_H_
|
|
|
|
#define SCUDO_BYTEMAP_H_
|
|
|
|
|
|
|
|
#include "atomic_helpers.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "mutex.h"
|
|
|
|
|
|
|
|
namespace scudo {
|
|
|
|
|
|
|
|
template <uptr Size> class FlatByteMap {
|
|
|
|
public:
|
2021-05-26 06:00:58 +08:00
|
|
|
void init() { DCHECK(Size == 0 || Map[0] == 0); }
|
[scudo][standalone] Add bytemap classes
Summary:
The bytemap classes will be used by the primary32 allocator to associate
classes with memory regions. It's similar to the sanitizer_common one
except for the fact that the base (level1) maps are mapped instead of
being static to reduce the memory footprint of an uninitialized allocator.
Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr
Reviewed By: vitalybuka, morehouse
Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D58723
llvm-svn: 355416
2019-03-06 01:36:11 +08:00
|
|
|
|
2021-05-26 06:00:58 +08:00
|
|
|
void unmapTestOnly() { memset(Map, 0, Size); }
|
2019-06-12 03:50:12 +08:00
|
|
|
|
[scudo][standalone] Add bytemap classes
Summary:
The bytemap classes will be used by the primary32 allocator to associate
classes with memory regions. It's similar to the sanitizer_common one
except for the fact that the base (level1) maps are mapped instead of
being static to reduce the memory footprint of an uninitialized allocator.
Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr
Reviewed By: vitalybuka, morehouse
Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D58723
llvm-svn: 355416
2019-03-06 01:36:11 +08:00
|
|
|
void set(uptr Index, u8 Value) {
|
|
|
|
DCHECK_LT(Index, Size);
|
|
|
|
DCHECK_EQ(0U, Map[Index]);
|
|
|
|
Map[Index] = Value;
|
|
|
|
}
|
|
|
|
u8 operator[](uptr Index) {
|
|
|
|
DCHECK_LT(Index, Size);
|
|
|
|
return Map[Index];
|
|
|
|
}
|
|
|
|
|
2020-01-10 03:43:16 +08:00
|
|
|
void disable() {}
|
|
|
|
void enable() {}
|
|
|
|
|
[scudo][standalone] Add bytemap classes
Summary:
The bytemap classes will be used by the primary32 allocator to associate
classes with memory regions. It's similar to the sanitizer_common one
except for the fact that the base (level1) maps are mapped instead of
being static to reduce the memory footprint of an uninitialized allocator.
Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr
Reviewed By: vitalybuka, morehouse
Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D58723
llvm-svn: 355416
2019-03-06 01:36:11 +08:00
|
|
|
private:
|
2021-05-26 06:00:58 +08:00
|
|
|
u8 Map[Size] = {};
|
[scudo][standalone] Add bytemap classes
Summary:
The bytemap classes will be used by the primary32 allocator to associate
classes with memory regions. It's similar to the sanitizer_common one
except for the fact that the base (level1) maps are mapped instead of
being static to reduce the memory footprint of an uninitialized allocator.
Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr
Reviewed By: vitalybuka, morehouse
Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D58723
llvm-svn: 355416
2019-03-06 01:36:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace scudo
|
|
|
|
|
|
|
|
#endif // SCUDO_BYTEMAP_H_
|