Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/heap/array-buffer-tracker.h

Issue 2065013002: [heap] Add inlined fast path for JSArrayBuffer (un)register in tracker (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/heap/array-buffer-tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef V8_HEAP_ARRAY_BUFFER_TRACKER_H_ 5 #ifndef V8_HEAP_ARRAY_BUFFER_TRACKER_H_
6 #define V8_HEAP_ARRAY_BUFFER_TRACKER_H_ 6 #define V8_HEAP_ARRAY_BUFFER_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 12 matching lines...) Expand all
23 enum ProcessingMode { 23 enum ProcessingMode {
24 kUpdateForwardedRemoveOthers, 24 kUpdateForwardedRemoveOthers,
25 kUpdateForwardedKeepOthers, 25 kUpdateForwardedKeepOthers,
26 }; 26 };
27 27
28 // The following methods are used to track raw C++ pointers to externally 28 // The following methods are used to track raw C++ pointers to externally
29 // allocated memory used as backing store in live array buffers. 29 // allocated memory used as backing store in live array buffers.
30 30
31 // Register/unregister a new JSArrayBuffer |buffer| for tracking. Guards all 31 // Register/unregister a new JSArrayBuffer |buffer| for tracking. Guards all
32 // access to the tracker by taking the page lock for the corresponding page. 32 // access to the tracker by taking the page lock for the corresponding page.
33 static void RegisterNew(Heap* heap, JSArrayBuffer* buffer); 33 inline static void RegisterNew(Heap* heap, JSArrayBuffer* buffer);
34 static void Unregister(Heap* heap, JSArrayBuffer* buffer); 34 inline static void Unregister(Heap* heap, JSArrayBuffer* buffer);
35 35
36 // Frees all backing store pointers for dead JSArrayBuffers in new space. 36 // Frees all backing store pointers for dead JSArrayBuffers in new space.
37 // Does not take any locks and can only be called during Scavenge. 37 // Does not take any locks and can only be called during Scavenge.
38 static void FreeDeadInNewSpace(Heap* heap); 38 static void FreeDeadInNewSpace(Heap* heap);
39 39
40 // Frees all backing store pointers for dead JSArrayBuffer on a given page. 40 // Frees all backing store pointers for dead JSArrayBuffer on a given page.
41 // Requires marking information to be present. Requires the page lock to be 41 // Requires marking information to be present. Requires the page lock to be
42 // taken by the caller. 42 // taken by the caller.
43 static void FreeDead(Page* page); 43 static void FreeDead(Page* page);
44 44
(...skipping 16 matching lines...) Expand all
61 public: 61 public:
62 typedef std::pair<void*, size_t> Value; 62 typedef std::pair<void*, size_t> Value;
63 typedef JSArrayBuffer* Key; 63 typedef JSArrayBuffer* Key;
64 64
65 enum CallbackResult { kKeepEntry, kUpdateEntry, kRemoveEntry }; 65 enum CallbackResult { kKeepEntry, kUpdateEntry, kRemoveEntry };
66 enum FreeMode { kFreeDead, kFreeAll }; 66 enum FreeMode { kFreeDead, kFreeAll };
67 67
68 explicit LocalArrayBufferTracker(Heap* heap) : heap_(heap) {} 68 explicit LocalArrayBufferTracker(Heap* heap) : heap_(heap) {}
69 ~LocalArrayBufferTracker(); 69 ~LocalArrayBufferTracker();
70 70
71 void Add(Key key, const Value& value); 71 inline void Add(Key key, const Value& value);
72 Value Remove(Key key); 72 inline Value Remove(Key key);
73 73
74 // Frees up array buffers determined by |free_mode|. 74 // Frees up array buffers determined by |free_mode|.
75 template <FreeMode free_mode> 75 template <FreeMode free_mode>
76 void Free(); 76 void Free();
77 77
78 // Processes buffers one by one. The CallbackResult of the callback decides 78 // Processes buffers one by one. The CallbackResult of the callback decides
79 // what action to take on the buffer. 79 // what action to take on the buffer.
80 // 80 //
81 // Callback should be of type: 81 // Callback should be of type:
82 // CallbackResult fn(JSArrayBuffer* buffer, JSArrayBuffer** new_buffer); 82 // CallbackResult fn(JSArrayBuffer* buffer, JSArrayBuffer** new_buffer);
(...skipping 11 matching lines...) Expand all
94 // platforms. 94 // platforms.
95 typedef std::map<Key, Value> TrackingMap; 95 typedef std::map<Key, Value> TrackingMap;
96 96
97 Heap* heap_; 97 Heap* heap_;
98 TrackingMap array_buffers_; 98 TrackingMap array_buffers_;
99 }; 99 };
100 100
101 } // namespace internal 101 } // namespace internal
102 } // namespace v8 102 } // namespace v8
103 #endif // V8_HEAP_ARRAY_BUFFER_TRACKER_H_ 103 #endif // V8_HEAP_ARRAY_BUFFER_TRACKER_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/heap/array-buffer-tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698