dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.57k forks source link

[dart2wasm] Extremely large const data collections emit functions that exceed maximum function size in wasm #56483

Open eyebrowsoffire opened 2 months ago

eyebrowsoffire commented 2 months ago

The tests in devtools have a few extremely large JSON maps that are built into the application. See https://github.com/flutter/devtools/blob/8aaa762e94c88b760516d70b6b16eddb79f3e5bb/packages/devtools_test/lib/src/test_data/_performance_data.dart#L9C18-L9C18 as well as https://github.com/flutter/devtools/blob/master/packages/devtools_test/lib/src/test_data/_performance_data_large.dart

When trying to instantiate the output wasm module, Chrome complains:

Uncaught (in promise) CompileError: WebAssembly.compileStreaming(): size 21871295 > maximum function size 7654321 @+7252987

We are going to restructure the tests to not create this pathological code path. However, we probably should have some better handling of this in the compiler. Either emit a hard failure and say that the data structure is too large, or maybe break it up into multiple initialization functions along with a warning that this is a problematic code path.

dart-github-bot commented 2 months ago

Summary: Dart2wasm fails to compile large const data collections due to exceeding the WebAssembly maximum function size limit. This issue arises when compiling large JSON maps, causing Chrome to throw a "CompileError" during instantiation.