Skip to content

dst in memassign_safe should move to next position after memmove_refs((void**)dst, (void**)src, nptr) #47228

@awfeequdng

Description

@awfeequdng
static inline void memassign_safe(int hasptr, jl_value_t *parent, char *dst, const jl_value_t *src, size_t nb) JL_NOTSAFEPOINT
{
    if (hasptr) {
        // assert that although dst might have some undefined bits, the src heap box should be okay with that
        assert(LLT_ALIGN(nb, sizeof(void*)) == LLT_ALIGN(jl_datatype_size(jl_typeof(src)), sizeof(void*)));
        size_t nptr = nb / sizeof(void*);
        memmove_refs((void**)dst, (void**)src, nptr);
        jl_gc_multi_wb(parent, src);
        src = (jl_value_t*)((char*)src + nptr * sizeof(void*));
        nb -= nptr * sizeof(void*);
    }
    else {
        // src must be a heap box.
        assert(nb == jl_datatype_size(jl_typeof(src)));
        if (nb >= 16) {
            memcpy(dst, jl_assume_aligned(src, 16), nb);
            return;
        }
    }
    memcpy(dst, jl_assume_aligned(src, sizeof(void*)), nb);
}

in memassign_safe, dst must move to the next position after memmove_refs((void**)dst, (void**)src, nptr),only src is doing that:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions