Skip to content
Draft
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
2 changes: 0 additions & 2 deletions crates/environ/src/component/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ pub enum CoreDef {
InstanceFlags(RuntimeComponentInstanceIndex),
Trampoline(TrampolineIndex),
UnsafeIntrinsic(ModuleInternedTypeIndex, UnsafeIntrinsic),
TaskMayBlock,

/// This is a special variant not present in `info::CoreDef` which
/// represents that this definition refers to a fused adapter function. This
Expand Down Expand Up @@ -913,7 +912,6 @@ impl LinearizeDfg<'_> {
}
info::CoreDef::UnsafeIntrinsic(*i)
}
CoreDef::TaskMayBlock => info::CoreDef::TaskMayBlock,
}
}

Expand Down
4 changes: 0 additions & 4 deletions crates/environ/src/component/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,6 @@ pub enum CoreDef {
Trampoline(TrampolineIndex),
/// An intrinsic for compile-time builtins.
UnsafeIntrinsic(UnsafeIntrinsic),
/// Reference to a wasm global which represents a runtime-managed boolean
/// indicating whether the currently-running task may perform a blocking
/// operation.
TaskMayBlock,
}

impl<T> From<CoreExport<T>> for CoreDef
Expand Down
1 change: 0 additions & 1 deletion crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ impl<'a, 'data> Translator<'a, 'data> {

let known_func = match arg {
CoreDef::InstanceFlags(_) => unreachable!("instance flags are not a function"),
CoreDef::TaskMayBlock => unreachable!("task_may_block is not a function"),

// We could in theory inline these trampolines, so it could
// potentially make sense to record that we know this
Expand Down
3 changes: 1 addition & 2 deletions crates/environ/src/component/translate/adapt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ impl PartitionAdapterModules {
// These items can't transitively depend on an adapter
dfg::CoreDef::Trampoline(_)
| dfg::CoreDef::InstanceFlags(_)
| dfg::CoreDef::UnsafeIntrinsic(..)
| dfg::CoreDef::TaskMayBlock => {}
| dfg::CoreDef::UnsafeIntrinsic(..) => {}
}
}

Expand Down
22 changes: 0 additions & 22 deletions crates/environ/src/fact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ pub struct Module<'a> {
helper_worklist: Vec<(FunctionId, Helper)>,

exports: Vec<(u32, String)>,

task_may_block: Option<GlobalIndex>,
}

struct AdapterData {
Expand Down Expand Up @@ -298,7 +296,6 @@ impl<'a> Module<'a> {
imported_unsafe_intrinsics: HashMap::new(),
imported_traps: HashMap::new(),
exports: Vec::new(),
task_may_block: None,
}
}

Expand Down Expand Up @@ -491,25 +488,6 @@ impl<'a> Module<'a> {
idx
}

fn import_task_may_block(&mut self) -> GlobalIndex {
if let Some(task_may_block) = self.task_may_block {
task_may_block
} else {
let task_may_block = self.import_global(
"instance",
"task_may_block",
GlobalType {
val_type: ValType::I32,
mutable: true,
shared: false,
},
CoreDef::TaskMayBlock,
);
self.task_may_block = Some(task_may_block);
task_may_block
}
}

fn import_transcoder(&mut self, transcoder: transcode::Transcoder) -> FuncIndex {
*self
.imported_transcoders
Expand Down
39 changes: 4 additions & 35 deletions crates/environ/src/fact/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,25 +769,7 @@ impl<'a, 'b> Compiler<'a, 'b> {
let saved_lower_may_leave =
self.trap_if_not_may_leave(adapter.lower.flags, Trap::CannotLeaveComponent);

let old_task_may_block = if self.module.tunables.concurrency_support {
// Save, clear, and later restore the `may_block` field.
let task_may_block = self.module.import_task_may_block();
let old_task_may_block = if self.types[adapter.lift.ty].async_ {
self.instruction(GlobalGet(task_may_block.as_u32()));
self.instruction(I32Eqz);
self.instruction(If(BlockType::Empty));
self.trap(Trap::CannotBlockSyncTask);
self.instruction(End);
None
} else {
let task_may_block = self.module.import_task_may_block();
self.instruction(GlobalGet(task_may_block.as_u32()));
let old_task_may_block = self.local_set_new_tmp(ValType::I32);
self.instruction(I32Const(0));
self.instruction(GlobalSet(task_may_block.as_u32()));
Some(old_task_may_block)
};

if self.module.tunables.concurrency_support {
// Push a task onto the current task stack.
//
// Note that for sync-to-sync calls, we replace this call with
Expand All @@ -809,8 +791,6 @@ impl<'a, 'b> Compiler<'a, 'b> {
));
let enter_sync_call = self.module.import_enter_sync_call();
self.instruction(Call(enter_sync_call.as_u32()));

old_task_may_block
} else if self.emit_resource_call {
assert!(!self.types[adapter.lift.ty].async_);
self.instruction(I32Const(
Expand All @@ -822,10 +802,7 @@ impl<'a, 'b> Compiler<'a, 'b> {
));
let enter_sync_call = self.module.import_enter_sync_call();
self.instruction(Call(enter_sync_call.as_u32()));
None
} else {
None
};
}

// Perform the translation of arguments. Note that the `may_leave` flag
// is cleared around this invocation for the callee as per the
Expand Down Expand Up @@ -874,7 +851,9 @@ impl<'a, 'b> Compiler<'a, 'b> {
// With all the arguments on the stack the actual target function is
// now invoked. The core wasm results of the function are then placed
// into locals for result translation afterwards.

self.instruction(Call(adapter.callee.as_u32()));

let mut result_locals = Vec::with_capacity(lift_sig.results.len());
let mut temps = Vec::new();
for ty in lift_sig.results.iter().rev() {
Expand Down Expand Up @@ -944,16 +923,6 @@ impl<'a, 'b> Compiler<'a, 'b> {
self.free_temp_local(tmp);
}

if self.module.tunables.concurrency_support {
// Restore old `may_block_field`
if let Some(old_task_may_block) = old_task_may_block {
let task_may_block = self.module.import_task_may_block();
self.instruction(LocalGet(old_task_may_block.idx));
self.instruction(GlobalSet(task_may_block.as_u32()));
self.free_temp_local(old_task_may_block);
}
}

self.exit_exception_barrier();

self.finish()
Expand Down
Loading
Loading