Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
Co-Authored-By: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
  • Loading branch information
daxpedda and Liamolucko committed Jun 6, 2023
1 parent 0ba5241 commit 750eccc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/cli-support/src/js/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ fn instruction(js: &mut JsBuilder, instr: &Instruction, log_error: &mut bool) ->
let tmp = js.tmp();
if invoc.defer() {
if let Instruction::DeferFree { .. } = instr {
// substract alignment
// Ignore `free`'s final `align` argument, since that's manually inserted later.
params -= 1;
}
// If the call is deferred, the arguments to the function still need to be
Expand Down
4 changes: 2 additions & 2 deletions crates/cli-support/src/wit/outgoing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl InstructionBuilder<'_, '_> {
// ... then defer a call to `free` to happen later
let free = self.cx.free()?;
self.instructions.push(InstructionData {
instr: Instruction::DeferFree { free, align: 4 },
instr: Instruction::DeferFree { free, align: 1 },
stack_change: StackChange::Modified {
popped: 2,
pushed: 2,
Expand Down Expand Up @@ -429,7 +429,7 @@ impl InstructionBuilder<'_, '_> {
// implementation.
let free = self.cx.free()?;
self.instructions.push(InstructionData {
instr: Instruction::DeferFree { free, align: 4 },
instr: Instruction::DeferFree { free, align: 1 },
stack_change: StackChange::Modified {
popped: 2,
pushed: 2,
Expand Down
3 changes: 1 addition & 2 deletions crates/cli-support/src/wit/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ pub enum AdapterType {
pub enum Instruction {
/// Calls a function by its id.
CallCore(walrus::FunctionId),
/// Schedules a function to be called after the whole lift/lower cycle is
/// finished, e.g. to deallocate a string or something.
/// Call the deallocation function.
DeferFree {
free: walrus::FunctionId,
align: usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/reference/result-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function exported() {
return getStringFromWasm0(ptr1, len1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 4);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions guide/src/contributing/design/exporting-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as wasm from './foo_bg';
function passStringToWasm(arg) {
const buf = new TextEncoder('utf-8').encode(arg);
const len = buf.length;
const ptr = wasm.__wbindgen_malloc(len, 4);
const ptr = wasm.__wbindgen_malloc(len, 1);
let array = new Uint8Array(wasm.memory.buffer);
array.set(buf, ptr);
return [ptr, len];
Expand All @@ -56,7 +56,7 @@ export function greet(arg0) {
wasm.__wbindgen_boxed_str_free(ret);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0, 4);
wasm.__wbindgen_free(ptr0, len0, 1);
}
}
```
Expand Down

0 comments on commit 750eccc

Please sign in to comment.