[Git][ghc/ghc][wip/decode_cloned_stack] Save
Sven Tennie (@supersven)
gitlab at gitlab.haskell.org
Fri Nov 25 16:35:53 UTC 2022
Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC
Commits:
44898a68 by Sven Tennie at 2022-11-25T16:35:36+00:00
Save
- - - - -
2 changed files:
- compile_flags.txt
- + libraries/ghc-heap/tests/stack_lib.c
Changes:
=====================================
compile_flags.txt
=====================================
@@ -2,4 +2,5 @@
-Irts
-Irts/include
-I.hie-bios/stage0/lib
+-I_build/stage1/rts/build/include/
-DDEBUG
=====================================
libraries/ghc-heap/tests/stack_lib.c
=====================================
@@ -0,0 +1,61 @@
+#include "Rts.h"
+#include "stg/Types.h"
+#include <stdlib.h>
+
+// Traverse the stack and return an arry representation of it's closure types.
+StgArrBytes *foldStackToArrayClosure(StgStack *stack) {}
+
+typedef struct ClosureTypeList_ {
+ struct ClosureTypeList *next;
+ StgWord closureType;
+} ClosureTypeList;
+
+// Do not traverse the whole heap. Instead add all closures that are on the
+// stack itself or referenced directly by such closures.
+ClosureTypeList *foldStackToList(StgStack *stack) {
+ StgPtr sp = stack->sp;
+ StgPtr spBottom = stack->stack + stack->stack_size;
+
+ for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) {
+ }
+}
+
+ClosureTypeList* create(StgWord closureType){
+ ClosureTypeList *entry = malloc(sizeof(ClosureTypeList));
+ entry->next=NULL;
+ entry->closureType = closureType;
+ return entry;
+}
+
+ClosureTypeList *add(ClosureTypeList *list, StgWord closureType) {
+ ClosureTypeList *newEntry = malloc(sizeof(ClosureTypeList));
+ newEntry->next = NULL;
+ newEntry->closureType = closureType;
+ lastEntry(list)->next = newEntry;
+ return newEntry;
+}
+
+ClosureTypeList *last(ClosureTypeList *list) {
+ while (list->next != NULL) {
+ list = list->next;
+ }
+ return list;
+}
+
+void freeList(ClosureTypeList *list) {
+ ClosureTypeList *tmp;
+ while (list != NULL) {
+ tmp = list;
+ list = list->next;
+ free(tmp);
+ }
+}
+
+StgWord listSize(ClosureTypeList *list) {
+ StgWord s = 0;
+ while (list != NULL) {
+ list = list->next;
+ s++;
+ }
+ return s;
+}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44898a68b073ff63b6c11749e5f5f00110cf8370
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44898a68b073ff63b6c11749e5f5f00110cf8370
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/20221125/ac3f5068/attachment-0001.html>
More information about the ghc-commits
mailing list