[Git][ghc/ghc][wip/decode_cloned_stack] Fix

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Sun Dec 25 17:37:31 UTC 2022



Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC


Commits:
690bade5 by Sven Tennie at 2022-12-25T17:37:13+00:00
Fix

- - - - -


2 changed files:

- + libraries/ghc-heap/tests/stack_misc_closures_c.c
- + libraries/ghc-heap/tests/stack_misc_closures_prim.cmm


Changes:

=====================================
libraries/ghc-heap/tests/stack_misc_closures_c.c
=====================================
@@ -0,0 +1,44 @@
+#include "MachDeps.h"
+#include "Rts.h"
+#include "RtsAPI.h"
+#include "rts/Messages.h"
+#include "rts/Types.h"
+#include "rts/storage/ClosureMacros.h"
+#include "rts/storage/Closures.h"
+#include "stg/Types.h"
+#include <stdlib.h>
+
+extern void printStack(StgStack *stack);
+
+// See rts/Threads.c
+#define MIN_STACK_WORDS (RESERVED_STACK_WORDS + sizeofW(StgStopFrame) + 3)
+
+// Copied from Cmm.h
+#define SIZEOF_W SIZEOF_VOID_P
+#define WDS(n) ((n)*SIZEOF_W)
+
+StgStack *any_update_frame() {
+  Capability *cap = rts_lock();
+  StgWord closureSizeWords =
+      sizeofW(StgStack) + sizeofW(StgUpdateFrame) + MIN_STACK_WORDS;
+  StgStack *stack = (StgStack *)allocate(cap, closureSizeWords);
+  StgWord closureSizeBytes = WDS(closureSizeWords);
+  SET_HDR(stack, &stg_upd_frame_info, CCS_SYSTEM);
+  stack->stack_size = closureSizeBytes;
+  stack->dirty = 0;
+  stack->marking = 0;
+
+  StgPtr spBottom = stack->stack + stack->stack_size;
+  stack->sp = spBottom;
+  stack->sp -= sizeofW(StgStopFrame);
+  SET_HDR((StgClosure *)stack->sp, &stg_stop_thread_info, CCS_SYSTEM);
+
+  stack->sp -= sizeofW(StgUpdateFrame);
+  StgUpdateFrame *updF = (StgUpdateFrame *)stack->sp;
+  SET_HDR(updF, &stg_upd_frame_info, CCS_SYSTEM);
+  StgClosure *payload = UNTAG_CLOSURE(rts_mkWord(cap, 42));
+  updF->updatee = payload;
+  rts_unlock(cap);
+  printStack(stack);
+  return stack;
+}


=====================================
libraries/ghc-heap/tests/stack_misc_closures_prim.cmm
=====================================
@@ -0,0 +1,7 @@
+#include "Cmm.h"
+
+any_update_framezh(){
+    P_ stack;
+    (stack) = ccall any_update_frame();
+    return (stack);
+}



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/690bade508b90f31f22b0ea8da776e7afff03628

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/690bade508b90f31f22b0ea8da776e7afff03628
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/20221225/4cb1a45a/attachment-0001.html>


More information about the ghc-commits mailing list