Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 59f7889

Browse files
committedJan 20, 2016
fix inference ignorance of sparams when caching tfunc results
fix #9222
1 parent bc97d7e commit 59f7889

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed
 

‎base/inference.jl

+13-11
Original file line numberDiff line numberDiff line change
@@ -1450,8 +1450,8 @@ CYCLE_ID = 1
14501450

14511451
# def is the original unspecialized version of a method. we aggregate all
14521452
# saved type inference data there.
1453-
function typeinf(linfo::LambdaStaticData,atypes::ANY,sparams::SimpleVector, def, cop, needtree)
1454-
if linfo.module === Core
1453+
function typeinf(linfo::LambdaStaticData, atypes::ANY, sparams::SimpleVector, def, cop, needtree)
1454+
if linfo.module === Core && isempty(sparams)
14551455
atypes = Tuple
14561456
end
14571457
#dbg =
@@ -1463,12 +1463,12 @@ function typeinf(linfo::LambdaStaticData,atypes::ANY,sparams::SimpleVector, def,
14631463
tf = def.tfunc
14641464
if !is(tf,nothing)
14651465
tfarr = tf::Array{Any,1}
1466-
for i = 1:3:length(tfarr)
1467-
if typeseq(tfarr[i],atypes)
1468-
code = tfarr[i+1]
1469-
if tfarr[i+2]
1466+
for i = 1:4:length(tfarr)
1467+
if tfarr[i + 3] === sparams && typeseq(tfarr[i], atypes)
1468+
code = tfarr[i + 1]
1469+
if tfarr[i + 2]
14701470
redo = true
1471-
tfunc_idx = i+1
1471+
tfunc_idx = i + 1
14721472
curtype = code
14731473
break
14741474
end
@@ -1501,24 +1501,26 @@ function typeinf(linfo::LambdaStaticData,atypes::ANY,sparams::SimpleVector, def,
15011501
end
15021502
tfarr = def.tfunc::Array{Any,1}
15031503
idx = -1
1504-
for i = 1:3:length(tfarr)
1505-
if typeseq(tfarr[i],atypes)
1504+
for i = 1:4:length(tfarr)
1505+
if sparams === tfarr[i + 3] && typeseq(tfarr[i], atypes)
15061506
idx = i; break
15071507
end
15081508
end
15091509
if idx == -1
15101510
l = length(tfarr)
1511-
idx = l+1
1512-
resize!(tfarr, l+3)
1511+
idx = l + 1
1512+
resize!(tfarr, l + 4)
15131513
end
15141514
tfarr[idx] = atypes
15151515
# in the "rec" state this tree will not be used again, so store
15161516
# just the return type in place of it.
15171517
tfarr[idx+1] = rec ? result : (fulltree,result)
15181518
tfarr[idx+2] = rec
1519+
tfarr[idx+3] = sparams
15191520
else
15201521
def.tfunc[tfunc_idx] = rec ? result : (fulltree,result)
15211522
def.tfunc[tfunc_idx+1] = rec
1523+
def.tfunc[tfunc_idx+2] = sparams
15221524
end
15231525

15241526
return (fulltree, result::Type)

‎src/dump.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -818,13 +818,13 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
818818
// not needed (e.g. they don't get inlined).
819819
if (tf && jl_typeis(tf, jl_array_any_type)) {
820820
size_t i, l = jl_array_len(tf);
821-
for(i=0; i < l; i += 3) {
821+
for(i=0; i < l; i += 4) {
822822
if (!jl_is_leaf_type(jl_cellref(tf,i))) {
823-
jl_value_t *ret = jl_cellref(tf,i+1);
823+
jl_value_t *ret = jl_cellref(tf, i + 1);
824824
if (jl_is_tuple(ret)) {
825825
jl_value_t *ast = jl_fieldref(ret, 0);
826826
if (jl_is_array(ast) && jl_array_len(ast) > 500)
827-
jl_cellset(tf, i+1, jl_fieldref(ret,1));
827+
jl_cellset(tf, i+1, jl_fieldref(ret, 1));
828828
}
829829
}
830830
}

‎test/core.jl

+20
Original file line numberDiff line numberDiff line change
@@ -3651,3 +3651,23 @@ end
36513651
# issue #14691
36523652
type T14691; a::UInt; end
36533653
@test (T14691(0).a = 0) === 0
3654+
3655+
# issue #9222
3656+
function SimpleTest9222{T1<:Real}(pdedata, mu_actual::Vector{T1},
3657+
nu_actual::Vector{T1}, v0::Vector{T1}, epsilon::T1, beta::Vector{T1},
3658+
delta::T1, l::T1, R::T1, s0::T1, show_trace::Bool = true)
3659+
return 0.0
3660+
end
3661+
function SimpleTest9222{T1<:Real}(pdedata, mu_actual::Vector{T1},
3662+
nu_actual::Vector{T1}, v0::Vector{T1}, epsilon::T1, beta::Vector{T1},
3663+
delta::T1, l::T1, R::T1)
3664+
return SimpleTest9222(pdedata, mu_actual, nu_actual, v0, epsilon,
3665+
beta, delta, l, R, v0[1])
3666+
end
3667+
function foo9222()
3668+
v0 = rand(10)
3669+
mu_actual = rand(10)
3670+
nu_actual = rand(10)
3671+
SimpleTest9222(0.0, mu_actual, nu_actual, v0, 0.0, [1.0,1.0], 0.5, 5.0, 20.0)
3672+
end
3673+
@test foo9222() === 0.0

0 commit comments

Comments
 (0)
Please sign in to comment.