This commit is contained in:
Graham Kelly 2024-08-11 20:43:39 -04:00
parent 28760e867e
commit c7d4e8ded3
3 changed files with 58 additions and 31 deletions

48
Cargo.lock generated
View file

@ -148,9 +148,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.1.6"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f"
checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292"
[[package]]
name = "cfg-if"
@ -257,7 +257,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustc_version",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -324,7 +324,7 @@ checksum = "77107325d07454a4de518e92b1e061ded5af8aa32d52edb1fde60c813d1eff1b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -335,9 +335,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "flate2"
version = "1.0.30"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -435,9 +435,9 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
[[package]]
name = "indexmap"
version = "2.2.6"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
dependencies = [
"equivalent",
"hashbrown",
@ -604,7 +604,7 @@ dependencies = [
"prettyplease",
"proc-macro2",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -617,7 +617,7 @@ dependencies = [
"quasiquote",
"quote",
"sha3",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -630,7 +630,7 @@ dependencies = [
"proc-macro2",
"quasiquote",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -645,7 +645,7 @@ dependencies = [
[[package]]
name = "portal-pc-waffle"
version = "0.0.27+portal"
source = "git+https://github.com/portal-co/waffle-.git?branch=pr/changes2#8db8a0234782a612db040282dda2ee177ff36f28"
source = "git+https://github.com/portal-co/waffle-.git?branch=pr/changes2#8fff4913c0dcd18db52a6d6aad3728c114d5d9a2"
dependencies = [
"addr2line",
"anyhow",
@ -672,7 +672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
dependencies = [
"proc-macro2",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -785,14 +785,14 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
name = "regex"
version = "1.10.5"
version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [
"aho-corasick",
"memchr",
@ -851,22 +851,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.204"
version = "1.0.206"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.204"
version = "1.0.206"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]
[[package]]
@ -953,9 +953,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.72"
version = "2.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
dependencies = [
"proc-macro2",
"quote",
@ -1215,5 +1215,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
"syn 2.0.74",
]

View file

@ -265,6 +265,7 @@ pub fn instantiate(m: &mut Module, cfg: &Cfg) -> anyhow::Result<()> {
initial: fs.len() as u64,
max: Some(fs.len() as u64),
func_elements: Some(fs.clone()),
table64: false,
});
if let ImportKind::Func(f) = i.kind {
let fsi = m.funcs[f].sig();

View file

@ -1,11 +1,14 @@
use std::{
collections::{BTreeMap, BTreeSet}, iter::once, mem::{replace, take}
collections::{BTreeMap, BTreeSet},
iter::once,
mem::{replace, take},
};
use anyhow::Context;
use pit_core::{Arg, ResTy};
use waffle::{
util::new_sig, Block, BlockTarget, Export, ExportKind, Func, FuncDecl, FunctionBody, Import, ImportKind, Module, Operator, SignatureData, Table, TableData, Type, Value
util::new_sig, Block, BlockTarget, Export, ExportKind, Func, FuncDecl, FunctionBody, Import,
ImportKind, Module, Operator, SignatureData, Table, TableData, Type, Value,
};
use waffle_ast::{add_op, results_ref_2, Builder, Expr};
@ -337,7 +340,13 @@ pub fn shim(
Ok((ep, end))
}
pub fn wrap(m: &mut Module) -> anyhow::Result<()> {
let t = m.tables.push(TableData{ty: Type::ExternRef, initial: 0, max: None, func_elements: None});
let t = m.tables.push(TableData {
ty: Type::ExternRef,
initial: 0,
max: None,
func_elements: None,
table64: false,
});
let talloc = talloc(m, t)?;
let tfree = tfree(m, t)?;
let is = get_interfaces(m)?.into_iter().collect::<BTreeSet<_>>();
@ -501,7 +510,15 @@ pub fn wrap(m: &mut Module) -> anyhow::Result<()> {
.map(|a| a.1)
.collect::<Vec<_>>()
.into_iter()
.zip(once(Arg::Resource { ty: ResTy::This, nullable: false, take: false, ann: vec![] }).chain(x.params.iter().cloned()));
.zip(
once(Arg::Resource {
ty: ResTy::This,
nullable: false,
take: false,
ann: vec![],
})
.chain(x.params.iter().cloned()),
);
let mut v2 = vec![];
for (v, r) in args {
let a;
@ -595,8 +612,17 @@ pub fn wrap(m: &mut Module) -> anyhow::Result<()> {
m.exports.push(export);
}
}
m.exports.push(Export{name: format!("tpit_alloc"),kind: ExportKind::Func(talloc)});
m.exports.push(Export{name: format!("tpit_free"),kind: ExportKind::Func(tfree)});
m.exports.push(Export{name: format!("tpit_table"),kind: ExportKind::Table(t)});
m.exports.push(Export {
name: format!("tpit_alloc"),
kind: ExportKind::Func(talloc),
});
m.exports.push(Export {
name: format!("tpit_free"),
kind: ExportKind::Func(tfree),
});
m.exports.push(Export {
name: format!("tpit_table"),
kind: ExportKind::Table(t),
});
Ok(())
}