Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Emit switch in wasm - #4769

Merged
morganbr merged 5 commits into
dotnet:masterfrom
jacano:EmitSwitchWasm
Oct 23, 2017
Merged

morganbr merged 5 commits into
dotnet:masterfrom
jacano:EmitSwitchWasm

Conversation

@jacano

@jacano jacano commented Oct 20, 2017 •

Copy link
Copy Markdown
Contributor

This is emit switch in LLVM for the WASM target.
As I said in my last contribution, I tried to implement the newarr op before this one but I think we first need the newobj.

@dnfclas

dnfclas commented Oct 20, 2017

Copy link
Copy Markdown

@jacano,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@jacano

jacano commented Oct 20, 2017 •

Copy link
Copy Markdown
Contributor Author

Forget to mention, I also refactor the HelloWasm sample a little. Not sure if I took too much freedom here.

@morganbr
morganbr self-requested a review October 20, 2017 23:18

@morganbr morganbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @jacano, this looks close, just a couple comments to address. I like the test refactoring.

{
var target = _basicBlocks[_currentOffset + jmpDelta[i]];
LLVM.AddCase(@switch, LLVM.ConstInt(LLVM.Int32Type(), (ulong)i, false), GetLLVMBasicBlockForBlock(target));
ImportFallthrough(target);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did you end up calling ImportFallthrough here? It looks like for other branching we don't need that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I used it to add a valid terminator at the end of the switch block

Comment thread tests/src/Simple/HelloWasm/Program.cs Outdated
PrintLine("Hello from C#!");
}

TwoByteStr str = new TwoByteStr() { first = 1, second = 2 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit -- indentation and tabs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same

Comment thread tests/src/Simple/HelloWasm/Program.cs Outdated
{
string s = "Hello from C#!";
PrintString(s);
PrintLine("Hello from C#!");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit -- indentation. Also, is this a tab? If so, please use spaces (and if I missed other tabs in this, please fix them as well)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I got this wrong in the merge.

Comment thread tests/src/Simple/HelloWasm/Program.cs Outdated
{
PrintString("\n");
PrintString("negInt test: Ok.");
PrintLine("negInt test: Ok.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tabs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm replacing all of them

@morganbr morganbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks!

@morganbr
morganbr merged commit 5aed515 into dotnet:master Oct 23, 2017
@jacano
jacano deleted the EmitSwitchWasm branch October 23, 2017 20:38
A-And pushed a commit to A-And/corert that referenced this pull request Oct 31, 2017
* Implement switch opcode Fix dotnet#4519
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants