Skip to content

Commit a75d041

Browse files
committed
Merge remote-tracking branch 'origin/main' into gfx/branch-hinting-v2
# Conflicts: # crates/cranelift/src/compiler.rs # crates/cranelift/src/func_environ.rs # crates/environ/src/compile/module_environ.rs
2 parents 7c5b1f5 + 5f3b67e commit a75d041

425 files changed

Lines changed: 14784 additions & 8466 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ jobs:
423423
-p wasmtime-wasi-http --no-default-features
424424
-p wasmtime-wasi-http --no-default-features --features p2
425425
-p wasmtime-wasi-http --no-default-features --features p3
426+
-p wasmtime-wasi-http --no-default-features --features p2,component-model-async
427+
-p wasmtime-wasi-http --no-default-features --features p3,component-model-async
426428
-p wasmtime-wasi-http --no-default-features --features p3 --all-targets
427429
428430
- name: wasmtime-wasi
@@ -605,7 +607,7 @@ jobs:
605607
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,pulley,async,debug,debug-builtins,demangle,anyhow &&
606608
cargo check -p cranelift-control --no-default-features &&
607609
cargo check -p cranelift-assembler-x64 --lib &&
608-
cargo check -p cranelift-codegen --no-default-features --features x86,arm64 &&
610+
cargo check -p cranelift-codegen --no-default-features --features x86,arm64,riscv64 &&
609611
cargo check -p cranelift-frontend --no-default-features &&
610612
cargo check -p pulley-interpreter --features encode,decode,disas,interp &&
611613
cargo check -p wasmtime-wasi-io --no-default-features

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ hyper = { workspace = true, optional = true }
9191
http = { workspace = true, optional = true }
9292
http-body-util = { workspace = true, optional = true }
9393
futures = { workspace = true, optional = true }
94+
pin-project-lite = { workspace = true, optional = true }
9495

9596
[target.'cfg(unix)'.dependencies]
9697
rustix = { workspace = true, features = ["mm", "process"] }
@@ -596,6 +597,7 @@ serve = [
596597
"component-model",
597598
"dep:http-body-util",
598599
"dep:http",
600+
"dep:pin-project-lite",
599601
"wasmtime-cli-flags/async",
600602
"wasmtime-wasi-http?/p2",
601603
]

ci/miri-provenance-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
set -ex
1313

