Skip to content

Commit 9e02cf0

Browse files
authored
use non rng seed dependent uuid to avoid collisions (#231)
* use non rng seed dependent uuid to avoid collisions * use our own rng
1 parent 6b93e04 commit 9e02cf0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/JuliaInterpreter.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using Core: CodeInfo, SSAValue, SlotNumber, TypeMapEntry, SimpleVector, LineInfo
66
GeneratedFunctionStub, MethodInstance, NewvarNode, TypeName
77

88
using UUIDs
9+
using Random
910
# The following are for circumventing #28, memcpy invalid instruction error,
1011
# in Base and stdlib
1112
using Random.DSFMT

src/optimize.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function lookup_global_refs!(ex::Expr)
9595
return nothing
9696
end
9797

98+
const rng = MersenneTwister()
99+
98100
"""
99101
optimize!(code::CodeInfo, mod::Module)
100102
@@ -161,7 +163,7 @@ function optimize!(code::CodeInfo, scope)
161163
# Check for :llvmcall
162164
arg1 = stmt.args[1]
163165
if (arg1 == :llvmcall || lookup_stmt(code.code, arg1) == Base.llvmcall) && isempty(sparams) && scope isa Method
164-
uuid = uuid4()
166+
uuid = uuid1(rng)
165167
ustr = replace(string(uuid), '-'=>'_')
166168
methname = Symbol("llvmcall_", ustr)
167169
nargs = length(stmt.args)-4
@@ -171,7 +173,7 @@ function optimize!(code::CodeInfo, scope)
171173
elseif isexpr(stmt, :foreigncall) && scope isa Method
172174
f = lookup_stmt(code.code, stmt.args[1])
173175
if isa(f, Ptr)
174-
f = string(uuid4())
176+
f = string(uuid1(rng))
175177
elseif isexpr(f, :call)
176178
length(f.args) == 3 || continue
177179
f.args[1] === tuple || continue
@@ -184,7 +186,7 @@ function optimize!(code::CodeInfo, scope)
184186
continue
185187
end
186188
# TODO: Only compile one ccall per call and argument types
187-
uuid = uuid4()
189+
uuid = uuid1(rng)
188190
ustr = replace(string(uuid), '-'=>'_')
189191
methname = Symbol("ccall", '_', f, '_', ustr)
190192
nargs = stmt.args[5]

0 commit comments

Comments
 (0)