OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4900 case MAP_SPACE: | 4900 case MAP_SPACE: |
4901 return map_space_->Contains(addr); | 4901 return map_space_->Contains(addr); |
4902 case LO_SPACE: | 4902 case LO_SPACE: |
4903 return lo_space_->SlowContains(addr); | 4903 return lo_space_->SlowContains(addr); |
4904 } | 4904 } |
4905 UNREACHABLE(); | 4905 UNREACHABLE(); |
4906 return false; | 4906 return false; |
4907 } | 4907 } |
4908 | 4908 |
4909 | 4909 |
4910 bool Heap::RootIsImmortalImmovable(int root_index) { | 4910 // static |
4911 switch (root_index) { | 4911 bool Heap::RootIsImmortalImmovable(RootListIndex index) { |
4912 #define CASE(name) \ | 4912 // Heap roots that are known to be immortal immovable, for which we can safely |
4913 case Heap::k##name##RootIndex: \ | 4913 // skip write barriers. This list is not complete and has omissions. |
4914 return true; | 4914 switch (index) { |
4915 IMMORTAL_IMMOVABLE_ROOT_LIST(CASE); | 4915 case Heap::kByteArrayMapRootIndex: |
4916 #undef CASE | 4916 case Heap::kFreeSpaceMapRootIndex: |
| 4917 case Heap::kOnePointerFillerMapRootIndex: |
| 4918 case Heap::kTwoPointerFillerMapRootIndex: |
| 4919 case Heap::kUndefinedValueRootIndex: |
| 4920 case Heap::kTheHoleValueRootIndex: |
| 4921 case Heap::kNullValueRootIndex: |
| 4922 case Heap::kTrueValueRootIndex: |
| 4923 case Heap::kFalseValueRootIndex: |
| 4924 case Heap::kUninitializedValueRootIndex: |
| 4925 case Heap::kCellMapRootIndex: |
| 4926 case Heap::kGlobalPropertyCellMapRootIndex: |
| 4927 case Heap::kSharedFunctionInfoMapRootIndex: |
| 4928 case Heap::kMetaMapRootIndex: |
| 4929 case Heap::kHeapNumberMapRootIndex: |
| 4930 case Heap::kMutableHeapNumberMapRootIndex: |
| 4931 case Heap::kFloat32x4MapRootIndex: |
| 4932 case Heap::kNativeContextMapRootIndex: |
| 4933 case Heap::kFixedArrayMapRootIndex: |
| 4934 case Heap::kCodeMapRootIndex: |
| 4935 case Heap::kScopeInfoMapRootIndex: |
| 4936 case Heap::kFixedCOWArrayMapRootIndex: |
| 4937 case Heap::kFixedDoubleArrayMapRootIndex: |
| 4938 case Heap::kWeakCellMapRootIndex: |
| 4939 case Heap::kNoInterceptorResultSentinelRootIndex: |
| 4940 case Heap::kHashTableMapRootIndex: |
| 4941 case Heap::kOrderedHashTableMapRootIndex: |
| 4942 case Heap::kEmptyFixedArrayRootIndex: |
| 4943 case Heap::kEmptyByteArrayRootIndex: |
| 4944 case Heap::kEmptyDescriptorArrayRootIndex: |
| 4945 case Heap::kArgumentsMarkerRootIndex: |
| 4946 case Heap::kSymbolMapRootIndex: |
| 4947 case Heap::kSloppyArgumentsElementsMapRootIndex: |
| 4948 case Heap::kFunctionContextMapRootIndex: |
| 4949 case Heap::kCatchContextMapRootIndex: |
| 4950 case Heap::kWithContextMapRootIndex: |
| 4951 case Heap::kBlockContextMapRootIndex: |
| 4952 case Heap::kModuleContextMapRootIndex: |
| 4953 case Heap::kScriptContextMapRootIndex: |
| 4954 case Heap::kUndefinedMapRootIndex: |
| 4955 case Heap::kTheHoleMapRootIndex: |
| 4956 case Heap::kNullMapRootIndex: |
| 4957 case Heap::kBooleanMapRootIndex: |
| 4958 case Heap::kUninitializedMapRootIndex: |
| 4959 case Heap::kArgumentsMarkerMapRootIndex: |
| 4960 case Heap::kJSMessageObjectMapRootIndex: |
| 4961 case Heap::kForeignMapRootIndex: |
| 4962 case Heap::kNeanderMapRootIndex: |
| 4963 case Heap::kempty_stringRootIndex: |
| 4964 #define STRING_INDEX_DECLARATION(Name, str) case Heap::k##Name##RootIndex: |
| 4965 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) |
| 4966 #undef STRING_INDEX_DECLARATION |
| 4967 #define SYMBOL_INDEX_DECLARATION(Name) case Heap::k##Name##RootIndex: |
| 4968 PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
| 4969 #undef SYMBOL_INDEX_DECLARATION |
| 4970 #define STRING_TYPE_INDEX_DECLARATION(NAME, size, name, Name) \ |
| 4971 case Heap::k##Name##MapRootIndex: |
| 4972 STRING_TYPE_LIST(STRING_TYPE_INDEX_DECLARATION) |
| 4973 #undef STRING_TYPE_INDEX_DECLARATION |
| 4974 return true; |
4917 default: | 4975 default: |
4918 return false; | 4976 return false; |
4919 } | 4977 } |
4920 } | 4978 } |
4921 | 4979 |
4922 | 4980 |
4923 bool Heap::GetRootListIndex(Handle<HeapObject> object, | 4981 bool Heap::GetRootListIndex(Object* object, RootListIndex* index_return) const { |
4924 Heap::RootListIndex* index_return) { | 4982 for (size_t i = 0; i < arraysize(roots_); ++i) { |
4925 Object* ptr = *object; | 4983 if (roots_[i] == object) { |
4926 #define IMMORTAL_IMMOVABLE_ROOT(Name) \ | 4984 *index_return = static_cast<RootListIndex>(i); |
4927 if (ptr == roots_[Heap::k##Name##RootIndex]) { \ | 4985 return true; |
4928 *index_return = k##Name##RootIndex; \ | 4986 } |
4929 return true; \ | |
4930 } | 4987 } |
4931 IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT) | |
4932 #undef IMMORTAL_IMMOVABLE_ROOT | |
4933 return false; | 4988 return false; |
4934 } | 4989 } |
4935 | 4990 |
4936 | 4991 |
4937 #ifdef VERIFY_HEAP | 4992 #ifdef VERIFY_HEAP |
4938 void Heap::Verify() { | 4993 void Heap::Verify() { |
4939 CHECK(HasBeenSetUp()); | 4994 CHECK(HasBeenSetUp()); |
4940 HandleScope scope(isolate()); | 4995 HandleScope scope(isolate()); |
4941 | 4996 |
4942 store_buffer()->Verify(); | 4997 store_buffer()->Verify(); |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6630 *object_type = "CODE_TYPE"; \ | 6685 *object_type = "CODE_TYPE"; \ |
6631 *object_sub_type = "CODE_AGE/" #name; \ | 6686 *object_sub_type = "CODE_AGE/" #name; \ |
6632 return true; | 6687 return true; |
6633 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6688 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6634 #undef COMPARE_AND_RETURN_NAME | 6689 #undef COMPARE_AND_RETURN_NAME |
6635 } | 6690 } |
6636 return false; | 6691 return false; |
6637 } | 6692 } |
6638 } // namespace internal | 6693 } // namespace internal |
6639 } // namespace v8 | 6694 } // namespace v8 |
OLD | NEW |