1 // Copyright 2014 The Chromium 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.
6 #include "platform/heap/Handle.h"
10 bool WrapperPersistentRegion::removeIfNotLast(WrapperPersistentRegion** headPtr)
13 // We are the last region in the list if both the region's m_prev and
15 if (!m_prev && !m_next)
18 m_prev->m_next = m_next;
20 ASSERT(*headPtr == this);
24 m_next->m_prev = m_prev;
30 void WrapperPersistentRegion::insertHead(WrapperPersistentRegion** headPtr, WrapperPersistentRegion* newHead)
33 WrapperPersistentRegion* oldHead = *headPtr;
35 ASSERT(!oldHead->m_prev);
36 oldHead->m_prev = newHead;
39 newHead->m_next = oldHead;
43 WrapperPersistentRegion* WrapperPersistentRegion::removeHead(WrapperPersistentRegion** headPtr)
45 // We only call this if there is at least one element in the list.
46 ASSERT(headPtr && *headPtr);
47 WrapperPersistentRegion* oldHead = *headPtr;
48 ASSERT(!oldHead->m_prev);
49 *headPtr = oldHead->m_next;
51 ASSERT(!(*headPtr) || (*headPtr)->m_prev == oldHead);
53 (*headPtr)->m_prev = 0;
57 Address WrapperPersistentRegion::outOfLineAllocate(ThreadState* state, WrapperPersistentRegion** regionPtr)
59 Address persistentSlot = 0;
60 // The caller has already tried allocating in the passed-in region, start
62 for (WrapperPersistentRegion* current = (*regionPtr)->m_next; current; current = current->m_next) {
63 persistentSlot = current->allocate();
66 return persistentSlot;
69 ASSERT(!persistentSlot);
70 WrapperPersistentRegion* newRegion = state->takeWrapperPersistentRegion();
71 persistentSlot = newRegion->allocate();
72 *regionPtr = newRegion;
73 ASSERT(persistentSlot);
74 return persistentSlot;