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

Add reference types to Cranelift #871

Merged
merged 1 commit into from
Aug 16, 2019

Conversation

c27kwan
Copy link
Contributor

@c27kwan c27kwan commented Jul 25, 2019

No description provided.

@c27kwan c27kwan mentioned this pull request Jul 26, 2019
@sunfishcode
Copy link
Member

Looks good! Other than the issue @philipc pointed out, this is in good shape!

@bnjbvr bnjbvr self-requested a review August 6, 2019 09:28
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Looking great! First round of comments on the first commit, mostly nits / naming suggestions, and small changes to remove the ref-to-bool conversions that don't feel type safe. (I'll continue the review later today.)

cranelift-codegen/meta/src/cdsl/types.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/cdsl/types.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/cdsl/types.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/cdsl/types.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/cdsl/typevar.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/cdsl/typevar.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/shared/types.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/ir/instructions.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/ir/instructions.rs Show resolved Hide resolved
cranelift-codegen/src/ir/types.rs Outdated Show resolved Hide resolved
@bnjbvr
Copy link
Member

bnjbvr commented Aug 6, 2019

Also, wanted to point out that you can give attribution to several authors on Github commits with this feature, if you're in the mood for doing so.

Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Second commit's feedback. I imagine the trapnf instruction is used thereafter.

cranelift-codegen/meta/src/shared/instructions.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/shared/instructions.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/shared/instructions.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/shared/instructions.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/verifier/mod.rs Outdated Show resolved Hide resolved
cranelift-simplejit/src/memory.rs Outdated Show resolved Hide resolved
cranelift-simplejit/src/backend.rs Outdated Show resolved Hide resolved
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Great work there! I think it is moving into the right direction. Many comments, but most of them are nits. I suspect some generated code is dead, we'll see.

I am still a bit unclear about what the new non-fatal trap does or allows; can you explain it a bit more, please? Thanks!


fn add_stackmap(&mut self, val_list: &[Value], func: &Function, isa: &dyn TargetIsa) {
let ofs = self.offset();
let sm = Stackmap::from_values(&val_list, func, isa);
Copy link
Member

Choose a reason for hiding this comment

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

nit: can you expand these two variable names to "offset" and "stack_map", please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll expand sm to stackmap, but ofs is more consistent with the rest of the impl for CodeSink. We use ofs inside of reloc_ebb , reloc_external, and reloc_jt. In general, the variable names in this impl are very short.

cranelift-codegen/src/binemit/memorysink.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/binemit/stackmap.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/binemit/stackmap.rs Outdated Show resolved Hide resolved
cranelift-codegen/src/binemit/stackmap.rs Outdated Show resolved Hide resolved
cranelift-faerie/src/backend.rs Outdated Show resolved Hide resolved
cranelift-filetests/src/test_savepoint.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/isa/x86/recipes.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/isa/x86/encodings.rs Outdated Show resolved Hide resolved
cranelift-codegen/meta/src/isa/x86/encodings.rs Outdated Show resolved Hide resolved
@bnjbvr
Copy link
Member

bnjbvr commented Aug 6, 2019

Ok, I looked at the last commit, which resolves some of the comments I've opened :) If possible, it'd be nice to play a bit with git rebase and include the changes from the last commit within the commit that introduced them. (The git-absorb addon could be useful to help you!)

Great work overall. Two open-ended questions:

  • do we want to support 32-bits references on 64-bits platforms, and conversely?
  • is there any additional work that's needed in Spidermonkey / Baldrdash to support ref types with the Cranelift backend for wasm?

Thanks!

@c27kwan
Copy link
Contributor Author

c27kwan commented Aug 6, 2019

@bnjbvr About trapnf: When writing the test files and mocking the trap interrupt that happens in function prologues, I was not able to use the trap instruction since it must always be a terminal. Presumably, we use a different kind of trap instruction that is non-terminal (e.g. trapif ) when we build the function prologue. After a discussion with @sunfishcode, it didn't seem right to only support traps that will terminate the program or conditional traps . So we added trapnf for general purpose traps that don't need to be a terminal in a block.

@bnjbvr
Copy link
Member

bnjbvr commented Aug 7, 2019

@c27kwan Thanks for the explanation for trapnf, sounds good to me.

@c27kwan c27kwan force-pushed the savepoint branch 2 times, most recently from ee60042 to f288568 Compare August 14, 2019 22:04
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

I've skimmed this again, and this looks in great shape for landing! (One minor comment, but we could take care of it after landing.)
Congratulations and great work here, thanks!

cranelift-codegen/meta/src/shared/instructions.rs Outdated Show resolved Hide resolved
-Add resumable_trap, safepoint, isnull, and null instructions
-Add Stackmap struct and StackmapSink trait

Co-authored-by: Mir Ahmed <mirahmed753@gmail.com>
Co-authored-by: Dan Gohman <sunfish@mozilla.com>
Copy link
Member

@sunfishcode sunfishcode 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 good to me to!

@sunfishcode sunfishcode merged commit 39f3fd0 into bytecodealliance:master Aug 16, 2019
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.

None yet

6 participants