| 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 20 matching lines...) Expand all Loading... |
| 31 #include <pthread.h> | 31 #include <pthread.h> |
| 32 #include <semaphore.h> | 32 #include <semaphore.h> |
| 33 #include <signal.h> | 33 #include <signal.h> |
| 34 #include <sys/prctl.h> | 34 #include <sys/prctl.h> |
| 35 #include <sys/time.h> | 35 #include <sys/time.h> |
| 36 #include <sys/resource.h> | 36 #include <sys/resource.h> |
| 37 #include <sys/syscall.h> | 37 #include <sys/syscall.h> |
| 38 #include <sys/types.h> | 38 #include <sys/types.h> |
| 39 #include <stdlib.h> | 39 #include <stdlib.h> |
| 40 | 40 |
| 41 #if defined(__GLIBC__) && !defined(__UCLIBC__) | |
| 42 #include <execinfo.h> | |
| 43 #include <cxxabi.h> | |
| 44 #endif | |
| 45 | |
| 46 // Ubuntu Dapper requires memory pages to be marked as | 41 // Ubuntu Dapper requires memory pages to be marked as |
| 47 // executable. Otherwise, OS raises an exception when executing code | 42 // executable. Otherwise, OS raises an exception when executing code |
| 48 // in that page. | 43 // in that page. |
| 49 #include <sys/types.h> // mmap & munmap | 44 #include <sys/types.h> // mmap & munmap |
| 50 #include <sys/mman.h> // mmap & munmap | 45 #include <sys/mman.h> // mmap & munmap |
| 51 #include <sys/stat.h> // open | 46 #include <sys/stat.h> // open |
| 52 #include <fcntl.h> // open | 47 #include <fcntl.h> // open |
| 53 #include <unistd.h> // sysconf | 48 #include <unistd.h> // sysconf |
| 54 #include <strings.h> // index | 49 #include <strings.h> // index |
| 55 #include <errno.h> | 50 #include <errno.h> |
| 56 #include <stdarg.h> | 51 #include <stdarg.h> |
| 57 | 52 |
| 58 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | 53 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. |
| 59 // Old versions of the C library <signal.h> didn't define the type. | 54 // Old versions of the C library <signal.h> didn't define the type. |
| 60 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |
| 61 (defined(__arm__) || defined(__aarch64__)) && \ | 56 (defined(__arm__) || defined(__aarch64__)) && \ |
| 62 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 57 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
| 63 #include <asm/sigcontext.h> | 58 #include <asm/sigcontext.h> |
| 64 #endif | 59 #endif |
| 65 | 60 |
| 66 #undef MAP_TYPE | 61 #undef MAP_TYPE |
| 67 | 62 |
| 68 #include "v8.h" | 63 #include "v8.h" |
| 69 | 64 |
| 70 #include "platform-posix.h" | |
| 71 #include "platform.h" | 65 #include "platform.h" |
| 72 #include "v8threads.h" | 66 #include "v8threads.h" |
| 73 #include "vm-state-inl.h" | 67 #include "vm-state-inl.h" |
| 74 | 68 |
| 75 | 69 |
| 76 namespace v8 { | 70 namespace v8 { |
| 77 namespace internal { | 71 namespace internal { |
| 78 | 72 |
| 79 | 73 |
| 80 #ifdef __arm__ | 74 #ifdef __arm__ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (mbase == MAP_FAILED) { | 142 if (mbase == MAP_FAILED) { |
| 149 LOG(i::Isolate::Current(), | 143 LOG(i::Isolate::Current(), |
| 150 StringEvent("OS::Allocate", "mmap failed")); | 144 StringEvent("OS::Allocate", "mmap failed")); |
| 151 return NULL; | 145 return NULL; |
| 152 } | 146 } |
| 153 *allocated = msize; | 147 *allocated = msize; |
| 154 return mbase; | 148 return mbase; |
| 155 } | 149 } |
| 156 | 150 |
| 157 | 151 |
| 158 void OS::DumpBacktrace() { | |
| 159 // backtrace is a glibc extension. | |
| 160 #if defined(__GLIBC__) && !defined(__UCLIBC__) | |
| 161 POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace(); | |
| 162 #endif | |
| 163 } | |
| 164 | |
| 165 | |
| 166 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 152 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 167 public: | 153 public: |
| 168 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 154 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 169 : file_(file), memory_(memory), size_(size) { } | 155 : file_(file), memory_(memory), size_(size) { } |
| 170 virtual ~PosixMemoryMappedFile(); | 156 virtual ~PosixMemoryMappedFile(); |
| 171 virtual void* memory() { return memory_; } | 157 virtual void* memory() { return memory_; } |
| 172 virtual int size() { return size_; } | 158 virtual int size() { return size_; } |
| 173 private: | 159 private: |
| 174 FILE* file_; | 160 FILE* file_; |
| 175 void* memory_; | 161 void* memory_; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 436 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
| 451 return munmap(base, size) == 0; | 437 return munmap(base, size) == 0; |
| 452 } | 438 } |
| 453 | 439 |
| 454 | 440 |
| 455 bool VirtualMemory::HasLazyCommits() { | 441 bool VirtualMemory::HasLazyCommits() { |
| 456 return true; | 442 return true; |
| 457 } | 443 } |
| 458 | 444 |
| 459 } } // namespace v8::internal | 445 } } // namespace v8::internal |
| OLD | NEW |