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_HEAP_INVALIDATED_SLOTS_H_
6 : #define V8_HEAP_INVALIDATED_SLOTS_H_
7 :
8 : #include <map>
9 : #include <stack>
10 :
11 : #include "src/allocation.h"
12 : #include "src/base/atomic-utils.h"
13 : #include "src/objects/heap-object.h"
14 : #include "src/utils.h"
15 :
16 : namespace v8 {
17 : namespace internal {
18 :
19 : // This data structure stores objects that went through object layout change
20 : // that potentially invalidates slots recorded concurrently. The second part
21 : // of each element is the size of the corresponding object before the layout
22 : // change.
23 : using InvalidatedSlots = std::map<HeapObject, int, Object::Comparer>;
24 :
25 : // This class provides IsValid predicate that takes into account the set
26 : // of invalidated objects in the given memory chunk.
27 : // The sequence of queried slot must be non-decreasing. This allows fast
28 : // implementation with complexity O(m*log(m) + n), where
29 : // m is the number of invalidated objects in the memory chunk.
30 : // n is the number of IsValid queries.
31 13647 : class V8_EXPORT_PRIVATE InvalidatedSlotsFilter {
32 : public:
33 : explicit InvalidatedSlotsFilter(MemoryChunk* chunk);
34 : inline bool IsValid(Address slot);
35 :
36 : private:
37 : InvalidatedSlots::const_iterator iterator_;
38 : InvalidatedSlots::const_iterator iterator_end_;
39 : Address sentinel_;
40 : Address invalidated_start_;
41 : Address invalidated_end_;
42 : HeapObject invalidated_object_;
43 : int invalidated_object_size_;
44 : bool slots_in_free_space_are_valid_;
45 : InvalidatedSlots empty_;
46 : #ifdef DEBUG
47 : Address last_slot_;
48 : #endif
49 : };
50 :
51 : } // namespace internal
52 : } // namespace v8
53 :
54 : #endif // V8_HEAP_INVALIDATED_SLOTS_H_
|