New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pseudo Computed Goto #272
Pseudo Computed Goto #272
Conversation
Interesting! How does this affect the performance? Can you run the benchmarks with and without this change and show us what the numbers look like? |
There are some numbers in the discussion on issue #269 |
Sorry I'm a bit late, but some things came up. In any case I ran the benchmark script, with the original to generate a base-line and then with the new implementation. (This is with visual studio.) Original:
New:
|
OK, I'm sold. :) I wish we didn't have to turn wren_opcodes.h into a giant macro, but I can't think of any other solution. I'll add some other comments at specific points, but would you mind also rebasing this patch against the latest master? I think some stuff has moved under you, making this hard to merge in. Thank you for doing so much work on this! |
// No computed gotos in Visual Studio. | ||
#define WREN_COMPUTED_GOTO 0 | ||
// No real computed gotos in Visual Studio. Use the pseudo version. | ||
#define WREN_COMPUTED_GOTO 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of numeric values, let's do separate defines, I'm thinking:
WREN_DISPATCH_SWITCH
WREN_DISPATCH_COMPUTED_GOTO
WREN_DISPATCH_JUMP_TABLES
SWITCH
is the 0 case here, COMPUTED_GOTO
is 1, and JUMP_TABLES
is 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that will indeed be more clear.
I also really dislike the wren_opcodes macro. I wish it could be different. Anyway, I tried to rebase the goto branch onto the new master branch. But somewhere along the line I did something that made my master branch end up being the same as the goto branch. I think I might have pushed it to the wrong branch or so... AND I fixed it! I didn't change your suggestions. Should I do that? |
Did you try what a function pointer table to declspec(naked) functions looks like with MSVC? Since you can get the address of the function thats like taking the address of a label, then the "naked" function call should become a jmp? |
I don't think that will work. It says on msdn: "The naked attribute On 11 May 2016 at 09:18, Paul notifications@github.com wrote:
|
I saw something else related to this today "__assume" https://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx apparently you could use this on the switch value to stop it generating the extract checks. Might be worth checking if you ever get time. Edit: Nevermind you are already using this |
Ugh, I'm so sorry, but I left this open so long that I'm not able to merge it in now since so many changes have happened since. :( |
Since it is not possible to use computed gotos in Visual Studio/VC++ I have simulated the dispatch table with a switch case containing goto statements.