-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Split operators in EvalScript's switch #5153
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
Conversation
Yikes. Could you elaborate on the reasoning? In particular, I could understand moving the logic for each opcode to a function so that they could be independently verified or changed, but the groupings like OpNumUnary make this seem like a high-risk lateral move. |
Yes, this change is about readability and maintainability (which includes being able to change a small part without affecting other parts). The groupings were already there, this is just the simplest (more reviewable) way to split the switch maintaining most of the code and just passsing opcode to those cases that were already grouped. Maybe later OpNumUnary(), OpNumBinary(), OpCrypto(), etc can be split further without replicating code (I doubt it), but in fact splitting them in the same commit actually seems more risky and less reviewable to me. EDIT: Anyway, the tests are failing in some platforms so I've must have done something wrong. |
Personally I'd rather not touch this code if not necessary. |
cbec446
to
273e2e7
Compare
I missed a break after OP_EQUAL, fixed but now it needs rebase... |
NACK from me, too dangerous to change, benefits do not outweigh the risks. |
In my opinion the benefits in readability in a critical part like this are underestimated. At the same time, I also believe the risks are overestimated. In any case, I also understand that pre0.10 is probably not the best time to have this discussion so I'm happy waiting for a better time and rebasing as many times as necessary. Obviously functional changes and releases should never be delayed to make refactorings easier. Nonetheless, early feedback is always greatly appreciated, thank you @theuni @laanwj @gavinandresen If keeping it open for later is a distraction, I can close it now and reopen it after0.10, no problem. |
Minor style nit : should it be OpCheckSig and OpCheckMultiSig? Otherwise, need a language lawyer to make sure that nothing changed with the introduction of a function call. Looks okay to me otherwise. |
-1 Risky, and slower too. |
How slower? The functions can be inlined (I assumed the compiler would figure it out by itself having only one call per function though). |
I don't like breaking the script execution engine into functions very much. The big switch statement is readable and generally easy to reason about. The rather long function prototypes are perhaps an indication that this isn't a good abstraction boundary. |
I obviously disagree with this.
The longer ones are precisely these two. Though, yes, the fact that these have such long list of attributes while most of the rest practically just use the stack may indicate something, but don't necessarily talk bad about this division. Maybe in favor given that it makes this "parameters asymmetry" more visible. |
To be clear I saw this after it was reduced to only |
@jtimon I generally agree with you that structuring code in a way to make reviewing easier is good. However this is code that is very unlikely to change in the first place. I'd only feel confident about changes like this if they don't change the resulting executable at all, or there would be some other rigorous proof system. |
@laanwj Not changing the resulting at all should clear all risk and performance concerns, thank you for suggesting that. |
@jtimon There's no one-ling thing, but you could follow my process here #4180 (comment) |
Thank you @laanwj that seems very useful. I feel tempted to use that to write a little python script that checks that the resulting builds from 2 different commits are identical. And then use that script to check this PR. But that's definitely after-0.10 (and with that tool we don't care much about an additional clang since I could just indent properly from the beginning without worrying about making the diff harder to read) so I'm closing this for now. |
After doing this, a clang pass is required.
If by chance we have time to get this in before the global clang before 0.10, then we save a clang-only commit on script/interpreter.