Skip to content

Commit 750eccc

Browse files
daxpeddaLiamolucko
andcommitted
Address review
Co-Authored-By: Liam Murphy <[email protected]>
1 parent 0ba5241 commit 750eccc

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

crates/cli-support/src/js/binding.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ fn instruction(js: &mut JsBuilder, instr: &Instruction, log_error: &mut bool) ->
556556
let tmp = js.tmp();
557557
if invoc.defer() {
558558
if let Instruction::DeferFree { .. } = instr {
559-
// substract alignment
559+
// Ignore `free`'s final `align` argument, since that's manually inserted later.
560560
params -= 1;
561561
}
562562
// If the call is deferred, the arguments to the function still need to be

crates/cli-support/src/wit/outgoing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl InstructionBuilder<'_, '_> {
105105
// ... then defer a call to `free` to happen later
106106
let free = self.cx.free()?;
107107
self.instructions.push(InstructionData {
108-
instr: Instruction::DeferFree { free, align: 4 },
108+
instr: Instruction::DeferFree { free, align: 1 },
109109
stack_change: StackChange::Modified {
110110
popped: 2,
111111
pushed: 2,
@@ -429,7 +429,7 @@ impl InstructionBuilder<'_, '_> {
429429
// implementation.
430430
let free = self.cx.free()?;
431431
self.instructions.push(InstructionData {
432-
instr: Instruction::DeferFree { free, align: 4 },
432+
instr: Instruction::DeferFree { free, align: 1 },
433433
stack_change: StackChange::Modified {
434434
popped: 2,
435435
pushed: 2,

crates/cli-support/src/wit/standard.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ pub enum AdapterType {
9393
pub enum Instruction {
9494
/// Calls a function by its id.
9595
CallCore(walrus::FunctionId),
96-
/// Schedules a function to be called after the whole lift/lower cycle is
97-
/// finished, e.g. to deallocate a string or something.
96+
/// Call the deallocation function.
9897
DeferFree {
9998
free: walrus::FunctionId,
10099
align: usize,

crates/cli/tests/reference/result-string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function exported() {
8585
return getStringFromWasm0(ptr1, len1);
8686
} finally {
8787
wasm.__wbindgen_add_to_stack_pointer(16);
88-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 4);
88+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
8989
}
9090
}
9191

guide/src/contributing/design/exporting-rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as wasm from './foo_bg';
3333
function passStringToWasm(arg) {
3434
const buf = new TextEncoder('utf-8').encode(arg);
3535
const len = buf.length;
36-
const ptr = wasm.__wbindgen_malloc(len, 4);
36+
const ptr = wasm.__wbindgen_malloc(len, 1);
3737
let array = new Uint8Array(wasm.memory.buffer);
3838
array.set(buf, ptr);
3939
return [ptr, len];
@@ -56,7 +56,7 @@ export function greet(arg0) {
5656
wasm.__wbindgen_boxed_str_free(ret);
5757
return realRet;
5858
} finally {
59-
wasm.__wbindgen_free(ptr0, len0, 4);
59+
wasm.__wbindgen_free(ptr0, len0, 1);
6060
}
6161
}
6262
```

0 commit comments

Comments
 (0)