OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 13863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13874 int entry = SearchOptimizedCodeMapEntry(native_context); | 13874 int entry = SearchOptimizedCodeMapEntry(native_context); |
13875 if (entry != kNotFound) { | 13875 if (entry != kNotFound) { |
13876 FixedArray* code_map = optimized_code_map(); | 13876 FixedArray* code_map = optimized_code_map(); |
13877 DCHECK_LE(entry + kEntryLength, code_map->length()); | 13877 DCHECK_LE(entry + kEntryLength, code_map->length()); |
13878 WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset)); | 13878 WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset)); |
13879 result = cell->cleared() ? nullptr : Code::cast(cell->value()); | 13879 result = cell->cleared() ? nullptr : Code::cast(cell->value()); |
13880 } | 13880 } |
13881 return result; | 13881 return result; |
13882 } | 13882 } |
13883 | 13883 |
13884 | 13884 void ObjectVisitor::VisitCodeTarget(Code* host, RelocInfo* rinfo) { |
13885 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { | |
13886 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 13885 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
13887 Object* old_pointer = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 13886 Object* old_pointer = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
13888 Object* new_pointer = old_pointer; | 13887 Object* new_pointer = old_pointer; |
13889 VisitPointer(&new_pointer); | 13888 VisitPointer(host, &new_pointer); |
13890 DCHECK_EQ(old_pointer, new_pointer); | 13889 DCHECK_EQ(old_pointer, new_pointer); |
13891 } | 13890 } |
13892 | 13891 |
13893 | 13892 void ObjectVisitor::VisitCodeAgeSequence(Code* host, RelocInfo* rinfo) { |
13894 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) { | |
13895 DCHECK(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); | 13893 DCHECK(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); |
13896 Object* old_pointer = rinfo->code_age_stub(); | 13894 Object* old_pointer = rinfo->code_age_stub(); |
13897 Object* new_pointer = old_pointer; | 13895 Object* new_pointer = old_pointer; |
13898 if (old_pointer != nullptr) { | 13896 if (old_pointer != nullptr) { |
13899 VisitPointer(&new_pointer); | 13897 VisitPointer(host, &new_pointer); |
13900 DCHECK_EQ(old_pointer, new_pointer); | 13898 DCHECK_EQ(old_pointer, new_pointer); |
13901 } | 13899 } |
13902 } | 13900 } |
13903 | 13901 |
13904 | 13902 void ObjectVisitor::VisitCodeEntry(JSFunction* host, Address entry_address) { |
13905 void ObjectVisitor::VisitCodeEntry(Address entry_address) { | |
13906 Object* old_pointer = Code::GetObjectFromEntryAddress(entry_address); | 13903 Object* old_pointer = Code::GetObjectFromEntryAddress(entry_address); |
13907 Object* new_pointer = old_pointer; | 13904 Object* new_pointer = old_pointer; |
13908 VisitPointer(&new_pointer); | 13905 VisitPointer(host, &new_pointer); |
13909 DCHECK_EQ(old_pointer, new_pointer); | 13906 DCHECK_EQ(old_pointer, new_pointer); |
13910 } | 13907 } |
13911 | 13908 |
13912 | 13909 void ObjectVisitor::VisitCellPointer(Code* host, RelocInfo* rinfo) { |
13913 void ObjectVisitor::VisitCell(RelocInfo* rinfo) { | |
13914 DCHECK(rinfo->rmode() == RelocInfo::CELL); | 13910 DCHECK(rinfo->rmode() == RelocInfo::CELL); |
13915 Object* old_pointer = rinfo->target_cell(); | 13911 Object* old_pointer = rinfo->target_cell(); |
13916 Object* new_pointer = old_pointer; | 13912 Object* new_pointer = old_pointer; |
13917 VisitPointer(&new_pointer); | 13913 VisitPointer(host, &new_pointer); |
13918 DCHECK_EQ(old_pointer, new_pointer); | 13914 DCHECK_EQ(old_pointer, new_pointer); |
13919 } | 13915 } |
13920 | 13916 |
13921 | 13917 void ObjectVisitor::VisitDebugTarget(Code* host, RelocInfo* rinfo) { |
13922 void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) { | |
13923 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 13918 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
13924 rinfo->IsPatchedDebugBreakSlotSequence()); | 13919 rinfo->IsPatchedDebugBreakSlotSequence()); |
13925 Object* old_pointer = | 13920 Object* old_pointer = |
13926 Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); | 13921 Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); |
13927 Object* new_pointer = old_pointer; | 13922 Object* new_pointer = old_pointer; |
13928 VisitPointer(&new_pointer); | 13923 VisitPointer(host, &new_pointer); |
13929 DCHECK_EQ(old_pointer, new_pointer); | 13924 DCHECK_EQ(old_pointer, new_pointer); |
13930 } | 13925 } |
13931 | 13926 |
13932 | 13927 void ObjectVisitor::VisitEmbeddedPointer(Code* host, RelocInfo* rinfo) { |
13933 void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) { | |
13934 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 13928 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
13935 Object* old_pointer = rinfo->target_object(); | 13929 Object* old_pointer = rinfo->target_object(); |
13936 Object* new_pointer = old_pointer; | 13930 Object* new_pointer = old_pointer; |
13937 VisitPointer(&new_pointer); | 13931 VisitPointer(host, &new_pointer); |
13938 DCHECK_EQ(old_pointer, new_pointer); | 13932 DCHECK_EQ(old_pointer, new_pointer); |
13939 } | 13933 } |
13940 | 13934 |
13941 | 13935 |
13942 void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) { | |
13943 Address old_reference = rinfo->target_external_reference(); | |
13944 Address new_reference = old_reference; | |
13945 VisitExternalReference(&new_reference); | |
13946 DCHECK_EQ(old_reference, new_reference); | |
13947 } | |
13948 | |
13949 | |
13950 void Code::InvalidateRelocation() { | 13936 void Code::InvalidateRelocation() { |
13951 InvalidateEmbeddedObjects(); | 13937 InvalidateEmbeddedObjects(); |
13952 set_relocation_info(GetHeap()->empty_byte_array()); | 13938 set_relocation_info(GetHeap()->empty_byte_array()); |
13953 } | 13939 } |
13954 | 13940 |
13955 | 13941 |
13956 void Code::InvalidateEmbeddedObjects() { | 13942 void Code::InvalidateEmbeddedObjects() { |
13957 HeapObject* undefined = GetHeap()->undefined_value(); | 13943 HeapObject* undefined = GetHeap()->undefined_value(); |
13958 Cell* undefined_cell = GetHeap()->undefined_cell(); | 13944 Cell* undefined_cell = GetHeap()->undefined_cell(); |
13959 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 13945 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
(...skipping 6693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20653 // depend on this. | 20639 // depend on this. |
20654 return DICTIONARY_ELEMENTS; | 20640 return DICTIONARY_ELEMENTS; |
20655 } | 20641 } |
20656 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20642 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20657 return kind; | 20643 return kind; |
20658 } | 20644 } |
20659 } | 20645 } |
20660 | 20646 |
20661 } // namespace internal | 20647 } // namespace internal |
20662 } // namespace v8 | 20648 } // namespace v8 |
OLD | NEW |