Commit Graph

1132 Commits

Author SHA1 Message Date
Vyacheslav Egorov f67ce21068 VM support for running Kernel binaries.
BUG=
R=asiva@google.com, fschneider@google.com

Review URL: https://codereview.chromium.org/2411823003 .
2016-10-15 22:48:46 +02:00
Ryan Macnak 3d00ecdc8f Reapply "Use a single file for app snapshots."
- Don't read script to check for an app snapshot if it is a pipe. Fixes loading source from a pipe.
 - Fix windows and fushsia builds.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2416973003 .
2016-10-14 09:57:54 -07:00
Ryan Macnak 6839a23240 Revert "Use a single file for app snapshots."
This reverts commit 4f8b16df3b.

Review URL: https://codereview.chromium.org/2410303008 .
2016-10-13 15:29:23 -07:00
Ryan Macnak 4f8b16df3b Use a single file for app snapshots.
For blobs, put all four pieces into a single file with a header describing their offsets.
For dynamic libraries, move the vm isolate and isolate pieces into the dynamic library as additional read-only sections.

Automatically detect if the script argument is an app snapshot and initialize the VM appropriately, similar to automatic detection of script snapshots.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2405393002 .
2016-10-13 14:33:56 -07:00
Martin Kustermann 9195014572 Fix off-by-one issue in clustered snapshot implementation and api impl
R=rmacnak@google.com, vegorov@google.com

Review URL: https://codereview.chromium.org/2381573002 .
2016-09-28 18:46:26 +02:00
Siva Annamalai 12f86594ec Add --parse-all option in order to benchmark and measure the scanner/parser performance.
R=hausner@google.com

Review URL: https://codereview.chromium.org/2327693002 .
2016-09-23 15:20:39 -07:00
John McCutchan decac71b70 Address Siva's DBCs on https://codereview.chromium.org/2350633003/
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/2359283002 .
2016-09-22 13:27:50 -07:00
Ryan Macnak 7432d20eaa Fix IsCompiletimeErrorObject for precompiled.
R=hausner@google.com

Review URL: https://codereview.chromium.org/2350973002 .
2016-09-19 14:11:29 -07:00
John McCutchan 632c76942c Add Dart_GetStickyError
- [x] Add Dart_GetStickyError.
- [x] Change Dart_SetStickyError to allow for null and also not set the pause on exit bit.

BUG=
R=turnidge@google.com

Review URL: https://codereview.chromium.org/2350633003 .
2016-09-19 13:31:09 -07:00
Matthias Hausner be003d70f2 Fix Windows build
BUG=

Review URL: https://codereview.chromium.org/2342303003 .
2016-09-16 11:16:50 -07:00
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
Ryan Macnak 3aa65a66d2 Assign external sizes to external strings and to external typed data created by the VM.
Observatory used to report that dart2js hello was using no external memory, but now reports 1.3MB of external memory (all token streams).

R=asiva@google.com

