Commit e3079285 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr][wasm] Fix handling of reference argument/return types

... when pointer compression is enabled.

Bug: v8:7581, v8:7703
Change-Id: Ie0928f813458d2ffa9159f5098c4f91bf8cee437
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1564052
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60773}
parent 4a7563d3
......@@ -3615,6 +3615,11 @@ const Operator* WasmGraphBuilder::GetSafeLoadOperator(int offset,
wasm::ValueType type) {
int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type));
MachineType mach_type = wasm::ValueTypes::MachineTypeFor(type);
if (COMPRESS_POINTERS_BOOL && mach_type.IsTagged()) {
// We are loading tagged value from off-heap location, so we need to load
// it as a full word otherwise we will not be able to decompress it.
mach_type = MachineType::Pointer();
}
if (alignment == 0 || mcgraph()->machine()->UnalignedLoadSupported(
wasm::ValueTypes::MachineRepresentationFor(type))) {
return mcgraph()->machine()->Load(mach_type);
......@@ -3626,6 +3631,11 @@ const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset,
wasm::ValueType type) {
int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type));
MachineRepresentation rep = wasm::ValueTypes::MachineRepresentationFor(type);
if (COMPRESS_POINTERS_BOOL && IsAnyTagged(rep)) {
// We are storing tagged value to off-heap location, so we need to store
// it as a full word otherwise we will not be able to decompress it.
rep = MachineType::PointerRepresentation();
}
if (alignment == 0 || mcgraph()->machine()->UnalignedStoreSupported(rep)) {
StoreRepresentation store_rep(rep, WriteBarrierKind::kNoWriteBarrier);
return mcgraph()->machine()->Store(store_rep);
......@@ -5578,9 +5588,9 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
offset = 0;
for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i);
Node* val = SetEffect(graph()->NewNode(
mcgraph()->machine()->Load(wasm::ValueTypes::MachineTypeFor(type)),
arg_buffer, Int32Constant(offset), Effect(), Control()));
Node* val = SetEffect(
graph()->NewNode(GetSafeLoadOperator(offset, type), arg_buffer,
Int32Constant(offset), Effect(), Control()));
returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment