| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
| 6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 class CodeRange { | 924 class CodeRange { |
| 925 public: | 925 public: |
| 926 explicit CodeRange(Isolate* isolate); | 926 explicit CodeRange(Isolate* isolate); |
| 927 ~CodeRange() { TearDown(); } | 927 ~CodeRange() { TearDown(); } |
| 928 | 928 |
| 929 // Reserves a range of virtual memory, but does not commit any of it. | 929 // Reserves a range of virtual memory, but does not commit any of it. |
| 930 // Can only be called once, at heap initialization time. | 930 // Can only be called once, at heap initialization time. |
| 931 // Returns false on failure. | 931 // Returns false on failure. |
| 932 bool SetUp(size_t requested_size); | 932 bool SetUp(size_t requested_size); |
| 933 | 933 |
| 934 // Frees the range of virtual memory, and frees the data structures used to | |
| 935 // manage it. | |
| 936 void TearDown(); | |
| 937 | |
| 938 bool valid() { return code_range_ != NULL; } | 934 bool valid() { return code_range_ != NULL; } |
| 939 Address start() { | 935 Address start() { |
| 940 DCHECK(valid()); | 936 DCHECK(valid()); |
| 941 return static_cast<Address>(code_range_->address()); | 937 return static_cast<Address>(code_range_->address()); |
| 942 } | 938 } |
| 943 size_t size() { | 939 size_t size() { |
| 944 DCHECK(valid()); | 940 DCHECK(valid()); |
| 945 return code_range_->size(); | 941 return code_range_->size(); |
| 946 } | 942 } |
| 947 bool contains(Address address) { | 943 bool contains(Address address) { |
| 948 if (!valid()) return false; | 944 if (!valid()) return false; |
| 949 Address start = static_cast<Address>(code_range_->address()); | 945 Address start = static_cast<Address>(code_range_->address()); |
| 950 return start <= address && address < start + code_range_->size(); | 946 return start <= address && address < start + code_range_->size(); |
| 951 } | 947 } |
| 952 | 948 |
| 953 // Allocates a chunk of memory from the large-object portion of | 949 // Allocates a chunk of memory from the large-object portion of |
| 954 // the code range. On platforms with no separate code range, should | 950 // the code range. On platforms with no separate code range, should |
| 955 // not be called. | 951 // not be called. |
| 956 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size, | 952 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size, |
| 957 const size_t commit_size, | 953 const size_t commit_size, |
| 958 size_t* allocated); | 954 size_t* allocated); |
| 959 bool CommitRawMemory(Address start, size_t length); | 955 bool CommitRawMemory(Address start, size_t length); |
| 960 bool UncommitRawMemory(Address start, size_t length); | 956 bool UncommitRawMemory(Address start, size_t length); |
| 961 void FreeRawMemory(Address buf, size_t length); | 957 void FreeRawMemory(Address buf, size_t length); |
| 962 | 958 |
| 963 void ReserveEmergencyBlock(); | 959 void ReserveEmergencyBlock(); |
| 964 void ReleaseEmergencyBlock(); | 960 void ReleaseEmergencyBlock(); |
| 965 | 961 |
| 966 private: | 962 private: |
| 963 // Frees the range of virtual memory, and frees the data structures used to |
| 964 // manage it. |
| 965 void TearDown(); |
| 966 |
| 967 Isolate* isolate_; | 967 Isolate* isolate_; |
| 968 | 968 |
| 969 // The reserved range of virtual memory that all code objects are put in. | 969 // The reserved range of virtual memory that all code objects are put in. |
| 970 base::VirtualMemory* code_range_; | 970 base::VirtualMemory* code_range_; |
| 971 // Plain old data class, just a struct plus a constructor. | 971 // Plain old data class, just a struct plus a constructor. |
| 972 class FreeBlock { | 972 class FreeBlock { |
| 973 public: | 973 public: |
| 974 FreeBlock() : start(0), size(0) {} | 974 FreeBlock() : start(0), size(0) {} |
| 975 FreeBlock(Address start_arg, size_t size_arg) | 975 FreeBlock(Address start_arg, size_t size_arg) |
| 976 : start(start_arg), size(size_arg) { | 976 : start(start_arg), size(size_arg) { |
| (...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 count = 0; | 2851 count = 0; |
| 2852 } | 2852 } |
| 2853 // Must be small, since an iteration is used for lookup. | 2853 // Must be small, since an iteration is used for lookup. |
| 2854 static const int kMaxComments = 64; | 2854 static const int kMaxComments = 64; |
| 2855 }; | 2855 }; |
| 2856 #endif | 2856 #endif |
| 2857 } | 2857 } |
| 2858 } // namespace v8::internal | 2858 } // namespace v8::internal |
| 2859 | 2859 |
| 2860 #endif // V8_HEAP_SPACES_H_ | 2860 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |