X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..14957cd040308e3eeec43d26bae5d76da13fcd85:/runtime/ArgList.cpp diff --git a/runtime/ArgList.cpp b/runtime/ArgList.cpp index 5ead733..c1aa9dd 100644 --- a/runtime/ArgList.cpp +++ b/runtime/ArgList.cpp @@ -1,5 +1,5 @@ /* - * 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 @@ -23,6 +23,8 @@ #include "JSValue.h" #include "JSCell.h" +#include "JSObject.h" +#include "ScopeChain.h" using std::min; @@ -30,28 +32,23 @@ namespace JSC { 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(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(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 @@ -59,8 +56,8 @@ void ArgList::slowAppend(JSValuePtr v) // 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);