What does "return" keyword mean in INFO_TABLE_RET declarations?

Ömer Sinan Ağacan omeragacan at gmail.com
Sun Mar 18 14:48:55 UTC 2018


I'm trying to understand what a "return" list in INFO_TABLE_RET declaration
line specifies. As far as I understand a "return" in the declaration line is
something different than a "return" in the body. For example, in this
definition: (in HeapStackCheck.cmm)

    INFO_TABLE_RET ( stg_ret_p, RET_SMALL, W_ info_ptr, P_ ptr )
        return (/* no return values */)
        return (ptr);

The return list is empty and it even says "no return values" explicitly, yet it
returns something.

My guess is that the "return" list in the header is actually for arguments. I
found this info table which has an argument: (in StgMiscClosures.cmm)

    INFO_TABLE_RET (stg_restore_cccs_eval, RET_SMALL, W_ info_ptr, W_ cccs)
        return (P_ ret)
        unwind Sp = Sp + WDS(2);
    #if defined(PROFILING)
        CCCS = cccs;
        jump stg_ap_0_fast(ret);

This is the use site: (in Interpreter.c)

    #if defined(PROFILING)
        // restore the CCCS after evaluating the closure
        SpW(1) = (W_)cap->r.rCCCS;
        SpW(0) = (W_)&stg_restore_cccs_eval_info;
        SpW(1) = (W_)tagged_obj;
        SpW(0) = (W_)&stg_enter_info;
        RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding);

If I understand this correctly, the "tagged_obj" code will put the return value
in R1, pop the stack (which will have stg_restore_ccs_eval_info at the bottom)
and jump to this the info table code shown above. So `P_ ret` is the value of
`tagged_obj`, and the "return" list is actually for parameters.

Did I get this right? If I did, I'm curious why it's called "return" and not
"args" or something like that.



More information about the ghc-devs mailing list