Comments (3)
Labels: area-web
, type-bug
Summary: The toJS
method on string literals is not being constant folded in dart2js, resulting in unnecessary JavaScript code generation. This leads to larger and less efficient code compared to manually inlining the string literal.
from sdk.
Constant-folding of final top-level/static variables is mostly done by CFE.
final foo = 123;
is handled somewhat like const foo = 123;
because dart2js can see the RHS is a constant in the Kernel IR.
Unfortunately, dart2js does not compile using a full callgraph-bottom-up schedule, so the non-const initializer expression that reduces to a constant it not seen by the users of the variable.
We could do something more limited if this is a popular code pattern./
from sdk.
We could do something more limited if this is a popular code pattern./
The reason I used that pattern in a benchmark is because on dart2wasm this is not a NOP and we'd do the key conversion every single time we do a map lookup. So it makes sense to hoist it there to top-level which then regresses dart2js.
If we recognize this specially in dart2wasm compiler (see #56046) then using the pattern inline in code (rather than top-levels) would not be needed.
Though any 3rd party user may also think it's more efficient to cache in a top level instead of executing every time - and it would be worse performance. So I think maybe it's a good idea to do this optimization regardless.
from sdk.
Related Issues (20)
- `@doNotSubmit` isn't valid on member-fields HOT 5
- dart2wasm CRASH with demo app HOT 2
- Regex with unicode and curly braces does not match correctly HOT 2
- Send Pointer through SendPort without an error, which is different from the doc. HOT 3
- proposal: `unnecessary_pattern_assignment` HOT 8
- [CP] [dart2wasm] Generate source maps HOT 4
- Analyzer Feedback from IntelliJ HOT 1
- Have "go to definition" jump to a class when used on a `ConstructorExpression` where the default constructor is missing HOT 2
- [analyzer] Switch cases for destructured records do not promote types HOT 1
- [Wildcard Variables] Verify that constant evaluation works as expected
- [Wildcard Variables] Resolution of wildcard import directives
- Analyzer Feedback from IntelliJ HOT 1
- Analyzer is very slow for large files HOT 1
- Enum hashCode is different when hot reloading HOT 1
- Dart lacks a way to create an error chain HOT 2
- [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 1900 HOT 1
- Inconsistent string interpolation in dart runtime with RTL languages HOT 1
- bug: Dart does not narrow the type properly across more than one level of inheritance in a collection type HOT 4
- `dart test --coverage`: getSourceReport: (-32000) Service connection disposed HOT 1
- Import name conflicts: Suggest adding "hide" on one of the conflicting imports HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.