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

Throw opcode with trap. - #4736

Merged
morganbr merged 5 commits into
dotnet:masterfrom
jacano:Throw
Oct 17, 2017
Merged

morganbr merged 5 commits into
dotnet:masterfrom
jacano:Throw

Conversation

@jacano

@jacano jacano commented Oct 16, 2017

Copy link
Copy Markdown
Contributor

I was unable to add a test for this. Without try ... catch I don't know how to really check.
Anyway, I tried with "throw null;" and the trap gets generated.

Name parameter updated in LLVM build methods to reflect the operation being built.
Use PushExpression method instead of direct push to stack.
# Conflicts:
#	tests/src/Simple/HelloWasm/Program.cs
@dnfclas

dnfclas commented Oct 16, 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 16, 2017

Copy link
Copy Markdown
Contributor Author

I didn't notice I included a draft version of the newarr op. Sorry for that. I'm removing it.

@morganbr

Copy link
Copy Markdown
Contributor

@dotnet-bot test Ubuntu Release please

{
var exceptionObject = _stack.Pop();

if (TrapFunction.Pointer == IntPtr.Zero)

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.

Rather than copying this logic, can you please factor it out into the property getter or somewhere else? I imagine we'll need trap in another couple of places too

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.

Of course, in fact I did it but them I discarded it because I wanted to focus only on the throw method : S

}
LLVM.BuildCall(_builder, TrapFunction, Array.Empty<LLVMValueRef>(), string.Empty);

LLVM.BuildUnreachable(_builder);

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.

Out of curiosity, was this required? My reading on llvm.trap is that LLVM already knows code afterward is unreachable.

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, right now it's completely useless. I guess the same, trap would also instruct the optimizer to discard the rest of the code. I just thought that it could be useful (as a hint for me or other committers) when a real implementation for throw gets implemented.
I'm going to remove it.

@morganbr
morganbr merged commit b600ecb into dotnet:master Oct 17, 2017
@morganbr

Copy link
Copy Markdown
Contributor

Thanks, @jacano!

@jacano
jacano deleted the Throw branch October 20, 2017 12:30
jacano added a commit to jacano/corert that referenced this pull request Oct 20, 2017
* Implement neg (float/integer) and not IL instructions. Fixes dotnet#4524 and dotnet#4525

* Neg and not basic tests added to HelloWasm.
Name parameter updated in LLVM build methods to reflect the operation being built.
Use PushExpression method instead of direct push to stack.

* Implement throw opcode. Fix for dotnet#4528

* Unreachable removed and trap call refactored in throw import method.
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.

4 participants