mirror of https://github.com/exaloop/codon
Fix static globals in JIT
parent
543324d347
commit
010fa3b347
|
@ -33,6 +33,7 @@ std::string Cache::rev(const std::string &s) {
|
|||
|
||||
void Cache::addGlobal(const std::string &name, ir::Var *var) {
|
||||
if (!in(globals, name)) {
|
||||
// LOG("[global] {}", name);
|
||||
globals[name] = var;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ bool SimplifyVisitor::checkCapture(const SimplifyContext::Item &val) {
|
|||
// Case: a global variable that has not been marked with `global` statement
|
||||
if (val->isVar() && val->getBaseName().empty()) {
|
||||
val->noShadow = true;
|
||||
if (val->scope.size() == 1)
|
||||
if (val->scope.size() == 1 && !val->isStatic())
|
||||
ctx->cache->addGlobal(val->canonicalName);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -153,8 +153,10 @@ StmtPtr SimplifyVisitor::transformAssignment(ExprPtr lhs, ExprPtr rhs, ExprPtr t
|
|||
}
|
||||
|
||||
// Register all toplevel variables as global in JIT mode
|
||||
bool isGlobal = (ctx->cache->isJit && ctx->isGlobal()) || (canonical == VAR_ARGV);
|
||||
if (isGlobal)
|
||||
bool isGlobal =
|
||||
(ctx->cache->isJit && ctx->isGlobal() && getStaticGeneric(type.get()) != 0) ||
|
||||
(canonical == VAR_ARGV);
|
||||
if (isGlobal && !getStaticGeneric(type.get()))
|
||||
ctx->cache->addGlobal(canonical);
|
||||
|
||||
return assign;
|
||||
|
|
Loading…
Reference in New Issue