OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
Mads Ager (chromium)
2014/09/02 11:45:48
Let's use the short copyright header for new files
wibling-chromium
2014/09/02 11:54:25
Done.
| |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "platform/heap/Handle.h" | |
33 | |
34 namespace blink { | |
35 | |
36 bool WrapperPersistentRegion::removeIfNotLast(WrapperPersistentRegion** headPtr) | |
37 { | |
38 ASSERT(!m_count); | |
39 // We are the last region in the list if both the region's m_prev and | |
40 // m_next are 0. | |
41 if (m_prev == 0 && m_next == 0) | |
42 return false; | |
43 if (m_prev) { | |
44 m_prev->m_next = m_next; | |
45 } else { | |
46 ASSERT(*headPtr == this); | |
47 *headPtr = m_next; | |
48 } | |
49 if (m_next) | |
50 m_next->m_prev = m_prev; | |
51 m_prev = 0; | |
52 m_next = 0; | |
53 return true; | |
54 } | |
55 | |
56 void WrapperPersistentRegion::insertHead(WrapperPersistentRegion** headPtr, Wrap perPersistentRegion* newHead) | |
57 { | |
58 ASSERT(headPtr); | |
59 WrapperPersistentRegion* oldHead = *headPtr; | |
60 if (oldHead) { | |
61 ASSERT(!oldHead->m_prev); | |
62 oldHead->m_prev = newHead; | |
63 } | |
64 newHead->m_prev = 0; | |
65 newHead->m_next = oldHead; | |
66 *headPtr = newHead; | |
67 } | |
68 | |
69 WrapperPersistentRegion* WrapperPersistentRegion::removeHead(WrapperPersistentRe gion** headPtr) | |
70 { | |
71 // We only call this if there is at least one element in the list. | |
72 ASSERT(headPtr && *headPtr); | |
73 WrapperPersistentRegion* oldHead = *headPtr; | |
74 ASSERT(!oldHead->m_prev); | |
75 *headPtr = oldHead->m_next; | |
76 oldHead->m_next = 0; | |
77 ASSERT(!(*headPtr) || (*headPtr)->m_prev == oldHead); | |
78 if (*headPtr) | |
79 (*headPtr)->m_prev = 0; | |
80 return oldHead; | |
81 } | |
82 | |
83 void* WrapperPersistentRegion::outOfLineAllocate(ThreadState* state, WrapperPers istentRegion* head) | |
84 { | |
85 void* persistent = 0; | |
86 // The caller has already tried allocating in the passed-in region, start | |
87 // from the next. | |
88 for (WrapperPersistentRegion* current = head->m_next; current; current = cur rent->m_next) { | |
89 persistent = current->allocate(); | |
90 if (persistent) | |
91 return persistent; | |
92 } | |
93 ASSERT(!persistent); | |
94 WrapperPersistentRegion* newRegion = state->addWrapperPersistentRegion(); | |
95 persistent = newRegion->allocate(); | |
96 ASSERT(persistent); | |
97 return persistent; | |
98 } | |
99 | |
100 } | |
OLD | NEW |