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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 155 i::Isolate* isolate = Isolate::Current(); |
156 // This loop will terminate once the scanning hits an EOF. | 156 // This loop will terminate once the scanning hits an EOF. |
157 while (true) { | 157 while (true) { |
158 uintptr_t start, end; | 158 uintptr_t start, end; |
159 char attr_r, attr_w, attr_x, attr_p; | 159 char attr_r, attr_w, attr_x, attr_p; |
160 // Parse the addresses and permission bits at the beginning of the line. | 160 // Parse the addresses and permission bits at the beginning of the line. |
161 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; | 161 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; | 162 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; |
163 | 163 |
164 int c; | 164 int c; |
165 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { | 165 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return VirtualFree(base, 0, MEM_RELEASE) != 0; | 361 return VirtualFree(base, 0, MEM_RELEASE) != 0; |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 bool VirtualMemory::HasLazyCommits() { | 365 bool VirtualMemory::HasLazyCommits() { |
366 // TODO(alph): implement for the platform. | 366 // TODO(alph): implement for the platform. |
367 return false; | 367 return false; |
368 } | 368 } |
369 | 369 |
370 } } // namespace v8::internal | 370 } } // namespace v8::internal |
OLD | NEW |