/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "JSValue.h"
#include "JSCell.h"
+#include "JSObject.h"
+#include "ScopeChain.h"
using std::min;
void ArgList::getSlice(int startIndex, ArgList& result) const
{
- ASSERT(!result.m_isReadOnly);
-
- const_iterator start = min(begin() + startIndex, end());
- result.m_vector.appendRange(start, end());
- result.m_size = result.m_vector.size();
- result.m_buffer = result.m_vector.data();
+ if (startIndex <= 0 || static_cast<unsigned>(startIndex) >= m_argCount) {
+ result = ArgList(m_args, 0);
+ return;
+ }
+ result = ArgList(m_args + startIndex, m_argCount - startIndex);
}
-void ArgList::markLists(ListSet& markSet)
+void MarkedArgumentBuffer::markLists(HeapRootVisitor& heapRootMarker, ListSet& markSet)
{
ListSet::iterator end = markSet.end();
for (ListSet::iterator it = markSet.begin(); it != end; ++it) {
- ArgList* list = *it;
-
- iterator end2 = list->end();
- for (iterator it2 = list->begin(); it2 != end2; ++it2)
- if (!(*it2).marked())
- (*it2).mark();
+ MarkedArgumentBuffer* list = *it;
+ heapRootMarker.mark(reinterpret_cast<JSValue*>(list->m_buffer), list->m_size);
}
}
-void ArgList::slowAppend(JSValuePtr v)
+void MarkedArgumentBuffer::slowAppend(JSValue v)
{
// As long as our size stays within our Vector's inline
// capacity, all our values are allocated on the stack, and
// our Vector's inline capacity, though, our values move to the
// heap, where they do need explicit marking.
if (!m_markSet) {
- // We can only register for explicit marking once we know which heap
- // is the current one, i.e., when a non-immediate value is appended.
+ // FIXME: Even if v is not a JSCell*, if previous values in the buffer
+ // are, then they won't be marked!
if (Heap* heap = Heap::heap(v)) {
ListSet& markSet = heap->markListSet();
markSet.add(this);