Review URL: https://codereview.chromium.org/2275803002 .
2016-09-01 10:56:40 -07:00
Ryan Macnak e46b3cd994 Treat background finalization as another GC task so it won't run in parallel with the marker.
Prevents a race between the marker and finalizer when the handle is freed (fixes #27029).

Disallow creating weak handles for immediate objects. We don't distinguish these from free handles, so their callbacks are never run.

Don't report freed handles over the vm service.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2281193002 .
2016-08-29 16:47:56 -07:00
Ryan Macnak d418dde65b Reduce copying in sending service responses.
Add missing safepoint transitions.

Issue #27092
Likely contributes to Issue #27010

dart2js hello
Peak RSS at first Observatory visit -> Peak RSS after visiting timeline (with endless recorder)
Before 215M -> 321M
After 182M -> 233M

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2254543006 .
2016-08-18 10:34:50 -07:00
Adam Barth fac99f35b3 Switch Dart_Initialize to use a struct
The number of NULL parameters was getting out of hand.

R=zra@google.com

Review URL: https://codereview.chromium.org/2223463003
2016-08-09 12:25:39 -07:00
Adam Barth bd41127c7f Revert "Switch Dart_Initialize to use a struct"
I landed the wrong version of my patch.

This reverts commit bdc25d5695.
2016-08-09 12:24:13 -07:00
Adam Barth bdc25d5695 Switch Dart_Initialize to use a struct
The number of NULL parameters was getting out of hand.

R=zra@google.com

Review URL: https://codereview.chromium.org/2223463003 .
2016-08-09 12:20:16 -07:00
John McCutchan 5a2193ecc4 Fix Windows build
BUG=

Review URL: https://codereview.chromium.org/2223863003 .
2016-08-08 12:30:37 -07:00
John McCutchan 800b1352ce Add an API for setting the sticky error
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/2223913002 .
2016-08-08 12:14:33 -07:00
Ryan Macnak 10863a8f0c DBC: Fail cleanly when attempting to create an AOT or JIT app snapshot.
Use the appropriate object pool entry type for native functions (makes a JIT app snapshot fail at snapshot creation time instead of runtime).

R=zra@google.com

Review URL: https://codereview.chromium.org/2196693003 .
2016-07-29 14:11:27 -07:00
Todd Turnidge ac5175d47a More fixes.
BUG=

Review URL: https://codereview.chromium.org/2196593003 .
2016-07-29 12:52:31 -07:00
Todd Turnidge 71c240470d Fix build. Fix tests.
BUG=

Review URL: https://codereview.chromium.org/2194973004 .
2016-07-29 12:32:53 -07:00
Todd Turnidge 1166f83bf6 Only reload libraries when they may have been modified.
We now check all of the scripts which make up a library.  If any
script is modified, then we consider that library to be modified.  We
also consider any library which imports a modified library to be
modified.  To propagate this info efficiently, we build and discard
the imported-by graph when beginning a reload.

The embedder must provide a FileModifiedCallback in order to support
the detection of modified scripts.

In order to detect changes to package: libraries, we have modified the
embedder interface to provide the resolved url when possible, so that
we don't need to re-resolve package uris when checking for reload.
This change is incompatible and all embedders will need to be updated.

We now support a "force" flag when reloading sources.  This causes all
libraries to be reloaded regardless of whether the underlying scripts
have been updated.

Closes #26919

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2186423002 .
2016-07-29 11:23:18 -07:00
Siva Annamalai b78aeee6f2 Fix race condition with HasMutatorThread that was being used without a lock.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2191723002 .
2016-07-28 18:32:52 -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
Ryan Macnak 0aea34396b Remove NoSafepointScope from Dart_IsolateData(Dart_Isolate).
May be called from a thread the VM doesn't know about. (In Flutter, the
Mojo handle watcher.)

R=asiva@google.com

Review URL: https://codereview.chromium.org/2148003002 .
2016-07-13 14:42:08 -07:00
Siva Annamalai fb3baee63d Guard some of the timeline API functions under #ifndef PRODUCT ... #endif as the windows compiler does not seem to do an effective job of dead code elimination leading to unresolved references in PRODUCT mode.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2140383002 .
2016-07-12 17:29:47 -07:00
Todd Turnidge f7242f2137 Reimplement devfs in dart. Implementation now writes to disk.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2120473004 .
2016-07-01 14:57:32 -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 a86111854a Allow null in Dart_SetRootLibrary.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2093813002 .
2016-06-23 17:22:30 -07:00
Siva Annamalai 72f7d1456c Change Dart_DefaultCanonicalizeUrl to accept the library url string instead of a library, this is useful to allow us to use this to generically resolve a Uri relative to another string.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2068833002 .
2016-06-14 17:15:51 -07:00
John McCutchan 1a4c2005cc DevFS initial implementation.
This cl implements an experimental filesystem maintained in the vm, called dart-devfs.  This will allow service protocol users to read and write source files while the vm is running.  This is needed for the reload support for flutter.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/2059883003 .
2016-06-10 12:33:50 -07:00
Siva Annamalai 6b9581e228 Move code that sends an isolate shutdown message to the service isolate to the block after we transition the thread state to ThreadInVM.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2047123002 .
2016-06-07 17:04:04 -07:00
Todd Turnidge a7d46eb5a6 Canonicalize uris in C++ instead of Dart for the standalone embedder.
Adds Dart_DefaultCanonicalizeUrl() to the dart embedding api.

