Commit Graph

117 Commits

Author SHA1 Message Date
Mike Fairhurst bffe47e678 First stab at #29153 range check in as-casts. Mostly working.
Having an issue forwarding Symbol::InTypeCheck into dart and back;
without it, the exceptions that are thrown are `TypeError`s and not
`CastError`s.

Certainly a bit longform to read, as well.

Committing for feedback/suggestions/help

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2805903004 .
2017-04-13 10:44:57 -07:00
John McCutchan a0ee5b24db Track async causal stack traces
This CL improves the stack traces that accompany exceptions. Whenever an
async function is entered, we remember how we got there. This is similar
in spirit to package:stack_trace but the implementation is more efficient
and memory usage can be more easily reasoned about.

Tracking causal stack traces:

- [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Before returning from an async function, clear the Thread's asynchronous stack trace.
- [x] After resuming an async function, load the sychronous stack trace prefix into the Thread.
- [x] Filter stack traces to remove async machinery.

Service protocol changes:

- [x] Send causal async stack trace.

Observatory changes:

- [x] Display causal async stack trace below async functions.

Fixes https://github.com/dart-lang/sdk/issues/27661

R=asiva@google.com, rmacnak@google.com

Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2646443005 .
2017-02-09 15:39:44 -08:00
Matthias Hausner 90b937a4ce Support covariant keyword in the VM parser
For Dart 1.5, the VM ignores the annotation. It is just consumed by the parser, but has otherwise no effect. Errors are reported on illegal covariant declarations.

BUG=#28166
R=regis@google.com

Review-Url: https://codereview.chromium.org/2625823004 .
2017-01-12 14:03:26 -08:00
Kevin Millikin 50348f5f22 Fixes to patch files necessary to use the analyzer
The analyzer has a stricter patch parser than the VM.  Patch files
cannot change signatures of patched members.  Specifically, they cannot
change:

  - the return type
  - a parameter's name
  - a parameter to an initializing formal
  - an optional parameter's default value

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2612043002 .
2017-01-05 12:23:51 +01:00
Lasse R.H. Nielsen 44594277e1 Make core libraries use generic method syntax.
Removes comment syntax where possible for the following platform libraries:
* async
* collection
* convert
* core
* internal
* io
* math

The HTML related libraries are not changed. The templates used to build them
must be changed as well.

R=floitsch@google.com

Committed: https://github.com/dart-lang/sdk/commit/68818315b5cc6c63fea0e10e90f515f6083ec095
Committed: https://github.com/dart-lang/sdk/commit/3f74b8d82edca8c342c43306714e68ddf84548e1
Review-Url: https://codereview.chromium.org/2529393002 .
2017-01-03 12:05:40 +01:00
Kevin Millikin d9f80a9ac1 Turn the VM's dart:typed_data into a patch
Before, the VM's dart:typed_data was a complete replacement of the SDK's
dart:typed_data implementation instead of a patch.  This is unlike all
the other SDK libraries.  This difference requires special-casing for
dart:typed_data in tools that handle the SDK libraries (e.g., the
Analyzer's patching support, the GN build).

This change makes dart:typed_data back into a patch to the SDK's
implementation.  It reintroduces a distinction between abstract
interface and concrete implementation classes, so there are more
classes.

BUG=
R=fschneider@google.com, vegorov@google.com

Committed: https://github.com/dart-lang/sdk/commit/a9b906d319c32525a0600c75c008c92753591d86
Review-Url: https://codereview.chromium.org/2571563005 .
2016-12-22 10:57:21 +01:00
Kevin Millikin f97440848f Revert "Turn the VM's dart:typed_data into a patch"
This reverts commit a9b906d319.

A lot of things were broken by the changes to implementation class
names.

BUG=

Review-Url: https://codereview.chromium.org/2598603002 .
2016-12-21 12:28:33 +01:00
Kevin Millikin a9b906d319 Turn the VM's dart:typed_data into a patch
Before, the VM's dart:typed_data was a complete replacement of the SDK's
dart:typed_data implementation instead of a patch.  This is unlike all
the other SDK libraries.  This difference requires special-casing for
dart:typed_data in tools that handle the SDK libraries (e.g., the
Analyzer's patching support, the GN build).

This change makes dart:typed_data back into a patch to the SDK's
implementation.  It reintroduces a distinction between abstract
interface and concrete implementation classes, so there are more
classes.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2571563005 .
2016-12-21 08:34:52 +01:00
Ryan Macnak 4607e38d28 Reapply "Save and restore feedback from JIT."
Ensure ICData is attached to the callee flow graph in the inliner when built from kernel IR, not just from source.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2572423004 .
2016-12-16 16:00:17 -08:00
Ryan Macnak 176d732cc3 Revert "Save and restore feedback from JIT."
This reverts commit 31ee20297e.

Review-Url: https://codereview.chromium.org/2579413002 .
2016-12-16 13:53:20 -08:00
Ryan Macnak 31ee20297e Save and restore feedback from JIT.
- Adjust fingerprints to be independent of the library's private key, which varies with load order.
 - Use usage_counter in AOT inlining decisions if JIT feedback is available.
 - Reduce inlining in cold functions.

dart2js product aot snapshot 15841351 -> 14436273 (-8.86%)

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2562693003 .
2016-12-16 10:21:40 -08:00
John McCutchan 985d03db2a Revert "Fix flutter build"
This reverts commit f45d5ad70e.

BUG=

Review URL: https://codereview.chromium.org/2508273003 .
2016-11-17 15:20:12 -08:00
John McCutchan f45d5ad70e Fix flutter build
BUG=

Review URL: https://codereview.chromium.org/2511653003 .
2016-11-17 15:15:24 -08:00
Vyacheslav Egorov f82cd6bb5d VM: Fix RegExp_ExecuteMatchSticky fingerprint.
TBR=rmacnak@google.com

Review URL: https://codereview.chromium.org/2508133003 .
2016-11-17 19:03:40 +01:00
Vyacheslav Egorov 2403444eba VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization.
This is the same as a sticky RegExp flag in ES2015.

Overlay some RegExp fields on top of each other - given that they should never be used simultaneously.

BUG=http://dartbug.com/27810
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2510783002 .
2016-11-17 17:46:21 +01:00
Vyacheslav Egorov 23fd1a184b VM: Support bootstrapping core libraries from Kernel binaries instead of source.
BUG=http://dartbug.com/27590
R=asiva@google.com

Review URL: https://codereview.chromium.org/2485993002 .
2016-11-16 13:56:20 +01:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Vyacheslav Egorov 0635b57d43 Reland "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This relands commit f4ec20abac.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2465793003 .
2016-11-01 16:49:02 +01:00
Vyacheslav Egorov 16e4f2f1c2 Revert "Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."""
This reverts commit e495e100dd.

Commit breaks bots that are using Android devices (SIMARM is unaffected).

R=rmacnak@google.com
BUG=

Review URL: https://codereview.chromium.org/2449013004 .
2016-10-26 16:53:32 +02:00
Vyacheslav Egorov e495e100dd Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern.""
This reverts commit 890f694de5.

Previous commit was passing field_type_map_ down in a place where it was not passed down before.

This caused some handles to be used across zones, which caused crashes.

BUG=

Review URL: https://codereview.chromium.org/2453463006 .
2016-10-26 12:25:48 +02:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Ryan Macnak 890f694de5 Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This reverts commit f4ec20abac.

Revert "Use ZoneHandle when creating ConstantInstr"

This reverts commit cb87f2d82f.

This change introduced crashes on AOT and runtime errors on the GN SDK build.

TBR=vegorov@google.com

Review URL: https://codereview.chromium.org/2451893002 .
2016-10-25 13:19:33 -07:00
Vyacheslav Egorov f4ec20abac Recognize and optimize a.runtimeType == b.runtimeType pattern.
Start by removing all get:runtimeType overrides in the patch files to have a single point computing the runtime type - Object.get:runtimeType. Handle string, double and integer types inside both intrinsic and runtime call to unify their handling and guarantee that code works even with intrinsifier disabled.

With overrides removed we can easily check that get:runtimeType is unique function name within the application that is being precompiled and use that to convert InstanceCall(get:runtimeType, ...) into StaticCall even nothing is known about the receiver.

This enables us to check if both left side and right side of comparison are StaticCall(Object.get:runtimeType, ...) when specializing InstanceCall(==, x, y). If they are we convert InstanceCall(==, StaticCall(get:runtimeType, a), StaticCall(get:runtimeType, b)) into StaticCall(Object._hasSameRuntimeType, a, b). A canonicalization rule will later delete unused get:runtimeType invocations.

Object._hasSameRuntimeType is implemented in C++ and intrinsified. It operates without creating new runtime types (except for Closures - where it does for simplicity). Cases of different class ids (i.e. a.[cid] != b.[cid]) and non-parameterized types are handled completely in the intrinsic. The rest is handled in the runtime code.

Microbenchmarking results:

Same parameterized classes: 15x improvement
Different parameterized classes: 300x improvement
Different/same non-parameterized classes: 2x improvement

BUG=
R=fschneider@google.com, regis@google.com

Review URL: https://codereview.chromium.org/2379733002 .
2016-10-25 10:03:06 +02:00
Zachary Anderson 088347fd9d Reland "Add DoubleTestOp instruction"
Fixes DoubteTestOpInstr::AttributesEqual()

Review URL: https://codereview.chromium.org/2433813002 .
2016-10-18 22:46:36 -07:00
Zachary Anderson f6296cc91b Revert "Add DoubleTestOp instruction"
Review URL: https://codereview.chromium.org/2432903002 .
2016-10-18 21:57:05 -07:00
Zachary Anderson fa855cf1c2 Add DoubleTestOp instruction
This gives a ~5% bump to the Flutter layout benchmark
in checked mode.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2423843002 .
2016-10-18 21:24:12 -07:00
Ryan Macnak 6137d020b9 AOT: Use a cid range check when possible to implement type tests.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2314133003 .
2016-09-08 15:25:08 -07:00
Florian Schneider 5dfa8a863c VM: Fix polymorphic inlining of recognized methods in the JIT.
Also, clean up the inlining white list: [] and []= operators are inlined
specially as recognized methods and don't need to be in the always-inline list.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2297033002 .
2016-08-30 16:25:09 -07:00
Florian Schneider 1a357a4f40 Add flow-graph generated SIMD array intrinsics.
Also fix usage of a command-line flag used in tests.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2249853002 .
2016-08-16 16:17:53 -07:00
Siva Annamalai cb36467568 - Fix for issue 27054 (leak when removing element from _GrowableList)
- _GrowableList.removeLast was not shrinking the backing array

BUG=27054
R=johnmccutchan@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2240313002 .
2016-08-12 16:06:12 -07:00
Florian Schneider f26b130de9 VM: Fix math intrinsic code.
The functions where we have intrinsics were always inlined, so the intrinsic
code was actually not used. Move these functions to the inline black list instead to
ensure the intrinsic code is used instead. Inlining these in the generic inliner would
 not help anyway since they are inlined as recognized methods by the optimizer.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2239903002 .
2016-08-11 15:48:57 -07:00
Florian Schneider eb600a9af6 VM: Add more array intrinsics.
Make building array intrinsics a little easier for future additions.

For now I added a few that are frequently used in Flutter.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2235433002 .
2016-08-09 17:38:53 -07:00
Matthias Hausner e11ca24053 Use metadata annotation @patch for patch classes
Annotate patch classes and top-level patch functions with @patch
instead of the pseudo-keyword patch. This allows the analyzer
to read patch files, and matches the syntax that dart2js uses.

The deprecated syntax is still supported, but a warning is printed when detected.

BUG=

Review URL: https://codereview.chromium.org/2220883004 .
2016-08-09 09:48:03 -07:00
Florian Schneider aec015a580 Inline white-listed intrinsics also in AOT compilation.
We don't inline intrinsics to produce smaller code, but for small methods
(array length getters, etc.) we should do it because the code actually
gets smaller by inlining, plus we get better type/range information.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2147683002 .
2016-07-12 13:59:37 -07:00
Stephen Adams 38fdb4bd4a vm: Generate 'and' instruction for Smi values.
This pattern ensures the generation of 'and' instructions on the Smi x Smi path of a polymorphic & operation.

There are two 'and' operations on most simple _InternalLinkedHashMap and _CompactLinkedHashSet operations. One of the inputs, the hashCode, is occasionally a _Bigint.  This change ensures that the usual case path has an 'and' instruction instead of a call to _IntegerImplementation.&

R=regis@google.com

Review URL: https://codereview.chromium.org/1913663002 .
2016-07-04 16:27:57 -07:00
Regis Crelier 4524d15d52 Fix sed expression to substitute recalculated fingerprints after format change.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2031153002 .
2016-06-03 14:38:16 -07:00
Ryan Macnak 2e9c5f9a91 Reapply "VM: Add result cid information for recognized methods."
- _HashVMBase._index is nullable
 - _HashVMBase._data is a regular Array
 - DBC fixes from Zach.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2033553002 .
2016-06-02 09:59:48 -07:00
Ryan Macnak 907a6b1c3b Revert "VM: Add result cid information for recognized methods."
In Flutter, this caused

  RangeError (index): Index out of range: index should be less than null: 0
  Uint32List.[]= (dart:typed_data)
  _HashVMBase&MapMixin&&_LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart)

This reverts commit 0ae4ae5033.

TBR=fschneider@google.com

Review URL: https://codereview.chromium.org/2023423002 .
2016-06-01 14:08:48 -07:00
Florian Schneider 0ae4ae5033 VM: Add result cid information for recognized methods.
We already had this for recognized factories. This CL adds a result cid
for the remaining recognized methods.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2018363004 .
2016-06-01 09:42:48 +02:00
John McCutchan 84e1fe5cb5 Add an intrinsified early out path for Dart timeline calls
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1985813002 .
2016-05-17 09:45:28 -07:00
Regis Crelier 845a447f9d Faster dispatch of integer operations on double.
R=iposva@google.com

Review URL: https://codereview.chromium.org/1974533002 .
2016-05-12 16:54:15 -07:00
Florian Schneider c1e6aef400 VM: Optimized code for all of [External]{One|Two}ByteString::codeUnitAt.
Added support for external string using flow graph based intrinsics
which helps with precompiled code, but also polymorphic calls in jitted code.
I also added support for the missing cases in the flow graph optimizer.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1961393002 .
2016-05-11 09:29:28 +02:00
Ivan Posva b2ac279269 - Use a map to lookup libraries by URL.
- Ensure the uniqueness of private keys without having to
  search the existing key space.
- Pass a thread parameter where useful to library methods.

BUG=

Review URL: https://codereview.chromium.org/1947393003 .
2016-05-05 10:42:28 -07:00
Florian Schneider 1217e539e9 VM: Remove _leftShiftWithMask32.
It was used for the Javascript integer overflow warnings which were already
removed from the VM.

BUG=
R=regis@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1900863004 .
2016-04-19 19:06:53 +02:00
Vyacheslav Egorov ee0f608ce4 Dart Byte Code interpreter.
This version is Clang/GCC only and does not support Windows because it uses computed goto's.

Only unoptimized mode is supported.

Architecture is described in constants_dbc.h and stack_frame_dbc.h.

R=fschneider@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1858283002 .
2016-04-18 23:02:01 +02:00
John McCutchan 24230689df Intrinsify some double operations, helps in AOT
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1832343003 .
2016-03-28 13:09:40 -07:00
Florian Schneider 6d27476cd1 VM: Fix a couple of issues in the AOT optimizer, add fast path smi multiply.
1. Add fast path smi multiply

2. Recognize more operands as likely smi: If they are the result
  another CheckedSmiOp, or the result of a phi that has a known smi.

3. Fix guessing receiver cids of getters/setters based.

4. Try to specialize calls based on propagated receiver type first before
  using guessed cids (which generates a call with checks + megamorphic slow path)

BUG=

Review URL: https://codereview.chromium.org/1824023002 .
2016-03-25 08:52:15 -07:00
John McCutchan 0a8c668e5c Add graph intrinsics for many math library functions:
- sin, cos, tan, asin, acos, atan, and atan2.

Other fixes:

- support calling from intrinsic code

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1823263002 .
2016-03-23 06:58:12 -07:00
John McCutchan 1e0abf4df0 Revert "Add graph intrinsics for many math library functions"
This reverts commit f5bc8fa353.

BUG=

Review URL: https://codereview.chromium.org/1825603002 .
2016-03-22 12:45:46 -07:00
John McCutchan f5bc8fa353 Add graph intrinsics for many math library functions
- sin, cos, tan, asin, acos, atan, and atan2.

This is my original CL including the CheckClass instruction.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1821783002 .
2016-03-22 09:28:49 -07:00