chore: cherry-pick 3 changes from 2-M131 (#45040)
This commit is contained in:
parent
8b060dc73e
commit
a2a644e948
5 changed files with 2069 additions and 0 deletions
|
@ -1,2 +1,4 @@
|
|||
tint_validate_that_align_is_large_enough.patch
|
||||
ir_fix_robustness_transform_on_textureload_of_sampled_and_depth.patch
|
||||
tint_validate_layout_constraints_for_all_address_spaces.patch
|
||||
msl_use_packed_vec3_for_workgroup_storage.patch
|
||||
|
|
1860
patches/dawn/msl_use_packed_vec3_for_workgroup_storage.patch
Normal file
1860
patches/dawn/msl_use_packed_vec3_for_workgroup_storage.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,126 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: James Price <jrprice@google.com>
|
||||
Date: Wed, 20 Nov 2024 19:06:01 +0000
|
||||
Subject: [tint] Validate layout constraints for all address spaces
|
||||
|
||||
The WGSL spec has a non-normative note that the layout constraints
|
||||
should be validated for all non-host-shareable address spaces, using
|
||||
the same constraints as for storage.
|
||||
|
||||
See linked bug for details of why this is important.
|
||||
|
||||
Bug: 378725734
|
||||
Change-Id: I3fb02506d8ded000dc3510bdc1b4a24a95089281
|
||||
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/214754
|
||||
Reviewed-by: David Neto <dneto@google.com>
|
||||
Commit-Queue: James Price <jrprice@google.com>
|
||||
Reviewed-by: dan sinclair <dsinclair@chromium.org>
|
||||
(cherry picked from commit dfa46d12ce63f131c437041d6d97a6d97c54c1b7)
|
||||
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/215936
|
||||
Auto-Submit: James Price <jrprice@google.com>
|
||||
Commit-Queue: dan sinclair <dsinclair@chromium.org>
|
||||
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
|
||||
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
|
||||
|
||||
diff --git a/src/tint/lang/wgsl/resolver/address_space_layout_validation_test.cc b/src/tint/lang/wgsl/resolver/address_space_layout_validation_test.cc
|
||||
index f1e14a36a3cdea07f5fc7735c3d9483515d754f1..6ef150c4476e9176e934a94c32d903c2e23083b8 100644
|
||||
--- a/src/tint/lang/wgsl/resolver/address_space_layout_validation_test.cc
|
||||
+++ b/src/tint/lang/wgsl/resolver/address_space_layout_validation_test.cc
|
||||
@@ -730,7 +730,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, RelaxedUniformLayout_ArrayStrid
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
-TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall) {
|
||||
+TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall_Storage) {
|
||||
// struct S {
|
||||
// @align(4) vector : vec4u;
|
||||
// scalar : u32;
|
||||
@@ -754,5 +754,73 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall) {
|
||||
56:78 note: 'S' used in address space 'storage' here)");
|
||||
}
|
||||
|
||||
+TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall_Workgroup) {
|
||||
+ // struct S {
|
||||
+ // @align(4) vector : vec4u;
|
||||
+ // scalar : u32;
|
||||
+ // };
|
||||
+ //
|
||||
+ // var<workgroup> a : array<S, 4>;
|
||||
+ Structure(
|
||||
+ "S", Vector{
|
||||
+ Member("vector", ty.vec4<u32>(), Vector{MemberAlign(Expr(Source{{12, 34}}, 4_a))}),
|
||||
+ Member("scalar", ty.u32()),
|
||||
+ });
|
||||
+
|
||||
+ GlobalVar(Source{{56, 78}}, "a", ty("S"), core::AddressSpace::kWorkgroup, Group(0_a));
|
||||
+
|
||||
+ ASSERT_FALSE(r()->Resolve());
|
||||
+ EXPECT_EQ(
|
||||
+ r()->error(),
|
||||
+ R"(12:34 error: alignment must be a multiple of '16' bytes for the 'workgroup' address space
|
||||
+56:78 note: 'S' used in address space 'workgroup' here)");
|
||||
+}
|
||||
+
|
||||
+TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall_Private) {
|
||||
+ // struct S {
|
||||
+ // @align(4) vector : vec4u;
|
||||
+ // scalar : u32;
|
||||
+ // };
|
||||
+ //
|
||||
+ // var<private> a : array<S, 4>;
|
||||
+ Structure(
|
||||
+ "S", Vector{
|
||||
+ Member("vector", ty.vec4<u32>(), Vector{MemberAlign(Expr(Source{{12, 34}}, 4_a))}),
|
||||
+ Member("scalar", ty.u32()),
|
||||
+ });
|
||||
+
|
||||
+ GlobalVar(Source{{56, 78}}, "a", ty("S"), core::AddressSpace::kPrivate, Group(0_a));
|
||||
+
|
||||
+ ASSERT_FALSE(r()->Resolve());
|
||||
+ EXPECT_EQ(
|
||||
+ r()->error(),
|
||||
+ R"(12:34 error: alignment must be a multiple of '16' bytes for the 'private' address space
|
||||
+56:78 note: 'S' used in address space 'private' here)");
|
||||
+}
|
||||
+
|
||||
+TEST_F(ResolverAddressSpaceLayoutValidationTest, AlignAttributeTooSmall_Function) {
|
||||
+ // struct S {
|
||||
+ // @align(4) vector : vec4u;
|
||||
+ // scalar : u32;
|
||||
+ // };
|
||||
+ //
|
||||
+ // fn foo() {
|
||||
+ // var a : array<S, 4>;
|
||||
+ // }
|
||||
+ Structure(
|
||||
+ "S", Vector{
|
||||
+ Member("vector", ty.vec4<u32>(), Vector{MemberAlign(Expr(Source{{12, 34}}, 4_a))}),
|
||||
+ Member("scalar", ty.u32()),
|
||||
+ });
|
||||
+
|
||||
+ GlobalVar(Source{{56, 78}}, "a", ty("S"), core::AddressSpace::kFunction, Group(0_a));
|
||||
+
|
||||
+ ASSERT_FALSE(r()->Resolve());
|
||||
+ EXPECT_EQ(
|
||||
+ r()->error(),
|
||||
+ R"(12:34 error: alignment must be a multiple of '16' bytes for the 'function' address space
|
||||
+56:78 note: 'S' used in address space 'function' here)");
|
||||
+}
|
||||
+
|
||||
} // namespace
|
||||
} // namespace tint::resolver
|
||||
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
|
||||
index 0d62d474780542a79a67698375319b6ab7c4560d..105e937be9e69df6a5a44d75d21cabc4eab2a2f7 100644
|
||||
--- a/src/tint/lang/wgsl/resolver/validator.cc
|
||||
+++ b/src/tint/lang/wgsl/resolver/validator.cc
|
||||
@@ -499,10 +499,6 @@ bool Validator::AddressSpaceLayout(const core::type::Type* store_ty,
|
||||
return true;
|
||||
}
|
||||
|
||||
- if (!core::IsHostShareable(address_space)) {
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
auto note_usage = [&] {
|
||||
AddNote(source) << style::Type(store_ty->FriendlyName()) << " used in address space "
|
||||
<< style::Enum(address_space) << " here";
|
|
@ -14,3 +14,4 @@ merged_heap_sandbox_update_ept_s_evacuation_entries_in_scavenger.patch
|
|||
merged_don_t_assume_all_turbofan_frames_are_javascript.patch
|
||||
merged_wasm_do_not_inline_wrappers_with_ref_extern_parameter.patch
|
||||
merged_wasm_fix_default_externref_exnref_reference.patch
|
||||
m126-lts_liftoff_fix_clobbered_scratch_register.patch
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Clemens Backes <clemensb@chromium.org>
|
||||
Date: Fri, 15 Nov 2024 16:00:15 +0100
|
||||
Subject: [M126-LTS][liftoff] Fix clobbered scratch register
|
||||
|
||||
`GetMemOp` returns an `Operand` which can contain `kScratchRegister`. We
|
||||
should hence not clobber that register until after the last use of the
|
||||
`Operand`.
|
||||
|
||||
This CL changes the scratch register to `kScratchRegister2` which has
|
||||
much fewer uses, and in particular none which collides with `GetMemOp`.
|
||||
|
||||
R=mliedtke@chromium.org
|
||||
|
||||
(cherry picked from commit 57a017e611a5abfb0e4b59f6de028bc4070a3615)
|
||||
|
||||
Fixed: 378779897, 378701682
|
||||
Change-Id: Id1ed25edfe76200d069ac2ab54e5000eed313c8f
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6022072
|
||||
Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
|
||||
Commit-Queue: Clemens Backes <clemensb@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#97224}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6056706
|
||||
Reviewed-by: Clemens Backes <clemensb@chromium.org>
|
||||
Commit-Queue: Gyuyoung Kim (xWF) <qkim@google.com>
|
||||
Reviewed-by: Daniel Lehmann <dlehmann@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/12.6@{#82}
|
||||
Cr-Branched-From: 3c9fa12db3183a6f4ea53d2675adb66ea1194529-refs/heads/12.6.228@{#2}
|
||||
Cr-Branched-From: 981bb15ba4dbf9e2381dfc94ec2c4af0b9c6a0b6-refs/heads/main@{#93835}
|
||||
|
||||
diff --git a/src/wasm/baseline/x64/liftoff-assembler-x64-inl.h b/src/wasm/baseline/x64/liftoff-assembler-x64-inl.h
|
||||
index b20867d7ec2a5724653ebe9baca8c8949d70cd74..be01772c27382e2c10314777e4058cf326327ba3 100644
|
||||
--- a/src/wasm/baseline/x64/liftoff-assembler-x64-inl.h
|
||||
+++ b/src/wasm/baseline/x64/liftoff-assembler-x64-inl.h
|
||||
@@ -50,6 +50,8 @@ constexpr Operand kInstanceDataOperand =
|
||||
|
||||
constexpr Operand kOSRTargetSlot = GetStackSlot(kOSRTargetOffset);
|
||||
|
||||
+// Note: The returned Operand might contain {kScratchRegister2}; make sure not
|
||||
+// to clobber that until after the last use of the Operand.
|
||||
inline Operand GetMemOp(LiftoffAssembler* assm, Register addr,
|
||||
Register offset_reg, uintptr_t offset_imm,
|
||||
ScaleFactor scale_factor = times_1) {
|
||||
@@ -60,7 +62,7 @@ inline Operand GetMemOp(LiftoffAssembler* assm, Register addr,
|
||||
: Operand(addr, offset_reg, scale_factor, offset_imm32);
|
||||
}
|
||||
// Offset immediate does not fit in 31 bits.
|
||||
- Register scratch = kScratchRegister;
|
||||
+ Register scratch = kScratchRegister2;
|
||||
assm->MacroAssembler::Move(scratch, offset_imm);
|
||||
if (offset_reg != no_reg) assm->addq(scratch, offset_reg);
|
||||
return Operand(addr, scratch, scale_factor, 0);
|
||||
diff --git a/test/mjsunit/regress/wasm/regress-378779897.js b/test/mjsunit/regress/wasm/regress-378779897.js
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fed1bc807165e1b9e83195a2df30aac33a544470
|
||||
--- /dev/null
|
||||
+++ b/test/mjsunit/regress/wasm/regress-378779897.js
|
||||
@@ -0,0 +1,22 @@
|
||||
+// Copyright 2024 the V8 project authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
+
|
||||
+const builder = new WasmModuleBuilder();
|
||||
+builder.addMemory(49149);
|
||||
+
|
||||
+builder.addFunction('main', kSig_i_v).addBody([
|
||||
+ ...wasmI32Const(-1118406780),
|
||||
+ ...wasmI32Const(-1),
|
||||
+ kAtomicPrefix, kExprI32AtomicOr8U, 0, 0
|
||||
+]).exportFunc();
|
||||
+
|
||||
+let instance;
|
||||
+try {
|
||||
+ instance = builder.instantiate();
|
||||
+} catch (e) {
|
||||
+ assertException(e, RangeError, /Out of memory/);
|
||||
+}
|
||||
+if (instance) instance.exports.main();
|
Loading…
Add table
Add a link
Reference in a new issue