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]] [[package]]
name = "cc" name = "cc"
version = "1.1.6" version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -257,7 +257,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustc_version", "rustc_version",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -324,7 +324,7 @@ checksum = "77107325d07454a4de518e92b1e061ded5af8aa32d52edb1fde60c813d1eff1b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -335,9 +335,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide",
@ -435,9 +435,9 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.2.6" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown", "hashbrown",
@ -604,7 +604,7 @@ dependencies = [
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -617,7 +617,7 @@ dependencies = [
"quasiquote", "quasiquote",
"quote", "quote",
"sha3", "sha3",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -630,7 +630,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quasiquote", "quasiquote",
"quote", "quote",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -645,7 +645,7 @@ dependencies = [
[[package]] [[package]]
name = "portal-pc-waffle" name = "portal-pc-waffle"
version = "0.0.27+portal" 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 = [ dependencies = [
"addr2line", "addr2line",
"anyhow", "anyhow",
@ -672,7 +672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -785,14 +785,14 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.5" version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -851,22 +851,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.204" version = "1.0.206"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.204" version = "1.0.206"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.72", "syn 2.0.74",
] ]
[[package]] [[package]]
@ -953,9 +953,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.72" version = "2.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1215,5 +1215,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "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, initial: fs.len() as u64,
max: Some(fs.len() as u64), max: Some(fs.len() as u64),
func_elements: Some(fs.clone()), func_elements: Some(fs.clone()),
table64: false,
}); });
if let ImportKind::Func(f) = i.kind { if let ImportKind::Func(f) = i.kind {
let fsi = m.funcs[f].sig(); let fsi = m.funcs[f].sig();

View file

@ -1,11 +1,14 @@
use std::{ use std::{
collections::{BTreeMap, BTreeSet}, iter::once, mem::{replace, take} collections::{BTreeMap, BTreeSet},
iter::once,
mem::{replace, take},
}; };
use anyhow::Context; use anyhow::Context;
use pit_core::{Arg, ResTy}; use pit_core::{Arg, ResTy};
use waffle::{ 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}; use waffle_ast::{add_op, results_ref_2, Builder, Expr};
@ -337,7 +340,13 @@ pub fn shim(
Ok((ep, end)) Ok((ep, end))
} }
pub fn wrap(m: &mut Module) -> anyhow::Result<()> { 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 talloc = talloc(m, t)?;
let tfree = tfree(m, t)?; let tfree = tfree(m, t)?;
let is = get_interfaces(m)?.into_iter().collect::<BTreeSet<_>>(); 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) .map(|a| a.1)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_iter() .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![]; let mut v2 = vec![];
for (v, r) in args { for (v, r) in args {
let a; let a;
@ -595,8 +612,17 @@ pub fn wrap(m: &mut Module) -> anyhow::Result<()> {
m.exports.push(export); m.exports.push(export);
} }
} }
m.exports.push(Export{name: format!("tpit_alloc"),kind: ExportKind::Func(talloc)}); m.exports.push(Export {
m.exports.push(Export{name: format!("tpit_free"),kind: ExportKind::Func(tfree)}); name: format!("tpit_alloc"),
m.exports.push(Export{name: format!("tpit_table"),kind: ExportKind::Table(t)}); 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(()) Ok(())
} }