Follow up: Modifying the "StgHeader" struct
Adithya Kumar
adi.obilisetty at gmail.com
Mon Mar 18 07:47:26 UTC 2024
Hey folks,
I'm adding a field to "StgHeader" under a flag.
```
typedef struct {
const StgInfoTable* info;
#if defined(NEW_WAY)
StgWord new_field;
#endif
#if defined(PROFILING)
StgProfHeader prof;
#endif
} StgHeader;
typedef struct {
const StgInfoTable* info;
#if defined(NEW_WAY)
StgWord new_field;
#endif
#if defined(PROFILING)
StgProfHeader prof;
#endif
StgSMPThunkHeader smp;
} StgThunkHeader;
```
Follow-up changes:
==================
The following are the additional changes I've made following the `PROFILING`
flag:
Similar to `PROF_HDR_FIELDS` macro, I've added `NEW_HDR_FIELDS` macro:
```
#if defined(NEW_WAY)
#define NEW_HDR_FIELDS(w_,hdr) w_ hdr,
#else
#define NEW_HDR_FIELDS(w_,hdr) /* Nothing */
#endif
```
and updated the required stg code accordingly following the changes from
`PROF_HDR_FIELDS`.
I've also updated `GHC.Exts.Heap.ClosureTypes.closureTypeHeaderSize`
accordingly.
Error:
======
I'm greeted with the following error,
```
ASSERTION FAILED: file rts/StgStartup.cmm, line 100
```
Basically, the following assert fails
```
#define CHECK_SENSIBLE_REGS() \
ASSERT(Hp != 0); \
ASSERT(HpAlloc == 0); \
ASSERT(Sp != 0); \
ASSERT(SpLim != 0); \
ASSERT(SpLim - WDS(RESERVED_STACK_WORDS) <= Sp);
```
More context for the error:
===========================
Values for the correct version:
```
Hp 283468906488
HpAlloc 0
Sp 283468911440
SpLim 283468910784
SpLim - WDS(RESERVED_STACK_WORDS) 1069080
```
Values with the changes:
```
Hp 283468906488
HpAlloc 0
Sp 7532120
SpLim 9301536
SpLim - WDS(RESERVED_STACK_WORDS) 9301368
```
I recorded these values by calling a C print from the Cmm code.
Clearly, my changes messed up a lot of things. How do I go about this now?
The
past 2 weeks I've only been looking at a lot of ghc code. If any more
additional
context is required I can provide it.
Best,
Adithya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20240318/b7fbc00b/attachment.html>
More information about the ghc-devs
mailing list