Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions JSTests/stress/marked-buffer-fill-should-be-gc-aware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ runDefault("--slowPathAllocsBetweenGCs=10", "--jitPolicyScale=0")
let a = new BigUint64Array(1000);

function foo(a0) {
~a0;
}

for (let i = 0; i < 1000; i++) {
foo.apply(null, a);
}
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@ static void handleVarargsCheckpoint(VM& vm, CallFrame* callFrame, JSGlobalObject
unsigned firstVarArg = bytecode.m_firstVarArg;

MarkedArgumentBuffer args;
args.fill(argumentCountIncludingThis - 1, [&] (JSValue* buffer) {
args.fill(vm, argumentCountIncludingThis - 1, [&](JSValue* buffer) {
loadVarargs(globalObject, buffer, callFrame->r(bytecode.m_arguments).jsValue(), firstVarArg, argumentCountIncludingThis - 1);
});
if (args.hasOverflowed()) {
Expand Down
11 changes: 9 additions & 2 deletions Source/JavaScriptCore/runtime/ArgList.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,21 @@ class MarkedVector : public OverflowHandler, public MarkedVectorBase {
}

template<typename Functor>
void fill(size_t count, const Functor& func)
void fill(VM& vm, size_t count, const Functor& func)
{
ASSERT(!m_size);
ensureCapacity(count);
if (OverflowHandler::hasOverflowed())
return;
if (LIKELY(!m_markSet)) {
m_markSet = &vm.heap.markListSet();
m_markSet->add(this);
}
m_size = count;
func(reinterpret_cast<JSValue*>(&slotFor(0)));
auto* buffer = reinterpret_cast<JSValue*>(&slotFor(0));
for (unsigned i = 0; i < count; ++i)
buffer[i] = JSValue();
func(buffer);
}

private:
Expand Down