diff options
author | Than McIntosh <thanm@google.com> | 2017-12-01 23:12:13 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-12-01 23:12:13 +0000 |
commit | 92f0112cab96a60bb777b81e93a5d10437c5fa60 (patch) | |
tree | 90ebd983c790cf1c3455070065240bae31afec39 /gcc/go/gofrontend/parse.cc | |
parent | 19041dad9b7f03b32775864c41649a81ebca8092 (diff) | |
download | gcc-92f0112cab96a60bb777b81e93a5d10437c5fa60.zip gcc-92f0112cab96a60bb777b81e93a5d10437c5fa60.tar.gz gcc-92f0112cab96a60bb777b81e93a5d10437c5fa60.tar.bz2 |
compiler: introduce size threshold for nil checks
Add a new control variable to the Gogo class that stores the size
threshold for nil checks. This value can be used to control the
policy for deciding when a given deference operation needs a check and
when it does not. A size threshold of -1 means that every potentially
faulting dereference needs an explicit check (and branch to error
call). A size threshold of K (where K > 0) means that if the size of
the object being dereferenced is >= K, then we need a check.
Reviewed-on: https://go-review.googlesource.com/80996
* go-c.h (go_create_gogo_args): Add nil_check_size_threshold
field.
* go-lang.c (go_langhook_init): Set nil_check_size_threshold.
From-SVN: r255340
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index f7d53af..be6f3f1 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -2745,14 +2745,17 @@ Parse::enclosing_var_reference(Named_object* in_function, Named_object* var, Expression* closure_ref = Expression::make_var_reference(closure, location); - closure_ref = Expression::make_unary(OPERATOR_MULT, closure_ref, location); + closure_ref = + Expression::make_dereference(closure_ref, + Expression::NIL_CHECK_DEFAULT, + location); // The closure structure holds pointers to the variables, so we need // to introduce an indirection. Expression* e = Expression::make_field_reference(closure_ref, ins.first->index(), location); - e = Expression::make_unary(OPERATOR_MULT, e, location); + e = Expression::make_dereference(e, Expression::NIL_CHECK_DEFAULT, location); return Expression::make_enclosing_var_reference(e, var, location); } |