These tests look for local variables by names in LocalScope.
However, in bytecode we keep information about local variables only
for debugging and LocalScope objects are not created.
This change adds implementation of local variables lookup using bytecode
debugging information. In PRODUCT mode (which doesn't have debugging
information) these tests are disabled.
Change-Id: Ia5eafb440fa19bc1007582a360c36a87aa637e6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113271
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This reverts commit beee442625.
Reason for revert: StackOverflow on language_2/deep_nesting_expression_test/01 in interpreted mode.
Original change's description:
> [vm/bytecode] Switch kernel service dill to bytecode if building Dart SDK with --bytecode
>
> Temporary setting of FLAG_enable_interpreter is avoided in the VM unit tests as
> this flag is global and used by kernel service isolate while running tests.
> Flipping this flag causes assertion failures in kernel isolate's background compiler
> or infinite loop between LazyCompile stub and CompileFunction as AttachBytecode
> doesn't set entry point to InterpretCall.
>
> The less intrusive way to ensure compilation of functions in unit tests is to set
> FLAG_compilation_counter_threshold to 0.
>
> Change-Id: Ia46ff8d03d66ab8b147b9d89336548c4a9c29f5d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113123
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>
TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com
Change-Id: I67cd03a56f9a2d29aa6597d38779e77ca3a16b18
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113480
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Temporary setting of FLAG_enable_interpreter is avoided in the VM unit tests as
this flag is global and used by kernel service isolate while running tests.
Flipping this flag causes assertion failures in kernel isolate's background compiler
or infinite loop between LazyCompile stub and CompileFunction as AttachBytecode
doesn't set entry point to InterpretCall.
The less intrusive way to ensure compilation of functions in unit tests is to set
FLAG_compilation_counter_threshold to 0.
Change-Id: Ia46ff8d03d66ab8b147b9d89336548c4a9c29f5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113123
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Add support for the `late` modifier on fields and local variables in
CFE, and `required` on named parameters When using the option
--enable-experiment=non-nullable the `isLate` and `isRequired` flags will be set
accordingly on Field and VariableDeclaration nodes.
Closes#37686Closes#37684
Change-Id: If37fc93defdabc5cc974f3f068f57752a665f4cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113036
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reading all bytecode results in significantly higher memory usage due to
more classes finalized and more Function, Field, OneByteString, ObjectPool
and Bytecode objects.
dart2js-compile/CompileHelloMemoryUse benchmark with bytecode:
heap.old.capacity.max 121.387 -> 112.016 MB
Change-Id: Ic702a1c61613e1fc0c2d1f0b3a972da238bab838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113140
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
The FlowGraph on which to run is available at each method call site, so
we don't need to store it.
This also avoids issues in the future if we ever rebuild the FlowGraph
entirely during compilation, since we won't be using a BlockScheduler
object that caches an older version of the FlowGraph.
Change-Id: I5653e1230131fbada3fe01cfa6c1ac37846fccb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113024
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
This is needed in order to account for redefinitions with less precise
type, such as AssertAssignable of Smi to a generic T.
x64, bytecode compiler:
CryptoDecrypt(RunTime): 8516.8 -> 8190.6 us
Change-Id: I8c5b8eb3efcc7ae1ccf204f5081772081be29c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112755
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Rationale:
Inlining constant constructors/mixin is practically always
profitable. So the heuristics have been changed to at least
consider these even at higher depth (note that they are of
course still subject to actual heuristics while inlining).
This brings back flutter gallery size to where it was
before mixins were introduced.
head:
VMIsolate(CodeSize): 4737
Isolate(CodeSize): 2005123 101%
ReadOnlyData(CodeSize): 2212408 103%
Instructions(CodeSize): 7006928 100%
Total(CodeSize): 11229196 101%
improved heuristic:
VMIsolate(CodeSize): 4737
Isolate(CodeSize): 1985691
ReadOnlyData(CodeSize): 2152880
Instructions(CodeSize): 6987616
Total(CodeSize): 11130924
https://github.com/dart-lang/sdk/issues/37126
Change-Id: I28de0fa6c92a785bbc47e9fa09ed55ae68593c0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112758
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Rationale:
The range analysis carefully computes ranges on Smis such
that the results are valid for both JIT and AOT. So the
IsRedundant() tests between the speculative and non-speculative
bounds checks can be shared. This does not only reduce the
amount of code, but also improves actual bounds check elimination.
https://github.com/dart-lang/sdk/issues/37687
Change-Id: I883a16d4be4d3704cad3e42264e1f36a5afc3b89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112167
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
PushStatic instruction expects field object to be pushed onto the stack.
This is useless, as PushStatic also references field with its D operand.
This change replaces PushStatic instruction with LoadStatic which doesn't
take field object on the stack, so PushConstant/PushStatic pair is replaced
with a single LoadStatic instruction.
This change also enables constant propagation of values of injected CID
fields, which are not known at bytecode generation time.
Change-Id: Ifbdd3aea2aab338f6c9ec3e5728948c4d8541a4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112489
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Code::ResetSwitchableCalls iterates all ICData objects and tries to find
corresponding PCs. Before this change, functions compiled from bytecode
had all ICData objects from constant pool in their ic_data_array().
This is a problem because constant pool is shared among closures, so it
could contain ICData objects for dynamic calls in other functions (closures),
so ResetSwitchableCalls won't be able to find their PCs.
The fix is to add ICData objects to ic_data_array only when generating
DynamicCall.
This change fixes the crash with the following call stack:
dart::MatchesPattern(unsigned long, short const*, long)
dart::CodePatcher::GetInstanceCallAt(unsigned long, dart::Code const&, dart::Object*)
dart::Code::ResetSwitchableCalls(dart::Zone*) const
...
Change-Id: Ia578520513d928c4aa9156825a369934e4bb95b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112482
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Refactor Kernel::CollectTokenPositionsFor, but do not try to factorize code for
fields and functions, as too many handles would need to be passed around.
Bytecode reading creates duplicate script objects requiring scripts to be
matched by their url rather than by their raw address when collecting token
positions in bytecode. However, url comparison is not yet used, because
collecting token positions in the duplicated script 'dart:core/map.dart'
(in default mode) causes crashes in kernel reading. Will revisit.
Fix service test valid_source locations_test.dart and make sure fields
are properly reloaded, except fields injected by fasta.
Remove unused argument 'record' of KernelReaderHelper::ReadPosition().
Handle bytecode stub frame in IsAsyncMachinery() tester in debugger.
Change-Id: Ifbddcaec00e0696f7de13c5cf1e74380b31d2419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112402
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This is needed for function subtype checks and mimics the behavior of
kernel AST reader (TypeTranslator::LoadAndSetupTypeParameters).
Fixes the following tests in bytecode mode:
co19_2/Language/Generics/typedef_A04_t06
co19_2/Language/Generics/typedef_A04_t07
Change-Id: I70fc86e811e77b2adc31d7bfce9ba55c5838666f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112144
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
* Adds non-static final field printing for `Instance`s
* Adds specialized printing for `Closure`s (tearoffs).
* Instances of `Mint` and `Type` can also appear in constant
pools, so handle both in ObjectToSExp.
* DartValueToSExp is a wrapper method for ObjectToSExp that
also checks to see if the value is defined in the constant
pool. If it is, the object is serialized as a reference to
that definition.
* Reworks the `tmp_*_` fields used for non-reentrant cases
to be per function to make it easier to understand how they
interact. (Only cross-function tmp field that remains is
`tmp_string_`, since its contents are always immediately
converted to a C string and then no longer needed.)
Bug: https://github.com/dart-lang/sdk/issues/36882
Change-Id: Ibad4bc2497dd1f580d1daa536c4a267818981c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111425
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This way, users of S-expression deserialization will not also pull in
the rest of the upcoming IL deserialization functionality (and
anything extra needed by that).
Also changes SExpParser::ReportError to just print the error
information to stderr and abort, instead of using the Dart VM
exception machinery.
Change-Id: Id01b2a6fdca1a6204d502f398df139c2faa12d07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111644
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
* Add a new `SExpDouble` atom and change `SExpNumber` to `SExpInteger`.
* Allow for negative integers in deserialization.
* Add support for `LocalVariable`s and related instructions.
* Function objects are now represented by actual S-expressions generated
with the new `FunctionToSExp` method. Previously, they were only represented
by a symbol containing their canonical name.
* The top-level tag for a serialized flow graph is now `FlowGraph`, not
`function`. This avoids confusion between serialized flow graphs and
serialized function references. Similarly, the old `FunctionToSExp`
method is now called `FlowGraphToSExp`.
* Made all SExpression* returning functions that take Object (or subclass)
instances return nullptr if the passed in instance is the null object,
except for ObjectToSExp, which returns the symbol `null`.
* Factored out creating tags for the different kind of block/function
entry and also created an `Entries` section to the top-level `FlowGraph`
form that contains function entry points similar to the `Constants` one
instead of inlining entries as separate elements in the `FlowGraph` form.
* Additional extra information in verbose mode for some elements.
Bug: https://github.com/dart-lang/sdk/issues/36882
Change-Id: Iede3865ec64f81955a87fd57b10e74d49ee8414c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110917
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>