Commit graph

1598 commits

Author SHA1 Message Date
Stephen Adams b37747934e Specialize Symbol.hashCode
Patch internal.Symbol.hashCode and specialize JS version to avoid
recomputing String.hashCode

R=sigmund@google.com

Review URL: https://codereview.chromium.org/2038853003 .
2016-06-03 15:10:51 -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
Lasse R.H. Nielsen fbf64bb7a5 Make Iterable.toList more efficient if the length is known.
Add more tests. Fix (some) bugs found by tests.

R=floitsch@google.com

Review URL: https://codereview.chromium.org/1999793002.
2016-05-23 10:00:19 +02:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07: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 fcb02325cc Cleanup various argument and range errors in double.dart and integers.dart.
R=hausner@google.com

Review URL: https://codereview.chromium.org/1985823002 .
2016-05-16 14:31:26 -07:00
Todd Turnidge 6b28b4f7ef Remove DebuggerEvent. Refactor remaining code.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1978603002 .
2016-05-13 09:49:31 -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
Matthias Hausner 68a6060794 Eliminate GrowableTokenStream
Eliminate building an intermediate array of tokens in the scanner. Build
the compressed TokenStream directly instead.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1969563002 .
2016-05-11 14:09:45 -07:00
Florian Loitsch fe1fda0766 Make dart:convert strong mode clean.
Also removes the ChunkedConverter.

R=lrn@google.com

Review URL: https://codereview.chromium.org/1964953003 .
2016-05-11 16:15:31 +02: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
John McCutchan 62f9135490 Dart Timeline improvements
- [x] Add _getThreadCpuClock to dart:developer.
- [x] Report CPU usage for Dart synchronous timeline blocks.
- [x] GetEnvironmentValue for 'dart.vm.product' will return "true" or "false" depending on whether or not we are running in product mode.
- [x] Early out of Dart timeline calls if we are running in product mode.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1966833002 .
2016-05-10 14:31:33 -07: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
Ryan Macnak 257b3a82b8 JIT precompilated snapshots.
(Precompiled snapshots with unoptimized code.)

+ ./out/ReleaseX64/dart --package-root=./out/ReleaseX64/packages ./pkg/compiler/lib/src/dart2js.dart /usr/local/google/home/rmacnak/hello.dart
Dart file (/usr/local/google/home/rmacnak/hello.dart) compiled to JavaScript: out.js

real	0m3.299s
user	0m3.197s
sys	0m0.831s

+ ./out/ProductX64/dart_bootstrap --full-snapshot-after-run=/usr/local/google/home/rmacnak/dart3/sdk/app --package-root=./out/ReleaseX64/packages ./pkg/compiler/lib/src/dart2js.dart /usr/local/google/home/rmacnak/hello.dart
Dart file (/usr/local/google/home/rmacnak/hello.dart) compiled to JavaScript: out.js
+ ./out/ProductX64/dart --run-full-snapshot=/usr/local/google/home/rmacnak/dart3/sdk/app --package-root=./out/ReleaseX64/packages ./pkg/compiler/lib/src/dart2js.dart /usr/local/google/home/rmacnak/hello.dart
vm-service: Isolate creation error: (null)
Dart file (/usr/local/google/home/rmacnak/hello.dart) compiled to JavaScript: out.js

real	0m1.979s
user	0m1.806s
sys	0m0.581s

+ ./out/ReleaseX64/dart_bootstrap --use_blobs --gen-precompiled-jit-snapshot=/usr/local/google/home/rmacnak/dart3/sdk --package-root=./out/ReleaseX64/packages ./pkg/compiler/lib/src/dart2js.dart /usr/local/google/home/rmacnak/hello.dart
Dart file (/usr/local/google/home/rmacnak/hello.dart) compiled to JavaScript: out.js
VMIsolate(CodeSize): 2699304
Isolate(CodeSize): 5930097
Instructions(CodeSize): 9440176
Total(CodeSize): 18069577
+ ./out/ReleaseX64/dart --use_blobs --run-precompiled-jit-snapshot=/usr/local/google/home/rmacnak/dart3/sdk --package-root=./out/ReleaseX64/packages ./pkg/compiler/lib/src/dart2js.dart /usr/local/google/home/rmacnak/hello.dart
Dart file (/usr/local/google/home/rmacnak/hello.dart) compiled to JavaScript: out.js

