Commit Graph

38 Commits

Author SHA1 Message Date
Vyacheslav Egorov 7558644bd6 [vm/compiler] Move compiler state (CHA, deopt id) from Thread to a special class
Also move deopt id computation logic into a separate class and add a comment
explaining while deopt ids are incremented by 2.

Change-Id: Ife489be7d10c7198a8e7adf9e97e0c516d78ea55
Reviewed-on: https://dart-review.googlesource.com/72685
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-09-03 16:01:24 +00:00
Samir Jindel 7583fb882a [vm] Refactor state bits to free up two bits on Function.
This was pulled out of old revision by Slava.

Change-Id: I9fa276b0768f4aa908754fec8369b1272ec465be
Reviewed-on: https://dart-review.googlesource.com/56108
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-23 13:59:25 +00:00
Ryan Macnak 074b43c863 [vm] Don't let the optimizer mislead coverage data.
Coverage uses the value of an execution counter to detect executed functions. However non-positive execution counter does not necessary mean that a function was never executed because we sometimes reset the counter.

Introduce additional bit on a function that is set whenever we reset positive execution counter and use this bit when generating coverage data.

Bug: https://github.com/dart-lang/sdk/issues/31326
Change-Id: I5357109603defad7e7c9415c433203f16bcf88f4
Reviewed-on: https://dart-review.googlesource.com/19760
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-10 22:35:48 +00:00
Vyacheslav Egorov 8a179fb953 [VM, Compiler] Move compiler to a separate folder.
New folder structure (nested under vm/):

- compiler/
-   jit/         - JIT specific code
-   aot/         - AOT specific code
-   backend/     - all middle-end and back-end code (IL, flow graph)
-   assembler/   - assemblers and disassemblers
-   frontend/    - front ends (AST -> IL, Kernel -> IL)

compiler/README.md would be the documentation root for the compiler
pipeline

Bug: https://github.com/dart-lang/sdk/issues/30575
Change-Id: I2dfd9688793bff737f7632ddc77fca766875ce36
Reviewed-on: https://dart-review.googlesource.com/2940
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-04 15:15:18 +00:00
Aske Simon Christensen 8cb752f73b Revised "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
Explicitly clear unbox_numeric_fields flag in PRODUCT builds. Fixes code bloat introduced by previous CL. New changes in Patch Set 2.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/3006923002 .
2017-09-04 13:13:26 +02:00
Ryan Macnak 9ce7fb5929 Revert "Reapply "Eliminate dependencies on assemblers and code stubs in precompiled runtime.""
This reverts commit 8ee4436355.

This change caused a 63% increase in AOT snapshot size of Flutter Gallery.

Issue #30472

Review-Url: https://codereview.chromium.org/2997993002 .
2017-08-17 13:33:37 -07:00
Aske Simon Christensen 8ee4436355 Reapply "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
Also exclude references to disassembler in precompiled mode.

New edits are in patch set #2.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2994863002 .
2017-08-12 02:15:23 +02:00
Ryan Macnak 3afd223f90 [gardening] Revert "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
This reverts commit 46c53882cc.

This changes introduced link errors on Windows.

Review-Url: https://codereview.chromium.org/3001463002 .
2017-08-09 15:49:51 -07:00
Aske Simon Christensen 46c53882cc Eliminate dependencies on assemblers and code stubs in precompiled runtime.
Guard all excluded code behind conditional compilation.

Removed precompiled runtime flag. Only preprocessor flag remains.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=rmacnak@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2976723003 .
2017-08-09 22:21:34 +02:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Regis Crelier 3633c5bd5e Rename Closure instance field type_arguments_ to instantiator_.
Simplify handling of closures as deferred objects.
The name "type_arguments_" is confusing, because class Closure is not generic.
Class Closure was forcefully made (kinda) generic by setting its
type_arguments_field_offset_in_words_ field to a valid value, so that the
type_arguments_ field in closure instances could be accessed similarly as in
generic instances. With generic functions, closures will potentially have more
than one instantiator and the name type_arguments_ becomes nonsensical.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2719603002 .
2017-02-27 11:14:04 -08: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
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 6d0be9b1ec Eliminate excessive increment of deoptimization counters (e.g., with deep recursion of deoptimized function). Instead increment deoptimization_count for all (inlined) functions at deoptimization point if deoptimization was triggered from function's optimized code. Cases where that is not the case are OSR codes, lazy-deopts and code disabling due to loading/finalizing classes or guard invalidation.
Rename deoptimization_counter_threshold to max_deoptimization_counter_threshold.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1557533002 .
2015-12-29 15:48:51 -08:00
Srdjan Mitrovic 6f53350611 Move deopt_id and related helpers/definitions from Isolate to Thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1390153004 .
2015-10-13 10:08:14 -07:00
Florian Schneider bac82e2592 VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

BUG=
R=koda@google.com, rmacnak@google.com

Committed: https://github.com/dart-lang/sdk/commit/1d343e5a7b75168fb6c9f86b64c55173cdbdc9b2

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-19 13:21:09 +02:00
Florian Schneider 7af7a2db87 Revert "VM: New calling convention for generated code."
This reverts commit 1d343e5a7b.

Because of Windows test failures.

BUG=
TBR=whesse@google.com

Review URL: https://codereview.chromium.org//1343373003 .
2015-09-16 13:46:05 +02:00
Florian Schneider 1d343e5a7b VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-16 13:05:58 +02:00
Florian Schneider 922516fbba Revert "VM: Materialize stub pc-markers (smi 0) eagerly on deoptimization."
This reverts commit fee8daa5c5.

Check if this was the reason for dart2js flaky crashes.

R=floitsch@google.com
TBR=floitsch@google.com

Review URL: https://codereview.chromium.org//1291543003 .
2015-08-17 14:48:04 +02:00
Florian Schneider fee8daa5c5 VM: Materialize stub pc-markers (smi 0) eagerly on deoptimization.
Deferred objects are malloced, and there is no need to allocate one
for the stub pc-marker (smi zero).

This is also part of preparing for running precompiled stub code: when
changing the pc-marker to hold the stub's code object, we want to materialize
it eagerly, so that the stack frame is valid after DeoptimizeFillFrame.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1289243002 .
2015-08-17 09:57:12 +02:00
Florian Schneider 265a54411a Object pool with support for untagged entries.
This adds meta-information to object pool entries to allow storing
untagged immediates or code addresses (ExternalLabel) directly.

This eliminates the need to generate extra code to preserve the LSB
when storing immediates as smis (x64, arm64).

BUG=

Review URL: https://codereview.chromium.org//1175523002.
2015-06-10 11:41:22 +02:00
Srdjan Mitrovic b611952ead Prevent excessive deoptimization when optimistically assuming Smi in typed data stores.
Moved ICData ahead of class Function, since class Function needs type ICData::DeoptReasonID.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org//1149403005
2015-06-01 11:42:42 -07:00
iposva@google.com a1854d45ac Fix http://dartbug.com/23290
- Ensure that we do have unoptimized code available when generating
  coverage information.

R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45419 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-24 23:31:15 +00:00
fschneider@google.com 9709db7f76 VM: Add infrastructure to support deferred generation of unoptimized code.
Add deferred deoptimization instructions for return address, pc marker and
object pool pointer. This enables generating unoptimized code lazily
on deoptimization.

This CL does not change the way unoptimized code is generated or collected
yet, but just provides the mechanisms needed. This can be used to allow
code GC for the unoptimized code of optimized functions.

R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44934 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-07 12:32:22 +00:00
fschneider@google.com b26ff22adf Allocation sinking for contexts.
Improved aliasing computation in presence of Redefinition and AssertAssignable.

Added possibility for inlining annotations via --enable-inlining-annotations flag.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41713 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-13 13:53:58 +00:00
fschneider@google.com 04563b8bce Fix crash with --trace-deoptimization-verbose and tweak formatting.
Uninitialized instances (e.g. closures) can't be printed using ToCString.
Print just the class instead.

Print values/addresses consistently with our disassembly output (no leading zeros)
This makes searching in the trace output easier.

Limit printing source lines to max 80 chars. Otherwise the trace output for
minified Dart code gets unreadable.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41134 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-15 15:49:40 +00:00
fschneider@google.com bdd6b29fd8 Revert r40306 because of crash.
TBR=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40312 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-16 12:14:33 +00:00
fschneider@google.com cd78dbe709 Refactor generating lazy deoptimization descriptors.
Instead of having special handling for closure calls, pass
the number of input operands down so that the correct lazy
deoptimization environment is generated at calls.

There is no functional change here - this is to simplify
having calls with pushed arguments and input operands
(like closure calls).

Runtime calls still do not have a correct lazy deoptimization environment
the environment should only be used for creating stack traces
from optimized code.

Fix a bug with --trace-deoptimization-verbose printing: We
cannot call ToCString on objects when the slots have not
been filled in yet. (e.g. Closures)

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40306 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-16 10:31:47 +00:00
vegorov@google.com 77c26187f2 Support allocation sinking for compound objects.
- Improve escape/alias analysis:
-- Storing an object into a field of another object does not mean that this object escapes (or has aliases) as long as that object does not have any loads from the same place;
-- Places like X.f and Y.f don't alias if X and Y are two different allocation instructions even if X and Y themselves potentially have aliases;
-- Improve precision of alias analysis for indexed properties;

