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

Side by Side Diff: src/platform-cygwin.cc

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 75
76 void* OS::Allocate(const size_t requested, 76 void* OS::Allocate(const size_t requested,
77 size_t* allocated, 77 size_t* allocated,
78 bool is_executable) { 78 bool is_executable) {
79 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); 79 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
80 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); 80 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
81 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 81 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
82 if (mbase == MAP_FAILED) { 82 if (mbase == MAP_FAILED) {
83 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); 83 LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed"));
84 return NULL; 84 return NULL;
85 } 85 }
86 *allocated = msize; 86 *allocated = msize;
87 return mbase; 87 return mbase;
88 } 88 }
89 89
90 90
91 void OS::DumpBacktrace() { 91 void OS::DumpBacktrace() {
92 // Currently unsupported. 92 // Currently unsupported.
93 } 93 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return new PosixMemoryMappedFile(file, memory, size); 134 return new PosixMemoryMappedFile(file, memory, size);
135 } 135 }
136 136
137 137
138 PosixMemoryMappedFile::~PosixMemoryMappedFile() { 138 PosixMemoryMappedFile::~PosixMemoryMappedFile() {
139 if (memory_) munmap(memory_, size_); 139 if (memory_) munmap(memory_, size_);
140 fclose(file_); 140 fclose(file_);
141 } 141 }
142 142
143 143
144 void OS::LogSharedLibraryAddresses() { 144 void OS::LogSharedLibraryAddresses(Isolate* isolate) {
145 // This function assumes that the layout of the file is as follows: 145 // This function assumes that the layout of the file is as follows:
146 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] 146 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
147 // If we encounter an unexpected situation we abort scanning further entries. 147 // If we encounter an unexpected situation we abort scanning further entries.
148 FILE* fp = fopen("/proc/self/maps", "r"); 148 FILE* fp = fopen("/proc/self/maps", "r");
149 if (fp == NULL) return; 149 if (fp == NULL) return;
150 150
151 // Allocate enough room to be able to store a full file name. 151 // Allocate enough room to be able to store a full file name.
152 const int kLibNameLen = FILENAME_MAX + 1; 152 const int kLibNameLen = FILENAME_MAX + 1;
153 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); 153 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));
154 154
155 i::Isolate* isolate = ISOLATE;
156 // This loop will terminate once the scanning hits an EOF. 155 // This loop will terminate once the scanning hits an EOF.
157 while (true) { 156 while (true) {
158 uintptr_t start, end; 157 uintptr_t start, end;
159 char attr_r, attr_w, attr_x, attr_p; 158 char attr_r, attr_w, attr_x, attr_p;
160 // Parse the addresses and permission bits at the beginning of the line. 159 // Parse the addresses and permission bits at the beginning of the line.
161 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; 160 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break;
162 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; 161 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break;
163 162
164 int c; 163 int c;
165 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { 164 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Use a multiple of 64k to prevent committing unused memory. 228 // Use a multiple of 64k to prevent committing unused memory.
230 // Note: This does not guarantee RWX regions will be within the 229 // Note: This does not guarantee RWX regions will be within the
231 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax 230 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax
232 #ifdef V8_HOST_ARCH_64_BIT 231 #ifdef V8_HOST_ARCH_64_BIT
233 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; 232 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
234 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; 233 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
235 #else 234 #else
236 static const intptr_t kAllocationRandomAddressMin = 0x04000000; 235 static const intptr_t kAllocationRandomAddressMin = 0x04000000;
237 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; 236 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
238 #endif 237 #endif
239 uintptr_t address = (V8::RandomPrivate(isolate) << kPageSizeBits) 238 uintptr_t address =
240 | kAllocationRandomAddressMin; 239 (isolate->random_number_generator()->NextInt() << kPageSizeBits) |
240 kAllocationRandomAddressMin;
241 address &= kAllocationRandomAddressMax; 241 address &= kAllocationRandomAddressMax;
242 return reinterpret_cast<void *>(address); 242 return reinterpret_cast<void *>(address);
243 } 243 }
244 return NULL; 244 return NULL;
245 } 245 }
246 246
247 247
248 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { 248 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) {
249 LPVOID base = NULL; 249 LPVOID base = NULL;
250 250
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return false; 337 return false;
338 } 338 }
339 return true; 339 return true;
340 } 340 }
341 341
342 342
343 bool VirtualMemory::Guard(void* address) { 343 bool VirtualMemory::Guard(void* address) {
344 if (NULL == VirtualAlloc(address, 344 if (NULL == VirtualAlloc(address,
345 OS::CommitPageSize(), 345 OS::CommitPageSize(),
346 MEM_COMMIT, 346 MEM_COMMIT,
347 PAGE_READONLY | PAGE_GUARD)) { 347 PAGE_NOACCESS)) {
348 return false; 348 return false;
349 } 349 }
350 return true; 350 return true;
351 } 351 }
352 352
353 353
354 bool VirtualMemory::UncommitRegion(void* base, size_t size) { 354 bool VirtualMemory::UncommitRegion(void* base, size_t size) {
355 return VirtualFree(base, size, MEM_DECOMMIT) != 0; 355 return VirtualFree(base, size, MEM_DECOMMIT) != 0;
356 } 356 }
357 357
358 358
359 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { 359 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
360 return VirtualFree(base, 0, MEM_RELEASE) != 0; 360 return VirtualFree(base, 0, MEM_RELEASE) != 0;
361 } 361 }
362 362
363 363
364 bool VirtualMemory::HasLazyCommits() { 364 bool VirtualMemory::HasLazyCommits() {
365 // TODO(alph): implement for the platform. 365 // TODO(alph): implement for the platform.
366 return false; 366 return false;
367 } 367 }
368 368
369
370 void OS::SetUp() {
371 // Seed the random number generator.
372 // Convert the current time to a 64-bit integer first, before converting it
373 // to an unsigned. Going directly can cause an overflow and the seed to be
374 // set to all ones. The seed will be identical for different instances that
375 // call this setup code within the same millisecond.
376 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
377 srandom(static_cast<unsigned int>(seed));
378 }
379
380
381 } } // namespace v8::internal 369 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698