Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3610,6 +3610,9 @@ void jl_init_types(void) JL_GC_DISABLED
jl_value_t *listt = jl_new_struct(jl_uniontype_type, jl_task_type, jl_nothing_type);
jl_svecset(jl_task_type->types, 0, listt);

const static uint32_t task_constfields[1] = {0x00000040}; // Set fields 7 as constant
Copy link
Member Author

Choose a reason for hiding this comment

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

@vtjnash should any of the task fields be atomic? I was surprised that things like _state weren't.

Copy link
Member

Choose a reason for hiding this comment

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

Most likely yes, correctness would seem to demand that (esp for acquire/release of result after the _state read/write). I think it must have gotten missed in my list of data race issues

jl_task_type->name->constfields = task_constfields;

tv = jl_svec2(tvar("A"), tvar("R"));
jl_opaque_closure_type = (jl_unionall_t*)jl_new_datatype(jl_symbol("OpaqueClosure"), core, jl_function_type, tv,
// N.B.: OpaqueClosure call code relies on specptr being field 5.
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Serialization/src/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1564,9 +1564,9 @@ function deserialize(s::AbstractSerializer, ::Type{UnionAll})
end

function deserialize(s::AbstractSerializer, ::Type{Task})
t = Task(()->nothing)
code = deserialize(s)
t = Task(code)
deserialize_cycle(s, t)

This comment was marked as resolved.

t.code = deserialize(s)
t.storage = deserialize(s)
state = deserialize(s)
if state === :runnable
Expand Down
1 change: 1 addition & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ for (T, c) in (
(TypeVar, [:name, :ub, :lb]),
(Core.Memory, [:length, :ptr]),
(Core.GenericMemoryRef, [:mem, :ptr_or_offset]),
(Core.Task, [:code]),
)
@test Set((fieldname(T, i) for i in 1:fieldcount(T) if isconst(T, i))) == Set(c)
end
Expand Down