Commit ee86913a authored by Albert J. Wong's avatar Albert J. Wong Committed by Commit Bot

PA: PartitionPage: move file static funcs up.

This moves the file local query functions that were implementing an
ad-hoc "package protection" style API into the PartitionPage public API.

After this, I think the functions are finally organized enough that
these classes can start being detangled into separate files.

See related bug for more details on methodology.

Bug: 787153
Change-Id: I4997fd73e1779c9ed4f9ded9aa8a4c94c0eb7d1e
Reviewed-on: https://chromium-review.googlesource.com/792090
Commit-Queue: Albert J. Wong <ajwong@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521788}
parent 7e7bd7c0
......@@ -318,11 +318,26 @@ struct PartitionPage {
}
ALWAYS_INLINE size_t get_raw_size() const;
ALWAYS_INLINE void set_raw_size(size_t size);
ALWAYS_INLINE void Reset();
// TODO(ajwong): Can this be made private? https://crbug.com/787153
BASE_EXPORT static PartitionPage* get_sentinel_page();
// Page State accessors.
// Note that it's only valid to call these functions on pages found on one of
// the page lists. Specifically, you can't call these functions on full pages
// that were detached from the active list.
//
// This restriction provides the flexibity for some of the status fields to
// be repurposed when a page is taken off a list. See the negation of
// |num_allocated_slots| when a full page is removed from the active list
// for an example of such repurposing.
ALWAYS_INLINE bool is_active() const;
ALWAYS_INLINE bool is_full() const;
ALWAYS_INLINE bool is_empty() const;
ALWAYS_INLINE bool is_decommitted() const;
};
static_assert(sizeof(PartitionPage) <= kPageMetadataSize,
"PartitionPage must be able to fit in a metadata slot");
......@@ -431,6 +446,8 @@ struct PartitionDirectMapExtent {
PartitionDirectMapExtent* prev_extent;
PartitionBucket* bucket;
size_t map_size; // Mapped size, not including guard pages and meta-data.
ALWAYS_INLINE static PartitionDirectMapExtent* FromPage(PartitionPage* page);
};
struct BASE_EXPORT PartitionRootBase {
......@@ -457,8 +474,10 @@ struct BASE_EXPORT PartitionRootBase {
// Pubic API
// gOomHandlingFunction is invoked when ParitionAlloc hits OutOfMemory.
// gOomHandlingFunction is invoked when PartitionAlloc hits OutOfMemory.
static void (*gOomHandlingFunction)();
ALWAYS_INLINE static PartitionRootBase* FromPage(PartitionPage* page);
};
enum PartitionPurgeFlags {
......@@ -767,7 +786,8 @@ ALWAYS_INLINE size_t PartitionPage::get_raw_size() const {
return 0;
}
ALWAYS_INLINE PartitionRootBase* PartitionPageToRoot(PartitionPage* page) {
ALWAYS_INLINE PartitionRootBase* PartitionRootBase::FromPage(
PartitionPage* page) {
PartitionSuperPageExtentEntry* extent_entry =
reinterpret_cast<PartitionSuperPageExtentEntry*>(
reinterpret_cast<uintptr_t>(page) & kSystemPageBaseMask);
......@@ -775,7 +795,7 @@ ALWAYS_INLINE PartitionRootBase* PartitionPageToRoot(PartitionPage* page) {
}
ALWAYS_INLINE bool PartitionPage::IsPointerValid(PartitionPage* page) {
PartitionRootBase* root = PartitionPageToRoot(page);
PartitionRootBase* root = PartitionRootBase::FromPage(page);
return root->inverted_self == ~reinterpret_cast<uintptr_t>(root);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment