[wasm][R2R] Interface calls go through CORINFO_HELP_VIRTUAL_FUNC_PTR instead of a dispatch cell

オープン
#137,107 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
44/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp, wasm

調査の方向性

Start in CorInfoImpl.ReadyToRun.cs at the Target.IsWasm && targetMethod.OwningType.IsInterface branch described in the issue, then compare it with the CORINFO_VIRTUALCALL_STUB path used on other targets and the external-method thunk work in #133146. Work is complete when wasm R2R interface calls use a dispatch cell instead of CORINFO_HELP_VIRTUAL_FUNC_PTR; verify the generated code no longer has those helper calls in the stated IndexOfAny case.

索引モデルが issue の本文から書いたものです。

説明

arch-wasm area-ReadyToRun tenet-performance
Description

On browser-wasm, crossgen2 compiles every interface call as CORINFO_VIRTUALCALL_LDVIRTFTN. That is the Target.IsWasm && targetMethod.OwningType.IsInterface branch in CorInfoImpl.ReadyToRun.cs (around line 2490). Each interface call becomes a CORINFO_HELP_VIRTUAL_FUNC_PTR helper call followed by a call_indirect. In shared generic code the helper first needs two generic lookups, one for the class handle and one for the method handle.

Other targets use CORINFO_VIRTUALCALL_STUB, which calls through a single looked-up dispatch cell. Class-virtual calls on wasm moved to external-method thunks in #133146; interface calls didn't.

Configuration
  • Current main, checked clrjit_universal_wasm_arm64 with crossgen2 --targetos:browser --targetarch:wasm -O.
  • Comparison: checked osx-arm64 JIT with crossgen2 --targetos:osx --targetarch:arm64 -O.
Regression?

No. This is the current wasm R2R design.

Data

Static codegen only, System.SpanHelpers:IndexOfAny[System.__Canon](byref,System.__Canon,System.__Canon,int) in System.Private.CoreLib, where value0.Equals(lookUp) is a constrained call through IEquatable<T>:

VIRTUAL_FUNC_PTR calls
browser-wasm R2R 28
osx-arm64 R2R 0

On osx-arm64 the call loads its target from one looked-up cell (ldr x2, [x11]; blr x2).

Analysis

Split out of #136723 (generic lookups not hoisted), which mentions this as a likely larger cost on wasm. Relates to the wasm CoreCLR performance tracking issue #124218.

[!NOTE]
This issue was generated with GitHub Copilot.

主要言語
C#
スター
18.4k
フォーク
5.8k
平均マージ
2日 19時間
マージ済み PR(30日)
590

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/runtime のほかの issue

dotnet/runtime の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。