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 // static | 4910 bool Heap::RootIsImmortalImmovable(int root_index) { |
4911 bool Heap::RootIsImmortalImmovable(RootListIndex index) { | 4911 switch (root_index) { |
4912 // Heap roots that are known to be immortal immovable, for which we can safely | 4912 #define CASE(name) \ |
4913 // skip write barriers. This list is not complete and has omissions. | 4913 case Heap::k##name##RootIndex: \ |
4914 switch (index) { | 4914 return true; |
4915 case Heap::kByteArrayMapRootIndex: | 4915 IMMORTAL_IMMOVABLE_ROOT_LIST(CASE); |
4916 case Heap::kFreeSpaceMapRootIndex: | 4916 #undef CASE |
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; | |
4975 default: | 4917 default: |
4976 return false; | 4918 return false; |
4977 } | 4919 } |
4978 } | 4920 } |
4979 | 4921 |
4980 | 4922 |
4981 bool Heap::GetRootListIndex(Object* object, RootListIndex* index_return) const { | 4923 bool Heap::GetRootListIndex(Handle<HeapObject> object, |
4982 for (size_t i = 0; i < arraysize(roots_); ++i) { | 4924 Heap::RootListIndex* index_return) { |
4983 if (roots_[i] == object) { | 4925 Object* ptr = *object; |
4984 *index_return = static_cast<RootListIndex>(i); | 4926 #define IMMORTAL_IMMOVABLE_ROOT(Name) \ |
4985 return true; | 4927 if (ptr == roots_[Heap::k##Name##RootIndex]) { \ |
4986 } | 4928 *index_return = k##Name##RootIndex; \ |
| 4929 return true; \ |
4987 } | 4930 } |
| 4931 IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT) |
| 4932 #undef IMMORTAL_IMMOVABLE_ROOT |
4988 return false; | 4933 return false; |
4989 } | 4934 } |
4990 | 4935 |
4991 | 4936 |
4992 #ifdef VERIFY_HEAP | 4937 #ifdef VERIFY_HEAP |
4993 void Heap::Verify() { | 4938 void Heap::Verify() { |
4994 CHECK(HasBeenSetUp()); | 4939 CHECK(HasBeenSetUp()); |
4995 HandleScope scope(isolate()); | 4940 HandleScope scope(isolate()); |
4996 | 4941 |
4997 store_buffer()->Verify(); | 4942 store_buffer()->Verify(); |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6685 *object_type = "CODE_TYPE"; \ | 6630 *object_type = "CODE_TYPE"; \ |
6686 *object_sub_type = "CODE_AGE/" #name; \ | 6631 *object_sub_type = "CODE_AGE/" #name; \ |
6687 return true; | 6632 return true; |
6688 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6633 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6689 #undef COMPARE_AND_RETURN_NAME | 6634 #undef COMPARE_AND_RETURN_NAME |
6690 } | 6635 } |
6691 return false; | 6636 return false; |
6692 } | 6637 } |
6693 } // namespace internal | 6638 } // namespace internal |
6694 } // namespace v8 | 6639 } // namespace v8 |
OLD | NEW |