| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119   return new PosixMemoryMappedFile(file, memory, size); | 119   return new PosixMemoryMappedFile(file, memory, size); | 
| 120 } | 120 } | 
| 121 | 121 | 
| 122 | 122 | 
| 123 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 123 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 
| 124   if (memory_) munmap(memory_, size_); | 124   if (memory_) munmap(memory_, size_); | 
| 125   fclose(file_); | 125   fclose(file_); | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 | 128 | 
| 129 void OS::LogSharedLibraryAddresses() { | 129 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 
| 130   // This function assumes that the layout of the file is as follows: | 130   // This function assumes that the layout of the file is as follows: | 
| 131   // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 131   // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 
| 132   // If we encounter an unexpected situation we abort scanning further entries. | 132   // If we encounter an unexpected situation we abort scanning further entries. | 
| 133   FILE* fp = fopen("/proc/self/maps", "r"); | 133   FILE* fp = fopen("/proc/self/maps", "r"); | 
| 134   if (fp == NULL) return; | 134   if (fp == NULL) return; | 
| 135 | 135 | 
| 136   // Allocate enough room to be able to store a full file name. | 136   // Allocate enough room to be able to store a full file name. | 
| 137   const int kLibNameLen = FILENAME_MAX + 1; | 137   const int kLibNameLen = FILENAME_MAX + 1; | 
| 138   char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 138   char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 
| 139 | 139 | 
| 140   i::Isolate* isolate = Isolate::Current(); |  | 
| 141   // This loop will terminate once the scanning hits an EOF. | 140   // This loop will terminate once the scanning hits an EOF. | 
| 142   while (true) { | 141   while (true) { | 
| 143     uintptr_t start, end; | 142     uintptr_t start, end; | 
| 144     char attr_r, attr_w, attr_x, attr_p; | 143     char attr_r, attr_w, attr_x, attr_p; | 
| 145     // Parse the addresses and permission bits at the beginning of the line. | 144     // Parse the addresses and permission bits at the beginning of the line. | 
| 146     if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; | 145     if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; | 
| 147     if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; | 146     if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; | 
| 148 | 147 | 
| 149     int c; | 148     int c; | 
| 150     if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { | 149     if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 225     uintptr_t address = | 224     uintptr_t address = | 
| 226         (isolate->random_number_generator()->NextInt() << kPageSizeBits) | | 225         (isolate->random_number_generator()->NextInt() << kPageSizeBits) | | 
| 227         kAllocationRandomAddressMin; | 226         kAllocationRandomAddressMin; | 
| 228     address &= kAllocationRandomAddressMax; | 227     address &= kAllocationRandomAddressMax; | 
| 229     return reinterpret_cast<void *>(address); | 228     return reinterpret_cast<void *>(address); | 
| 230   } | 229   } | 
| 231   return NULL; | 230   return NULL; | 
| 232 } | 231 } | 
| 233 | 232 | 
| 234 } }  // namespace v8::internal | 233 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|