Commit Graph

303 Commits

Author SHA1 Message Date
Matthias Hausner 3e0d13bc28 Make compile-time errors catchable
If an error happens during the compilation of a function body, an Error is thrown which can be intercepted, and ensures that finally blocks are executed before the isolate is terminated.

The language spec is vague about compilation errors. A doc describing the intentions behind this CL is at
https://docs.google.com/document/d/1_MWOgwJadLCQSBps0zD6Rj5dG4iP1UBuiDvTMH-WMzI/edit#

Example:
     1	void bad() {
     2	    return 5
     3	}
     4
     5	void main(args) {
     6	    bad();
     7	}

Before this CL:
$ dart ~/tmp/e.dart
'file:///Users/hausner/tmp/e.dart': error: line 2 pos 11: semicolon expected
  return 5
          ^
$

After this change:
$ dart ~/tmp/e.dart
Unhandled exception:
'file:///Users/hausner/tmp/e.dart': error: line 2 pos 11: semicolon expected
  return 5
          ^

#0      main (file:///Users/hausner/tmp/e.dart:6:3)
#1      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:259)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
$

Notice that the stack trace points to the call site of bad(), not the text location of the syntax error. That's not a bug. The location of the syntax error is given in the error message.

BUG= https://github.com/dart-lang/sdk/issues/23684
R=asiva@google.com, lrn@google.com

Review URL: https://codereview.chromium.org/2044753002 .
2016-09-16 10:10:38 -07:00
Siva Annamalai aaa0867567 More changes to use #ifndef PRODUCT ... #endif explicitly instead of relying on compiler magic.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2146713004 .
2016-07-14 11:13:13 -07:00
Lars Bak 21a3a27aff Made simple instance-of checks fast for unoptimized code.
This change makes dart2js 15% faster when compiling 60KLOC. 15sec -> 13sec.

BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/2147123002 .
2016-07-14 11:11:17 -07:00
Ryan Macnak ee942bd8d6 Remove per-isolate compile-time constants cache.
There are no scripts in the VM isolate as of 83da4db9f9.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2147493005 .
2016-07-12 17:35:54 -07:00
Todd Turnidge 62ccff992f Cache compile-time constants on the script object, sometimes.
When a script is not in the vm heap, we now cache compile time
constants on the script object itself.  During isolate reload we may
have both an old and a new version of a script being compiled at the
same time and they need to cache their constants separately.  This
also means that compile time constants from old scripts can be
collected when the script is collected, which is good.

When a script is in the vm heap, we continue to use the old system of
employing a shared per-isolate cache stored in the object store.

Closes #26833

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

Review URL: https://codereview.chromium.org/2126393003 .
2016-07-11 14:15:37 -07:00
Ryan Macnak 524fbc1e0f Use clustered serialization for full snapshots.
Retain the recursive-descent format for script and message snapshots.

Flutter gallery app on a Nexus 4
 - Snapshot, excluding instruction/rodata sections 3429177 -> 2874997B (-16%)
 - InitOnce 54.1 -> 8.4ms (-84%)
 - InitializeIsolate 374.3 -> 170.8ms (-54%)

R=asiva@google.com

Review URL: https://codereview.chromium.org/2032153003 .
2016-06-29 19:50:06 -07:00
Ryan Macnak 435b371cb7 Make the object store visible in Observatory.
R=turnidge@google.com

Review URL: https://codereview.chromium.org/2012333002 .
2016-06-01 13:00:22 -07:00
Ryan Macnak 7bdf01560a Speculatively revert "Make the object store visible in Observatory."
This reverts commit 2eb8408969.

TBR=turnidge@google.com

Review URL: https://codereview.chromium.org/2002253005 .
2016-05-25 17:33:52 -07:00
Ryan Macnak 2eb8408969 Make the object store visible in Observatory.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2005983002 .
2016-05-25 11:12:32 -07:00
Siva Annamalai 5de775a823 - Canonicalize generic types in a global isolate hash
table, this ensures that we do not linearly walk through
  a large type list in the class calling the expensive
  'Type::Equals' method (some applications have close to
  1304 generic types in them)

- Use the stand hash table implementation for TypeArguments
  canonicalization instead of a custom hash table

R=johnmccutchan@google.com, regis@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1965493004 .
2016-05-17 14:35:23 -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
Ryan Macnak f55c9c54a8 Split Snapshot::kFull into kCore, kAppWithJIT, and kAppNoJIT. Remove snapshot_code flag.
R=asiva@google.com

Review URL: https://codereview.chromium.org/1918313003 .
2016-04-26 17:03:24 -07:00
Siva Annamalai 2964f9e750 Change return value of ObjectStore::PreallocateObjects to return the error object or null instead of a bool. Most of the times the sticky error is cleared and returned as an error so returning a bool and querying the sticky error here does not work as the sticky error is a null object.
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1721053002 .
2016-02-22 13:37:22 -08:00
Srdjan Mitrovic 4316d1bd17 Move sticky_error_ from isolate to thread
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1672853002 .
2016-02-05 15:46:55 -08:00
Regis Crelier 7f57ebcfa1 Remove signature classes from the VM.
They were used as the class of closure instances and as the type class of
function types.
All closure instances now have class _Closure and function types are represented
by a new class FunctionType extending AbstractType.
Fix issue 24567 and add regression test.

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

Review URL: https://codereview.chromium.org/1584223006 .
2016-01-19 16:32:59 -08:00
Srdjan Mitrovic a9ea73b60b --collect_dynamic_function_names (default false): find unique virtual function names and use them to populate ICData (precompilation only) Measured some performance improvement, some performance loss. Next: tune inlining of getters/setters, check heuristics.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1496713002 .
2015-12-04 13:19:00 -08:00
Matthias Hausner 648e52baa8 Collect closure functions in isolate
Instead of collecting closures functions in each class object, maintain one list per isolate. This is a step towards getting rid of top-level classes.

I'd appreciate if John could take a look at the service isolate and coverage related change.

I'd appreciate if Ryan could take a look at the precompilation related change.

When compiling all of corelib, the list of closures in the isolate is about 600 entries long. If this linear list should become a bottleneck, I'll deal with it later. (Sadly, some code relies on the fact that a closure can be identified with a list index, so making it a hash table instead of an array does not work.)

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1436243005 .
2015-11-17 15:40:27 -08:00
Srdjan Mitrovic 354fcb12cf Cleanups. More mutator thread asserts.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1448463004 .
2015-11-16 10:29:01 -08:00
Ryan Macnak 830bfe61b7 Precompilation: Generate instance calls as IC calls that can switch to Megamoprhic calls.
dart2js ARM -10.3% size

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1418863003 .
2015-11-04 09:31:19 -08:00
Florian Loitsch be025b8412 Revert "Remove deprecated dart:profiler library"
This reverts commit 535a9715ac.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1415843008 .
2015-11-04 01:59:53 +01:00
Matthias Hausner 59dce43dfe Shared token objects
Instead of one array for literal and identifier tokens for each TokenStream, share one array among all TokenStreams in an isolate.

The shared array and the token-to-index map is stored in the object store until the embedder is done loading. Then the map is thrown away (and the array remains shared, referred to by the TokenStreams).

When new files get loaded, a new shared array is created. For temporary scripts, e.g. when evaluating one-shot functions, the token arrays are not shared.

This eliminates many duplicate LiteralToken and identifier tokens. Looking at the core libraries:

Before: 30877 identifiers and 9618 literal tokens
After: 12899 identifiers and 6371 literal tokens

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1420103006 .
2015-10-28 16:02:58 -07:00
Srdjan Mitrovic 8915fb6fde More work for background compilation; move pending_functions_ from ObjectStore to Thread.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1409173002 .
2015-10-16 17:02:43 -07:00
John McCutchan 535a9715ac Remove deprecated dart:profiler library
Fixes #24510

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1398433002 .
2015-10-07 10:01:33 -07:00
John McCutchan af0ab36f7c Make dart:_vmservice a proper builtin library
- Drops custom resource table for sources.
- Stops loading dart:vmservice library by sources.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1387043002 .
2015-10-06 07:58:14 -07:00
Ryan Macnak 491b1d42f8 Reapply "Move megamorphic cache table into the Dart heap."
Prevent megamorphic miss function from losing its code:
 - Only include megamorphic function in precompiled snapshots.
 - Also put the megamorphic miss code in the object store.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1339363002 .
2015-09-15 11:18:43 -07:00
Ryan Macnak 33b037125f Revert "Move megamorphic cache table into the Dart heap."
We're somewhere attempting to recompile the megamoprhic miss function.

Review URL: https://codereview.chromium.org//1334283004 .
2015-09-14 17:54:43 -07:00
Ryan Macnak 3068f1e092 Move megamorphic cache table into the Dart heap.
R=asiva@google.com

Review URL: https://codereview.chromium.org//1346473002 .
2015-09-14 17:11:55 -07:00
Matthias Hausner 62e9d05668 Introduce per-isolate cache for compile time constants
Compile-time constant values are maintained in a cache, keyed
by script and token position. When the same code is compiled
again later, e.g. by the optimizing compiler, the value is
found in the cache and does not need to be computed again.

In this version, the key is a string concatenated from the
script url and the token position. That’s probably more overhead
than we want.

Added two compiler stat counters for number of cached constants
and number of cache hits. Running dart2js to compile a hello world
program results in about 1400 cached values and 85 cache hits.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1308073005 .
2015-08-26 16:17:20 -07:00
asiva@google.com 05d7eb5dfa Move symbol table from per isolate snapshot to vm isolate snapshot, this reduces the per isolate initial heap size
from New space (0k of 1024k) Old space (1274k of 1536k)
to New space (0k of 1024k) Old space (756k of 1280k)

R=hausner@google.com

Review URL: https://codereview.chromium.org//1123813002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45795 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-14 20:14:37 +00:00
johnmccutchan@google.com f01c1490f7 Revert 45783
BUG=

Review URL: https://codereview.chromium.org//1138993005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45784 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-14 00:32:32 +00:00
johnmccutchan@google.com 95515238cc Move 'dart:profiler' contents into 'dart:developer' and remove 'dart:profiler'
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1139503002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45783 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-13 23:48:04 +00:00
johnmccutchan@google.com 1f851efdbb Rename 'dart:debugger' to 'dart:developer'
- Rename 'dart:debugger' to 'dart:developer'
- Make 'breakHere' and 'breakHereIf' top level functions.

R=iposva@google.com

Review URL: https://codereview.chromium.org//1132113002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45658 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 21:24:57 +00:00
johnmccutchan@google.com a19cd071e5 Add 'dart:debugger' library
- Add the 'dart:debugger' library.
- Add the 'Debugger' class.
- Add explicit Dart breakpoint triggered by a call to: Debugger.breakHere();
- Add Debugger.breakHereIf(bool expr)

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

Review URL: https://codereview.chromium.org//1116263004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45529 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-05 17:05:37 +00:00
iposva@google.com 91e105d8c6 - Implement some more missing pieces of the Isolate API.
Added:
    * addOnExitListener, removeOnExitListener
    * setErrorsFatal
    * addOnErrorListener, removeOnErrorListener

R=asiva@google.com

Review URL: https://codereview.chromium.org//881373002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44307 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-07 01:04:19 +00:00
iposva@google.com 57b4eef0d4 - Remove entirely disconnected unhandled exception handler.
R=asiva@google.com

Review URL: https://codereview.chromium.org//796003006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42759 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-09 22:39:42 +00:00
hausner@google.com 8ece5c1b84 Allow Symbols in switch and maps
Allow Symbol literals (and const Symbol instances) as switch expression
and as key values in const Maps.

This implements the most recent Spec changes.

R=regis@google.com

Review URL: https://codereview.chromium.org//781203005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42230 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-10 00:24:07 +00:00
hausner@google.com 95dc65a0e9 Implement await for statement
Implement await for statement to iterate over streams. Uses
the built-in class StreamIterator.

await for (var e in stream_expr) {
  S;
}

Is translated to:

var it = new StreamIterator(stream_expr);
while (await it.moveNext()) {
  var e = it.current;
  S;
}

