-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Emit inlining information to improve line numbers #12544
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,7 +288,7 @@ isexpr(x, ts...) = any(T->isa(T, Type) && isa(x, T), ts) | |
|
||
function unblock(ex) | ||
isexpr(ex, :block) || return ex | ||
exs = filter(ex->!isexpr(ex, :line), ex.args) | ||
exs = filter(ex -> !(isa(ex, LineNumberNode) || isexpr(ex, :line)), ex.args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, in macro expansions we call |
||
length(exs) == 1 || return ex | ||
return unblock(exs[1]) | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,11 +99,13 @@ immutable LineInfo | |
func::ByteString | ||
file::ByteString | ||
line::Int | ||
inlined_file::ByteString | ||
inlined_line::Int | ||
fromC::Bool | ||
ip::Int64 # large enough that this struct can be losslessly read on any machine (32 or 64 bit) | ||
end | ||
|
||
const UNKNOWN = LineInfo("?", "?", -1, true, 0) | ||
const UNKNOWN = LineInfo("?", "?", -1, "?", -1, true, 0) | ||
|
||
# | ||
# If the LineInfo has function and line information, we consider two of them the same | ||
|
@@ -134,8 +136,8 @@ maxlen_data() = convert(Int, ccall(:jl_profile_maxlen_data, Csize_t, ())) | |
|
||
function lookup(ip::Ptr{Void}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably make more use of this interface to |
||
info = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), ip, false) | ||
if length(info) == 5 | ||
return LineInfo(string(info[1]), string(info[2]), Int(info[3]), info[4], Int64(info[5])) | ||
if length(info) == 7 | ||
return LineInfo(string(info[1]), string(info[2]), Int(info[3]), string(info[4]), Int(info[5]), info[6], Int64(info[7])) | ||
else | ||
return UNKNOWN | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,30 +326,49 @@ static jl_value_t *scm_to_julia_(value_t e, int eo) | |
|
||
e = cdr_(e); | ||
if (!eo) { | ||
if (sym == line_sym && n==1) { | ||
return jl_new_struct(jl_linenumbernode_type, | ||
scm_to_julia_(car_(e),0)); | ||
if (sym == line_sym && n==2) { | ||
jl_value_t *filename = NULL, *linenum = NULL; | ||
JL_GC_PUSH2(&filename, &linenum); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note that assuming filename is a Symbol, it doesn't need a root. If it wasn't a symbol, this root would have been needed before the call to create the box to linenum. |
||
filename = scm_to_julia_(car_(cdr_(e)),0); | ||
linenum = scm_to_julia_(car_(e),0); | ||
jl_value_t *temp = jl_new_struct(jl_linenumbernode_type, | ||
filename, linenum); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
jl_value_t *scmv = NULL, *temp = NULL; | ||
JL_GC_PUSH(&scmv); | ||
if (sym == label_sym) { | ||
return jl_new_struct(jl_labelnode_type, | ||
scm_to_julia_(car_(e),0)); | ||
scmv = scm_to_julia_(car_(e),0); | ||
temp = jl_new_struct(jl_labelnode_type, scmv); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
if (sym == goto_sym) { | ||
return jl_new_struct(jl_gotonode_type, | ||
scm_to_julia_(car_(e),0)); | ||
scmv = scm_to_julia_(car_(e),0); | ||
temp = jl_new_struct(jl_gotonode_type, scmv); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
if (sym == inert_sym || (sym == quote_sym && (!iscons(car_(e))))) { | ||
return jl_new_struct(jl_quotenode_type, | ||
scm_to_julia_(car_(e),0)); | ||
scmv = scm_to_julia_(car_(e),0); | ||
temp = jl_new_struct(jl_quotenode_type, scmv); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
if (sym == top_sym) { | ||
return jl_new_struct(jl_topnode_type, | ||
scm_to_julia_(car_(e),0)); | ||
scmv = scm_to_julia_(car_(e),0); | ||
temp = jl_new_struct(jl_topnode_type, scmv); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
if (sym == newvar_sym) { | ||
return jl_new_struct(jl_newvarnode_type, | ||
scm_to_julia_(car_(e),0)); | ||
scmv = scm_to_julia_(car_(e),0); | ||
temp = jl_new_struct(jl_newvarnode_type, scmv); | ||
JL_GC_POP(); | ||
return temp; | ||
} | ||
JL_GC_POP(); | ||
} | ||
else if (sym == inert_sym && !iscons(car_(e))) { | ||
sym = quote_sym; | ||
|
@@ -459,8 +478,14 @@ static value_t julia_to_scm_(jl_value_t *v) | |
fl_free_gc_handles(1); | ||
return scmv; | ||
} | ||
if (jl_typeis(v, jl_linenumbernode_type)) | ||
return julia_to_list2((jl_value_t*)line_sym, jl_fieldref(v,0)); | ||
if (jl_typeis(v, jl_linenumbernode_type)) { | ||
value_t args = julia_to_list2(jl_fieldref(v,1), jl_fieldref(v,0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you are still missing a gc-root for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
fl_gc_handle(&args); | ||
value_t hd = julia_to_scm_((jl_value_t*)line_sym); | ||
value_t scmv = fl_cons(hd, args); | ||
fl_free_gc_handles(1); | ||
return scmv; | ||
} | ||
if (jl_typeis(v, jl_labelnode_type)) | ||
return julia_to_list2((jl_value_t*)label_sym, jl_fieldref(v,0)); | ||
if (jl_typeis(v, jl_gotonode_type)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to work on surface syntax ASTs? (used from macros)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (I think). Thanks.