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

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

Issue 10823209: Add support for building the Dart VM for Android OS. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
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 <sys/mman.h> 7 #include <sys/mman.h>
8 #include <sys/unistd.h>
9 #include <unistd.h> 8 #include <unistd.h>
10 9
11 #include "platform/assert.h" 10 #include "platform/assert.h"
12 #include "platform/utils.h" 11 #include "platform/utils.h"
13 12
14 namespace dart { 13 namespace dart {
15 14
16 // standard MAP_FAILED causes "error: use of old-style cast" as it 15 // standard MAP_FAILED causes "error: use of old-style cast" as it
17 // defines MAP_FAILED as ((void *) -1) 16 // defines MAP_FAILED as ((void *) -1)
18 #undef MAP_FAILED 17 #undef MAP_FAILED
19 #define MAP_FAILED reinterpret_cast<void*>(-1) 18 #define MAP_FAILED reinterpret_cast<void*>(-1)
20 19
21 uword VirtualMemory::page_size_ = 0; 20 uword VirtualMemory::page_size_ = 0;
22 21
23 22
24 void VirtualMemory::InitOnce() { 23 void VirtualMemory::InitOnce() {
25 page_size_ = getpagesize(); 24 page_size_ = getpagesize();
26 } 25 }
27 26
28 27
29 VirtualMemory* VirtualMemory::Reserve(intptr_t size) { 28 VirtualMemory* VirtualMemory::Reserve(intptr_t size) {
30 void* address = mmap(NULL, size, PROT_NONE, 29 void* address = mmap(NULL, size, PROT_NONE,
cshapiro 2012/08/07 20:56:54 I think this should use the ashmem interface inste
jackpal 2012/08/07 21:43:26 Good idea, but I need to learn how to use ashmem,
cshapiro 2012/08/07 22:39:39 I would add a comment like this one TODO(4480):
jackpal 2012/08/08 00:26:19 Done.
31 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 30 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
32 -1, 0); 31 -1, 0);
33 if (address == MAP_FAILED) { 32 if (address == MAP_FAILED) {
34 return NULL; 33 return NULL;
35 } 34 }
36 MemoryRegion region(address, size); 35 MemoryRegion region(address, size);
37 return new VirtualMemory(region, NULL); 36 return new VirtualMemory(region, NULL);
38 } 37 }
39 38
40 39
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 prot = PROT_READ | PROT_EXEC; 88 prot = PROT_READ | PROT_EXEC;
90 break; 89 break;
91 case kReadWriteExecute: 90 case kReadWriteExecute:
92 prot = PROT_READ | PROT_WRITE | PROT_EXEC; 91 prot = PROT_READ | PROT_WRITE | PROT_EXEC;
93 break; 92 break;
94 } 93 }
95 return (mprotect(address(), size(), prot) == 0); 94 return (mprotect(address(), size(), prot) == 0);
96 } 95 }
97 96
98 } // namespace dart 97 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698