Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

cranelift-wasm hooks to instrument wasm operators#861

Merged
iximeow merged 2 commits intomasterfrom
cranelift-wasm-hooks
Jul 25, 2019
Merged

cranelift-wasm hooks to instrument wasm operators#861
iximeow merged 2 commits intomasterfrom
cranelift-wasm-hooks

Conversation

@iximeow
Copy link
Copy Markdown
Collaborator

@iximeow iximeow commented Jul 22, 2019

In some circumstances we'd like to insert instructions, and update translator-internal state, based on the wasm operations being translated. This adds a pair of functions to FuncEnvironment to support that (and adjusts func_translator to call them appropriately)

@iximeow iximeow requested a review from pchickey July 22, 2019 18:02
let op = reader.read_operator()?;
translate_operator(op, builder, state, environ)?;
environ.before_translate_operator(&op, builder)?;
translate_operator(&op, builder, state, environ)?;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

op being used in {before,after}_translate_operator is what necessitates the bulk of this PR, by changing to &op here.

/// - The depth of the two unreachable control blocks stacks, that are manipulated when translating
/// unreachable code;
pub struct TranslationState {
/// A stack of values corresponding to the active values in the input wasm function at this
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was initially thinking we'd want to expose the function's corresponding TranslationState (in case a user of cranelift-wasm wanted to add/modify values or the control stack), but that ended up not being necessary in how I'm using this right now. #[deny(missing_docs)] got me to fill in docs here and I figure they don't hurt to keep around :)

It seems like tweaking TranslationState would be a very typical {before,after}_translate_operator use case, so passing along TranslationState might make sense even if not strictly necessary in my use right now

Copy link
Copy Markdown
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for adding docs!

@iximeow iximeow merged commit d7f3973 into master Jul 25, 2019
@iximeow iximeow deleted the cranelift-wasm-hooks branch July 25, 2019 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants