[Git][ghc/ghc][wip/ghci-primcall] fixups

Luite Stegeman (@luite) gitlab at gitlab.haskell.org
Sat Sep 17 13:19:04 UTC 2022



Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC


Commits:
463548bf by Luite Stegeman at 2022-09-17T15:18:37+02:00
fixups

- - - - -


3 changed files:

- compiler/GHC/StgToByteCode.hs
- rts/Disassembler.c
- rts/StgMiscClosures.cmm


Changes:

=====================================
compiler/GHC/StgToByteCode.hs
=====================================
@@ -649,7 +649,7 @@ schemeT d s p app
    -- Case 1
 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty)
    = if isSupportedCConv ccall_spec
-      then generateCCall d s p ccall_spec result_ty args -- (reverse args)
+      then generateCCall d s p ccall_spec result_ty args
       else unsupportedCConvException
 
 schemeT d s p (StgOpApp (StgPrimOp op) args _ty)
@@ -1280,7 +1280,7 @@ generatePrimCall d s p target _mb_unit _result_ty args
                 the layoutTuple function?
           -}
          (args_info, args_offsets) =
-              layoutTuple profile 0 (primRepCmmType platform . argPrimRep) args
+              layoutTuple profile d (primRepCmmType platform . argPrimRep) args
          args_ptrs =
             map (\(r, off) ->
                   (isFollowableArg (toArgRep platform . argPrimRep $ r), off))


=====================================
rts/Disassembler.c
=====================================
@@ -84,7 +84,7 @@ disInstr ( StgBCO *bco, int pc )
                          literals[instrs[pc]] );
          pc += 1; break;
       case bci_PRIMCALL:
-         debugBelch("PRIMCALL\n ");
+         debugBelch("PRIMCALL\n");
          break;
      case bci_STKCHECK:  {
          StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1;


=====================================
rts/StgMiscClosures.cmm
=====================================
@@ -406,6 +406,33 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO )
 }
 
 
+ /*
+    Note [GHCi prim calling convention]
+
+    The stg_primcall frame is used by the bytecode interpreter to call
+    a Cmm function. The frame contains an args_info word that contains
+    a bitmap describing the register arguments.
+
+    The register arguments are moved to registers first (they are on
+    the stack in the order that POP_TUPLE_REGS expects) while the
+    remaining arguments are left on the stack.
+
+    When the target function is called, Sp points to the topmost stack
+    argument.
+
+       ...
+       next_stack_frame
+       arg_1
+       arg_2
+       ...
+       arg_n
+       target_funptr       (pointer to the function we're calling)
+       args_info           (describes the registers containing the arguments)
+       primcall_BCO        (contains bitmap describing pointers in args)
+       stg_primcall_info   <- Sp
+
+ */
+
 INFO_TABLE_RET ( stg_primcall, RET_BCO )
 {
     W_ args_info, prim_fun;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/463548bf5ba8b6691648b0ef03578fd08e211dd9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/463548bf5ba8b6691648b0ef03578fd08e211dd9
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220917/7b984a83/attachment-0001.html>


More information about the ghc-commits mailing list