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, ...@@ -3615,6 +3615,11 @@ const Operator* WasmGraphBuilder::GetSafeLoadOperator(int offset,
wasm::ValueType type) { wasm::ValueType type) {
int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type)); int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type));
MachineType mach_type = wasm::ValueTypes::MachineTypeFor(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( if (alignment == 0 || mcgraph()->machine()->UnalignedLoadSupported(
wasm::ValueTypes::MachineRepresentationFor(type))) { wasm::ValueTypes::MachineRepresentationFor(type))) {
return mcgraph()->machine()->Load(mach_type); return mcgraph()->machine()->Load(mach_type);
...@@ -3626,6 +3631,11 @@ const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset, ...@@ -3626,6 +3631,11 @@ const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset,
wasm::ValueType type) { wasm::ValueType type) {
int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type)); int alignment = offset % (wasm::ValueTypes::ElementSizeInBytes(type));
MachineRepresentation rep = wasm::ValueTypes::MachineRepresentationFor(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)) { if (alignment == 0 || mcgraph()->machine()->UnalignedStoreSupported(rep)) {
StoreRepresentation store_rep(rep, WriteBarrierKind::kNoWriteBarrier); StoreRepresentation store_rep(rep, WriteBarrierKind::kNoWriteBarrier);
return mcgraph()->machine()->Store(store_rep); return mcgraph()->machine()->Store(store_rep);
...@@ -5578,9 +5588,9 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -5578,9 +5588,9 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
offset = 0; offset = 0;
for (size_t i = 0; i < return_count; ++i) { for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i); wasm::ValueType type = sig_->GetReturn(i);
Node* val = SetEffect(graph()->NewNode( Node* val = SetEffect(
mcgraph()->machine()->Load(wasm::ValueTypes::MachineTypeFor(type)), graph()->NewNode(GetSafeLoadOperator(offset, type), arg_buffer,
arg_buffer, Int32Constant(offset), Effect(), Control())); Int32Constant(offset), Effect(), Control()));
returns[i] = val; returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type); 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