OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 OS::Abort(); | 224 OS::Abort(); |
225 } | 225 } |
226 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, | 226 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, |
227 fileno(f), 0); | 227 fileno(f), 0); |
228 ASSERT(addr != MAP_FAILED); | 228 ASSERT(addr != MAP_FAILED); |
229 OS::Free(addr, size); | 229 OS::Free(addr, size); |
230 fclose(f); | 230 fclose(f); |
231 } | 231 } |
232 | 232 |
233 | 233 |
| 234 uintptr_t OS::TotalPhysicalMemory(int pages_name) { |
| 235 intptr_t pages = sysconf(pages_name); |
| 236 intptr_t page_size = sysconf(_SC_PAGESIZE); |
| 237 if (pages == -1 || page_size == -1) { |
| 238 UNREACHABLE(); |
| 239 return 0; |
| 240 } |
| 241 return static_cast<uintptr_t>(pages) * page_size; |
| 242 } |
| 243 |
234 | 244 |
235 // Constants used for mmap. | 245 // Constants used for mmap. |
236 static const int kMmapFd = -1; | 246 static const int kMmapFd = -1; |
237 static const int kMmapFdOffset = 0; | 247 static const int kMmapFdOffset = 0; |
238 | 248 |
239 | 249 |
240 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 250 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
241 | 251 |
242 | 252 |
243 VirtualMemory::VirtualMemory(size_t size) | 253 VirtualMemory::VirtualMemory(size_t size) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 return munmap(base, size) == 0; | 372 return munmap(base, size) == 0; |
363 } | 373 } |
364 | 374 |
365 | 375 |
366 bool VirtualMemory::HasLazyCommits() { | 376 bool VirtualMemory::HasLazyCommits() { |
367 // TODO(alph): implement for the platform. | 377 // TODO(alph): implement for the platform. |
368 return false; | 378 return false; |
369 } | 379 } |
370 | 380 |
371 } } // namespace v8::internal | 381 } } // namespace v8::internal |
OLD | NEW |