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

Unified Diff: src/heap/array-buffer-tracker.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/array-buffer-tracker.h ('k') | src/heap/array-buffer-tracker-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/array-buffer-tracker.cc
diff --git a/src/heap/array-buffer-tracker.cc b/src/heap/array-buffer-tracker.cc
index 9163b877d0e98d65ec3870f3ea135ca64254c92b..e7eecf884ac02a1f5630330977e50e1e91708aab 100644
--- a/src/heap/array-buffer-tracker.cc
+++ b/src/heap/array-buffer-tracker.cc
@@ -3,11 +3,8 @@
// found in the LICENSE file.
#include "src/heap/array-buffer-tracker.h"
+#include "src/heap/array-buffer-tracker-inl.h"
#include "src/heap/heap.h"
-#include "src/isolate.h"
-#include "src/objects-inl.h"
-#include "src/objects.h"
-#include "src/v8.h"
namespace v8 {
namespace internal {
@@ -16,22 +13,6 @@ LocalArrayBufferTracker::~LocalArrayBufferTracker() {
CHECK(array_buffers_.empty());
}
-void LocalArrayBufferTracker::Add(Key key, const Value& value) {
- auto ret = array_buffers_.insert(std::make_pair(key, value));
- USE(ret);
- // Check that we indeed inserted a new value and did not overwrite an existing
- // one (which would be a bug).
- DCHECK(ret.second);
-}
-
-LocalArrayBufferTracker::Value LocalArrayBufferTracker::Remove(Key key) {
- TrackingMap::iterator it = array_buffers_.find(key);
- DCHECK(it != array_buffers_.end());
- Value value = it->second;
- array_buffers_.erase(it);
- return value;
-}
-
template <LocalArrayBufferTracker::FreeMode free_mode>
void LocalArrayBufferTracker::Free() {
size_t freed_memory = 0;
@@ -92,44 +73,6 @@ void LocalArrayBufferTracker::Process(Callback callback) {
}
}
-void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) {
- void* data = buffer->backing_store();
- if (!data) return;
-
- size_t length = NumberToSize(heap->isolate(), buffer->byte_length());
- Page* page = Page::FromAddress(buffer->address());
- {
- base::LockGuard<base::Mutex> guard(page->mutex());
- LocalArrayBufferTracker* tracker = page->local_tracker();
- if (tracker == nullptr) {
- page->AllocateLocalTracker();
- tracker = page->local_tracker();
- }
- DCHECK_NOT_NULL(tracker);
- tracker->Add(buffer, std::make_pair(data, length));
- }
- // We may go over the limit of externally allocated memory here. We call the
- // api function to trigger a GC in this case.
- reinterpret_cast<v8::Isolate*>(heap->isolate())
- ->AdjustAmountOfExternalAllocatedMemory(length);
-}
-
-void ArrayBufferTracker::Unregister(Heap* heap, JSArrayBuffer* buffer) {
- void* data = buffer->backing_store();
- if (!data) return;
-
- Page* page = Page::FromAddress(buffer->address());
- size_t length = 0;
- {
- base::LockGuard<base::Mutex> guard(page->mutex());
- LocalArrayBufferTracker* tracker = page->local_tracker();
- DCHECK_NOT_NULL(tracker);
- length = tracker->Remove(buffer).second;
- }
- heap->update_amount_of_external_allocated_memory(
- -static_cast<intptr_t>(length));
-}
-
void ArrayBufferTracker::FreeDeadInNewSpace(Heap* heap) {
DCHECK_EQ(heap->gc_state(), Heap::HeapState::SCAVENGE);
NewSpacePageIterator from_it(heap->new_space()->FromSpaceStart(),
« no previous file with comments | « src/heap/array-buffer-tracker.h ('k') | src/heap/array-buffer-tracker-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698