Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 "-DUSE_EABI_HARDFLOAT\n"); | 127 "-DUSE_EABI_HARDFLOAT\n"); |
| 128 exit(1); | 128 exit(1); |
| 129 #endif | 129 #endif |
| 130 } | 130 } |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 135 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 136 #if(defined(__mips_hard_float) && __mips_hard_float != 0) | 136 #if(defined(__mips_hard_float) && __mips_hard_float != 0) |
| 137 // Here gcc is telling us that we are on an MIPS and gcc is assuming that we | 137 // Here gcc is telling us that we are on an MIPS and gcc is assuming that we |
|
Vyacheslav Egorov (Chromium)
2011/09/14 12:46:51
Accident edit?
Lasse Reichstein
2011/09/15 10:58:49
No edit visible to me?
| |
| 138 // have FPU instructions. If gcc can assume it then so can we. | 138 // have FPU instructions. If gcc can assume it then so can we. |
| 139 return 1u << FPU; | 139 return 1u << FPU; |
| 140 #else | 140 #else |
| 141 return 0; // Linux runs on anything. | 141 return 0; // Linux runs on anything. |
| 142 #endif | 142 #endif |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 #ifdef __arm__ | 146 #ifdef __arm__ |
| 147 static bool CPUInfoContainsString(const char * search_string) { | 147 static bool CPUInfoContainsString(const char * search_string) { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 #else // ndef __GLIBC__ | 600 #else // ndef __GLIBC__ |
| 601 return 0; | 601 return 0; |
| 602 #endif // ndef __GLIBC__ | 602 #endif // ndef __GLIBC__ |
| 603 } | 603 } |
| 604 | 604 |
| 605 | 605 |
| 606 // Constants used for mmap. | 606 // Constants used for mmap. |
| 607 static const int kMmapFd = -1; | 607 static const int kMmapFd = -1; |
| 608 static const int kMmapFdOffset = 0; | 608 static const int kMmapFdOffset = 0; |
| 609 | 609 |
| 610 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | |
| 610 | 611 |
| 611 VirtualMemory::VirtualMemory(size_t size) { | 612 VirtualMemory::VirtualMemory(size_t size) { |
| 612 address_ = ReserveRegion(size); | 613 address_ = ReserveRegion(size); |
| 613 size_ = size; | 614 size_ = size; |
| 614 } | 615 } |
| 615 | 616 |
| 616 | 617 |
| 618 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | |
| 619 : address_(NULL), size_(0) { | |
| 620 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | |
| 621 size_t request_size = RoundUp(size + alignment, | |
| 622 static_cast<intptr_t>(OS::AllocateAlignment())); | |
| 623 void* reservation = mmap(GetRandomMmapAddr(), | |
| 624 request_size, | |
| 625 PROT_NONE, | |
| 626 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | |
| 627 kMmapFd, | |
| 628 kMmapFdOffset); | |
| 629 if (reservation == MAP_FAILED) return; | |
| 630 Address base = static_cast<Address>(reservation); | |
| 631 Address aligned_base = RoundUp(base, alignment); | |
| 632 ASSERT(base <= aligned_base); | |
| 633 | |
| 634 // Unmap extra memory reserved before and after the desired block. | |
| 635 size_t bytes_prior = static_cast<size_t>(aligned_base - base); | |
| 636 if (bytes_prior > 0) { | |
| 637 munmap(base, bytes_prior); | |
| 638 } | |
| 639 if (static_cast<size_t>(aligned_base - base) < request_size - size) { | |
| 640 munmap(aligned_base + size, request_size - size - bytes_prior); | |
| 641 } | |
| 642 | |
| 643 address_ = static_cast<void*>(aligned_base); | |
| 644 size_ = size; | |
| 645 | |
| 646 address_ = reservation; | |
| 647 size_ = request_size; | |
| 648 } | |
| 649 | |
| 650 | |
| 617 VirtualMemory::~VirtualMemory() { | 651 VirtualMemory::~VirtualMemory() { |
| 618 if (IsReserved()) { | 652 if (IsReserved()) { |
| 619 if (ReleaseRegion(address(), size())) address_ = NULL; | 653 bool result = ReleaseRegion(address(), size()); |
| 654 ASSERT(result); | |
| 655 USE(result); | |
| 620 } | 656 } |
| 621 } | 657 } |
| 622 | 658 |
| 623 | 659 |
| 624 bool VirtualMemory::IsReserved() { | 660 bool VirtualMemory::IsReserved() { |
| 625 return address_ != NULL; | 661 return address_ != NULL; |
| 626 } | 662 } |
| 627 | 663 |
| 628 | 664 |
| 665 void VirtualMemory::Reset() { | |
| 666 address_ = NULL; | |
| 667 size_ = 0; | |
| 668 } | |
| 669 | |
| 670 | |
| 629 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { | 671 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { |
| 630 return CommitRegion(address, size, is_executable); | 672 return CommitRegion(address, size, is_executable); |
| 631 } | 673 } |
| 632 | 674 |
| 633 | 675 |
| 634 bool VirtualMemory::Uncommit(void* address, size_t size) { | 676 bool VirtualMemory::Uncommit(void* address, size_t size) { |
| 635 return UncommitRegion(address, size); | 677 return UncommitRegion(address, size); |
| 636 } | 678 } |
| 637 | 679 |
| 638 | 680 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1179 | 1221 |
| 1180 | 1222 |
| 1181 void Sampler::Stop() { | 1223 void Sampler::Stop() { |
| 1182 ASSERT(IsActive()); | 1224 ASSERT(IsActive()); |
| 1183 SignalSender::RemoveActiveSampler(this); | 1225 SignalSender::RemoveActiveSampler(this); |
| 1184 SetActive(false); | 1226 SetActive(false); |
| 1185 } | 1227 } |
| 1186 | 1228 |
| 1187 | 1229 |
| 1188 } } // namespace v8::internal | 1230 } } // namespace v8::internal |
| OLD | NEW |