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

Move code_typed and return_types out of inference #11600

Merged
merged 1 commit into from
Jun 23, 2015

Conversation

yuyichao
Copy link
Contributor

@yuyichao yuyichao commented Jun 6, 2015

I'm still not sure what exactly is the reason for #11590 but this seems to fix it, as well as the error when inspecting code_typed I mentioned in that issue #11590 (comment)

IMHO, these methods (including other code_*'s) doesn't really belong to Core.Inference and can probably be moved into a different file (interactiveutil.jl?). (Leave them here for now since I don't want to change everything at the same time....)

Fix #11590

@mbauman

@@ -3276,44 +3276,6 @@ function replace_getfield!(ast, e::ANY, tupname, vals, sv, i0)
end
end

function code_typed(f, types::ANY; optimize=true)
types = to_tuple_type(types)
code_typed(call, Tuple{isa(f,Type)?Type{f}:typeof(f), types.parameters...}, optimize=optimize)
Copy link
Member

Choose a reason for hiding this comment

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

It was using the wrong "call" function here. @JeffBezanson is it possible to express the notion of "the call function that would have been visible to the callee" in this function? (cough#11452cough)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yeah. This is exactly why I felt so strange when I saw #11452 .....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although hopefully this is not blocking the PR. Since this is also the old behavior.

Copy link
Member

Choose a reason for hiding this comment

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

no, although it means you could also fix this by doing a one-liner change from call to Main.Base.call here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vtjnash Will that do it? This is in the Base module and the call should already be Base.call. No?

Copy link
Member

Choose a reason for hiding this comment

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

no, and that's the current behavior. This call refers to Core.Inference.call because of the file that it is in, not Main.Base.call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vtjnash Ahh. Maybe that's why it was broken before then. This used to be only defined in Core.Inference with a wrapper in Base. After moving it out of Inference, the call is pointing to the correct function now. (Note that reflection.jl is also included in sysimg.jl)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vtjnash Somehow I always thought you what you meant is that the code in this PR is having problem getting the correct call.

So should I do the one-liner (ok maybe two since there's also return_types) and experimenting with moving these out of Inference in another PR?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to move these out with this PR, I just wanted to point out why this worked (more than just "seems to fix it") and see if @JeffBezanson could recommend any other improvement

Copy link
Member

Choose a reason for hiding this comment

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

One thing that can be done is to have the macros generate an escaped call symbol, in order to pass the call function from the calling context.

The general problem is a case like methods(call, Tuple{Any, ..., where you obviously can't look at the first argument to see what module call is from.

@yuyichao
Copy link
Contributor Author

Any more comments? @JeffBezanson maybe? I'll rebase and merge in a day or two if the CI passes again and there's no more comments.

@mbauman
Copy link
Member

mbauman commented Jun 20, 2015

Seems like a straightforward fix, and reflection.jl seems like a good home for these methods. Thanks for tackling this, @yuyichao!

@vtjnash
Copy link
Member

vtjnash commented Jun 20, 2015

my main concern is just that this would make these functions unavailable for use from the inference.ji image @carnaval

@yuyichao
Copy link
Contributor Author

They are currently still in Inference. I was going to move them out in the next step but I could also try something else.

@carnaval
Copy link
Contributor

Fine for me, go ahead.

JeffBezanson added a commit that referenced this pull request Jun 23, 2015
Move code_typed and return_types out of inference
@JeffBezanson JeffBezanson merged commit bca9e80 into JuliaLang:master Jun 23, 2015
@tkelman
Copy link
Contributor

tkelman commented Jun 23, 2015

Uh, this was freezing during bootstrap on appveyor.

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.

Code_typed macro doesn't show correct constructor
6 participants