Skip to content
Closed
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
7 changes: 5 additions & 2 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ true
```
"""
macro task(ex)
:(Task(()->$(esc(ex))))
# Avoid using `@opaque` to make bootstrap easier
thunk = esc(Expr(:opaque_closure, :(()->($ex))))
:(Task($thunk))
end

"""
Expand Down Expand Up @@ -473,7 +475,8 @@ isolating the asynchronous code from changes to the variable's value in the curr
macro async(expr)
letargs = Base._lift_one_interp!(expr)

thunk = esc(:(()->($expr)))
# Avoid using `@opaque` to make bootstrap easier
thunk = esc(Expr(:opaque_closure, :(()->($expr))))
var = esc(sync_varname)
quote
let $(letargs...)
Expand Down
3 changes: 2 additions & 1 deletion base/threadingconstructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ isolating the asynchronous code from changes to the variable's value in the curr
macro spawn(expr)
letargs = Base._lift_one_interp!(expr)

thunk = esc(:(()->($expr)))
# Avoid using `@opaque` to make bootstrap easier
thunk = esc(Expr(:opaque_closure, :(()->($expr))))
var = esc(Base.sync_varname)
quote
let $(letargs...)
Expand Down
1 change: 1 addition & 0 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ static Value *julia_pgv(jl_codectx_t &ctx, const char *cname, void *addr)
if (gv->getParent() != M)
gv = cast_or_null<GlobalVariable>(M->getNamedValue(localname));
}
assert(localname != "");
if (gv == nullptr)
gv = new GlobalVariable(*M, ctx.types().T_pjlvalue,
false, GlobalVariable::PrivateLinkage,
Expand Down
21 changes: 21 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7735,9 +7735,30 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
for (const auto &F: Mod->functions())
if (!F.isDeclaration())
Exports.push_back(F.getName().str());
SmallVector<std::pair<std::string,GlobalVariable*>> Globals;
for (auto pair : ctx.global_targets)
if (pair.second->getParent() == &*Mod)
Globals.push_back({std::string(pair.second->getName()), pair.second});
jl_merge_module(jl_Module, std::move(Mod));
for (auto FN: Exports)
jl_Module->getFunction(FN)->setLinkage(GlobalVariable::InternalLinkage);
// Remove or refresh globals defined in `Mod`
auto &globals = ctx.global_targets;
for (auto it = globals.begin(); it != globals.end();) {
bool remove = false;
for (auto pair: Globals)
if (pair.second == it->second) {
if (auto G = jl_Module->getNamedValue(pair.first))
it->second = cast<GlobalVariable>(G);
else
remove = true;
break;
}
if (remove)
it = globals.erase(it);
else
++it;
}
}

JL_GC_POP();
Expand Down