1414
compile() {
15-
cargo run --no-default-features --features compile,pulley,wat,gc-drc,component-model,component-model-async,debug \
15+
cargo run --no-default-features --features compile,pulley,wat,gc-copying,component-model,component-model-async,debug \
1616
compile --target pulley64 $1 \
1717
-o ${1%.wat}.cwasm \
1818
-O memory-reservation=$((1 << 20)) \

cranelift/codegen/meta/src/gen_inst.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@ fn gen_instruction_data_impl(formats: &[Rc<InstructionFormat>], fmt: &mut Format
557557
OperandKindFields::VariableArgs => {
558558
fmtln!(fmt, "{member}: mapper.map_value_list({member}),");
559559
}
560+
OperandKindFields::ImmValue
561+
if field.kind.rust_type == "ir::MemFlags" =>
562+
{
563+
fmtln!(fmt, "{member}: mapper.map_mem_flags({member}),");
564+
}
560565
OperandKindFields::ImmValue |
561566
OperandKindFields::ImmEnum(_) |
562567
OperandKindFields::TypeVar(_) => fmtln!(fmt, "{member},"),
@@ -1153,7 +1158,14 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo
11531158
} else {
11541159
let t = if op.is_immediate() {
11551160
let t = format!("T{}", tmpl_types.len() + 1);
1156-
tmpl_types.push(format!("{}: Into<{}>", t, op.kind.rust_type));
1161+
// For memflags, the public API type is MemFlagsData (the data),
1162+
// while InstructionData stores MemFlags (the entity index).
1163+
let api_type = if op.kind.rust_type == "ir::MemFlags" {
1164+
"ir::MemFlagsData"
1165+
} else {
1166+
op.kind.rust_type
1167+
};
1168+
tmpl_types.push(format!("{t}: Into<{api_type}>"));
11571169
into_args.push(op.name);
11581170
t
11591171
} else {
@@ -1164,9 +1176,13 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo
11641176
}
11651177
}
11661178

1167-
// We need to mutate `self` if this instruction accepts a value list, or will construct
1168-
// BlockCall values.
1169-
if format.has_value_list || !block_args.is_empty() {
1179+
// We need to mutate `self` if this instruction accepts a value list, will construct
1180+
// BlockCall values, or has memflags operands (which need DFG insertion).
1181+
let has_memflags = inst
1182+
.operands_in
1183+
.iter()
1184+
.any(|op| op.kind.rust_type == "ir::MemFlags");
1185+
if format.has_value_list || !block_args.is_empty() || has_memflags {
11701186
args[0].push_str("mut self");
11711187
} else {
11721188
args[0].push_str("self");
@@ -1221,6 +1237,17 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo
12211237
fmtln!(fmt, "let {} = {}.into();", arg, arg);
12221238
}
12231239

1240+
// Insert memflags data into the DFG to get entity indices.
1241+
for op in &inst.operands_in {
1242+
if op.kind.rust_type == "ir::MemFlags" && op.is_immediate() {
1243+
fmtln!(
1244+
fmt,
1245+
"let {0} = self.data_flow_graph_mut().mem_flags.insert({0}).unwrap();",
1246+
op.name
1247+
);
1248+
}
1249+
}
1250+
12241251
// Convert block references
12251252
for op in block_args {
12261253
fmtln!(

cranelift/codegen/meta/src/gen_isle.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ fn gen_common_isle(
6161
for ty in others.keys() {
6262
fmtln!(fmt, "(type {} (primitive {}))", ty, ty);
6363
}
64+
// Also declare the MemFlagsData type, which is the resolved form of MemFlags.
65+
// MemFlags is an entity index into the DFG's MemFlagsSet, while MemFlagsData
66+
// contains the actual flag bits. Backend MachInst types use MemFlagsData.
67+
fmt.line("(type MemFlagsData (primitive MemFlagsData))");
6468
fmt.empty_line();
6569

6670
// Generate the `enum` immediates, expanding all of the available variants

cranelift/codegen/meta/src/shared/immediates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Immediates {
161161
)
162162
},
163163

164-
memflags: new_imm("flags", "ir::MemFlagsData", "Memory operation flags"),
164+
memflags: new_imm("flags", "ir::MemFlags", "Memory operation flags"),
165165

166166
trapcode: {
167167
let mut trapcode_values = HashMap::new();

cranelift/codegen/meta/src/shared/instructions.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ pub(crate) fn define(
772772
&formats.load,
773773
)
774774
.operands_in(vec![
775-
Operand::new("MemFlagsData", &imm.memflags),
775+
Operand::new("MemFlags", &imm.memflags),
776776
Operand::new("p", iAddr),
777777
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
778778
])
@@ -792,7 +792,7 @@ pub(crate) fn define(
792792
&formats.store,
793793
)
794794
.operands_in(vec![
795-
Operand::new("MemFlagsData", &imm.memflags),
795+
Operand::new("MemFlags", &imm.memflags),
796796
Operand::new("x", Mem).with_doc("Value to be stored"),
797797
Operand::new("p", iAddr),
798798
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
@@ -817,7 +817,7 @@ pub(crate) fn define(
817817
&formats.load,
818818
)
819819
.operands_in(vec![
820-
Operand::new("MemFlagsData", &imm.memflags),
820+
Operand::new("MemFlags", &imm.memflags),
821821
Operand::new("p", iAddr),
822822
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
823823
])
@@ -836,7 +836,7 @@ pub(crate) fn define(
836836
&formats.load,
837837
)
838838
.operands_in(vec![
839-
Operand::new("MemFlagsData", &imm.memflags),
839+
Operand::new("MemFlags", &imm.memflags),
840840
Operand::new("p", iAddr),
841841
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
842842
])
@@ -855,7 +855,7 @@ pub(crate) fn define(
855855
&formats.store,
856856
)
857857
.operands_in(vec![
858-
Operand::new("MemFlagsData", &imm.memflags),
858+
Operand::new("MemFlags", &imm.memflags),
859859
Operand::new("x", iExt8),
860860
Operand::new("p", iAddr),
861861
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
@@ -880,7 +880,7 @@ pub(crate) fn define(
880880
&formats.load,
881881
)
882882
.operands_in(vec![
883-
Operand::new("MemFlagsData", &imm.memflags),
883+
Operand::new("MemFlags", &imm.memflags),
884884
Operand::new("p", iAddr),
885885
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
886886
])
@@ -899,7 +899,7 @@ pub(crate) fn define(
899899
&formats.load,
900900
)
901901
.operands_in(vec![
902-
Operand::new("MemFlagsData", &imm.memflags),
902+
Operand::new("MemFlags", &imm.memflags),
903903
Operand::new("p", iAddr),
904904
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
905905
])
@@ -918,7 +918,7 @@ pub(crate) fn define(
918918
&formats.store,
919919
)
920920
.operands_in(vec![
921-
Operand::new("MemFlagsData", &imm.memflags),
921+
Operand::new("MemFlags", &imm.memflags),
922922
Operand::new("x", iExt16),
923923
Operand::new("p", iAddr),
924924
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
@@ -943,7 +943,7 @@ pub(crate) fn define(
943943
&formats.load,
944944
)
945945
.operands_in(vec![
946-
Operand::new("MemFlagsData", &imm.memflags),
946+
Operand::new("MemFlags", &imm.memflags),
947947
Operand::new("p", iAddr),
948948
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
949949
])
@@ -962,7 +962,7 @@ pub(crate) fn define(
962962
&formats.load,
963963
)
964964
.operands_in(vec![
965-
Operand::new("MemFlagsData", &imm.memflags),
965+
Operand::new("MemFlags", &imm.memflags),
966966
Operand::new("p", iAddr),
967967
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
968968
])
@@ -981,7 +981,7 @@ pub(crate) fn define(
981981
&formats.store,
982982
)
983983
.operands_in(vec![
984-
Operand::new("MemFlagsData", &imm.memflags),
984+
Operand::new("MemFlags", &imm.memflags),
985985
Operand::new("x", iExt32),
986986
Operand::new("p", iAddr),
987987
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
@@ -1069,7 +1069,7 @@ pub(crate) fn define(
10691069
&formats.load,
10701070
)
10711071
.operands_in(vec![
1072-
Operand::new("MemFlagsData", &imm.memflags),
1072+
Operand::new("MemFlags", &imm.memflags),
10731073
Operand::new("p", iAddr),
10741074
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
10751075
])
@@ -1087,7 +1087,7 @@ pub(crate) fn define(
10871087
&formats.load,
10881088
)
10891089
.operands_in(vec![
1090-
Operand::new("MemFlagsData", &imm.memflags),
1090+
Operand::new("MemFlags", &imm.memflags),
10911091
Operand::new("p", iAddr),
10921092
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
10931093
])
@@ -1115,7 +1115,7 @@ pub(crate) fn define(
11151115
&formats.load,
11161116
)
11171117
.operands_in(vec![
1118-
Operand::new("MemFlagsData", &imm.memflags),
1118+
Operand::new("MemFlags", &imm.memflags),
11191119
Operand::new("p", iAddr),
11201120
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
11211121
])
@@ -1133,7 +1133,7 @@ pub(crate) fn define(
11331133
&formats.load,
11341134
)
11351135
.operands_in(vec![
1136-
Operand::new("MemFlagsData", &imm.memflags),
1136+
Operand::new("MemFlags", &imm.memflags),
11371137
Operand::new("p", iAddr),
11381138
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
11391139
])
@@ -1161,7 +1161,7 @@ pub(crate) fn define(
11611161
&formats.load,
11621162
)
11631163
.operands_in(vec![
1164-
Operand::new("MemFlagsData", &imm.memflags),
1164+
Operand::new("MemFlags", &imm.memflags),
11651165
Operand::new("p", iAddr),
11661166
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
11671167
])
@@ -1179,7 +1179,7 @@ pub(crate) fn define(
11791179
&formats.load,
11801180
)
11811181
.operands_in(vec![
1182-
Operand::new("MemFlagsData", &imm.memflags),
1182+
Operand::new("MemFlags", &imm.memflags),
11831183
Operand::new("p", iAddr),
11841184
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address"),
11851185
])
@@ -3132,17 +3132,17 @@ pub(crate) fn define(
31323132
31333133
The input and output types must be storable to memory and of the same
31343134
size. A bitcast is equivalent to storing one type and loading the other
3135-
type from the same address, both using the specified MemFlagsData.
3135+
type from the same address, both using the specified MemFlags.
31363136
3137-
Note that this operation only supports the `big` or `little` MemFlagsData.
3137+
Note that this operation only supports the `big` or `little` MemFlags.
31383138
The specified byte order only affects the result in the case where
31393139
input and output types differ in lane count/size. In this case, the
31403140
operation is only valid if a byte order specifier is provided.
31413141
"#,
31423142
&formats.load_no_offset,
31433143
)
31443144
.operands_in(vec![
3145-
Operand::new("MemFlagsData", &imm.memflags),
3145+
Operand::new("MemFlags", &imm.memflags),
31463146
Operand::new("x", Mem),
31473147
])
31483148
.operands_out(vec![
@@ -3773,7 +3773,7 @@ pub(crate) fn define(
37733773
&formats.atomic_rmw,
37743774
)
37753775
.operands_in(vec![
3776-
Operand::new("MemFlagsData", &imm.memflags),
3776+
Operand::new("MemFlags", &imm.memflags),
37773777
Operand::new("AtomicRmwOp", &imm.atomic_rmw_op),
37783778
Operand::new("p", iAddr),
37793779
Operand::new("x", AtomicMem).with_doc("Value to be atomically stored"),
@@ -3802,7 +3802,7 @@ pub(crate) fn define(
38023802
&formats.atomic_cas,
38033803
)
38043804
.operands_in(vec![
3805-
Operand::new("MemFlagsData", &imm.memflags),
3805+
Operand::new("MemFlags", &imm.memflags),
38063806
Operand::new("p", iAddr),
38073807
Operand::new("e", AtomicMem).with_doc("Expected value in CAS"),
38083808
Operand::new("x", AtomicMem).with_doc("Value to be atomically stored"),
@@ -3830,7 +3830,7 @@ pub(crate) fn define(
38303830
&formats.load_no_offset,
38313831
)
38323832
.operands_in(vec![
3833-
Operand::new("MemFlagsData", &imm.memflags),
3833+
Operand::new("MemFlags", &imm.memflags),
38343834
Operand::new("p", iAddr),
38353835
])
38363836
.operands_out(vec![
@@ -3855,7 +3855,7 @@ pub(crate) fn define(
38553855
&formats.store_no_offset,
38563856
)
38573857
.operands_in(vec![
3858-
Operand::new("MemFlagsData", &imm.memflags),
3858+
Operand::new("MemFlags", &imm.memflags),
38593859
Operand::new("x", AtomicMem).with_doc("Value to be atomically stored"),
38603860
Operand::new("p", iAddr),
38613861
])

0 commit comments

Comments
 (0)