Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wasm: Optimize varargs by removing JSArrayConstr #5172

Open
Labels
wasmApplies to the WebAssembly backend only
@tanishiking

Description

@tanishiking

Currently in Scala.js, varargs call is translated to the IRjs.WrappedArray(JSArrayConstr(...)). That requires JS interop for constructing the arguments and accessing its elements. Since Wasm-JS calls are expensive, this is undesirable for performance.

I revisit#5148 that translate varargs to something likenew WrappedArray$ofInt(ArrayValue(1, 2, 3)) (ornew ArraySeq$ofInt(...) on 2.13)

And take a micro benchmark usingtanishiking/scalajs-benchmarks@37c7bd8 (call varargs methods with 0/1/5 arguments, 10000 times). (fastLinkJS, 2.13)

Image

https://colab.research.google.com/drive/17dJmqx9Wv1uhoPx23O1vHTydd_2f7TrA?usp=sharing

The result showsscala.Array-based varargs implementation is more than twice faster on WebAssembly.
(but it is much slower than js.Array on JS, maybe there's better optimization for Wasm than ArraySeq?)


Of course the runtime performance deteriorates in JS withscala.Array-based varargs.

We want to somehow virtualize the varargs IR, and translate to the appropriate IR at the optimizer (or backend).

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmApplies to the WebAssembly backend only

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp