rts: fix threadStackUnderflow type in cmm
authorSergei Trofimovich <siarheit@google.com>
Fri, 11 Mar 2016 22:31:58 +0000 (22:31 +0000)
committerSergei Trofimovich <siarheit@google.com>
Fri, 11 Mar 2016 23:19:47 +0000 (23:19 +0000)
stg_stack_underflow_frame had an incorrect
call of C function 'threadStackUnderflow':
    ("ptr" ret_off) =
      foreign "C" threadStackUnderflow(
        MyCapability(),
        CurrentTSO);

Which means it's prototype is:
    void * (*) (W_, void*);
While real prototype is:
    W_ (*) (Capability *cap, StgTSO *tso);

The fix is simple. Fix type annotations:
    (ret_off) =
      foreign "C" threadStackUnderflow(
        MyCapability() "ptr",
        CurrentTSO "ptr");

Noticed when debugged T9045 test failure
on m68k target which distincts between
pointer and non pointer return types
(uses different registers)

While at it noticed and fixed return types
for 'throwTo' and 'findSpark'.

Trac #11395

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
rts/Exception.cmm
rts/PrimOps.cmm
rts/StgMiscClosures.cmm

index a89bd19..2a07eaa 100644 (file)
@@ -307,7 +307,7 @@ stg_killThreadzh (P_ target, P_ exception)
     } else {
         W_ msg;
 
-        (msg) = ccall throwTo(MyCapability() "ptr",
+        ("ptr" msg) = ccall throwTo(MyCapability() "ptr",
                                     CurrentTSO "ptr",
                                     target "ptr",
                                     exception "ptr");
index 7add835..a802e67 100644 (file)
@@ -2344,7 +2344,7 @@ stg_getSparkzh ()
 #ifndef THREADED_RTS
     return (0,ghczmprim_GHCziTypes_False_closure);
 #else
-    (spark) = ccall findSpark(MyCapability());
+    ("ptr" spark) = ccall findSpark(MyCapability() "ptr");
     if (spark != 0) {
         return (1,spark);
     } else {
index 757730e..905f81e 100644 (file)
@@ -32,8 +32,8 @@ INFO_TABLE_RET (stg_stack_underflow_frame, UNDERFLOW_FRAME,
     SAVE_STGREGS
 
     SAVE_THREAD_STATE();
-    ("ptr" ret_off) = foreign "C" threadStackUnderflow(MyCapability(),
-                                                       CurrentTSO);
+    (ret_off) = foreign "C" threadStackUnderflow(MyCapability() "ptr",
+                                                 CurrentTSO);
     LOAD_THREAD_STATE();
 
     RESTORE_STGREGS