Add bound check for list and range (#185) #255
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#255
Loading…
Reference in New Issue
No description provided.
Delete Branch "bound_check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
f1a99e4bfb
to86ce513cb5
force-pushed to rebase on the latest master branch
@ -230,3 +230,3 @@
output_int32_list([int32(b) for b in bl5])
bl6 = bl[:]
bl6[3:-5] = [True, False, False]
bl6[3:-5] = [True, False]
what is this?
This is the 'fix broken test' commit. This test should not pass because the length of
bl6
is 10, sobl[3:-5]
isbl[3,5]
, which has length 2, so this test is actually extending the list, which is not supported.Previously this test happened to accidentally pass because we do not have the check on the list slice assignment yet, and the value of the assignment accidentally make the test pass. In fact, just by changing the
bl6[3:-5] = [True, False, False]
tobl6[3:-5] = [True, False, True]
or something else, this test will fail before this PR.@ -77,6 +77,7 @@ pub struct CodeGenContext<'ctx, 'a> {
pub outer_catch_clauses:
Option<(Vec<Option<BasicValueEnum<'ctx>>>, BasicBlock<'ctx>, PhiValue<'ctx>)>,
pub need_sret: bool,
pub current_loc: Location,
I wonder if we should add
current_loc
toCodeGenContext
. You can pass the location information when you call functions like list assignment, so this change is really not necessary. The problem with this is that the location information is only updated when we visitExpr
nodes, but not updated for other nodes such as statements.I wrote it such that it is also updated when visiting statements in
gen_stmt
.. And I think this along withgen_expr
should suffice for updating the location? The location for the current several exception throwed seems fine when I tested them.Indeed we can pass the location in an additional argument to some functions.. but I just thought that it might be useful to add it here so that later we do not need to bother changing a lot of function signatures again when location information is needed elsewhere.
I also did a profiling on the performance impact of this using a file that is ~10k lines and generated by repeating the
mandelbrot.py
, and it seems fine?in master
after this PR
It should be fine if updated when visiting statements. I am not worried about performance issue as this is just a simple copy... But I'm wondering why would it take 17.3s to compile a file with 10k lines...
Oh I run this profile under the debug release just to get a brief idea of the performance impact of this PR. Here are the results under the release build:
current master branch:
after this PR