@@ -34,6 +34,13 @@ int jl_is_toplevel_only_expr(jl_value_t *e);
3434
3535// type definition forms
3636
37+ // TODO: separate the codegen and toplevel locks
38+ // currently using a coarser lock seems like
39+ // the best way to avoid acquisition priority
40+ // ordering violations
41+ //static jl_mutex_t toplevel_lock;
42+ #define toplevel_lock codegen_lock
43+
3744extern int inside_typedef ;
3845
3946// this is a heuristic for allowing "redefining" a type to something identical
@@ -128,7 +135,7 @@ SECT_INTERP void jl_set_datatype_super(jl_datatype_t *tt, jl_value_t *super)
128135static void eval_abstracttype (jl_expr_t * ex , interpreter_state * s )
129136{
130137 jl_value_t * * args = jl_array_ptr_data (ex -> args );
131- JL_LOCK (& codegen_lock );
138+ JL_LOCK (& toplevel_lock );
132139 if (inside_typedef )
133140 jl_error ("cannot eval a new abstract type definition while defining another type" );
134141 jl_value_t * name = args [0 ];
@@ -168,13 +175,13 @@ static void eval_abstracttype(jl_expr_t *ex, interpreter_state *s)
168175 jl_checked_assignment (b , w );
169176 }
170177 JL_GC_POP ();
171- JL_UNLOCK (& codegen_lock );
178+ JL_UNLOCK (& toplevel_lock );
172179}
173180
174181static void eval_primitivetype (jl_expr_t * ex , interpreter_state * s )
175182{
176183 jl_value_t * * args = (jl_value_t * * )jl_array_ptr_data (ex -> args );
177- JL_LOCK (& codegen_lock );
184+ JL_LOCK (& toplevel_lock );
178185 if (inside_typedef )
179186 jl_error ("cannot eval a new primitive type definition while defining another type" );
180187 jl_value_t * name = args [0 ];
@@ -221,13 +228,13 @@ static void eval_primitivetype(jl_expr_t *ex, interpreter_state *s)
221228 jl_checked_assignment (b , w );
222229 }
223230 JL_GC_POP ();
224- JL_UNLOCK (& codegen_lock );
231+ JL_UNLOCK (& toplevel_lock );
225232}
226233
227234static void eval_structtype (jl_expr_t * ex , interpreter_state * s )
228235{
229236 jl_value_t * * args = jl_array_ptr_data (ex -> args );
230- JL_LOCK (& codegen_lock );
237+ JL_LOCK (& toplevel_lock );
231238 if (inside_typedef )
232239 jl_error ("cannot eval a new struct type definition while defining another type" );
233240 jl_value_t * name = args [0 ];
@@ -287,7 +294,7 @@ static void eval_structtype(jl_expr_t *ex, interpreter_state *s)
287294 }
288295
289296 JL_GC_POP ();
290- JL_UNLOCK (& codegen_lock );
297+ JL_UNLOCK (& toplevel_lock );
291298}
292299
293300// method definition form
0 commit comments