This CL adds an assert to check we're not writing beyond the allocated
stack space. This assert triggers at compile-time, rather than at
runtime, and it catches cases which would sometimes go correct at
runtime because the stack is also 16-byte aligned.
This only occurred on MacOS/iOS Arm64 because structs are word-aligned
on the stack in the other ABIs.
The fix in this CL is to always add 4 bytes extra in this ABI.
The alternative fix would be to stop copying word-size chunks and use
smaller moves. However, this would require a major re-engineering of
the marshaller because it breaks structs up in word-size definitions
currently.
TEST=tests/ffi/function_structs_by_value_generated_test.dart
(would trigger the assert without the fix on MacOS arm64)
Fixed: https://github.com/dart-lang/sdk/issues/48806
Change-Id: Ia590be76919a192fed144520ee28b1abaf3aa485
Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,dart-sdk-mac-arm64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241607
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Adds an experimental `@trustTypes` annotation which can be used during
migration to static interop to preserve the older semantics for JS interop.
Change-Id: Ic00a6c968b15f8c8f5d0840b82db5a6670eaf0eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241362
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
test.py's output is truncated to a certain length to avoid
tests flooding the terminal.
However, the way it's implemented it likely cuts off a line
of output at an arbitrary point, and then prints its own
message to let the user know the truncation happened.
This ultimately means that said message will often be hard to
spot as it flows together with the output.
This change makes sure there is always a newline at the end
of the output, ensuring the message will be on its own line.
TEST=Manual testing locally.
Change-Id: I91146ce7ce3d4fb0a35465a77aaf783df2acf4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241742
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
Hoisting function literals isn't necessary because evaluating a
function literal doesn't have any side effects.
This paves the way for adding support for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.), which will require deferring type analysis of function
literals. By not hoisting them, we will be able to avoid a lot of
unnecessary complexity in the logic to defer them.
Change-Id: I0a49aa9f769f0506569e6029a3697898308600c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241007
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Forked process should use _exit() rather than exit()
when exiting without exec-ing otherwise it risks
to hit an issue (e.g. deadlock) in an atexit handler.
Additionally `man fork` states:
> After a fork() in a multithreaded program, the child can
> safely call only async-signal-safe functions (see
> signal-safety(7)) until such time as it calls execve(2).
_exit is on the list of async-signal-safe functions, but
exit is not.
Fixes b/216834909
TEST=runtime/tests/vm/dart{,_2}/regress_b_216834909_test.dart
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-android-release-arm64c-try,vm-kernel-mac-release-x64-try
Change-Id: Ia67f23825fc0ee1c1918faf2d4ef3b81033263eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241608
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Currently, running `test.py --build` will attempt to build
the necessary files, before running the tests specified.
However, the tests are run even if this build fails, which
usually means old build artefacts are used for running the tests.
This can lead to some very confusing results if you do not yourself
catch that the build failed half-way through the run.
This change makes `test.py` exit with an error code and a message,
and does not proceed with the tests, if the build fails.
TEST=Manual testing locally.
Change-Id: I4e0f1d3f8d695219f2e4c0d7b474542af136aca9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241740
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
This updates the analysis helpers to add a test for the `map().toList()`
problem addressed in https://dart-review.googlesource.com/c/sdk/+/241605
Included in the CL is the addition of the 'analyze.dart' tools, which
can be used for advanced code searches. This was used to find the
occurences of `map().toList()`.
Change-Id: I6e9da282e37fde4534ed5e308260f092779d0750
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241744
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Expressions like
List<VariableDeclaration> variables = ...
List<Expression> reads = variables.map((v) => VariableGet(v)).toList()
don't get the intended type argument `<Expression>` through inference,
but instead the type inferred from the return type of the closure, in
this case `<VariableGet>`.
This causes problems when used with the AST which assumes that
expressions are interchangeable wherever they are used, and is likely
the cause of https://github.com/flutter/flutter/issues/102077 .
This CL adds an explicit type argument in these cases.
TEST=general/infer_map
Change-Id: I0bcae21f06c54f290dc20686b0d84c065d8ea04c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241605
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
`entities.dart` is now a migrated library.
The definitions formerly moved to `entities_migrated.dart` have been
moved back.
There are a few methods of ParameterStructure that can't yet be
migrated.
The unmigrated methods of ParameterStructure have been moved to static
methods of ParameterStructureMethods and static extension methods in
`entities_parameter_structure_methods.dart`.
These methods will eventually be moved back into ParameterStructure.
The long file name is chosen to sort next to `entities.dart`.
Change-Id: Ie9e798315287b196db694fe66c323a92bc1a1f1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241701
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This ensures that the helpers are seen as being part of the main unit
for deferred-load compiles.
Prior to this change, debug dart2js would assert:
$ sdk/bin/dart2js_developer --test-mode --packages=.packages benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart --out=om1c/o.js
org-dartlang-sdk:///lib/_internal/js_runtime/lib/late_helper.dart@343+1:
Internal Error: The compiler crashed when compiling this element.
The compiler is broken.
When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.
The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.
Please include the following information:
* the name and version of your operating system,
* the Dart SDK build number (build number could not be determined), and
* the entire message you see here (including the full stack trace
below as well as the source location above).
The compiler crashed: 'package:compiler/src/deferred_load/output_unit.dart': Failed assertion: line 272 pos 12: 'unit != null': No output unit for member j:method(throwLateFieldNI)
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2 OutputUnitData.outputUnitForMember (package:compiler/src/deferred_load/output_unit.dart:272:12)
#3 OutputUnitData.hasOnlyNonDeferredImportPaths (package:compiler/src/deferred_load/output_unit.dart:306:33)
#4 KernelSsaGraphBuilder._tryInlineMethod.heuristicSayGoodToGo (package:compiler/src/ssa/builder_kernel.dart:5922:12)
Change-Id: Ic31c4894105a9a22eb0821a489c8dd2a4e3d0110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241686
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Previously, the analyzer didn't actually fix the type parameters; it
simply stopped accumulating type constraints for them, and then
re-inferred them in later rounds of inference. In theory this doesn't
actually fix the type parameters, since a type parameter can have an
"extends" constraint that causes it to depend on other type
parameters; if those type parameters change in later rounds of
inference, then the re-inferred type parameter might actually wind up
changing. In practice I haven't been able to construct a
(non-erroneous) case where this actually occurs, but to make the code
easier to reason about, I think it's better to actually fix the type
parameters when we say we do.
This change makes the analyzer's type inference logic more similar to
the front end's type inference logic.
Change-Id: Ia1f86a27eaca98520903a2aba9d0359afd59e36f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241680
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Helps readability and ease of debugging for dump info.
Note: IDs only shadow each other for Class and ClassType info objects,
but these are already disambiguated with a serializedId that prepends
the info type to the ID.
Change-Id: Ie9862d474436cba85a972f567f606c1e3190b929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240917
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Even if the main program disables executable stacks, dlopen'ing a library that doesn't itself disable executable stack will switch the stack to executable. (Presumably in the name of compatability with GNU nested functions.)
Dart does not need executable stacks, and executable stacks are an additional attack surface.
TEST=readelf
Bug: b/229648756
Change-Id: Ia8c234ebc6178a26528d37b1359a10dd42039a9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241540
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
The "Proposed Edits" panel displays the number of edits, but only when
this number not immediately displayed below and would need to be
calculated.
Change-Id: I89793305876d5488c9d14b03a91470ae3f4fe4f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241340
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Previously, the front end would perform downwards and upwards
inference using separate TypeConstraintGatherer objects. This meant
that any constraint gathering work performed during downwards
inference had to be repeated during upwards inference.
This change avoids the extra work by using a single
TypeConstraintGatherer object for both downwards and upwards
inference.
This should help pave the way to implementing support for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.)
Change-Id: Ib4031ab1397d6a8547a705f386632de0e4dd1a2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Since tests of our internal tools often deliberately contain edge cases
and unusual code constructs, scrape supports ignoring Dart files in
those directories in order to focus on more representative code.
This updates that ignore list to handle all of the various
compiler-related packages I could find.
Change-Id: I4006d2b3b14a81572f27db0b65e6c6194c4f7f54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241506
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
The rich hierarchy of operators is no longer relevant since parsing
was moved to the common front-end.
All that remains is a Set of operator names that can be used to
declare instance methods.
This set is used for picking the 'operator' variety of Selector. I'm not
sure we even need operator selectors, but I am leaving that for future
consideration.
Change-Id: I7337c0cf82a3cb8f7ebf5fa17a737bac3a83f48b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241560
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Only the 'fileUri' property was used, so we pass it directly instead.
Change-Id: I7b47f18f7ebc2c50036c5202e469caad4ba35897
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241009
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Remove LibraryBuilder.addBuilder to let the implementations in
SourceLibraryBuilder and DillLibraryBuilder to change independently.
Offset argument removed from DillLibraryBuilder.addMember and
'addX' members are in DillLibraryBuilder are made private.
Change-Id: If239ae441655d3d7f7484fd5e809cc015effd78c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241005
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>