People have often wondered if I'll ever actually do any punching. Those people obviously have never seen what I drink. :-) However, I like to dream that one day, I'll be rich, and spend my time flying across the country, and administering some very necessary (if late) justice. And in my dream, it looks an awful lot like this:
You know, with all that money we've been making man we can buy alot of plane tickets...
Seriously, you would think that SWITCH statements would just get compiled into a giant if then else tree. Good guess. That’s what I thought, but you need to support case fall through. So you would think that they would have an If, then else tree where you test each case, and jump to a area of code, where at the end of each block you can Jump to the end of the switch statement (ie.e they end that case with a "break") or simply fall through to the next cases code block.
Make sense. An If/then/else tree to test cases and a layer of indirection to the code blocks to allow for fall through.
Only Adobe makes add yet another level on indirection. They have the if/then/else tree, they test each case statement for a value, then push a special value on the stack, then jump to a dispatcher, which jumps to different code block based on the magical stack value, which then jumps you to the code blocks so you can fall through.
Are you freaking kidding me?
Behold, this is the source code.
trace("before");
switch(x) {
case 1:
trace("case 1");
break;
case 2:
trace("case 2");
break;
default:
trace("default");
break;
}
trace("after");
Becomes because the following Flash pseudo-assembly code.
Push "before" onto stack
Call trace()
Push x onto stack
If(x == 1) {
Push 0 onto stack
Jump to DISPATCHER
}
If(x == 2) {
Push 1 onto stack
Jump to DISPATCHER
}
Push 2 onto stack
Jump to DISPATCHER
.
. //unimportant crap
.
BLOCK1:
Push "case 1" onto stack
Call trace()
Jump to POSTSWTICH:
BLOCK2:
Push "case 2" onto stack
Call trace()
Jump to POSTSWTICH:
BLOCK3:
Push "default" onto stack
Call trace()
Jump to POSTSWTICH:
.
. //unimportant crap
.
DISPATCHER:
//lookupswitch is an op code (yes, they have a freaking opcode for this)
//that reads the byte on the top of the stack and uses that as
//an index into a list of locations to jump to and then jumps to that
//corresponding label. So if say, 0, is on the stack, it will jump to
//BLOCK1, etc
Lookupswitch BLOCK1, BLOCK2, BLOCK3
POSTSWITCH:
Push "after" onto stack
Call trace()
I'm going to punch someone in the head. It's took me a solid 2 hours to trace this stuff and try to find a pattern (With default, without, swtiching on diff datatypes, etc). I too way long to figure out how to actually recognize this crap mixed into a giant mess of other nested if/else clauses, ternary ops, while loops, etc.
Oh, and I didn't even include the dead code. Yeah. That’s right, DEAD CODE! For each case the silly compiler actually generates dead code containing extra JUMPs that are impossible to get to. Just to make the jump/branch tables even more complex. As if 3 freaking levels of indirection were not enough, they have to throw in crap that will not even get executed!
We've long joked that the Bristol Palin-Levi Johnston marriage would be indefinitely postponed post-Obama victory. Well, we hate to say "I told you so...." Actually, scrap that. We sorta love saying "I told you so."
VAN SUSTEREN: What about Levi? How is he taking all this?
BRISTOL: Well, he's a really hands-on dad. He's just in love with him as much as I am.
VAN SUSTEREN: Does he -- how often does he see his son?
BRISTOL: He sees him every day.
VAN SUSTEREN: What are your plans?
BRISTOL: Eventually, we'd like to get married. We're focusing on, like, getting through school and just getting an education and stuff, getting a career going.
Good for Bristol and Levi. There's nothing sillier than compounding the pressure of an unplanned pregnancy with the pressure of a rushed wedding and marriage at age 18.
... is not my social security number. Just a test number for the regexs. But mad thanks to the 5 folks who texted messaged me from Shmoocon warning me that Prajakta might have commited identity murder in from of a room full of hacekrs :-)
I wish, as a decompiler writer, there would be no loops. Programmers use thousands of goto statements with if statements. But as it is not the case I must understand how to parse MSIL instructions that were generated from the loops.
HAHAHAHAHA! God this is so so true!
I'd also point out that the phrase "backward conditional branch target" should never make sense to any sane human being.
Dan Kaminsky was in Atlanta yesterday. We and some of the usual suspects met for food and drinks at the Vortex in midtown. Some odd/funny things were said, and To keep track, I kept SMSing myself so I could preserve these for posterity.
Chris: I'm going to create Nemisis-oasis. Its the inverse of Match.com and Facebook. You type in what you like and it finds someone that you would absolutely hate. Dan: Its like a Fuck You Cupid!
Tom: (handing me a girlie drink) Here Billy, this will make hair grow on your vagina.
(I have no context for this next quote. I have no idea why Tom said this) Tom: I can only get off if the sheep is from Luxembourg Billy: I'm totally putting this on Memestreams... how do you spell Luxembourg?
Tom: (About a computer scientist at a recent conference) They're proof that every now and then Appalachia produces something good. So its: Bucked Toothed Redneck, Bucked Toothed Redneck, Bucked Toothed Redneck, Cryptographer, Bucked Toothed Redneck...
I nice thing about how my social circles have expanded over the last few years is that, while I'm hardly a huge sports fan, I all the highlights. Mmmm social filters!
Anyway, got this int the mail today and absolutely loved it! The "3 ball catch" is probably the best of the clips.