| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 | 88 |
| 89 double ceiling(double x) { | 89 double ceiling(double x) { |
| 90 return ceil(x); | 90 return ceil(x); |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 static Mutex* limit_mutex = NULL; | 94 static Mutex* limit_mutex = NULL; |
| 95 | 95 |
| 96 | 96 |
| 97 void OS::PostSetUp() { | |
| 98 POSIXPostSetUp(); | |
| 99 } | |
| 100 | |
| 101 | |
| 102 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 97 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 103 return 0; // Solaris runs on a lot of things. | 98 return 0; // Solaris runs on a lot of things. |
| 104 } | 99 } |
| 105 | 100 |
| 106 | 101 |
| 107 int OS::ActivationFrameAlignment() { | 102 int OS::ActivationFrameAlignment() { |
| 108 // GCC generates code that requires 16 byte alignment such as movdqa. | 103 // GCC generates code that requires 16 byte alignment such as movdqa. |
| 109 return Max(STACK_ALIGN, 16); | 104 return Max(STACK_ALIGN, 16); |
| 110 } | 105 } |
| 111 | 106 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 Max(highest_ever_allocated, | 138 Max(highest_ever_allocated, |
| 144 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 139 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
| 145 } | 140 } |
| 146 | 141 |
| 147 | 142 |
| 148 bool OS::IsOutsideAllocatedSpace(void* address) { | 143 bool OS::IsOutsideAllocatedSpace(void* address) { |
| 149 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 144 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
| 150 } | 145 } |
| 151 | 146 |
| 152 | 147 |
| 153 size_t OS::AllocateAlignment() { | |
| 154 return static_cast<size_t>(getpagesize()); | |
| 155 } | |
| 156 | |
| 157 | |
| 158 void* OS::Allocate(const size_t requested, | 148 void* OS::Allocate(const size_t requested, |
| 159 size_t* allocated, | 149 size_t* allocated, |
| 160 bool is_executable) { | 150 bool is_executable) { |
| 161 const size_t msize = RoundUp(requested, getpagesize()); | 151 const size_t msize = RoundUp(requested, getpagesize()); |
| 162 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 152 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 163 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); | 153 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); |
| 164 | 154 |
| 165 if (mbase == MAP_FAILED) { | 155 if (mbase == MAP_FAILED) { |
| 166 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); | 156 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); |
| 167 return NULL; | 157 return NULL; |
| 168 } | 158 } |
| 169 *allocated = msize; | 159 *allocated = msize; |
| 170 UpdateAllocatedSpaceLimits(mbase, msize); | 160 UpdateAllocatedSpaceLimits(mbase, msize); |
| 171 return mbase; | 161 return mbase; |
| 172 } | 162 } |
| 173 | 163 |
| 174 | 164 |
| 175 void OS::Free(void* address, const size_t size) { | |
| 176 // TODO(1240712): munmap has a return value which is ignored here. | |
| 177 int result = munmap(address, size); | |
| 178 USE(result); | |
| 179 ASSERT(result == 0); | |
| 180 } | |
| 181 | |
| 182 | |
| 183 void OS::Sleep(int milliseconds) { | |
| 184 useconds_t ms = static_cast<useconds_t>(milliseconds); | |
| 185 usleep(1000 * ms); | |
| 186 } | |
| 187 | |
| 188 | |
| 189 int OS::NumberOfCores() { | |
| 190 return sysconf(_SC_NPROCESSORS_ONLN); | |
| 191 } | |
| 192 | |
| 193 | |
| 194 void OS::Abort() { | |
| 195 // Redirect to std abort to signal abnormal program termination. | |
| 196 abort(); | |
| 197 } | |
| 198 | |
| 199 | |
| 200 void OS::DebugBreak() { | |
| 201 asm("int $3"); | |
| 202 } | |
| 203 | |
| 204 | |
| 205 void OS::DumpBacktrace() { | 165 void OS::DumpBacktrace() { |
| 206 // Currently unsupported. | 166 // Currently unsupported. |
| 207 } | 167 } |
| 208 | 168 |
| 209 | 169 |
| 210 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 170 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 211 public: | 171 public: |
| 212 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 172 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 213 : file_(file), memory_(memory), size_(size) { } | 173 : file_(file), memory_(memory), size_(size) { } |
| 214 virtual ~PosixMemoryMappedFile(); | 174 virtual ~PosixMemoryMappedFile(); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 limit_mutex = CreateMutex(); | 587 limit_mutex = CreateMutex(); |
| 628 } | 588 } |
| 629 | 589 |
| 630 | 590 |
| 631 void OS::TearDown() { | 591 void OS::TearDown() { |
| 632 delete limit_mutex; | 592 delete limit_mutex; |
| 633 } | 593 } |
| 634 | 594 |
| 635 | 595 |
| 636 } } // namespace v8::internal | 596 } } // namespace v8::internal |
| OLD | NEW |