Review URL: https://codereview.chromium.org//662603003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41328 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-27 18:03:43 +00:00
hausner@google.com 2f49f29c38 Await always waits
The expression ‘await e’ always suspends the enclosing function. If e does not
evaluate to a an object o of type Future, a new Future is created using Future.value(o).

A small change in the backend allows a return instruction to be followed by
other instructions. In async functions, a return can suspend the function and the
continuation point is in the same code block after the return.

Other small changes:
- More user-friendly error message if async/await is not enabled.
- Programs no longer need to import dart:async when using async/await.

R=fschneider@google.com

Review URL: https://codereview.chromium.org//634603002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41105 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-14 19:58:06 +00:00
asiva@google.com 8762719b28 Remove some of the unused classes stored in the object store.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//589733002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40531 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-19 23:48:49 +00:00
asiva@google.com 302c93b050 1. Add user tag to the pointers traversed in the object store
2. Added support for UserTag objects in a full snapshot.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//583583007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40508 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-19 18:00:13 +00:00
srdjan@google.com 5ef243e688 Make sure Bigint._digits is always a Uint32List and bever null. Adapt type information for get:_digits.
R=regis@google.com

Review URL: https://codereview.chromium.org//580903004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40463 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-18 21:18:25 +00:00
asiva@google.com 3f6e337e87 Fix issue 20983 (https://code.google.com/p/dart/issues/detail?id=20983)
The check for load error on completion of async load was very inefficient.
Added a Hash set to ensure we don't repeatedly traverse through a library
when trying to establish transitive load errors.

R=iposva@google.com

Review URL: https://codereview.chromium.org//573293004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40422 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-18 02:01:26 +00:00
hausner@google.com 4258c115b4 Handle load errors in deferred code
IO errors on the URL of a deferred library are forwarded to the Future
that handles the deferred load. Syntax errors and finalization errors
are lethal, killing the isolate.

Review URL: https://codereview.chromium.org//419103003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38800 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-31 21:09:33 +00:00
koda@google.com 1cdcb12b4e Add VM class for Map/LinkedHashMap.
Introduces a new internal class for the most common case, the default Map.

Passes all functionality tests.
Slow: Dart side simply calls into runtime for now.
Hidden behind "--use_internal_hash_map".

Add copies of hash map tests to exercise this implementation.

R=asiva@google.com

Review URL: https://codereview.chromium.org//380333002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38588 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-25 20:04:11 +00:00
fschneider@google.com 26470e8384 Avoid allocating an exception object in the snapshot reader.
The unhandled exception object needs only be allocated before
actually returning an error from the snapshot reader, and not
at each invocation of ReadObject.

R=asiva@google.com

Review URL: https://codereview.chromium.org//388963003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38280 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-16 11:49:45 +00:00
iposva@google.com 5686b6a793 - Implement Isolate.pause and Isolate.resume.
- Implement a minimum Capability functionality.

R=asiva@google.com

Review URL: https://codereview.chromium.org//354763004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37982 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-03 12:56:02 +00:00
johnmccutchan@google.com 850074a704 Refactor 'dart:profiler' UserTag API
- Each isolate starts off with a 'Default' UserTag set.
- A null tag cannot be set.
- Calls to clearCurrentTag() should be replaced with a call to UserTag.defaultTag.makeCurrent().
- makeCurrent returns the previously current tag.

This allows for the following pattern to work:

callee() {
  var old = calleeTag.makeCurrent();
  ...
  old.makeCurrent();
}

caller() {
  var old = callerTag.makeCurrent();
  ...
  callee();
  assert(getCurrentTag() == callerTag);
  ...
  old.makeCurrent();
}

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

Review URL: https://codereview.chromium.org//266913010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35810 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-06 17:07:26 +00:00
iposva@google.com d8753e6f8b - Remove some unnecessary classes from the object store.
R=asiva@google.com

Review URL: https://codereview.chromium.org//257413002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35343 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 23:45:17 +00:00
iposva@google.com fd8565b071 - Add a minimal implementation of Capability.
- Make RawReceivePort and SendPort VM internal objects.
- Rationalize the creation of ports and their handling within the VM.

R=asiva@google.com

Review URL: https://codereview.chromium.org//243973002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35325 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 19:44:03 +00:00