Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: src/heap/spaces.cc

Issue 1086253004: If a code space commit partially succeeds, free the memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index af04b5229e99ba7fcb8ef0a0bbcc2828777b0e0e..5e78c6aef8408994484a4e555396cb5d75a80979 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -875,30 +875,28 @@ bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm,
Address start, size_t commit_size,
size_t reserved_size) {
// Commit page header (not executable).
- if (!vm->Commit(start, CodePageGuardStartOffset(), false)) {
- return false;
- }
-
- // Create guard page after the header.
- if (!vm->Guard(start + CodePageGuardStartOffset())) {
- return false;
- }
-
- // Commit page body (executable).
- if (!vm->Commit(start + CodePageAreaStartOffset(),
- commit_size - CodePageGuardStartOffset(), true)) {
- return false;
- }
-
- // Create guard page before the end.
- if (!vm->Guard(start + reserved_size - CodePageGuardSize())) {
- return false;
+ Address header = start;
+ size_t header_size = CodePageGuardStartOffset();
+ if (vm->Commit(header, header_size, false)) {
+ // Create guard page after the header.
+ if (vm->Guard(start + CodePageGuardStartOffset())) {
+ // Commit page body (executable).
+ Address body = start + CodePageAreaStartOffset();
+ size_t body_size = commit_size - CodePageGuardStartOffset();
+ if (vm->Commit(body, body_size, true)) {
+ // Create guard page before the end.
+ if (vm->Guard(start + reserved_size - CodePageGuardSize())) {
+ UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() +
+ commit_size -
+ CodePageGuardStartOffset());
+ return true;
+ }
+ vm->Uncommit(body, body_size);
+ }
+ }
+ vm->Uncommit(header, header_size);
}
-
- UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() +
- commit_size -
- CodePageGuardStartOffset());
- return true;
+ return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698