Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 3 additions & 41 deletions kiln-runtime/src/atomic_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use core::sync::atomic::{
Ordering as AtomicOrdering,
};
use core::time::Duration;
#[cfg(feature = "std")]
use alloc::{
collections::BTreeMap,
sync::Arc,
Expand All @@ -35,8 +34,6 @@ use kiln_error::{
ErrorCategory,
Result,
};
#[cfg(all(not(feature = "std"), not(feature = "std")))]
use kiln_foundation::bounded::BoundedVec;
use kiln_foundation::{
traits::BoundedCapacity,
MemArg,
Expand Down Expand Up @@ -65,12 +62,7 @@ use crate::{

// Type alias for return results
/// Result vector type for std environments
#[cfg(feature = "std")]
pub type ResultVec = Vec<u32>;
/// Result vector type for `no_std` environments with bounded capacity
#[cfg(all(not(feature = "std"), not(feature = "std")))]
pub type ResultVec =
kiln_foundation::bounded::BoundedVec<u32, 256, kiln_foundation::safe_memory::NoStdProvider<8192>>;

// Type alias for thread ID vectors - use bounded collections consistently
type ThreadIdVec = kiln_foundation::bounded::BoundedVec<
Expand All @@ -83,47 +75,17 @@ type ThreadIdVec = kiln_foundation::bounded::BoundedVec<
macro_rules! result_vec {
() => {
{
#[cfg(feature = "std")]
{
Ok(Vec::new())
}
#[cfg(all(not(feature = "std"), not(feature = "std")))]
{
let provider = kiln_foundation::safe_managed_alloc!(8192, kiln_foundation::budget_aware_provider::CrateId::Runtime)?;
kiln_foundation::bounded::BoundedVec::new(provider)?
}
Ok(Vec::new())
}
};
($item:expr; $count:expr) => {
{
#[cfg(feature = "std")]
{
Ok(vec![$item; $count])
}
#[cfg(all(not(feature = "std"), not(feature = "std")))]
{
let provider = kiln_foundation::safe_managed_alloc!(8192, kiln_foundation::budget_aware_provider::CrateId::Runtime)?;
let mut v = kiln_foundation::bounded::BoundedVec::new(provider)?;
for _ in 0..$count {
v.push($item)?;
}
Ok(v)
}
Ok(vec![$item; $count])
}
};
($($item:expr),+) => {
{
#[cfg(feature = "std")]
{
Ok(vec![$($item),+])
}
#[cfg(all(not(feature = "std"), not(feature = "std")))]
{
let provider = kiln_foundation::safe_managed_alloc!(8192, kiln_foundation::budget_aware_provider::CrateId::Runtime)?;
let mut v = kiln_foundation::bounded::BoundedVec::new(provider)?;
$(v.push($item)?;)+
v
}
Ok(vec![$($item),+])
}
};
}
Expand Down
21 changes: 5 additions & 16 deletions kiln-runtime/src/atomic_memory_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@ type ResourceVec = kiln_foundation::bounded::BoundedVec<usize, 16, AtomicProvide
type ViolationString = kiln_foundation::bounded::BoundedString<64>;
type OperationTypeVec = kiln_foundation::bounded::BoundedVec<ViolationString, 16, AtomicProvider1K>;

#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::{
sync::Arc,
vec::Vec,
};
#[cfg(feature = "std")]
use alloc::{
sync::Arc,
vec::Vec,
};
#[cfg(feature = "std")]
use std::time::Instant;

/// WebAssembly atomic memory model implementation
#[derive(Debug)]
pub struct AtomicMemoryModel {
Expand Down Expand Up @@ -120,7 +114,6 @@ impl AtomicMemoryModel {
self.apply_pre_operation_ordering(&operation)?;

// Record operation timing
#[cfg(feature = "std")]
let start_time = Instant::now();

// Execute the atomic operation
Expand Down Expand Up @@ -187,13 +180,10 @@ impl AtomicMemoryModel {
};

// Record operation timing
#[cfg(feature = "std")]
{
let duration = start_time.elapsed();
self.model_stats.total_execution_time += duration.as_nanos() as u64;
if duration.as_nanos() as u64 > self.model_stats.max_operation_time {
self.model_stats.max_operation_time = duration.as_nanos() as u64;
}
let duration = start_time.elapsed();
self.model_stats.total_execution_time += duration.as_nanos() as u64;
if duration.as_nanos() as u64 > self.model_stats.max_operation_time {
self.model_stats.max_operation_time = duration.as_nanos() as u64;
}

// Apply memory ordering constraints after operation
Expand Down Expand Up @@ -808,7 +798,6 @@ mod tests {
assert!(result.data_races.is_empty());
}

#[cfg(feature = "std")]
#[test]
fn test_atomic_memory_model_creation() {
let thread_manager = ThreadManager::new(ThreadConfig::default()).unwrap();
Expand Down
1 change: 0 additions & 1 deletion kiln-runtime/src/atomic_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use crate::atomic_execution::{
AtomicMemoryContext,
};

#[cfg(any(feature = "std", feature = "alloc"))]
use crate::thread_manager::ThreadId;

/// Provider trait for atomic operations across ASIL levels
Expand Down
5 changes: 0 additions & 5 deletions kiln-runtime/src/capability_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//!
//! This module provides simple integration examples for the capability system.

#[cfg(feature = "std")]
use kiln_foundation::capabilities::{
PlatformAllocator,
PlatformCapabilityBuilder,
Expand All @@ -12,7 +11,6 @@ use kiln_foundation::capabilities::{
use crate::prelude::*;

/// Simple demonstration of capability integration
#[cfg(feature = "std")]
pub fn create_simple_capability_provider(
memory_limit: usize,
) -> Result<PlatformCapabilityProvider> {
Expand All @@ -24,11 +22,9 @@ pub fn create_simple_capability_provider(
}

/// Simple allocator for demonstration
#[cfg(feature = "std")]
#[derive(Debug)]
struct SimpleAllocator;

#[cfg(feature = "std")]
impl PlatformAllocator for SimpleAllocator {
fn available_memory(&self) -> usize {
1024 * 1024 * 1024 // 1GB
Expand All @@ -43,7 +39,6 @@ impl PlatformAllocator for SimpleAllocator {
mod tests {
use super::*;

#[cfg(feature = "std")]
#[test]
fn test_simple_capability_provider() {
let provider = create_simple_capability_provider(1024 * 1024);
Expand Down
10 changes: 1 addition & 9 deletions kiln-runtime/src/cfi_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ mod cfi_types {
}

// CFI imports temporarily disabled since CFI module is disabled
// #[cfg(not(feature = "std"))]
// use kiln_instructions::cfi_control_ops::{CfiHardwareInstruction,
// CfiSoftwareValidation}; Available for both std and no_std since CFI module is
// disabled
// Available for both std and no_std since CFI module is disabled
use kiln_foundation::traits::DefaultMemoryProvider;

use self::cfi_types::ShadowStackRequirement;
Expand All @@ -148,11 +145,6 @@ pub use self::cfi_types::{
ShadowStackEntry,
};
// CFI imports temporarily disabled since CFI module is disabled
// #[cfg(feature = "std")]
// use kiln_instructions::cfi_control_ops::{
// CfiHardwareInstruction, ArmBtiMode, CfiSoftwareValidation,
// ShadowStackRequirement, ShadowStackEntry
// };
use crate::{
execution::ExecutionContext,
prelude::{
Expand Down
22 changes: 1 addition & 21 deletions kiln-runtime/src/clean_runtime_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! instead of provider-embedded types, serving as a prototype for the
//! full kiln-runtime migration.

#[cfg(any(feature = "std", feature = "alloc"))]
use alloc::{
string::String,
vec::Vec,
Expand All @@ -16,7 +15,6 @@ use kiln_error::{
ErrorCategory,
Result,
};
#[cfg(any(feature = "std", feature = "alloc"))]
use kiln_foundation::{
CleanFuncType,
CleanMemoryType,
Expand All @@ -28,7 +26,6 @@ use kiln_foundation::{
};

/// Clean runtime module using provider-free types
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct CleanRuntime {
/// Runtime type factory for allocation
factory: RuntimeTypeFactory<65536>,
Expand All @@ -40,7 +37,6 @@ pub struct CleanRuntime {
tables: Vec<CleanTable>,
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl CleanRuntime {
/// Create a new clean runtime
pub fn new() -> Self {
Expand Down Expand Up @@ -124,15 +120,13 @@ impl CleanRuntime {
}
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl Default for CleanRuntime {
fn default() -> Self {
Self::new()
}
}

/// Clean function representation without provider embedding
#[cfg(any(feature = "std", feature = "alloc"))]
#[derive(Debug, Clone)]
pub struct CleanFunction {
/// Function name
Expand All @@ -143,8 +137,7 @@ pub struct CleanFunction {
pub id: u32,
}

/// Clean memory representation without provider embedding
#[cfg(any(feature = "std", feature = "alloc"))]
/// Clean memory representation without provider embedding
#[derive(Debug, Clone)]
pub struct CleanMemory {
/// Memory name
Expand All @@ -158,7 +151,6 @@ pub struct CleanMemory {
pub data: Vec<u8>,
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl CleanMemory {
/// Read from memory
pub fn read(&self, offset: u32, size: u32) -> Result<Vec<u8>> {
Expand Down Expand Up @@ -188,7 +180,6 @@ impl CleanMemory {
}

/// Clean table representation without provider embedding
#[cfg(any(feature = "std", feature = "alloc"))]
#[derive(Debug, Clone)]
pub struct CleanTable {
/// Table name
Expand All @@ -201,14 +192,3 @@ pub struct CleanTable {
pub elements: Vec<Option<u32>>, // Function references
}

// Provide empty implementations for no-alloc environments
#[cfg(not(any(feature = "std", feature = "alloc")))]
pub struct CleanRuntime;

#[cfg(not(any(feature = "std", feature = "alloc")))]
impl CleanRuntime {
pub fn new() -> Self {
Self
}
}

Loading
Loading