summaryrefslogtreecommitdiff
path: root/deps/v8/src/base/platform/platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/base/platform/platform.h')
-rw-r--r--deps/v8/src/base/platform/platform.h59
1 files changed, 45 insertions, 14 deletions
diff --git a/deps/v8/src/base/platform/platform.h b/deps/v8/src/base/platform/platform.h
index 5b2dbc9a0b..d3b6c9c1cf 100644
--- a/deps/v8/src/base/platform/platform.h
+++ b/deps/v8/src/base/platform/platform.h
@@ -26,6 +26,7 @@
#include <vector>
#include "src/base/build_config.h"
+#include "src/base/compiler-specific.h"
#include "src/base/platform/mutex.h"
#include "src/base/platform/semaphore.h"
@@ -154,18 +155,19 @@ class OS {
// Print output to console. This is mostly used for debugging output.
// On platforms that has standard terminal output, the output
// should go to stdout.
- static void Print(const char* format, ...);
- static void VPrint(const char* format, va_list args);
+ static PRINTF_FORMAT(1, 2) void Print(const char* format, ...);
+ static PRINTF_FORMAT(1, 0) void VPrint(const char* format, va_list args);
// Print output to a file. This is mostly used for debugging output.
- static void FPrint(FILE* out, const char* format, ...);
- static void VFPrint(FILE* out, const char* format, va_list args);
+ static PRINTF_FORMAT(2, 3) void FPrint(FILE* out, const char* format, ...);
+ static PRINTF_FORMAT(2, 0) void VFPrint(FILE* out, const char* format,
+ va_list args);
// Print error output to console. This is mostly used for error message
// output. On platforms that has standard terminal output, the output
// should go to stderr.
- static void PrintError(const char* format, ...);
- static void VPrintError(const char* format, va_list args);
+ static PRINTF_FORMAT(1, 2) void PrintError(const char* format, ...);
+ static PRINTF_FORMAT(1, 0) void VPrintError(const char* format, va_list args);
// Allocate/Free memory used by JS heap. Pages are readable/writable, but
// they are not guaranteed to be executable unless 'executable' is true.
@@ -222,11 +224,10 @@ class OS {
// Safe formatting print. Ensures that str is always null-terminated.
// Returns the number of chars written, or -1 if output was truncated.
- static int SNPrintF(char* str, int length, const char* format, ...);
- static int VSNPrintF(char* str,
- int length,
- const char* format,
- va_list args);
+ static PRINTF_FORMAT(3, 4) int SNPrintF(char* str, int length,
+ const char* format, ...);
+ static PRINTF_FORMAT(3, 0) int VSNPrintF(char* str, int length,
+ const char* format, va_list args);
static char* StrChr(char* str, int c);
static void StrNCpy(char* dest, int length, const char* src, size_t n);
@@ -234,13 +235,20 @@ class OS {
// Support for the profiler. Can do nothing, in which case ticks
// occuring in shared libraries will not be properly accounted for.
struct SharedLibraryAddress {
- SharedLibraryAddress(
- const std::string& library_path, uintptr_t start, uintptr_t end)
- : library_path(library_path), start(start), end(end) {}
+ SharedLibraryAddress(const std::string& library_path, uintptr_t start,
+ uintptr_t end)
+ : library_path(library_path), start(start), end(end), aslr_slide(0) {}
+ SharedLibraryAddress(const std::string& library_path, uintptr_t start,
+ uintptr_t end, intptr_t aslr_slide)
+ : library_path(library_path),
+ start(start),
+ end(end),
+ aslr_slide(aslr_slide) {}
std::string library_path;
uintptr_t start;
uintptr_t end;
+ intptr_t aslr_slide;
};
static std::vector<SharedLibraryAddress> GetSharedLibraryAddresses();
@@ -329,6 +337,23 @@ class VirtualMemory {
// Creates a single guard page at the given address.
bool Guard(void* address);
+ // Releases the memory after |free_start|.
+ void ReleasePartial(void* free_start) {
+ DCHECK(IsReserved());
+ // Notice: Order is important here. The VirtualMemory object might live
+ // inside the allocated region.
+ size_t size = size_ - (reinterpret_cast<size_t>(free_start) -
+ reinterpret_cast<size_t>(address_));
+ CHECK(InVM(free_start, size));
+ DCHECK_LT(address_, free_start);
+ DCHECK_LT(free_start, reinterpret_cast<void*>(
+ reinterpret_cast<size_t>(address_) + size_));
+ bool result = ReleasePartialRegion(address_, size_, free_start, size);
+ USE(result);
+ DCHECK(result);
+ size_ -= size;
+ }
+
void Release() {
DCHECK(IsReserved());
// Notice: Order is important here. The VirtualMemory object might live
@@ -361,6 +386,12 @@ class VirtualMemory {
// and the same size it was reserved with.
static bool ReleaseRegion(void* base, size_t size);
+ // Must be called with a base pointer that has been returned by ReserveRegion
+ // and the same size it was reserved with.
+ // [free_start, free_start + free_size] is the memory that will be released.
+ static bool ReleasePartialRegion(void* base, size_t size, void* free_start,
+ size_t free_size);
+
// Returns true if OS performs lazy commits, i.e. the memory allocation call
// defers actual physical memory allocation till the first memory access.
// Otherwise returns false.