[mono] Optimize "constant_string".Length

Open
#108,857 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

No source file, test, or entry point is named. Start by reading the related mono#5310 discussion and tracing the runtime's constant_string.Length optimization path; done means the example folds to 5 and the generated assembly no longer loads the string length from memory.

Written by the indexing model from the issue text.

Description

area-Codegen-JIT-mono
static int Test() => "Hello".Length; // replace with just `5`

Before:

movabs rax,0x7fd6c1758160
mov    eax,DWORD PTR [rax]
ret 

Now:

mov    eax,0x5
ret

Originally posted by @EgorBo in mono#5310

Related:

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.