- Support dematerialization and rematerialization of objects that are referenced by other dematerialized objects.
-- Use fix-point algorithm to collect candidates for allocation sinking;
-- Support aborting unsuccessful allocation sinking.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38404 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-18 18:35:08 +00:00
fschneider@google.com bd110db87a Use range information for optimizing integer boxing and fix bug in range analysis.
1. When the input to a BoxInteger operation is in smi-range, we can eliminate
the range check and just perform a smi-tag operation on the input.

2. There was a bug in checking for smi-overflow for range boundaries: Calling Smi::IsValid
with a int64_t argument resulted in silent truncation of the input and therefore a wrong result.

Compiling with -Wconversion would have caught this, but currently we cannot compile with this flag
because of too many broken places.

Instead, I removed Smi::IsValid64 and created one variant Smi::IsValid that is specialized for the
input type with a template parameter. This way calling Smi::IsValid is always safe and will never
 result in silent alteration of the input argument.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37657 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-24 13:41:48 +00:00
turnidge@google.com 18a8d7fe4c Fixes bug where we would occasionally materialize a corrupted object.
On the slow path for a stack overflow check we manually spill the live
registers before our call to the runtime function.  We were updating
all uses of these spilled registers in the Environment object but this
was not enough - we also need to update any uses of these spilled
registers in MaterializeObjectInstrs which are hanging off of the
Environment.

This would fail when a deoptimization was triggered during a stack
overflow check and a materialized object happened to refer to
registers.

I've been chasing this for a while and I was able to get it to
reliably reproduce by using the --stacktrace_every=N and the
--stacktrace_filter flags, which were added for this purpose.

ALSO:

Set the top context to null on exceptions/errors.  This is needed for
the --verify-incoming-context flag.

Minor printing improvements.

R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35443 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-25 20:24:27 +00:00
fschneider@google.com 1fbec40a7f Change deoptimization description for materialized objects.
Use field offset instead of fields as arguments in the deoptimization
instructions for materialization of objects. This is to prepare for
materializing contexts and fixed-size arrays when doing allocation sinking.

R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33267 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-04 11:53:16 +00:00
johnmccutchan@google.com ed5894d0cf Unbox/Box Float64x2 and inline typed array loads and stores
R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32869 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-20 20:41:54 +00:00
fschneider@google.com 15dfa97ab6 Fix bug and refactor optimized try-catch.
When untagged values flow into a exception-throwing instruction
 they need to be converted eagerly. Catch block entries assume all
 values are tagged at the entry.

 I changed the generation of moves at throwing
 instructions in try-catch: Instead of manuallu emitting moves,
 construct a parallel move and use the resolver to emit the native code.
 This eliminates a lot of duplicated code from all platforms.

 It will also allow to re-use stack space that is currently allocated
 separately for each individual try-catch in a function.

 I added a few more unrelated minor changes in various parts of the VM
 * Simpilify guard code generation
 * Resolve refactoring TODO in deoptimization
 * Improve names

R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31536 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-07 09:58:45 +00:00
fschneider@google.com e994d8b697 Revert r31326.
TBR=johnmccutchan@google.com,

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31332 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 12:21:09 +00:00
fschneider@google.com fe726e1971 Use parallel move resolver for optimized try-catch.
This CL has no change in functionality and is purely clean up and
refactoring. Instead of manually generating the moves at throwing
instructions in try-catch, construct a parallel move and use the resolver
to emit the native code. This eliminates a lot of duplicated code
from all platforms.

It will also allow to re-use stack space that is currently allocated
separately for each individual try-catch in a function.

I added a few more unrelated minor changes in various parts of the VM
* Simpilify guard code generation
* Resolve refactoring TODO in deoptimization
* Improve names

R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31326 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 09:41:42 +00:00
johnmccutchan@google.com 29c01044bc This is the final breaking change in dart:typed_data needed for Dart 1.0. We need this change because the ECMAScript SIMD specification only includes Int32x4 and Int32x4List and our types must match.
R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29849 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-04 21:56:59 +00:00
turnidge@google.com baeb23f9a5 Refactor some deoptimization code.
Primarily this change moves deoptimization state/code out of Isolate
and into DeoptContext (formerly DeoptimizationContext).  The lifetime
of DeoptizationContext changes to survive through the entire
deoptimization process.

Some minor renaming.  DeoptizationContext -> DeoptContext to make it
consistent with DeoptInstr and to save my wrists.

New files deferred_object.{cc,h} contain a bunch of the stuff lifted
from isolate.{cc,h}.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28112 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-01 19:34:12 +00:00