Lines Matching defs:region

60   // Find the possible insertion position by identifying the first region whose
72 // Check whether to also merge with the region below.
107 // Not adjacent to any existing region: insert between {below} and {above}.
119 size_t size, base::AddressRegion region) {
120 // Get an iterator to the first contained region whose start address is not
121 // smaller than the start address of {region}. Start the search from the
122 // region one before that (the last one whose start address is smaller).
123 auto it = regions_.lower_bound(region);
127 base::AddressRegion overlap = it->GetOverlap(region);
133 // We use the full region --> nothing to add back.
135 // We return a region at the start --> shrink old region from front.
138 // We return a region at the end --> shrink remaining region.
141 // We return something in the middle --> split the remaining region
142 // (insert the region with smaller address first).
534 free_code_space_.Merge(code_space.region());
540 // On Windows, we cannot commit a region that straddles different reservations
544 // to chunk the region to commit.
644 // 1) {region} must be fully contained in {writable_memory_};
658 [](size_t old, base::AddressRegion region) {
659 return old + region.size();
666 [this](auto region) { return region.contains(new_region_); }));
672 [](size_t old, auto region) { return old + region.size(); });
677 [](auto region) { return region.is_empty(); }));
682 Address{0}, [](Address previous_end, auto region) {
683 DCHECK_LT(previous_end, region.begin());
684 return region.end();
711 NativeModule* native_module, size_t size, base::AddressRegion region) {
716 free_code_space_.AllocateInRegion(size, region);
718 // Only allocations without a specific region are allowed to fail. Otherwise
719 // the region must have been allocated big enough to hold all initial
721 CHECK_EQ(kUnrestrictedRegion, region);
743 base::AddressRegion new_region = new_mem.region();
822 void WasmCodeAllocator::MakeWritable(base::AddressRegion region) {
825 DCHECK(!region.is_empty());
831 Address begin = RoundDown(region.begin(), commit_page_size);
832 Address end = RoundUp(region.end(), commit_page_size);
833 region = base::AddressRegion(begin, end - begin);
835 InsertIntoWritableRegions(region, true);
854 for (auto region : freed_regions.regions()) {
855 auto merged_region = freed_code_space_.Merge(region);
858 RoundDown(region.begin(), commit_page_size));
861 RoundUp(region.end(), commit_page_size));
867 for (auto region : regions_to_decommit.regions()) {
868 size_t old_committed = committed_code_space_.fetch_sub(region.size());
869 DCHECK_GE(old_committed, region.size());
872 SplitRangeByReservationsIfNeeded(region, owned_code_space_)) {
882 void WasmCodeAllocator::InsertIntoWritableRegions(base::AddressRegion region,
886 CheckWritableMemoryRegions check_on_return{writable_memory_, region,
890 // Subroutine to make a non-writable region writable (if {switch_to_writable}
893 base::AddressRegion region) {
894 new_writable_memory += region.size();
897 SplitRangeByReservationsIfNeeded(region, owned_code_space_)) {
906 // Insert {region} into {writable_memory_} before {insert_pos}, potentially
911 if (previous->end() == region.begin()) {
912 region = {previous->begin(), previous->size() + region.size()};
917 region.end() == insert_pos->begin()) {
918 region = {region.begin(), insert_pos->size() + region.size()};
921 writable_memory_.insert(insert_pos, region);
924 DCHECK(!region.is_empty());
925 // Find a possible insertion position by identifying the first region whose
927 // merge from the existing region before that.
928 auto it = writable_memory_.lower_bound(region);
931 if (it == writable_memory_.end() || it->begin() >= region.end()) {
933 make_writable(it, region);
936 if (it->end() <= region.begin()) continue; // Continue after {it}.
937 base::AddressRegion overlap = it->GetOverlap(region);
939 if (overlap.begin() == region.begin()) {
940 if (overlap.end() == region.end()) return; // Fully contained already.
942 region = {overlap.end(), region.end() - overlap.end()};
945 if (overlap.end() == region.end()) {
947 // region writable.
948 region = {region.begin(), overlap.begin() - region.begin()};
949 make_writable(it, region);
952 // Split {region}, make the split writable, and continue with the rest.
953 base::AddressRegion split = {region.begin(),
954 overlap.begin() - region.begin()};
956 region = {overlap.end(), region.end() - overlap.end()};
1012 auto initial_region = code_space.region();
1030 single_code_space_region = code_space_data_[0].region;
1168 base::AddressRegion single_code_space_region = code_space_data_[0].region;
1487 int jump_table_size, base::AddressRegion region) {
1493 code_allocator_.AllocateForCodeInRegion(this, jump_table_size, region);
1579 void NativeModule::AddCodeSpaceLocked(base::AddressRegion region) {
1584 DCHECK_GE(region.size(),
1598 code_allocator_.AllocateForCodeInRegion(this, size, region);
1599 CHECK_EQ(reinterpret_cast<Address>(padding.begin()), region.begin());
1601 reinterpret_cast<void*>(region.begin()), region.size());
1612 !FindJumpTablesForRegionLocked(region).is_valid();
1617 JumpTableAssembler::SizeForNumberOfSlots(num_wasm_functions), region);
1618 CHECK(region.contains(jump_table->instruction_start()));
1627 region);
1628 CHECK(region.contains(far_jump_table->instruction_start()));
1655 code_space_data_.push_back(CodeSpaceData{region, jump_table, far_jump_table});
1796 // Compute the maximum distance from anywhere in the code region to anywhere
1802 // every call or jump will target an address *within* the region, but never
1803 // exactly the end of the region. So all occuring offsets are actually
1910 void WasmCodeManager::Commit(base::AddressRegion region) {
1913 DCHECK(IsAligned(region.begin(), CommitPageSize()));
1914 DCHECK(IsAligned(region.size(), CommitPageSize()));
1920 if (region.size() > max_committed_code_space_ - old_value) {
1927 old_value, old_value + region.size())) {
1951 memory_protection_key_, region.begin(), region.end());
1953 GetPlatformPageAllocator(), region, permission, memory_protection_key_);
1956 region.begin(), region.end());
1957 success = SetPermissions(GetPlatformPageAllocator(), region.begin(),
1958 region.size(), permission);
1964 "WasmCodeManager::Commit: Cannot make pre-reserved region writable");
1969 void WasmCodeManager::Decommit(base::AddressRegion region) {
1973 DCHECK(IsAligned(region.begin(), allocator->CommitPageSize()));
1974 DCHECK(IsAligned(region.size(), allocator->CommitPageSize()));
1975 size_t old_committed = total_committed_code_space_.fetch_sub(region.size());
1976 DCHECK_LE(region.size(), old_committed);
1979 region.begin(), region.end());
1980 CHECK(allocator->DecommitPages(reinterpret_cast<void*>(region.begin()),
1981 region.size()));
1984 void WasmCodeManager::AssignRange(base::AddressRegion region,
1988 region.begin(), std::make_pair(region.end(), native_module)));
2323 // region. If this ever happens, we need to handle this case (by splitting the