[Git][ghc/ghc][wip/fendor/remove-stg_stackDecode] Remove stg_decodeStackzh
Hannes Siebenhandl pushed to branch wip/fendor/remove-stg_stackDecode at Glasgow Haskell Compiler / GHC Commits: 5dbb3e43 by fendor at 2025-08-26T11:31:14+02:00 Remove stg_decodeStackzh - - - - - 5 changed files: - libraries/ghc-internal/cbits/StackCloningDecoding.cmm - libraries/ghc-internal/jsbits/base.js - rts/CloneStack.c - rts/CloneStack.h - rts/RtsSymbols.c Changes: ===================================== libraries/ghc-internal/cbits/StackCloningDecoding.cmm ===================================== @@ -17,10 +17,3 @@ stg_sendCloneStackMessagezh (gcptr threadId, gcptr mVarStablePtr) { return (); } - -stg_decodeStackzh (gcptr stgStack) { - gcptr stackEntries; - ("ptr" stackEntries) = ccall decodeClonedStack(MyCapability() "ptr", stgStack "ptr"); - - return (stackEntries); -} ===================================== libraries/ghc-internal/jsbits/base.js ===================================== @@ -1245,7 +1245,7 @@ function h$mkdir(path, path_offset, mode) { // It is required by Google Closure Compiler to be at least defined if // somewhere it is used -var h$stg_cloneMyStackzh, h$stg_decodeStackzh, +var h$stg_cloneMyStackzh, h$advanceStackFrameLocationzh, h$getStackFieldszh, h$getStackClosurezh, h$getWordzh, h$getStackInfoTableAddrzh, h$getRetFunSmallBitmapzh, h$getRetFunLargeBitmapzh, h$isArgGenBigRetFunTypezh, @@ -1253,7 +1253,6 @@ var h$stg_cloneMyStackzh, h$stg_decodeStackzh, h$getInfoTableAddrszh, h$getLargeBitmapzh, h$getSmallBitmapzh, h$getBCOLargeBitmapzh h$stg_cloneMyStackzh - = h$stg_decodeStackzh = h$advanceStackFrameLocationzh = h$getStackFieldszh = h$getStackClosurezh = h$getWordzh, h$getStackInfoTableAddrzh = h$getRetFunSmallBitmapzh = h$getRetFunLargeBitmapzh ===================================== rts/CloneStack.c ===================================== @@ -26,11 +26,6 @@ #include <string.h> -static StgWord getStackFrameCount(StgStack* stack); -static StgWord getStackChunkClosureCount(StgStack* stack); -static StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes); -static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack); - static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack) { StgWord spOffset = stack->sp - stack->stack; @@ -112,94 +107,3 @@ void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) } #endif // end !defined(THREADED_RTS) - -// Creates a MutableArray# (Haskell representation) that contains a -// InfoProvEnt* for every stack frame on the given stack. Thus, the size of the -// array is the count of stack frames. -// Each InfoProvEnt* is looked up by lookupIPE(). If there's no IPE for a stack -// frame it's represented by null. -StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack) { - StgWord closureCount = getStackFrameCount(stack); - - StgArrBytes* array = allocateByteArray(cap, sizeof(StgInfoTable*) * closureCount); - - copyPtrsToArray(array, stack); - - return array; -} - -// Count the stack frames that are on the given stack. -// This is the sum of all stack frames in all stack chunks of this stack. -StgWord getStackFrameCount(StgStack* stack) { - StgWord closureCount = 0; - StgStack *last_stack = stack; - while (true) { - closureCount += getStackChunkClosureCount(last_stack); - - // check whether the stack ends in an underflow frame - StgUnderflowFrame *frame = (StgUnderflowFrame *) (last_stack->stack - + last_stack->stack_size - sizeofW(StgUnderflowFrame)); - if (frame->info == &stg_stack_underflow_frame_d_info - ||frame->info == &stg_stack_underflow_frame_v16_info - ||frame->info == &stg_stack_underflow_frame_v32_info - ||frame->info == &stg_stack_underflow_frame_v64_info) { - last_stack = frame->next_chunk; - } else { - break; - } - } - return closureCount; -} - -StgWord getStackChunkClosureCount(StgStack* stack) { - StgWord closureCount = 0; - StgPtr sp = stack->sp; - StgPtr spBottom = stack->stack + stack->stack_size; - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { - closureCount++; - } - - return closureCount; -} - -// Allocate and initialize memory for a ByteArray# (Haskell representation). -StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes) { - // Idea stolen from PrimOps.cmm:stg_newArrayzh() - StgWord words = sizeofW(StgArrBytes) + bytes; - - StgArrBytes* array = (StgArrBytes*) allocate(cap, words); - - SET_HDR(array, &stg_ARR_WORDS_info, CCS_SYSTEM); - array->bytes = bytes; - return array; -} - -static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack) { - StgWord index = 0; - StgStack *last_stack = stack; - const StgInfoTable **result = (const StgInfoTable **) arr->payload; - while (true) { - StgPtr sp = last_stack->sp; - StgPtr spBottom = last_stack->stack + last_stack->stack_size; - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { - const StgInfoTable* infoTable = ((StgClosure *)sp)->header.info; - result[index] = infoTable; - index++; - } - - // Ensure that we didn't overflow the result array - ASSERT(index-1 < arr->bytes / sizeof(StgInfoTable*)); - - // check whether the stack ends in an underflow frame - StgUnderflowFrame *frame = (StgUnderflowFrame *) (last_stack->stack - + last_stack->stack_size - sizeofW(StgUnderflowFrame)); - if (frame->info == &stg_stack_underflow_frame_d_info - ||frame->info == &stg_stack_underflow_frame_v16_info - ||frame->info == &stg_stack_underflow_frame_v32_info - ||frame->info == &stg_stack_underflow_frame_v64_info) { - last_stack = frame->next_chunk; - } else { - break; - } - } -} ===================================== rts/CloneStack.h ===================================== @@ -15,8 +15,6 @@ StgStack* cloneStack(Capability* capability, const StgStack* stack); void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); -StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack); - #include "BeginPrivate.h" #if defined(THREADED_RTS) ===================================== rts/RtsSymbols.c ===================================== @@ -951,7 +951,6 @@ extern char **environ; SymI_HasProto(lookupIPE) \ SymI_HasProto(sendCloneStackMessage) \ SymI_HasProto(cloneStack) \ - SymI_HasProto(decodeClonedStack) \ SymI_HasProto(stg_newPromptTagzh) \ SymI_HasProto(stg_promptzh) \ SymI_HasProto(stg_control0zh) \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dbb3e43e6e4bec76743b2518bb9fd20... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dbb3e43e6e4bec76743b2518bb9fd20... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Hannes Siebenhandl (@fendor)