real	0m0.994s
user	0m1.259s
sys	0m0.229s

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

Review URL: https://codereview.chromium.org/1938653002 .
2016-05-04 18:47:36 -07:00
Siva Annamalai 95904322e7 Minor cleanup based on profiler output of CompileParseFunction.
- Add a zone parameter to TokenStream::Iterator
- Add IsXXXX() functions in raw_object.h using GetClassId()
- Modify
    - Function::owner
    - Function::origin
    - Type::IsMalformed
    - Type::IsMalbounded
    - Type::error
  to not create a Handle in the common path

R=regis@google.com

Review URL: https://codereview.chromium.org/1952023002 .
2016-05-04 15:30:56 -07:00
Ivan Posva 3884fd4e4b - Allow for loading dart:html and friends into the standalone
dart_bootstrap binary to evaluate startup and compilation
  performance.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1916793003 .
2016-05-03 20:33:14 -07:00
Siva Annamalai 964a659470 - reset 'dirty' flag to false after the libraries mirrors is computed, this ensures that we compute the libraries only when new library modules are loaded and the 'dirty' flag is set to true.
- Use passed in 'zone' argument in the native string functions

- Use passed in 'thread' argument in the library mirror creation functions

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1935703002 .
2016-04-29 15:15:19 -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
Stephen Adams 2bb2a12720 Avoid multiple reallocations of StringBuffer._parts
The original code

    _parts = [ str ];

allocated a _GrowableList backed by a single element _List.
Subsequent calls to _parts.add() grows the backing list to 2, then 4, etc.

On a dart2js workload, allocating with a reasonable initial capacity
reduces the number of _List objects allocated by 8%, with 4% reduction in
_List bytes allocated.

R=lrn@google.com

Review URL: https://codereview.chromium.org/1888453011 .
2016-04-18 18:08:16 -07:00
Ryan Macnak f731dd0615 Reapply "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
- Rehash constants table during tree-shaking.
 - Rehash constants table on snapshot load.

R=regis@google.com

