| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // variety of ASLR modes (PAE kernel, NX compat mode, etc). | 93 // variety of ASLR modes (PAE kernel, NX compat mode, etc). |
| 94 raw_addr &= 0x3ffff000; | 94 raw_addr &= 0x3ffff000; |
| 95 raw_addr += 0x20000000; | 95 raw_addr += 0x20000000; |
| 96 #endif | 96 #endif |
| 97 return reinterpret_cast<void*>(raw_addr); | 97 return reinterpret_cast<void*>(raw_addr); |
| 98 } | 98 } |
| 99 return NULL; | 99 return NULL; |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 void OS::PostSetUp() { | |
| 104 POSIXPostSetUp(); | |
| 105 } | |
| 106 | |
| 107 | |
| 108 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 103 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 109 return 0; | 104 return 0; |
| 110 } | 105 } |
| 111 | 106 |
| 112 | 107 |
| 113 int OS::ActivationFrameAlignment() { | 108 int OS::ActivationFrameAlignment() { |
| 114 // With gcc 4.4 the tree vectorization optimizer can generate code | 109 // With gcc 4.4 the tree vectorization optimizer can generate code |
| 115 // that requires 16 byte alignment such as movdqa on x86. | 110 // that requires 16 byte alignment such as movdqa on x86. |
| 116 return 16; | 111 return 16; |
| 117 } | 112 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 Max(highest_ever_allocated, | 148 Max(highest_ever_allocated, |
| 154 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 149 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
| 155 } | 150 } |
| 156 | 151 |
| 157 | 152 |
| 158 bool OS::IsOutsideAllocatedSpace(void* address) { | 153 bool OS::IsOutsideAllocatedSpace(void* address) { |
| 159 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 154 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
| 160 } | 155 } |
| 161 | 156 |
| 162 | 157 |
| 163 size_t OS::AllocateAlignment() { | |
| 164 return sysconf(_SC_PAGESIZE); | |
| 165 } | |
| 166 | |
| 167 | |
| 168 void* OS::Allocate(const size_t requested, | 158 void* OS::Allocate(const size_t requested, |
| 169 size_t* allocated, | 159 size_t* allocated, |
| 170 bool is_executable) { | 160 bool is_executable) { |
| 171 const size_t msize = RoundUp(requested, AllocateAlignment()); | 161 const size_t msize = RoundUp(requested, AllocateAlignment()); |
| 172 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 162 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 173 void* addr = GetRandomMmapAddr(); | 163 void* addr = GetRandomMmapAddr(); |
| 174 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); | 164 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); |
| 175 if (mbase == MAP_FAILED) { | 165 if (mbase == MAP_FAILED) { |
| 176 LOG(i::Isolate::Current(), | 166 LOG(i::Isolate::Current(), |
| 177 StringEvent("OS::Allocate", "mmap failed")); | 167 StringEvent("OS::Allocate", "mmap failed")); |
| 178 return NULL; | 168 return NULL; |
| 179 } | 169 } |
| 180 *allocated = msize; | 170 *allocated = msize; |
| 181 UpdateAllocatedSpaceLimits(mbase, msize); | 171 UpdateAllocatedSpaceLimits(mbase, msize); |
| 182 return mbase; | 172 return mbase; |
| 183 } | 173 } |
| 184 | 174 |
| 185 | 175 |
| 186 void OS::Free(void* address, const size_t size) { | |
| 187 // TODO(1240712): munmap has a return value which is ignored here. | |
| 188 int result = munmap(address, size); | |
| 189 USE(result); | |
| 190 ASSERT(result == 0); | |
| 191 } | |
| 192 | |
| 193 | |
| 194 void OS::Sleep(int milliseconds) { | |
| 195 unsigned int ms = static_cast<unsigned int>(milliseconds); | |
| 196 usleep(1000 * ms); | |
| 197 } | |
| 198 | |
| 199 | |
| 200 int OS::NumberOfCores() { | |
| 201 return sysconf(_SC_NPROCESSORS_ONLN); | |
| 202 } | |
| 203 | |
| 204 | |
| 205 void OS::Abort() { | |
| 206 // Redirect to std abort to signal abnormal program termination. | |
| 207 abort(); | |
| 208 } | |
| 209 | |
| 210 | |
| 211 void OS::DebugBreak() { | |
| 212 asm("int $3"); | |
| 213 } | |
| 214 | |
| 215 | |
| 216 void OS::DumpBacktrace() { | 176 void OS::DumpBacktrace() { |
| 217 // Currently unsupported. | 177 // Currently unsupported. |
| 218 } | 178 } |
| 219 | 179 |
| 220 | 180 |
| 221 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 181 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 222 public: | 182 public: |
| 223 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 183 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 224 : file_(file), memory_(memory), size_(size) { } | 184 : file_(file), memory_(memory), size_(size) { } |
| 225 virtual ~PosixMemoryMappedFile(); | 185 virtual ~PosixMemoryMappedFile(); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 limit_mutex = CreateMutex(); | 643 limit_mutex = CreateMutex(); |
| 684 } | 644 } |
| 685 | 645 |
| 686 | 646 |
| 687 void OS::TearDown() { | 647 void OS::TearDown() { |
| 688 delete limit_mutex; | 648 delete limit_mutex; |
| 689 } | 649 } |
| 690 | 650 |
| 691 | 651 |
| 692 } } // namespace v8::internal | 652 } } // namespace v8::internal |
| OLD | NEW |