| 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 10 matching lines...) Expand all  Loading... | 
|   21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |   21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
|   22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |   22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
|   23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |   23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
|   24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |   24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
|   25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |   25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
|   26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |   26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|   27  |   27  | 
|   28 // Platform specific code for Linux goes here. For the POSIX comaptible parts |   28 // Platform specific code for Linux goes here. For the POSIX comaptible parts | 
|   29 // the implementation is in platform-posix.cc. |   29 // the implementation is in platform-posix.cc. | 
|   30  |   30  | 
|   31 #include "platform.h" |  | 
|   32  |  | 
|   33 #include <pthread.h> |   31 #include <pthread.h> | 
|   34 #include <semaphore.h> |   32 #include <semaphore.h> | 
|   35 #include <signal.h> |   33 #include <signal.h> | 
|   36 #include <sys/prctl.h> |   34 #include <sys/prctl.h> | 
|   37 #include <sys/time.h> |   35 #include <sys/time.h> | 
|   38 #include <sys/resource.h> |   36 #include <sys/resource.h> | 
|   39 #include <sys/syscall.h> |   37 #include <sys/syscall.h> | 
|   40 #include <sys/types.h> |   38 #include <sys/types.h> | 
|   41 #include <stdlib.h> |   39 #include <stdlib.h> | 
|   42  |   40  | 
|   43 #if defined(__GLIBC__) && !defined(__UCLIBC__) |   41 #if defined(__GLIBC__) && !defined(__UCLIBC__) | 
|   44 #include <execinfo.h> |   42 #include <execinfo.h> | 
|   45 #include <cxxabi.h> |   43 #include <cxxabi.h> | 
|   46 #endif |   44 #endif | 
|   47  |   45  | 
|   48 // Ubuntu Dapper requires memory pages to be marked as |   46 // Ubuntu Dapper requires memory pages to be marked as | 
|   49 // executable. Otherwise, OS raises an exception when executing code |   47 // executable. Otherwise, OS raises an exception when executing code | 
|   50 // in that page. |   48 // in that page. | 
|   51 #include <sys/types.h>  // mmap & munmap |   49 #include <sys/types.h>  // mmap & munmap | 
|   52 #include <sys/mman.h>   // mmap & munmap |   50 #include <sys/mman.h>   // mmap & munmap | 
|   53 #include <sys/stat.h>   // open |   51 #include <sys/stat.h>   // open | 
|   54 #include <fcntl.h>      // open |   52 #include <fcntl.h>      // open | 
|   55 #include <unistd.h>     // sysconf |   53 #include <unistd.h>     // sysconf | 
|   56 #include <strings.h>    // index |   54 #include <strings.h>    // index | 
|   57 #include <errno.h> |   55 #include <errno.h> | 
|   58 #include <stdarg.h> |   56 #include <stdarg.h> | 
|   59  |   57  | 
|   60 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. |   58 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | 
|   61 // Old versions of the C library <signal.h> didn't define the type. |   59 // Old versions of the C library <signal.h> didn't define the type. | 
|   62 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |   60 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 
|   63     V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |   61     defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 
|   64 #include <asm/sigcontext.h> |   62 #include <asm/sigcontext.h> | 
|   65 #endif |   63 #endif | 
|   66  |   64  | 
|   67 #undef MAP_TYPE |   65 #undef MAP_TYPE | 
|   68  |   66  | 
|   69 #include "v8.h" |   67 #include "v8.h" | 
|   70  |   68  | 
|   71 #include "platform-posix.h" |   69 #include "platform-posix.h" | 
 |   70 #include "platform.h" | 
|   72 #include "v8threads.h" |   71 #include "v8threads.h" | 
|   73 #include "vm-state-inl.h" |   72 #include "vm-state-inl.h" | 
|   74  |   73  | 
|   75  |   74  | 
|   76 namespace v8 { |   75 namespace v8 { | 
|   77 namespace internal { |   76 namespace internal { | 
|   78  |   77  | 
|   79  |   78  | 
|   80 static Mutex* limit_mutex = NULL; |   79 static Mutex* limit_mutex = NULL; | 
|   81  |   80  | 
|   82  |   81  | 
|   83 #if V8_HOST_ARCH_ARM |   82 #ifdef __arm__ | 
|   84 static bool CPUInfoContainsString(const char * search_string) { |   83 static bool CPUInfoContainsString(const char * search_string) { | 
|   85   const char* file_name = "/proc/cpuinfo"; |   84   const char* file_name = "/proc/cpuinfo"; | 
|   86   // This is written as a straight shot one pass parser |   85   // This is written as a straight shot one pass parser | 
|   87   // and not using STL string and ifstream because, |   86   // and not using STL string and ifstream because, | 
|   88   // on Linux, it's reading from a (non-mmap-able) |   87   // on Linux, it's reading from a (non-mmap-able) | 
|   89   // character special device. |   88   // character special device. | 
|   90   FILE* f = NULL; |   89   FILE* f = NULL; | 
|   91   const char* what = search_string; |   90   const char* what = search_string; | 
|   92  |   91  | 
|   93   if (NULL == (f = fopen(file_name, "r"))) { |   92   if (NULL == (f = fopen(file_name, "r"))) { | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  216  |  215  | 
|  217  |  216  | 
|  218 bool OS::ArmUsingHardFloat() { |  217 bool OS::ArmUsingHardFloat() { | 
|  219   // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify |  218   // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify | 
|  220   // the Floating Point ABI used (PCS stands for Procedure Call Standard). |  219   // the Floating Point ABI used (PCS stands for Procedure Call Standard). | 
|  221   // We use these as well as a couple of other defines to statically determine |  220   // We use these as well as a couple of other defines to statically determine | 
|  222   // what FP ABI used. |  221   // what FP ABI used. | 
|  223   // GCC versions 4.4 and below don't support hard-fp. |  222   // GCC versions 4.4 and below don't support hard-fp. | 
|  224   // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or |  223   // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or | 
|  225   // __ARM_PCS_VFP. |  224   // __ARM_PCS_VFP. | 
 |  225  | 
 |  226 #define GCC_VERSION (__GNUC__ * 10000                                          \ | 
 |  227                      + __GNUC_MINOR__ * 100                                    \ | 
 |  228                      + __GNUC_PATCHLEVEL__) | 
 |  229 #if GCC_VERSION >= 40600 | 
|  226 #if defined(__ARM_PCS_VFP) |  230 #if defined(__ARM_PCS_VFP) | 
|  227   return true; |  231   return true; | 
|  228 #elif V8_CC_GNU && (V8_GNUC_PREREQ(4, 6) || !V8_GNUC_PREREQ(4, 5)) |  232 #else | 
|  229   return false; |  233   return false; | 
 |  234 #endif | 
 |  235  | 
 |  236 #elif GCC_VERSION < 40500 | 
 |  237   return false; | 
 |  238  | 
 |  239 #else | 
 |  240 #if defined(__ARM_PCS_VFP) | 
 |  241   return true; | 
|  230 #elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__) |  242 #elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__) | 
|  231   return false; |  243   return false; | 
|  232 #else |  244 #else | 
|  233 #error "Your version of GCC does not report the FP ABI compiled for."          \ |  245 #error "Your version of GCC does not report the FP ABI compiled for."          \ | 
|  234        "Please report it on this issue"                                        \ |  246        "Please report it on this issue"                                        \ | 
|  235        "http://code.google.com/p/v8/issues/detail?id=2140" |  247        "http://code.google.com/p/v8/issues/detail?id=2140" | 
 |  248  | 
|  236 #endif |  249 #endif | 
 |  250 #endif | 
 |  251 #undef GCC_VERSION | 
|  237 } |  252 } | 
|  238  |  253  | 
|  239 #endif  // V8_HOST_ARCH_ARM |  254 #endif  // def __arm__ | 
|  240  |  255  | 
|  241  |  256  | 
|  242 #if V8_HOST_ARCH_MIPS |  257 #ifdef __mips__ | 
|  243 bool OS::MipsCpuHasFeature(CpuFeature feature) { |  258 bool OS::MipsCpuHasFeature(CpuFeature feature) { | 
|  244   const char* search_string = NULL; |  259   const char* search_string = NULL; | 
|  245   const char* file_name = "/proc/cpuinfo"; |  260   const char* file_name = "/proc/cpuinfo"; | 
|  246   // Simple detection of FPU at runtime for Linux. |  261   // Simple detection of FPU at runtime for Linux. | 
|  247   // It is based on /proc/cpuinfo, which reveals hardware configuration |  262   // It is based on /proc/cpuinfo, which reveals hardware configuration | 
|  248   // to user-space applications.  According to MIPS (early 2010), no similar |  263   // to user-space applications.  According to MIPS (early 2010), no similar | 
|  249   // facility is universally available on the MIPS architectures, |  264   // facility is universally available on the MIPS architectures, | 
|  250   // so it's up to individual OSes to provide such. |  265   // so it's up to individual OSes to provide such. | 
|  251   // |  266   // | 
|  252   // This is written as a straight shot one pass parser |  267   // This is written as a straight shot one pass parser | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  283       } else { |  298       } else { | 
|  284         what = search_string; |  299         what = search_string; | 
|  285       } |  300       } | 
|  286     } |  301     } | 
|  287   } |  302   } | 
|  288   fclose(f); |  303   fclose(f); | 
|  289  |  304  | 
|  290   // Did not find string in the proc file. |  305   // Did not find string in the proc file. | 
|  291   return false; |  306   return false; | 
|  292 } |  307 } | 
|  293 #endif  // V8_HOST_ARCH_MIPS |  308 #endif  // def __mips__ | 
|  294  |  309  | 
|  295  |  310  | 
|  296 const char* OS::LocalTimezone(double time) { |  311 const char* OS::LocalTimezone(double time) { | 
|  297   if (std::isnan(time)) return ""; |  312   if (std::isnan(time)) return ""; | 
|  298   time_t tv = static_cast<time_t>(floor(time/msPerSecond)); |  313   time_t tv = static_cast<time_t>(floor(time/msPerSecond)); | 
|  299   struct tm* t = localtime(&tv); |  314   struct tm* t = localtime(&tv); | 
|  300   if (NULL == t) return ""; |  315   if (NULL == t) return ""; | 
|  301   return t->tm_zone; |  316   return t->tm_zone; | 
|  302 } |  317 } | 
|  303  |  318  | 
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  745   limit_mutex = CreateMutex(); |  760   limit_mutex = CreateMutex(); | 
|  746 } |  761 } | 
|  747  |  762  | 
|  748  |  763  | 
|  749 void OS::TearDown() { |  764 void OS::TearDown() { | 
|  750   delete limit_mutex; |  765   delete limit_mutex; | 
|  751 } |  766 } | 
|  752  |  767  | 
|  753  |  768  | 
|  754 } }  // namespace v8::internal |  769 } }  // namespace v8::internal | 
| OLD | NEW |