Review URL: https://codereview.chromium.org/1900863002 .
2016-04-18 16:46:26 -07:00
Regis Crelier bab552edaf Fix mirrors to keep typedef as scope class of function types (fixes #26187).
Add mirror regression test.
Adjust expectation of a mirror test.
Fix parser to mark current class as typedef before parsing signature.
Fix canonicalization of typedef function types (a typedef class can be the scope
class of more than one function type, even if not generic).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1890013002 .
2016-04-15 13:21:22 -07:00
Siva Annamalai 8ce7b6291a Revert "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
This reverts commit 95a2b02a9e.

Once the tree shaker in precompiled code is fixed to treat the constants array in a class as a hash table this CL can be re-applied.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1888593003 .
2016-04-13 18:49:53 -07:00
Siva Annamalai 95a2b02a9e - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances.
- Some minor cleanups
  - Return an empty array right away in the parser instead of creating an
    empty array and canonicalizing it
  - The canonical bit was not being set for some of the singleton objects.

R=regis@google.com

Review URL: https://codereview.chromium.org/1873143003 .
2016-04-13 10:26:17 -07:00
Florian Loitsch 50bdab3841 Steps towards making the convert library strong-mode compliant.
This version has a few deprecated methods. In a future release they will be removed.

See https://codereview.chromium.org/1827803002 for the final patch (once the deprecated methods have been removed).

R=leafp@google.com, lrn@google.com

Committed: 4ab1219bf9
Reverted: 045a375366

Review URL: https://codereview.chromium.org/1847843002 .
2016-04-12 20:59:21 +02:00
Ryan Macnak 71676a1e5b Use exact name lookup for static fields in mirrors.
R=hausner@google.com

Review URL: https://codereview.chromium.org/1877813003 .
2016-04-12 11:15:38 -07:00
Ivan Posva 5be5d54529 - Refactor Symbol allocation to expect a thread parameter.
- Preallocate all tokens as symbols to avoid repeated lookups.
- Pass thread/zone where useful while doing this change.
- Avoid allocating symbols for error messages.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1870343002 .
2016-04-11 16:28:29 -07:00
Ryan Macnak e048774776 Precompilation: Specialize instance calls when the call receiver is the method receiver and the method class has a small number of concrete subclasses (currently 5).
CompileOnceHelloHtml (ARMv7HF) +17.194%
DeltaBlueClosures (ARMv7HF) +28.379%
DeltaBlue (ARMv7HF) +30.190%

precompiled dart2js arm 19071745 -> 19504726 (+2.3%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1867913004 .
2016-04-11 12:52:28 -07:00
Florian Loitsch 045a375366 Revert "Steps towards making the convert library strong-mode compliant."
This reverts commit 4ab1219bf9.

Review URL: https://codereview.chromium.org/1881553002 .
2016-04-11 19:52:57 +02:00
Florian Loitsch 4ab1219bf9 Steps towards making the convert library strong-mode compliant.
This version has a few deprecated methods. In a future release they will be removed.

See https://codereview.chromium.org/1827803002 for the final patch (once the deprecated methods have been removed).

R=leafp@google.com, lrn@google.com

Review URL: https://codereview.chromium.org/1847843002 .
2016-04-11 19:16:04 +02:00
Florian Schneider be298b60e9 VM: Remove unnecessary _Num class from runtime/lib.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1874853002 .
2016-04-08 16:25:52 -07:00
Matthias Hausner 425b9a36b9 Use symbols when looking up fields in a class
The slow string comparison is only necessary when looking up
non-symbols or untangled private names.

Compiling all of dart2js seems to be about 1% faster, but it's really in the noise.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1868803002 .
2016-04-07 16:36:35 -07:00
Stephen Adams 3e4d8fe6c7 Eliminate megamorphic lookup in Null.hashCode
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1860793002 .
2016-04-05 09:01:49 -07:00
Regis Crelier 48dc790398 Fix core lib DateTime in the VM (fixes #19923).
Symptom of the problem:
Set your Linux workstation (or Mac or MIPS board) to the Europe/London timezone
and the corelib/date_time test will fail, claiming that 1/1/1970 was a Wednesday
(it was actually a Thursday, trust me, I was already born).

Problem:
The implementation of DateTime in the VM relies on Unix time_t, the number of
seconds since the Epoch (1/1/1970 UTC). When asked for the weekday of a given
time, our implementation limits itself to a 32-bit positive range of time_t.
If the time falls outside of this range, the implementation picks an equivalent
time in the valid range with the same weekday, also in leap year or not, etc...
The issue is that DateTime is using the underlying OS in an inconsistent manner.
Let's take the example above: 1/1/1970 in the Europe/London timezone.
First, the number of seconds since the Epoch in UTC is calculated, here 0.
Then, the timezone offset at the given time is calculated using the underlying
OS. In this case, an historical deviation is taken into account. Indeed, London
stayed on British Summer Time between 27 October 1968 and 31 October 1971. See
https://en.wikipedia.org/wiki/British_Summer_Time#Periods_of_deviation for
details.
Our resulting time is therefore negative (one hour difference with UTC).
When asked about the weekday of this time, the implementation notices that the
time is not in the positive range and picks an "equivalent" time in the future.
It then asks the underlying OS about the timezone offset for this time, which
is 0 (usually no daylight saving time in January in London). Unfortunately,
this time is not really equivalent, because it ignores the original historical
deviation. The result is wrongly equivalent to 12/31/1969 23:00 in London, i.e.
a Wednesday, and not a Thursday as expected.

Solution:
We should use the underlying OS in a consistent way, by simply allowing the
value of time_t passed to the underlying OS to be negative, which is legal.

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

Review URL: https://codereview.chromium.org/1845483002 .
2016-03-30 10:09:58 -07:00
Siva Annamalai 341643cb2b Do not compile a class when the class mirror tries to access the metadata.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1834673003 .
2016-03-28 11:16:15 -07:00
Stephen Adams 83e73400db VM: Fix _CompactLinkedHashSet performance regression.
Directly initializing field helps the VM figure out that they cannot be null.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1834093002 .
2016-03-28 07:44:04 -07:00
Stephen Adams 20c2ece316 Avoid useless allocations in _CompactLinkedHashSet constructor
Fix for: https://github.com/dart-lang/sdk/issues/26071

R=hausner@google.com

Review URL: https://codereview.chromium.org/1834513002 .
2016-03-23 16:59:49 -07:00
Ryan Macnak b070d98f6e Simpler regex names:
C++ JSRegExp -> RegExp
  Dart _JSSyntaxRegExp -> _RegExp
  Function RegExp.:irregexp: pattern -> RegExp.:matcher: pattern

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1815333002 .
2016-03-21 17:21:05 -07:00
Regis Crelier 966aea003b Remove recently introduced FunctionType vm class by merging it into class Type.
Fix syntax used when printing function type with optional named parameters.
Fix several issues discovered with cloning function types.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1815733003 .
2016-03-21 14:08:57 -07:00
Stephen Adams dce10bba79 VM library tweaks to avoid megamorphic calls in dart2js
Problems this addresses:

1. dart2js has hashCode functions like

   get hashCode = this.x.hashCode + 17 * this.y.hashCode

When x and y are ints or bools VM optimizing compiler inlined the call
to Object.hashCode and generated MegamorphicLookups for
Object._identityHashCode.

2. HashMaps with _Smi keys had a double MegamorphicLookup: The hash
table reasonably calls MegamorphicLookup(get:hashCode) which returns
Object.hashCode; the compiled Object.hashCode is essentially
MegamorphicLookup(get:_identityHashCode), which returns
_Smi._identityHashCode which finally returns 'this'.

3. _interpolateSingle's call to o.toString() is megamorphic. We can
avoid it for the common case of String arguments, this is often
comming from StringBuffer.write() with a literal or interpolated
argument.

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1820653002 .
2016-03-21 09:38:13 -07:00
Florian Schneider f3de2377ab Move the VM's typed_data implementation to runtime/lib.
This removes the additional indirection to the VM's implementation
for all the factory constructors.

Additionally, it removes one class per typed data list type, thus reducing
snapshot and generated code size.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1790593002 .
2016-03-21 13:39:49 +01:00
Siva Annamalai f7d2b2e31e - Fix for issue 25950 (add registration of a thread exit callback)
- Moved some of the file and entropy callbacks to class Dart from
  class Isolate as they are not isolate specific.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1807293002 .
2016-03-17 13:40:20 -07:00
John McCutchan c65114b6b4 Timeline API fixes for Flutter
API changes:

- Remove isolate specific Timeline APIs.
- Remove Dart_EmbedderTimelineGetTimeline callback.
- Add Dart_TimelineEvent so that arbitrary trace events can be added.

Internal changes:

- Remove isolate specific streams which were never used or controllable from outside the VM.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1811613002 .
2016-03-16 12:18:46 -07:00
Florian Schneider bec43a3b8f Simplify the VM's typed_data constructors.
Remove _new native functions to have one indirection less
when constructing typed data lists.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1782003002 .
2016-03-10 09:38:08 +01:00
Regis Crelier ba69c8a898 Enumerate URIs of all types in type errors in order to help the user diagnose
the error (it was previously only printed for types with identical names).
Cleanup and simplify construction of type errors.

R=hausner@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1778133002 .
2016-03-09 15:16:47 -08:00
Florian Schneider 48b0183926 Make precompiler work with product mode.
For now, change compilation-related flags to be regular
command line options. They won't affect the size of the
precompiled runtime anyway since the compiler is not included
there.

Also introduce a separate switch for precompiled runtime. This can be
 used instead of the macro since it is a compile-time constant in the
 precompiled runtime.

BUG=

Review URL: https://codereview.chromium.org/1759913002 .
2016-03-02 13:59:54 -08:00
Florian Loitsch 55630a5e90 Support 'dart.library.X' env variables in the VM.
BUG= http://dartbug.com/24587
R=iposva@google.com, johnmccutchan@google.com

Committed: c2a06e22cb
Reverted: 5eb5b42989

Review URL: https://codereview.chromium.org/1640853004 .
2016-02-29 20:58:32 +01:00
Matthias Hausner 11767827db Add comment to async* support code
Addresses review comment.

Review URL: https://codereview.chromium.org/1751503002 .
2016-02-29 11:22:04 -08:00
Srdjan Mitrovic 5a69e3661b In background compilation make a copy of Field in order to freeze its state. Add flag --force_clone_compiler_objects for debugging purpose.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1722733002 .
2016-02-26 09:07:49 -08:00