vandadnp / going-deep-with-dart Goto Github PK
View Code? Open in Web Editor NEWDart Optimization Tips and Tricks
Dart Optimization Tips and Tricks
Hi, dear Vandad!
I have some questions about the dart compilers that I thought this repository would be a great place to speak about it and document for others.
--define=<key>=<value>
option. Now my question is the below code snnipts.// JIT compiler
// $ dart --define=name=ehsan main.dart
var definition = String.fromEnvironment('name');
print(definition); // ehsan
but in AOT compilation value isn't accessible, if the variable type qualifier be var
and should be const
// AOT compiler
// $ dart compile exe --define=name=ehsan -o main main.dart; ./main
var definition = String.fromEnvironment('name'); // also `bool.hasEnvironment('name')` returns false
print(definition); // '' empty String, false boolean, 0 int
Actully my question is what happen in generated code that makes this difference in AOT and JIT compilation?
// the is<platform> static variables also use this getter
switch (Platform.operatingSystem) {
case 'linux':
// do something linux
break;
case 'macos':
// do something in mac
break;
// and so on...
}
The section for
loops over variable iterables misinterprets the meaning of call qword [rax+rcx*8+0x60]
, this is how interface calls work in the code produced by Dart AOT compiler. We use an approach called "global dispatch table". In the sequence above rax
would be a pointer to the dispatch table, rcx
would be class id of the receiver object and 0x60
is a selector id (which determines which virtual method we are looking up).
Based on the call sequence I'd say this is an invocation of get current
on the iterator object which is implicitly created by the for-in loops.
https://github.com/vandadnp/going-deep-with-dart/blob/main/issue-3-for-loop-in-dart/issue-3-for-loop-in-dart.md#non-entry-for-loops-with-const-startend-values
it says it's declared with const constructors but none are present in the snippet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.