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

Side by Side Diff: runtime/vm/virtual_memory.cc

Issue 106593002: Write protect executable pages in the VM. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/virtual_memory.h ('k') | runtime/vm/virtual_memory_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/virtual_memory.h" 5 #include "vm/virtual_memory.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 bool VirtualMemory::InSamePage(uword address0, uword address1) {
13 return (Utils::RoundDown(address0, PageSize()) ==
14 Utils::RoundDown(address1, PageSize()));
15 }
16
17
12 VirtualMemory* VirtualMemory::ReserveAligned(intptr_t size, 18 VirtualMemory* VirtualMemory::ReserveAligned(intptr_t size,
13 intptr_t alignment) { 19 intptr_t alignment) {
14 ASSERT((size & (PageSize() - 1)) == 0); 20 ASSERT((size & (PageSize() - 1)) == 0);
15 ASSERT(Utils::IsPowerOfTwo(alignment)); 21 ASSERT(Utils::IsPowerOfTwo(alignment));
16 ASSERT(alignment >= PageSize()); 22 ASSERT(alignment >= PageSize());
17 VirtualMemory* result = VirtualMemory::Reserve(size + alignment); 23 VirtualMemory* result = VirtualMemory::Reserve(size + alignment);
18 if (result == NULL) { 24 if (result == NULL) {
19 FATAL("Out of memory.\n"); 25 FATAL("Out of memory.\n");
20 } 26 }
21 uword start = result->start(); 27 uword start = result->start();
(...skipping 12 matching lines...) Expand all
34 FreeSubSegment(address(), split); 40 FreeSubSegment(address(), split);
35 region_.Subregion(region_, split, size() - split); 41 region_.Subregion(region_, split, size() - split);
36 } 42 }
37 ASSERT(new_size <= size()); 43 ASSERT(new_size <= size());
38 FreeSubSegment(reinterpret_cast<void*>(start() + new_size), 44 FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
39 size() - new_size); 45 size() - new_size);
40 region_.Subregion(region_, 0, new_size); 46 region_.Subregion(region_, 0, new_size);
41 } 47 }
42 48
43 } // namespace dart 49 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/virtual_memory.h ('k') | runtime/vm/virtual_memory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698