Skip to content

Commit ffe22ff

Browse files
committed
Added support for recording all boundaries of Func and TypedFunc; completed core wasm rr
1 parent c4645ab commit ffe22ff

File tree

28 files changed

+607
-335
lines changed

28 files changed

+607
-335
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ webpki-roots = "0.26.0"
411411
itertools = "0.14.0"
412412
base64 = "0.22.1"
413413
termcolor = "1.4.1"
414+
sha2 = { version = "0.10.2", default-features = false }
414415

415416
# =============================================================================
416417
#

crates/c-api/include/wasmtime/extern.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ typedef struct wasmtime_func {
3030
/// this field is otherwise never zero.
3131
uint64_t store_id;
3232
/// Private field for Wasmtime, undefined if `store_id` is zero.
33-
void *__private;
33+
void *__private1;
34+
/// Private field for Wasmtime
35+
uint32_t *__private2;
36+
/// Private field for Wasmtime
37+
uint32_t *__private3;
38+
/// Private field for Wasmtime
39+
uint32_t *__private4;
3440
} wasmtime_func_t;
3541

3642
/// \brief Representation of a table in Wasmtime.

crates/c-api/include/wasmtime/val.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ typedef union wasmtime_val_raw {
418418
// Assert that the shape of this type is as expected since it needs to match
419419
// Rust.
420420
static inline void __wasmtime_val_assertions() {
421-
static_assert(sizeof(wasmtime_valunion_t) == 16, "should be 16-bytes large");
421+
static_assert(sizeof(wasmtime_valunion_t) == 32, "should be 16-bytes large");
422422
static_assert(__alignof(wasmtime_valunion_t) == 8,
423423
"should be 8-byte aligned");
424424
static_assert(sizeof(wasmtime_val_raw_t) == 16, "should be 16 bytes large");

crates/c-api/src/val.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub union wasmtime_val_union {
152152
}
153153

154154
const _: () = {
155-
assert!(std::mem::size_of::<wasmtime_val_union>() == 16);
155+
assert!(std::mem::size_of::<wasmtime_val_union>() == 32);
156156
assert!(std::mem::align_of::<wasmtime_val_union>() == std::mem::align_of::<u64>());
157157
};
158158

crates/environ/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ wasmprinter = { workspace = true, optional = true }
3737
wasmtime-component-util = { workspace = true, optional = true }
3838
semver = { workspace = true, optional = true, features = ['serde'] }
3939
smallvec = { workspace = true, features = ['serde'] }
40+
sha2 = { workspace = true }
4041

4142
[dev-dependencies]
4243
clap = { workspace = true, features = ['default'] }

crates/environ/src/compile/module_artifacts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::{
1010
use anyhow::{Result, bail};
1111
use object::SectionKind;
1212
use object::write::{Object, SectionId, StandardSegment, WritableBuffer};
13+
use sha2::{Digest, Sha256};
1314
use std::ops::Range;
1415

1516
/// Helper structure to create an ELF file as a compilation artifact.
@@ -124,6 +125,7 @@ impl<'a> ObjectBuilder<'a> {
124125
debuginfo,
125126
has_unparsed_debuginfo,
126127
data,
128+
wasm,
127129
data_align,
128130
passive_data,
129131
..
@@ -228,6 +230,7 @@ impl<'a> ObjectBuilder<'a> {
228230
has_wasm_debuginfo: self.tunables.parse_wasm_debuginfo,
229231
dwarf,
230232
},
233+
checksum: Sha256::digest(wasm).into(),
231234
})
232235
}
233236

crates/environ/src/module_artifacts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ pub struct CompiledModuleInfo {
5252

5353
/// General compilation metadata.
5454
pub meta: Metadata,
55+
56+
/// Checksum of the source Wasm binary from which this module was compiled
57+
pub checksum: [u8; 32],
5558
}
5659

5760
/// The name of a function stored in the

crates/wasmtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bitflags = { workspace = true }
6363
futures = { workspace = true, features = ["alloc"], optional = true }
6464
bytes = { workspace = true, optional = true }
6565
embedded-io = { version = "0.6.1", features = ["alloc"], optional = true }
66-
sha2 = { version = "0.10.2", default-features = false }
66+
sha2 = { workspace = true }
6767

6868
[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
6969
workspace = true

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use crate::component::matching::InstanceType;
44
use crate::component::resources::{HostResourceData, HostResourceIndex, HostResourceTables};
55
use crate::component::{Instance, ResourceType};
66
use crate::prelude::*;
7-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
8-
use crate::rr::component_events::ResultEvent;
97
#[cfg(feature = "rr-component")]
108
use crate::rr::component_hooks::ReplayLoweringPhase;
119
use crate::rr::{ConstMemorySliceCell, MemorySliceCell};
@@ -14,7 +12,7 @@ use crate::rr::{
1412
RREvent, RecordBuffer, ReplayError, Replayer, component_events::ReallocEntryEvent,
1513
};
1614
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
17-
use crate::rr::{Validate, component_events::ReallocReturnEvent};
15+
use crate::rr::{ResultEvent, Validate, component_events::ReallocReturnEvent};
1816
use crate::runtime::vm::component::{
1917
CallContexts, ComponentInstance, InstanceFlags, ResourceTable, ResourceTables,
2018
};
@@ -139,7 +137,7 @@ impl Options {
139137

140138
// Invoke the wasm malloc function using its raw and statically known
141139
// signature.
142-
let result = unsafe { ReallocFunc::call_raw(store, realloc_ty, realloc, params)? };
140+
let result = unsafe { ReallocFunc::call_raw(store, realloc_ty, realloc, params, None)? };
143141

144142
if result % old_align != 0 {
145143
bail!("realloc return: result not aligned");
@@ -560,40 +558,6 @@ impl<'a, T: 'static> LowerContext<'a, T> {
560558
)
561559
}
562560

563-
/// Perform a replay of only [`ReallocEntryEvent`] + [`ReallocReturnEvent`] events
564-
///
565-
/// Panics if replay not enabled
566-
#[cfg(feature = "rr-component")]
567-
pub fn replay_realloc(&mut self) -> Result<usize> {
568-
let get_event = |cx: &mut Self| cx.store.0.replay_buffer_mut().unwrap().next_event();
569-
let (record_has_validation, _replay_validate) = {
570-
let buf = self.store.0.replay_buffer_mut().unwrap();
571-
(buf.trace_settings().add_validation, buf.settings().validate)
572-
};
573-
574-
let ptr = match get_event(self)? {
575-
RREvent::ComponentReallocEntry(e) => {
576-
self.realloc_inner(e.old_addr, e.old_size, e.old_align, e.new_size)
577-
}
578-
_ => bail!(ReplayError::IncorrectEventVariant),
579-
};
580-
581-
if record_has_validation {
582-
match get_event(self)? {
583-
RREvent::ComponentReallocReturn(e) =>
584-
{
585-
#[cfg(feature = "rr-validate")]
586-
if _replay_validate {
587-
e.0.validate(&ptr)?
588-
}
589-
}
590-
_ => bail!(ReplayError::IncorrectEventVariant),
591-
};
592-
}
593-
594-
ptr
595-
}
596-
597561
/// Perform a replay of all the type lowering-associated events for this context
598562
///
599563
/// These typically include all `Lower*` and `Realloc*` event, along with the putting

0 commit comments

Comments
 (0)