Commit 19fda9e7 authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

[base] Use GetCurrentProcess() instead of nullptr

While nullptr also mostly seems to work, GetCurrentProcess() is the
correct way of specifying the current process for operations like
MapViewOfFile3 or VirtualAlloc2.

Bug: chromium:1218005
Change-Id: I988140374a708018dca089c29eb699e0536a5285
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3620288Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80324}
parent 3b150938
......@@ -868,7 +868,8 @@ DWORD GetFileViewAccessFromMemoryPermission(OS::MemoryPermission access) {
void* VirtualAllocWrapper(void* address, size_t size, DWORD flags,
DWORD protect) {
if (VirtualAlloc2) {
return VirtualAlloc2(nullptr, address, size, flags, protect, NULL, 0);
return VirtualAlloc2(GetCurrentProcess(), address, size, flags, protect,
NULL, 0);
} else {
return VirtualAlloc(address, size, flags, protect);
}
......@@ -1266,7 +1267,8 @@ bool AddressSpaceReservation::Allocate(void* address, size_t size,
? MEM_RESERVE | MEM_REPLACE_PLACEHOLDER
: MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER;
DWORD protect = GetProtectionFromMemoryPermission(access);
return VirtualAlloc2(nullptr, address, size, flags, protect, nullptr, 0);
return VirtualAlloc2(GetCurrentProcess(), address, size, flags, protect,
nullptr, 0);
}
bool AddressSpaceReservation::Free(void* address, size_t size) {
......@@ -1283,15 +1285,16 @@ bool AddressSpaceReservation::AllocateShared(void* address, size_t size,
DWORD protect = GetProtectionFromMemoryPermission(access);
HANDLE file_mapping = FileMappingFromSharedMemoryHandle(handle);
return MapViewOfFile3(file_mapping, nullptr, address, offset, size,
MEM_REPLACE_PLACEHOLDER, protect, nullptr, 0);
return MapViewOfFile3(file_mapping, GetCurrentProcess(), address, offset,
size, MEM_REPLACE_PLACEHOLDER, protect, nullptr, 0);
}
bool AddressSpaceReservation::FreeShared(void* address, size_t size) {
DCHECK(Contains(address, size));
CHECK(UnmapViewOfFile2);
return UnmapViewOfFile2(nullptr, address, MEM_PRESERVE_PLACEHOLDER);
return UnmapViewOfFile2(GetCurrentProcess(), address,
MEM_PRESERVE_PLACEHOLDER);
}
bool AddressSpaceReservation::SetPermissions(void* address, size_t size,
......
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