已合并
[SharedGC] Fix SharedCC TLAB reset order and CC prepare scope #15112
jinouwen创建于 6 天前
[SharedGC] Fix SharedCC TLAB reset order and CC prepare scope #15112
已合并
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 jinouwen 的贡献)6 天前 关联了issue:[Bug]: SharedCC resets TLABs after posting sweeper tasks and skips string table concurrent-sweep guards
6 天前 关联了issue:[Bug]: SharedCC resets TLABs after posting sweeper tasks and skips string table concurrent-sweep guards
6 天前 添加了label:waiting_on_author
openharmony_ci
6 天前 评论:
6 天前 评论:
感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接。
Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.


6 天前 添加了label:dco检查成功
6 天前 审查状态已重置,审查人: klooer
此处折叠了83条消息 查看更多
jinouwen
2 天前 评论:
2 天前 评论:
submit


2 天前 关闭了关联的issue
2 天前 合入了pull request,合并节点 SHA:2487f1baefc42530f448df820d1c708e654591ab
2 天前 删除了label:waiting_for_review
2 天前 添加了label:merged
关联的Issue
https://gitcode.com/openharmony/arkcompiler_ets_runtime/issues/13571
修改原因(目的、解决的问题等)
ReMarkAndPrepareposted concurrent sweeper tasks (PostTask(true)) before mutator TLABs were retired (ResetTlabran later insidePrepareForCopy). Once tasks are posted, worker threads concurrently build free objects over unmarked TLAB remains in shared non-movable regions (FillFreeObject+freeList_->Free), while the daemon still writes the same memory viaThreadLocalAllocationBuffer::Reset -> FillBumpPointer -> FillFreeObjectwithout any lock. The unlocked write clobbers sweeper-builtFreeObjectnodes (next reset to INVALID_OBJECT, available overwritten), which can break the free list chain or corrupt span metadata — subsequentFreeListAllocator::Allocatemay hand out memory overlapping live objects (heap corruption). All other shared GCs (SharedGC / SharedFullGC / SharedPartialGC) reset TLABs before posting sweep tasks; only SharedCC had the order inverted.Note: the string table concurrent-sweep guard issue also tracked in #13571 is intentionally NOT addressed in this change (deferring it needs a safe protocol w.r.t. threads already inside string table critical sections); it will be handled separately.
修改描述(做了什么,变更了什么)
ResetTlabfor all threads fromPrepareForCopyto beforeSweep(true)/PostTask(true)inReMarkAndPrepare(same STW section, mutators suspended;SetReadBarrierStatetiming unchanged, still after the FROM/TO swap).ParallelCopyskip condition (CalculateCopyThreadNumalways returns >= 1); it now checkscopyTasks_.empty()directly.PrepareAllThreadstoPrepareMainThread: only the main thread is posted before marking (theWaitMainThreadReadyhandshake); other threads are switched directly when their stack is empty, or posted at their next idle point fromCCMarkFlipFunctionduring initial mark, where the flip iteration also guarantees thread liveness.ThreadManagedScope) inJSNApi::SetPostTaskToThreadCallbackbefore installing the callback: SharedCC sweeper/marker threads readpostTaskToThreadCallback_concurrently (shared_cc.cpp/shared_concurrent_marker.cpp), and the RUNNING/GC mutual exclusion prevents a data race on the store.自测试项(测试结果截图,直接贴到每一个测试项底下)
jit-workload 本地执行(compiler/jit/isa/stub/ic/对象布局等修改必须执行)
interpreter-js_perf 性能测试(性能优化/性能敏感场景:IR化/ic/hClass/对象布局/isa/builtins等修改必须执行)
aot-js_perf 性能测试(性能优化/性能敏感场景:IR化/ic/hClass/对象布局/isa/builtins等修改必须执行)
interpreter-workload性能测试(性能优化/性能敏感场景:IR化/ic/hClass/对象布局/isa/builtins等修改必须执行)
aot-workload性能测试(性能优化/性能敏感场景:IR化/compiler/aot/isa/stub/ic/对象布局等修改必须执行)
非StableArray不能采用ElementKind读取元素(修改解释器相关IR代码需要自检)
在IR时添加fastpath时,需要检查是否有分支会改变非字典序模式或者修改数组长度,此时应该走slowpath(修改解释器相关IR代码需要自检)
IR化后的逻辑需要与与c++实现一致,不一致的地方需要有分支用例看护(修改解释器相关IR代码需要自检)
c++代码中检测或抛出异常的地方,IR需要同样实现(修改解释器相关IR代码需要自检)
IR中使用默认入参是HeapObject对象的接口时,需要在上下文中保证了参数的正确性(修改解释器相关IR代码需要自检)
修改c解释器,需要同时检查汇编解释器与AOT是否需要修改
是否已执行L0用例