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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // determining that pointers are outside the heap (used mostly in assertions | 144 // determining that pointers are outside the heap (used mostly in assertions |
145 // and verification). The estimate is conservative, i.e., not all addresses in | 145 // and verification). The estimate is conservative, i.e., not all addresses in |
146 // 'allocated' space are actually allocated to our heap. The range is | 146 // 'allocated' space are actually allocated to our heap. The range is |
147 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 147 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
148 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 148 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
149 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 149 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
150 | 150 |
151 | 151 |
152 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 152 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
153 ASSERT(limit_mutex != NULL); | 153 ASSERT(limit_mutex != NULL); |
154 ScopedLock lock(limit_mutex); | 154 LockGuard<Mutex> lock_guard(limit_mutex); |
155 | 155 |
156 lowest_ever_allocated = Min(lowest_ever_allocated, address); | 156 lowest_ever_allocated = Min(lowest_ever_allocated, address); |
157 highest_ever_allocated = | 157 highest_ever_allocated = |
158 Max(highest_ever_allocated, | 158 Max(highest_ever_allocated, |
159 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 159 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 bool OS::IsOutsideAllocatedSpace(void* address) { | 163 bool OS::IsOutsideAllocatedSpace(void* address) { |
164 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 164 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 564 |
565 Semaphore* OS::CreateSemaphore(int count) { | 565 Semaphore* OS::CreateSemaphore(int count) { |
566 return new LinuxSemaphore(count); | 566 return new LinuxSemaphore(count); |
567 } | 567 } |
568 | 568 |
569 | 569 |
570 void OS::SetUp() { | 570 void OS::SetUp() { |
571 // Seed the random number generator. We preserve microsecond resolution. | 571 // Seed the random number generator. We preserve microsecond resolution. |
572 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()) ^ (getpid() << 16); | 572 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()) ^ (getpid() << 16); |
573 srandom(static_cast<unsigned int>(seed)); | 573 srandom(static_cast<unsigned int>(seed)); |
574 limit_mutex = CreateMutex(); | 574 limit_mutex = new Mutex(); |
575 } | 575 } |
576 | 576 |
577 | 577 |
578 void OS::TearDown() { | 578 void OS::TearDown() { |
579 delete limit_mutex; | 579 delete limit_mutex; |
580 } | 580 } |
581 | 581 |
582 | 582 |
583 } } // namespace v8::internal | 583 } } // namespace v8::internal |
OLD | NEW |