Skip to content

[mono] Intrinsify API's in SpanHelpers.ByteMemOps.cs #99161

Closed
@fanyang-mono

Description

@fanyang-mono

Two new API's were added and intrinsified by CoreCLR. They are used in the library which caused Performance regression in Mono. See dotnet/perf-autofiling-issues#29872. These new API's were added via #98623

The API's to intrinsify are

  • SpanHelpers.Memmove -> Update existing intrinsics support for Buffer.Memmove. See the code below
    if (in_corlib && !strcmp (m_class_get_name (cmethod->klass), "Buffer")) {
    if (!strcmp (cmethod->name, "Memmove") && fsig->param_count == 3 && m_type_is_byref (fsig->params [0]) && m_type_is_byref (fsig->params [1]) && !cmethod->is_inflated) {
    MonoBasicBlock *end_bb;
    NEW_BBLOCK (cfg, end_bb);
    // do nothing if len == 0 (even if src or dst are nulls)
    MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, args [2]->dreg, 0);
    MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBEQ, end_bb);
    // throw NRE if src or dst are nulls
    MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, args [0]->dreg, 0);
    MONO_EMIT_NEW_COND_EXC (cfg, EQ, "NullReferenceException");
    MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, args [1]->dreg, 0);
    MONO_EMIT_NEW_COND_EXC (cfg, EQ, "NullReferenceException");
    MONO_INST_NEW (cfg, ins, OP_MEMMOVE);
    ins->sreg1 = args [0]->dreg; // i1* dst
    ins->sreg2 = args [1]->dreg; // i1* src
    ins->sreg3 = args [2]->dreg; // i32/i64 len
    MONO_ADD_INS (cfg->cbb, ins);
    MONO_START_BB (cfg, end_bb);
    }
    }
  • SpanHelpers.ClearWithoutReferences
  • SpanHelpers.Fill

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions