| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // 0 is never a valid thread id on Linux since tids and pids share a | 65 // 0 is never a valid thread id on Linux since tids and pids share a |
| 66 // name space and pid 0 is reserved (see man 2 kill). | 66 // name space and pid 0 is reserved (see man 2 kill). |
| 67 static const pthread_t kNoThread = (pthread_t) 0; | 67 static const pthread_t kNoThread = (pthread_t) 0; |
| 68 | 68 |
| 69 | 69 |
| 70 double ceiling(double x) { | 70 double ceiling(double x) { |
| 71 return ceil(x); | 71 return ceil(x); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 static Mutex* limit_mutex = NULL; |
| 76 |
| 77 |
| 75 void OS::Setup() { | 78 void OS::Setup() { |
| 76 // Seed the random number generator. | 79 // Seed the random number generator. |
| 77 // Convert the current time to a 64-bit integer first, before converting it | 80 // Convert the current time to a 64-bit integer first, before converting it |
| 78 // to an unsigned. Going directly can cause an overflow and the seed to be | 81 // to an unsigned. Going directly can cause an overflow and the seed to be |
| 79 // set to all ones. The seed will be identical for different instances that | 82 // set to all ones. The seed will be identical for different instances that |
| 80 // call this setup code within the same millisecond. | 83 // call this setup code within the same millisecond. |
| 81 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 84 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| 82 srandom(static_cast<unsigned int>(seed)); | 85 srandom(static_cast<unsigned int>(seed)); |
| 86 limit_mutex = CreateMutex(); |
| 83 } | 87 } |
| 84 | 88 |
| 85 | 89 |
| 86 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 90 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 87 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) | 91 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) |
| 88 // Here gcc is telling us that we are on an ARM and gcc is assuming that we | 92 // Here gcc is telling us that we are on an ARM and gcc is assuming that we |
| 89 // have VFP3 instructions. If gcc can assume it then so can we. | 93 // have VFP3 instructions. If gcc can assume it then so can we. |
| 90 return 1u << VFP3; | 94 return 1u << VFP3; |
| 91 #elif CAN_USE_ARMV7_INSTRUCTIONS | 95 #elif CAN_USE_ARMV7_INSTRUCTIONS |
| 92 return 1u << ARMv7; | 96 return 1u << ARMv7; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // We keep the lowest and highest addresses mapped as a quick way of | 212 // We keep the lowest and highest addresses mapped as a quick way of |
| 209 // determining that pointers are outside the heap (used mostly in assertions | 213 // determining that pointers are outside the heap (used mostly in assertions |
| 210 // and verification). The estimate is conservative, ie, not all addresses in | 214 // and verification). The estimate is conservative, ie, not all addresses in |
| 211 // 'allocated' space are actually allocated to our heap. The range is | 215 // 'allocated' space are actually allocated to our heap. The range is |
| 212 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 216 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
| 213 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 217 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
| 214 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 218 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
| 215 | 219 |
| 216 | 220 |
| 217 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 221 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
| 222 ASSERT(limit_mutex != NULL); |
| 223 ScopedLock lock(limit_mutex); |
| 224 |
| 218 lowest_ever_allocated = Min(lowest_ever_allocated, address); | 225 lowest_ever_allocated = Min(lowest_ever_allocated, address); |
| 219 highest_ever_allocated = | 226 highest_ever_allocated = |
| 220 Max(highest_ever_allocated, | 227 Max(highest_ever_allocated, |
| 221 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 228 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
| 222 } | 229 } |
| 223 | 230 |
| 224 | 231 |
| 225 bool OS::IsOutsideAllocatedSpace(void* address) { | 232 bool OS::IsOutsideAllocatedSpace(void* address) { |
| 226 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 233 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
| 227 } | 234 } |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 861 |
| 855 // This sampler is no longer the active sampler. | 862 // This sampler is no longer the active sampler. |
| 856 active_sampler_ = NULL; | 863 active_sampler_ = NULL; |
| 857 active_ = false; | 864 active_ = false; |
| 858 } | 865 } |
| 859 | 866 |
| 860 | 867 |
| 861 #endif // ENABLE_LOGGING_AND_PROFILING | 868 #endif // ENABLE_LOGGING_AND_PROFILING |
| 862 | 869 |
| 863 } } // namespace v8::internal | 870 } } // namespace v8::internal |
| OLD | NEW |