Skip to content

Commit

Permalink
Bug 1885829 - Track ArrayDataPointer at safepoints. r=bvisness,rhunt …
Browse files Browse the repository at this point in the history
…a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D205846
  • Loading branch information
yurydelendik committed Mar 29, 2024
1 parent 63a3a8b commit 3b0a465
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions js/src/jit/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15112,25 +15112,33 @@ static bool CreateStackMapFromLSafepoint(LSafepoint& safepoint,
// REG DUMP AREA, if any.
size_t regDumpWords = 0;
const LiveGeneralRegisterSet wasmAnyRefRegs = safepoint.wasmAnyRefRegs();
GeneralRegisterForwardIterator wasmAnyRefRegsIter(wasmAnyRefRegs);
const LiveGeneralRegisterSet slotsOrElementsRegs =
safepoint.slotsOrElementsRegs();
const LiveGeneralRegisterSet refRegs(GeneralRegisterSet::Union(
wasmAnyRefRegs.set(), slotsOrElementsRegs.set()));
GeneralRegisterForwardIterator refRegsIter(refRegs);
switch (safepoint.wasmSafepointKind()) {
case WasmSafepointKind::LirCall:
case WasmSafepointKind::CodegenCall: {
size_t spilledNumWords = nRegisterDumpBytes / sizeof(void*);
regDumpWords += spilledNumWords;

for (; wasmAnyRefRegsIter.more(); ++wasmAnyRefRegsIter) {
Register reg = *wasmAnyRefRegsIter;
for (; refRegsIter.more(); ++refRegsIter) {
Register reg = *refRegsIter;
size_t offsetFromSpillBase =
safepoint.liveRegs().gprs().offsetOfPushedRegister(reg) /
sizeof(void*);
MOZ_ASSERT(0 < offsetFromSpillBase &&
offsetFromSpillBase <= spilledNumWords);
size_t index = spilledNumWords - offsetFromSpillBase;

stackMap->set(index, wasm::StackMap::AnyRef);
if (wasmAnyRefRegs.has(reg)) {
stackMap->set(index, wasm::StackMap::AnyRef);
} else {
MOZ_ASSERT(slotsOrElementsRegs.has(reg));
stackMap->set(index, wasm::StackMap::ArrayDataPointer);
}
}

// Float and vector registers do not have to be handled; they cannot
// contain wasm anyrefs, and they are spilled after general-purpose
// registers. Gprs are therefore closest to the spill base and thus their
Expand All @@ -15139,8 +15147,8 @@ static bool CreateStackMapFromLSafepoint(LSafepoint& safepoint,
case WasmSafepointKind::Trap: {
regDumpWords += trapExitLayoutNumWords;

for (; wasmAnyRefRegsIter.more(); ++wasmAnyRefRegsIter) {
Register reg = *wasmAnyRefRegsIter;
for (; refRegsIter.more(); ++refRegsIter) {
Register reg = *refRegsIter;
size_t offsetFromTop = trapExitLayout.getOffset(reg);

// If this doesn't hold, the associated register wasn't saved by
Expand All @@ -15153,7 +15161,12 @@ static bool CreateStackMapFromLSafepoint(LSafepoint& safepoint,
// offset up from the bottom of the (integer register) save area.
size_t offsetFromBottom = trapExitLayoutNumWords - 1 - offsetFromTop;

stackMap->set(offsetFromBottom, wasm::StackMap::AnyRef);
if (wasmAnyRefRegs.has(reg)) {
stackMap->set(offsetFromBottom, wasm::StackMap::AnyRef);
} else {
MOZ_ASSERT(slotsOrElementsRegs.has(reg));
stackMap->set(offsetFromBottom, wasm::StackMap::ArrayDataPointer);
}
}
} break;
default:
Expand Down

0 comments on commit 3b0a465

Please sign in to comment.