diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-18 06:33:03 +1000 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-18 06:33:03 +1000 |
commit | 33c029dd77888ee5f9b1c7ce8884c982e0428adf (patch) | |
tree | 6c38a3f4c4dcc2fb20a8ce4a1c9d1dc520ec6f9d /rts/sm/Sanity.c | |
parent | 5d80d14196ef048ffe037b2d92af2e9af0cb9e19 (diff) | |
download | haskell-33c029dd77888ee5f9b1c7ce8884c982e0428adf.tar.gz |
rts: More const correct-ness fixes
In addition to more const-correctness fixes this patch fixes an
infelicity of the previous const-correctness patch (995cf0f356) which
left `UNTAG_CLOSURE` taking a `const StgClosure` pointer parameter
but returning a non-const pointer. Here we restore the original type
signature of `UNTAG_CLOSURE` and add a new function
`UNTAG_CONST_CLOSURE` which takes and returns a const `StgClosure`
pointer and uses that wherever possible.
Test Plan: Validate on Linux, OS X and Windows
Reviewers: Phyx, hsyl20, bgamari, austin, simonmar, trofi
Reviewed By: simonmar, trofi
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2231
Diffstat (limited to 'rts/sm/Sanity.c')
-rw-r--r-- | rts/sm/Sanity.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index 2abe56b9bc..62d53e046d 100644 --- a/rts/sm/Sanity.c +++ b/rts/sm/Sanity.c @@ -83,7 +83,7 @@ checkClosureShallow( const StgClosure* p ) { const StgClosure *q; - q = UNTAG_CLOSURE(p); + q = UNTAG_CONST_CLOSURE(p); ASSERT(LOOKS_LIKE_CLOSURE_PTR(q)); /* Is it a static closure? */ @@ -137,11 +137,11 @@ checkStackFrame( StgPtr c ) case RET_FUN: { - StgFunInfoTable *fun_info; + const StgFunInfoTable *fun_info; StgRetFun *ret_fun; ret_fun = (StgRetFun *)c; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + fun_info = get_fun_itbl(UNTAG_CONST_CLOSURE(ret_fun->fun)); size = ret_fun->size; switch (fun_info->f.fun_type) { case ARG_GEN: @@ -182,10 +182,10 @@ checkStackChunk( StgPtr sp, StgPtr stack_end ) static void checkPAP (StgClosure *tagged_fun, StgClosure** payload, StgWord n_args) { - StgClosure *fun; - StgFunInfoTable *fun_info; + const StgClosure *fun; + const StgFunInfoTable *fun_info; - fun = UNTAG_CLOSURE(tagged_fun); + fun = UNTAG_CONST_CLOSURE(tagged_fun); ASSERT(LOOKS_LIKE_CLOSURE_PTR(fun)); fun_info = get_fun_itbl(fun); @@ -217,13 +217,13 @@ checkPAP (StgClosure *tagged_fun, StgClosure** payload, StgWord n_args) StgOffset -checkClosure( StgClosure* p ) +checkClosure( const StgClosure* p ) { const StgInfoTable *info; ASSERT(LOOKS_LIKE_CLOSURE_PTR(p)); - p = UNTAG_CLOSURE(p); + p = UNTAG_CONST_CLOSURE(p); /* Is it a static closure (i.e. in the data segment)? */ if (!HEAP_ALLOCED(p)) { ASSERT(closure_STATIC(p)); @@ -634,7 +634,7 @@ void checkStaticObjects ( StgClosure* static_objects ) { StgClosure *p = static_objects; - StgInfoTable *info; + const StgInfoTable *info; while (p != END_OF_STATIC_OBJECT_LIST) { p = UNTAG_STATIC_LIST_PTR(p); @@ -643,8 +643,9 @@ checkStaticObjects ( StgClosure* static_objects ) switch (info->type) { case IND_STATIC: { - StgClosure *indirectee = UNTAG_CLOSURE(((StgIndStatic *)p)->indirectee); + const StgClosure *indirectee; + indirectee = UNTAG_CONST_CLOSURE(((StgIndStatic *)p)->indirectee); ASSERT(LOOKS_LIKE_CLOSURE_PTR(indirectee)); ASSERT(LOOKS_LIKE_INFO_PTR((StgWord)indirectee->header.info)); p = *IND_STATIC_LINK((StgClosure *)p); |