Motivation:

As we try to get source reloading working for the standalone embedder, things get simpler if an isolate doesn't run Dart code while it is loading Dart code.  We intend to solve this by moving the embedder tag handler calls to the service isolate.  But making a blocking rpc into the service isolate whenever a url needs to be canonicalized during parsing seems like it would slow things down and make things complicated.  By moving canonicalization into C++, we avoid this.

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

Review URL: https://codereview.chromium.org/2011543002 .
2016-06-02 12:29:57 -07:00
Siva Annamalai 79e4792dd6 Fix for issue 26511 (VM hangs waiting for all threads that are not already at
a safepoint to check-in)

BUG=26511
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2018673003 .
2016-05-27 15:30:34 -07:00
Ryan Macnak ef8baa8760 Add test harness option for app snapshots with unoptimized code.
./tools/test.py -m all -c dart2appjit -r dart_app --use-blobs

Rename 'dart_product' runtime to 'dart_app'.

Rename Dart_PrecompiledJITSnapshotBlob to Dart_CreateAppJITSnapshot and add documentation.

Remove out-of-date scripts in tools/precompilation.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1992703005 .
2016-05-26 10:37:47 -07: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
Ryan Macnak 1e38923643 Check snapshots for feature compatibility.
- Full snapshots must be written and read by VMs in the same
   mode (debug/release/product).
 - Snapshots with ICData must be written and read by VMs in same
   checked-mode state.
 - Snapshots with code must be written and read by VMs targeting the
   same architecture and ABI.

Fix use-after-free of VM isolate snapshot error message.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1975423002 .
2016-05-16 14:00:05 -07:00
Ryan Macnak 37d08d6ebc Add timeline events for compiling static initializers and writing full snapshots. Remove timeline event for InitCompiler. Fail gracefully for missing flags when writing full snapshots.
Also fix PRODUCT build.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1970363002 .
2016-05-16 09:28:49 -07: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
Ryan Macnak 1e8fdaee68 Support for taking full snapshots from 'dart', not just 'dart_bootstrap'.
- Don't create rival copies of the predefined symbols in isolates in dart_bootstrap.
 - Don't do work to save these rival copies during symbol table compaction.
 - Create unified symbol table just before writing the vm isolate.
 - Create unified list of scripts to include in the vm isolate.
 - Ignore object ids of the old vm isolate when writing a new one.
 - Ensure token stream private keys are hashed.
 - Use the type of isolate we are writing instead of an object's current isolate to decide if vm isolate objects are written symbolically.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1944213002 .
2016-05-10 10:13:33 -07:00
John McCutchan 234250189b Include the field name and function name in Dart_GetField and Dart_Invoke timeline events
Fixes #26395

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1951003002 .
2016-05-05 16:50:11 -07:00
Ryan Macnak e0184aa823 Remove unnecessary full GCs before snapshot creation.
R=asiva@google.com

Review URL: https://codereview.chromium.org/1953673004 .
2016-05-05 15:55:01 -07:00
Ryan Macnak 354a26ce52 Add Dart_IsPrecompiledRuntime to help simplify logic in embedders that conditionally use precompilation or the JIT.
R=chinmaygarde@google.com

Review URL: https://codereview.chromium.org/1948183002 .
2016-05-05 11:32:43 -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
Ryan Macnak f262fad639 Option to output precompiled instructions as a blob for use with mmap instead of assembly for use in a shared library.
BUG=http://dartbug.com/26199
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1915853004 .
2016-04-25 16:19:34 -07:00
Ryan Macnak 0555b799cd Timeline: Copy event labels of embedder events.
Fixes use-after-free of the label for the 'SkyActivity.onSkyReady' event.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1882313002 .
2016-04-15 09:48:07 -07:00
Ryan Macnak b63dc021ea Remove timeline events for Dart_GetNativeX, etc.
These are common leaf functions.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1887203004 .
2016-04-15 09:31:35 -07:00