Commit 008ea12d authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Ben Gamari

Use __FILE__ for Cmm assertion locations, fix #8619

It seems like we currently support string literals in Cmm, so we can use
__LINE__ CPP macro in assertion macros. This improves error messages
that previously looked like

    ASSERTION FAILED: file (null), line 1302

(null) part now shows the actual file name.

Also inline some single-use string literals in PrimOps.cmm.

Reviewers: bgamari, simonmar, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4862
parent b8e34992
...@@ -402,8 +402,6 @@ statics :: { [CmmParse [CmmStatic]] } ...@@ -402,8 +402,6 @@ statics :: { [CmmParse [CmmStatic]] }
: {- empty -} { [] } : {- empty -} { [] }
| static statics { $1 : $2 } | static statics { $1 : $2 }
-- Strings aren't used much in the RTS HC code, so it doesn't seem
-- worth allowing inline strings. C-- doesn't allow them anyway.
static :: { CmmParse [CmmStatic] } static :: { CmmParse [CmmStatic] }
: type expr ';' { do e <- $2; : type expr ';' { do e <- $2;
return [CmmStaticLit (getLit e)] } return [CmmStaticLit (getLit e)] }
......
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
if (predicate) { \ if (predicate) { \
/*null*/; \ /*null*/; \
} else { \ } else { \
foreign "C" _assertFail(NULL, __LINE__) never returns; \ foreign "C" _assertFail(__FILE__, __LINE__) never returns; \
} }
#else #else
#define ASSERT(p) /* nothing */ #define ASSERT(p) /* nothing */
......
...@@ -646,8 +646,6 @@ stg_atomicModifyMutVarzh ( gcptr mv, gcptr f ) ...@@ -646,8 +646,6 @@ stg_atomicModifyMutVarzh ( gcptr mv, gcptr f )
Weak Pointer Primitives Weak Pointer Primitives
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
STRING(stg_weak_msg,"New weak pointer at %p\n")
stg_mkWeakzh ( gcptr key, stg_mkWeakzh ( gcptr key,
gcptr value, gcptr value,
gcptr finalizer /* or stg_NO_FINALIZER_closure */ ) gcptr finalizer /* or stg_NO_FINALIZER_closure */ )
...@@ -670,7 +668,7 @@ stg_mkWeakzh ( gcptr key, ...@@ -670,7 +668,7 @@ stg_mkWeakzh ( gcptr key,
Capability_weak_ptr_list_tl(MyCapability()) = w; Capability_weak_ptr_list_tl(MyCapability()) = w;
} }
IF_DEBUG(weak, ccall debugBelch(stg_weak_msg,w)); IF_DEBUG(weak, ccall debugBelch("New weak pointer at %p\n",w));
return (w); return (w);
} }
...@@ -680,8 +678,6 @@ stg_mkWeakNoFinalizzerzh ( gcptr key, gcptr value ) ...@@ -680,8 +678,6 @@ stg_mkWeakNoFinalizzerzh ( gcptr key, gcptr value )
jump stg_mkWeakzh (key, value, stg_NO_FINALIZER_closure); jump stg_mkWeakzh (key, value, stg_NO_FINALIZER_closure);
} }
STRING(stg_cfinalizer_msg,"Adding a finalizer to %p\n")
stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer
W_ ptr, W_ ptr,
W_ flag, // has environment (0 or 1) W_ flag, // has environment (0 or 1)
...@@ -715,7 +711,7 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer ...@@ -715,7 +711,7 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer
recordMutable(w); recordMutable(w);
IF_DEBUG(weak, ccall debugBelch(stg_cfinalizer_msg,w)); IF_DEBUG(weak, ccall debugBelch("Adding a finalizer to %p\n",w));
return (1); return (1);
} }
...@@ -2037,8 +2033,6 @@ stg_waitWritezh ( W_ fd ) ...@@ -2037,8 +2033,6 @@ stg_waitWritezh ( W_ fd )
#endif #endif
} }
STRING(stg_delayzh_malloc_str, "stg_delayzh")
stg_delayzh ( W_ us_delay ) stg_delayzh ( W_ us_delay )
{ {
#if defined(mingw32_HOST_OS) #if defined(mingw32_HOST_OS)
...@@ -2059,7 +2053,7 @@ stg_delayzh ( W_ us_delay ) ...@@ -2059,7 +2053,7 @@ stg_delayzh ( W_ us_delay )
/* could probably allocate this on the heap instead */ /* could probably allocate this on the heap instead */
("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult, ("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult,
stg_delayzh_malloc_str); "stg_delayzh");
(reqID) = ccall addDelayRequest(us_delay); (reqID) = ccall addDelayRequest(us_delay);
StgAsyncIOResult_reqID(ares) = reqID; StgAsyncIOResult_reqID(ares) = reqID;
StgAsyncIOResult_len(ares) = 0; StgAsyncIOResult_len(ares) = 0;
...@@ -2104,7 +2098,6 @@ while: ...@@ -2104,7 +2098,6 @@ while:
#if defined(mingw32_HOST_OS) #if defined(mingw32_HOST_OS)
STRING(stg_asyncReadzh_malloc_str, "stg_asyncReadzh")
stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf ) stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf )
{ {
W_ ares; W_ ares;
...@@ -2119,7 +2112,7 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf ) ...@@ -2119,7 +2112,7 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf )
/* could probably allocate this on the heap instead */ /* could probably allocate this on the heap instead */
("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult, ("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult,
stg_asyncReadzh_malloc_str); "stg_asyncReadzh");
(reqID) = ccall addIORequest(fd, 0/*FALSE*/,is_sock,len,buf "ptr"); (reqID) = ccall addIORequest(fd, 0/*FALSE*/,is_sock,len,buf "ptr");
StgAsyncIOResult_reqID(ares) = reqID; StgAsyncIOResult_reqID(ares) = reqID;
StgAsyncIOResult_len(ares) = 0; StgAsyncIOResult_len(ares) = 0;
...@@ -2130,7 +2123,6 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf ) ...@@ -2130,7 +2123,6 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf )
#endif #endif
} }
STRING(stg_asyncWritezh_malloc_str, "stg_asyncWritezh")
stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf ) stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf )
{ {
W_ ares; W_ ares;
...@@ -2144,7 +2136,7 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf ) ...@@ -2144,7 +2136,7 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf )
StgTSO_why_blocked(CurrentTSO) = BlockedOnWrite::I16; StgTSO_why_blocked(CurrentTSO) = BlockedOnWrite::I16;
("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult, ("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult,
stg_asyncWritezh_malloc_str); "stg_asyncWritezh");
(reqID) = ccall addIORequest(fd, 1/*TRUE*/,is_sock,len,buf "ptr"); (reqID) = ccall addIORequest(fd, 1/*TRUE*/,is_sock,len,buf "ptr");
StgAsyncIOResult_reqID(ares) = reqID; StgAsyncIOResult_reqID(ares) = reqID;
...@@ -2156,7 +2148,6 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf ) ...@@ -2156,7 +2148,6 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf )
#endif #endif
} }
STRING(stg_asyncDoProczh_malloc_str, "stg_asyncDoProczh")
stg_asyncDoProczh ( W_ proc, W_ param ) stg_asyncDoProczh ( W_ proc, W_ param )
{ {
W_ ares; W_ ares;
...@@ -2171,7 +2162,7 @@ stg_asyncDoProczh ( W_ proc, W_ param ) ...@@ -2171,7 +2162,7 @@ stg_asyncDoProczh ( W_ proc, W_ param )
/* could probably allocate this on the heap instead */ /* could probably allocate this on the heap instead */
("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult, ("ptr" ares) = ccall stgMallocBytes(SIZEOF_StgAsyncIOResult,
stg_asyncDoProczh_malloc_str); "stg_asyncDoProczh");
(reqID) = ccall addDoProcRequest(proc "ptr",param "ptr"); (reqID) = ccall addDoProcRequest(proc "ptr",param "ptr");
StgAsyncIOResult_reqID(ares) = reqID; StgAsyncIOResult_reqID(ares) = reqID;
StgAsyncIOResult_len(ares) = 0; StgAsyncIOResult_len(ares) = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment