Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_INVALIDATED_SLOTS_INL_H
6 : #define V8_INVALIDATED_SLOTS_INL_H
7 :
8 : #include <map>
9 :
10 : #include "src/allocation.h"
11 : #include "src/heap/invalidated-slots.h"
12 : #include "src/heap/spaces.h"
13 : #include "src/objects-body-descriptors-inl.h"
14 : #include "src/objects-body-descriptors.h"
15 : #include "src/objects.h"
16 :
17 : namespace v8 {
18 : namespace internal {
19 :
20 10418954 : bool InvalidatedSlotsFilter::IsValid(Address slot) {
21 : #ifdef DEBUG
22 : DCHECK_LT(slot, sentinel_);
23 : // Slots must come in non-decreasing order.
24 : DCHECK_LE(last_slot_, slot);
25 : last_slot_ = slot;
26 : #endif
27 20880983 : while (slot >= invalidated_end_) {
28 : ++iterator_;
29 43075 : if (iterator_ != iterator_end_) {
30 : // Invalidated ranges must not overlap.
31 : DCHECK_LE(invalidated_end_, iterator_->first->address());
32 42956 : invalidated_start_ = iterator_->first->address();
33 42956 : invalidated_end_ = invalidated_start_ + iterator_->second;
34 42956 : invalidated_object_ = nullptr;
35 42956 : invalidated_object_size_ = 0;
36 : } else {
37 119 : invalidated_start_ = sentinel_;
38 119 : invalidated_end_ = sentinel_;
39 : }
40 : }
41 : // Now the invalidated region ends after the slot.
42 10418955 : if (slot < invalidated_start_) {
43 : // The invalidated region starts after the slot.
44 : return true;
45 : }
46 : // The invalidated region includes the slot.
47 : // Ask the object if the slot is valid.
48 1268858 : if (invalidated_object_ == nullptr) {
49 42496 : invalidated_object_ = HeapObject::FromAddress(invalidated_start_);
50 : invalidated_object_size_ =
51 42496 : invalidated_object_->SizeFromMap(invalidated_object_->map());
52 : }
53 1268858 : int offset = static_cast<int>(slot - invalidated_start_);
54 : DCHECK_GT(offset, 0);
55 : DCHECK_LE(invalidated_object_size_,
56 : static_cast<int>(invalidated_end_ - invalidated_start_));
57 :
58 1268858 : if (offset >= invalidated_object_size_) {
59 : // A new object could have been allocated during evacuation in the free
60 : // space outside the object. Since objects are not invalidated in GC pause
61 : // we can return true here.
62 : return true;
63 : }
64 906338 : return invalidated_object_->IsValidSlot(offset);
65 : }
66 :
67 : } // namespace internal
68 : } // namespace v8
69 :
70 : #endif // V8_INVALIDATED_SLOTS_INL_H
|