-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace C NULL for iter stop with StopIteration #2054
Conversation
@nordlander I added a new test case which demonstrates some failure in the compiler to mark variables volatile. The new test case is in test/core_lang_auto/exceptions_volatile.act First we can look at the working case, although note the two lines I commented out: def fun2():
a = "FOOBAR2" # easy to find in C source
my_list = [1]
complete = True
#if 1 == 1:
# complete = False
for r in my_list:
complete = False
return complete kll@Kristians-MacBook-Air core_lang_auto % actonc --cgen exceptions_volatile.act | grep -A20 FOOBA
B_str a = to$str("FOOBAR2");
B_list my_list = B_mk_list(1, to$int(1));
volatile B_bool complete = B_True;
B_Iterator N_1iter = ((B_Iterator (*) (B_Iterable, B_list))W_27->$class->__iter__)(W_27, my_list);
if ($PUSH()) {
while ((B_True)->val) {
B_int N_2val = ((B_int (*) (B_Iterator))N_1iter->$class->__next__)(N_1iter);
B_int r = N_2val;
complete = B_False;
}
$DROP();
}
else {
B_BaseException N_3x = $POP();
if ($ISINSTANCE0(N_3x, B_StopIteration)) {
}
else {
$RAISE(N_3x);
}
}
return complete; most importantly we see def fun2():
a = "FOOBAR2" # easy to find in C source
my_list = [1]
complete = True
if 1 == 1:
complete = False
for r in my_list:
complete = False
return complete and notice how kll@Kristians-MacBook-Air core_lang_auto % actonc --cgen exceptions_volatile.act | grep -A20 FOOBA
B_str a = to$str("FOOBAR2");
B_list my_list = B_mk_list(1, to$int(1));
B_bool complete = B_True;
if (ORD_B_int__eq__(to$int(1), to$int(1))) {
complete = B_False;
}
B_Iterator N_1iter = ((B_Iterator (*) (B_Iterable, B_list))W_37->$class->__iter__)(W_37, my_list);
if ($PUSH()) {
while ((B_True)->val) {
B_int N_2val = ((B_int (*) (B_Iterator))N_1iter->$class->__next__)(N_1iter);
B_int r = N_2val; |
a8aa3bc
to
78edddf
Compare
I've spotted the error. It's in Björn's recent additions to CodeGen, duplicating an error I also made in my recent mod to CPS (but was lucky enough to find and iron out!). Essentially, its root is the dubious nature of our utility function I'll commit a fix to CodeGen tomorrow. But ideally we should also straighten up all code that deals with scopes in the compiler, for the benefit of our future selves! :-/ |
@nordlander the telemetrify test is failing. Compilation and the (very small) test suite passes but then the final somewhat larger test of loading in a schema from a replay file fails:
I can only presume that control flow is messed up somehow. This is normally a very stable & deterministic test - I . Nonetheless, I have just cleared all CI caches and started a rerun just on the off chance there was an intermittent failure here. |
Same failure after clean rebuild... @nordlander |
Instead of returning a C NULL when we want to stop iteration, we now raise the StopIteration exception. This is a prerequisite for doing unboxed values since we need the NULL value for unboxed values. Longer term, we might go back to using NULL but packed in a tuple, like a tagged union basically, which is likely faster than raising an exception (that uses longjmp) but that requires some other support.
dd42d54
to
a6e67c1
Compare
🎆 |
No description provided.