]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/ArgList.cpp
ab2b5d7dae7143c5166aa943cb8abce37e4ba67e
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
31 void ArgList::getSlice(int startIndex
, ArgList
& result
) const
33 if (startIndex
<= 0 || static_cast<unsigned>(startIndex
) >= m_argCount
) {
34 result
= ArgList(m_args
, 0);
37 result
= ArgList(m_args
+ startIndex
, m_argCount
- startIndex
);
40 void MarkedArgumentBuffer::markLists(MarkStack
& markStack
, ListSet
& markSet
)
42 ListSet::iterator end
= markSet
.end();
43 for (ListSet::iterator it
= markSet
.begin(); it
!= end
; ++it
) {
44 MarkedArgumentBuffer
* list
= *it
;
45 markStack
.appendValues(reinterpret_cast<JSValue
*>(list
->m_buffer
), list
->m_size
);
49 void MarkedArgumentBuffer::slowAppend(JSValue v
)
51 // As long as our size stays within our Vector's inline
52 // capacity, all our values are allocated on the stack, and
53 // therefore don't need explicit marking. Once our size exceeds
54 // our Vector's inline capacity, though, our values move to the
55 // heap, where they do need explicit marking.
57 // We can only register for explicit marking once we know which heap
58 // is the current one, i.e., when a non-immediate value is appended.
59 if (Heap
* heap
= Heap::heap(v
)) {
60 ListSet
& markSet
= heap
->markListSet();
66 if (m_vector
.size() < m_vector
.capacity()) {
67 m_vector
.uncheckedAppend(v
);
71 // 4x growth would be excessive for a normal vector, but it's OK for Lists
72 // because they're short-lived.
73 m_vector
.reserveCapacity(m_vector
.capacity() * 4);
75 m_vector
.uncheckedAppend(v
);
76 m_buffer
= m_vector
.data();