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

Unified Diff: Source/platform/heap/Handle.cpp

Issue 556823003: Revert "Revert of [oilpan]: optimize the way we allocate persistent handles in wrappers. (patchset … (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review feedback Created 6 years, 3 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 | « Source/platform/heap/Handle.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Handle.cpp
diff --git a/Source/platform/heap/Handle.cpp b/Source/platform/heap/Handle.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f1cf96c661147a413ddcadf14f11d4510cb7160a
--- /dev/null
+++ b/Source/platform/heap/Handle.cpp
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+bool WrapperPersistentRegion::removeIfNotLast(WrapperPersistentRegion** headPtr)
+{
+ ASSERT(!m_count);
+ // We are the last region in the list if both the region's m_prev and
+ // m_next are 0.
+ if (!m_prev && !m_next)
+ return false;
+ if (m_prev) {
+ m_prev->m_next = m_next;
+ } else {
+ ASSERT(*headPtr == this);
+ *headPtr = m_next;
+ }
+ if (m_next)
+ m_next->m_prev = m_prev;
+ m_prev = 0;
+ m_next = 0;
+ return true;
+}
+
+void WrapperPersistentRegion::insertHead(WrapperPersistentRegion** headPtr, WrapperPersistentRegion* newHead)
+{
+ ASSERT(headPtr);
+ WrapperPersistentRegion* oldHead = *headPtr;
+ if (oldHead) {
+ ASSERT(!oldHead->m_prev);
+ oldHead->m_prev = newHead;
+ }
+ newHead->m_prev = 0;
+ newHead->m_next = oldHead;
+ *headPtr = newHead;
+}
+
+WrapperPersistentRegion* WrapperPersistentRegion::removeHead(WrapperPersistentRegion** headPtr)
+{
+ // We only call this if there is at least one element in the list.
+ ASSERT(headPtr && *headPtr);
+ WrapperPersistentRegion* oldHead = *headPtr;
+ ASSERT(!oldHead->m_prev);
+ *headPtr = oldHead->m_next;
+ oldHead->m_next = 0;
+ ASSERT(!(*headPtr) || (*headPtr)->m_prev == oldHead);
+ if (*headPtr)
+ (*headPtr)->m_prev = 0;
+ return oldHead;
+}
+
+Address WrapperPersistentRegion::outOfLineAllocate(ThreadState* state, WrapperPersistentRegion** regionPtr)
+{
+ Address persistentSlot = 0;
+ // The caller has already tried allocating in the passed-in region, start
+ // from the next.
+ for (WrapperPersistentRegion* current = (*regionPtr)->m_next; current; current = current->m_next) {
+ persistentSlot = current->allocate();
+ if (persistentSlot) {
+ *regionPtr = current;
+ return persistentSlot;
+ }
+ }
+ ASSERT(!persistentSlot);
+ WrapperPersistentRegion* newRegion = state->takeWrapperPersistentRegion();
+ persistentSlot = newRegion->allocate();
+ *regionPtr = newRegion;
+ ASSERT(persistentSlot);
+ return persistentSlot;
+}
+
+}
« no previous file with comments | « Source/platform/heap/Handle.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698