Skip to content
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

cps, cps/environment: only desym environment fields #73

Merged
merged 7 commits into from
Apr 28, 2021

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented Apr 26, 2021

Experiments shows that we only have to desym due to issues in
environment definition and access.

Upstream bug: nim-lang/Nim#17851

Has #72 bundled.

By keeping the symbols, we avoid the foreign bindsym issue altogether.

alaviss added 3 commits April 26, 2021 22:26
This is a WIP commit.

Experiments shows that we only have to desym due to issues in
environment definition and access.

Upstream bug: nim-lang/Nim#17851

This commit disable blanket desymification and only perform them
on environment as a workaround for the mentioned bug, which fixes
the foreign symbol tests.
@alaviss alaviss force-pushed the wip-selective-desym branch from 46b90e4 to 849d129 Compare April 27, 2021 03:33
@alaviss
Copy link
Contributor Author

alaviss commented Apr 27, 2021

I'll need a bit of help to clean this up, the desym insertions is a hack atm, not to mention error prone. IMO we can build a kind of filter that desym any usage of a genSym-ed identifier from Env, but not sure if it's feasible.

@disruptek
Copy link
Contributor

Gensym'd symbols have names that don't match their repr. That's enough to identify them for purposes of another rewrite, but usages of Env symbols can be filtered more easily -- either do something special once, when they are inserted into the in-memory cache of locals, or do something special N times when they are plucked out.

alaviss added 2 commits April 28, 2021 08:30
The better fix in nim-works#72 removed the need for this 🎉.
A proper workaround for nim-lang/Nim#17851,
which lets us remove the desym injections into cps/environment.
@alaviss
Copy link
Contributor Author

alaviss commented Apr 28, 2021

It's working now, and it's beautiful.

@alaviss alaviss marked this pull request as ready for review April 28, 2021 13:44
@alaviss alaviss requested review from disruptek and saem April 28, 2021 13:44
Copy link
Contributor

@disruptek disruptek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice; I like executing less code. 👍

cps.nim Outdated
@@ -37,18 +38,19 @@ func getCallSym(n: NimNode): NimNode =
of nnkSym:
break
of nnkIdent:
raise newException(CatchableError, "This call is not typed")
result = nil
break
else:
assert false, "unknown node type: " & $result.kind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise here? Or do you really want to skip this node in the event that assertions are disabled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising an error should be the job of whatever is calling this proc, imo. So the updated logic makes more sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then we assert false in the last leg...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, it's an infinite loop without assertions to crash it. Suggest you rewrite the case as if/if/else or whatever. All three of us missed it the first time around.

Copy link
Contributor

@saem saem Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're right that the logic is busted.

A break after the assert should be sufficient. During debug having it assert is handy for the smell factor until we narrow it down.

(Wow, typing this on the phone really messed it up)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds fine to me. 👍

cps/spec.nim Outdated
proc genField*(ident = ""): NimNode =
## generate an unique field to put inside an object definition
##
## made as a walkaround for [nim-lang/Nim#17851](/~https://github.com/nim-lang/Nim/issues/17851)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/walkaround/workaround/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a unique.

saem
saem previously approved these changes Apr 28, 2021
Copy link
Contributor

@saem saem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot better. \o/

cps.nim Outdated
@@ -37,18 +38,19 @@ func getCallSym(n: NimNode): NimNode =
of nnkSym:
break
of nnkIdent:
raise newException(CatchableError, "This call is not typed")
result = nil
break
else:
assert false, "unknown node type: " & $result.kind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising an error should be the job of whatever is calling this proc, imo. So the updated logic makes more sense.

@alaviss alaviss changed the title cps, cps/environment: only desym environment access cps, cps/environment: only desym environment fields Apr 28, 2021
@disruptek disruptek merged commit 58904bd into nim-works:master Apr 28, 2021
@alaviss alaviss deleted the wip-selective-desym branch April 29, 2021 00:06
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