Skip to content

Move cblock, lblock and fwdrefs out of frontend, making it a part of IRState#4854

Merged
WalterBright merged 4 commits intodlang:masterfrom
ibuclaw:blocks
Aug 11, 2015
Merged

Move cblock, lblock and fwdrefs out of frontend, making it a part of IRState#4854
WalterBright merged 4 commits intodlang:masterfrom
ibuclaw:blocks

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Aug 1, 2015

As requested in #4569

@yebblies - this has O(n) search complexity, it should really be O(1).
@WalterBright - useless refactoring that only benefits GDC+LDC. But at least the crossing between C++ <-> D boundaries have been reduced.

I noticed during writing this that Blocks fwdrefs will only ever have an array length of 0 or 1 - this seemed odd until I discovered that DMD only errors at the label location, and not the location of the original goto. This seems a bit backwards, considering (contrived example):

    if (foo > 42)
        goto Lbar;
    try {
        if (foo < -42)
            goto Lbar;
        throw new Exception("unhandled");
      Lbar:          // compiler error location is here, but which goto caused it?
        /* ... */
    }
    catch {
        /* ... */
    }

So I fixed it up so it errors at the location of the goto (mimicking what GDC does), for good or ill...

If all is good, I'll add cblock to this list too, as I've made it so that getLabel is compatible.

@ibuclaw ibuclaw force-pushed the blocks branch 2 times, most recently from 1a2989e to 96359cf Compare August 1, 2015 12:06
@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 1, 2015

Tests were passing, so push in commit for cblock too.

@ibuclaw ibuclaw changed the title Move lblock and fwdrefs out of frontend, making it a part of IRState Move cblock, lblock and fwdrefs out of frontend, making it a part of IRState Aug 1, 2015
@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 4, 2015

I've now removed uses of cblock, lblock, fwdrefs and ctype in my 2.067 branch of GDC, and will land in master shortly.

DMD has some catching up to do.

@yebblies
Copy link
Contributor

yebblies commented Aug 7, 2015

Oh ok, I see what's going on. How about using aav instead of a linear lookup? The number of labels per function can get big when auto-generated switch-cases are involved.

@yebblies
Copy link
Contributor

yebblies commented Aug 7, 2015

It would also allow removing some of the types from headers, since aav uses void* and casting.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 7, 2015

I've now completely remove IRState from GDC. :o)

@ibuclaw ibuclaw force-pushed the blocks branch 3 times, most recently from 70184f1 to d693ce7 Compare August 7, 2015 16:53
@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 7, 2015

@yebblies - the fact that it's a pointer doesn't seem to sit too well (unlike the stack allocated array). If the AA is initialized deep in a nested block, the parents won't see the initialization.

statement = 0x7fbaeae05fd0, label = 0x7fbae80eeae0, irs = 0x7ffc1f4bd6d0
statement = 0x7fbaeae05fd0, label = 0x7fbae80eeaf0, irs = 0x7ffc1f4bd1a0

I'll see if there is a destructor that allows copying back up.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 7, 2015

Ooh, actually it's a bit worse. There's a slight reorder that needs to be done.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 7, 2015

@yebblies - I think it should be good... There's now a pointer to the stack which should be shared across all IRState levels in the function.

WalterBright added a commit that referenced this pull request Aug 11, 2015
Move cblock, lblock and fwdrefs out of frontend, making it a part of IRState
@WalterBright WalterBright merged commit 407dac3 into dlang:master Aug 11, 2015
@ibuclaw ibuclaw deleted the blocks branch August 11, 2015 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants