Skip to content

SIMD#222

Draft
ospencer wants to merge 2 commits intomasterfrom
oscar/simd
Draft

SIMD#222
ospencer wants to merge 2 commits intomasterfrom
oscar/simd

Conversation

@ospencer
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@spotandjake spotandjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, I just had one general question.

@spotandjake spotandjake added the Api Issues or pull requests relating to implementing or modifying a binaryen api. label Dec 6, 2025
@spotandjake
Copy link
Copy Markdown
Member

Closes: #106

Copy link
Copy Markdown
Member

@spotandjake spotandjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me, it matches the binaryen api.

I just had a few small questions, two related to allocating strings and then a few related to c types.

BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenOp op = BinaryenOp_val(_op);
BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec);
int index = Int_val(_index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this type be uint8_t to match the binaryen header rather than int?

BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenOp op = BinaryenOp_val(_op);
BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec);
int index = Int_val(_index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

CAMLxparam1(_memoryName);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenOp op = BinaryenOp_val(_op);
int offset = Int_val(_offset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are uint32_t in the C header, similar question to above

CAMLxparam3(_ptr, _vec, _memoryName);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenOp op = BinaryenOp_val(_op);
int offset = Int_val(_offset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

BinaryenOp op = BinaryenOp_val(_op);
int offset = Int_val(_offset);
int align = Int_val(_align);
int index = Int_val(_index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is uint8_t in the bindinds similar question to above.

//Requires: Binaryen
//Requires: caml_jsstring_of_string, caml_alloc_string_on_heap
function caml_binaryen_simd_load(wasm_mod, op, offset, align, ptr, memoryName) {
var memory = caml_alloc_string_on_heap(caml_jsstring_of_string(memoryName));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we completely safe to use caml_alloc_string_on_heap.

I know in the js api in binaryen you need to call prserveStack before passing strings and I'm just wondering if we have the same semantics.

vec,
memoryName
) {
var memory = caml_alloc_string_on_heap(caml_jsstring_of_string(memoryName));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above

Bytes.set_int32_le bytes 0 low;
Bytes.set_int32_le bytes 4 low_mid;
Bytes.set_int32_le bytes 8 high_mid;
Bytes.set_int32_le bytes 12 high;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird to me that we don't just construct the array directly with bit shifting and masking, but I guess this is less instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Api Issues or pull requests relating to implementing or modifying a binaryen api.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants