Commit graph

21 commits

Author SHA1 Message Date
Samir Jindel f5fc335a4c [kernel] Check bounds of type arguments in strong mode.
Change-Id: I2cb230db322cc26fb62e932b40882200de38c3d4
Reviewed-on: https://dart-review.googlesource.com/24180
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-01 14:55:56 +00:00
Alexander Markov 0af232924c [VM, Compiler] Add initial implementation of check null instruction
This CL introduces new IL instruction, CheckNullInstr, for testing
if an object is null. This instruction will be used to ensure
correctness when AOT relies on strong mode types, which are nullable
by default (unless proven otherwise).

Code generation of CheckNullInstr is implemented without major code
duplication between different CPUs using common macro-assembler
pseudo-instructions implemented by all platforms.

Also, code generation of GenericCheckBoundInstr is refactored in
the similar way.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I35e9b556302fe7db98ce5167b3601f08ddbee642
Reviewed-on: https://dart-review.googlesource.com/4540
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-09-12 19:25:43 +00:00
Vyacheslav Egorov 7887c34a29 VM(RegExp): Allow OSR optimization of RegExp :matcher functions.
Previously these functions would only contain a single CheckStackOverflowInstr
in a backtracking block and that CheckStackOverflowInstr would have a zero
loop_depth - which means it would not be considered eligable for OSR.

This change:

* adds CheckStackOverflowInstr with non-zero loop_depth in two other places
  (Boyer-Moore lookahead skip loop and greedy loop) where loops arise in the
  generated IL;
* sets non-zero loop depth on the CheckStackOverflowInstr in the backtracking
  block;
* adds a flag on CheckStackOverflowInstr that allows optimizing compiler to
  optimize away those checks that were inserted solely to serve as OSR entries.
* ensures that IR generated by IRRegExpMacroAssembler is OSR compatible:
  * GraphEntryInstr has correct osr_id;
  * GraphEntry and normal entry have different block ids (B0 and B1 - instead of B0 and B0);
  * unreachable blocks are pruned and GraphEntry is rewired to point to OSR entry;
  * IRRegExpMacroAssembler::GrowStack should not assume that  stack_array_cell and :stack
    are always in sync, because :stack can come from OSR or deoptimization why stack_array_cell
    is a constant associated with a particular Code object.
* refactors the way the RegExp stack was growing: instead of having a special instruction
  just emit a call to a Dart function;
* refactors the way block pruning for OSR is done by consolidating duplicated code
  in a single function.

We allow the optimizing compiler to remove preemption checks from
non-backtracking loops in the regexp code because those loops
unlike backtracking have guaranteed O(input_length) time
complexity.

Performance Implications
------------------------

This change improves performance of regexps in cases where regexp spends a lot
of time in the first invocation (either due to backtracking or due to long non
matching prefix) by allowing VM to optimize the :matcher while :matcher is
running.

For example on regex-redux[1] benchmark it improves Dart performance by 3x
(from ~18s to ~6s on my Mac Book Pro).

CL history
----------

This relands commit d87cc52c3e.

Original code review: https://codereview.chromium.org/2950783003/

[1] https://benchmarksgame.alioth.debian.org/u64q/program.php?test=regexredux&lang=dart&id=2

R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2951053003 .
2017-06-23 12:51:53 +02:00
Erik Corry 9b1b85b48c Remove unused code for stubs with three checked args
R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2667963005 .
2017-02-01 10:27:26 +01:00
Todd Turnidge e0d350aa27 Implement rewind on all platforms except for dbc.
BUG=

Review URL: https://codereview.chromium.org/2534413005 .
2016-12-01 17:19:31 -08:00
Todd Turnidge 193ddba4db Revert "Implement rewind: drop one or more frames from the debugger."
This reverts commit af1875be91.

BUG=

Review URL: https://codereview.chromium.org/2521413002 .
2016-11-22 16:05:26 -08:00
Todd Turnidge af1875be91 Implement rewind: drop one or more frames from the debugger.
Not yet implemented on dbc.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2523053002 .
2016-11-22 15:26:08 -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
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 2bc6e0a71d AOT: Add a separate switchable call state for unlinked calls.
Flutter gallery
Isolate(CodeSize): 2213525 =>
Isolate(CodeSize): 2070395 (-6.4%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2357313003 .
2016-09-26 10:34:36 -07:00
Ryan Macnak ba94427eb1 AOT: When a call goes polymorphic but has a single target, transition to a stub that does a cid range check.
Expand the range on a miss if all classes in the range have the same lookup result, otherwise transition to the stub that does a linear scan of ICData.

Because we do a depth-first sort of classes during AOT, if a call site sees only objects all inheriting the same function as the call target, the call site will be handled by this new stub.

Adjust LoadClassIdMayBeSmi on x64 to preserve the object.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2279563002 .
2016-08-31 11:12:22 -07:00
Ryan Macnak 7ff2dd4117 Optimize AOT's switchable calls for the monomorphic case.
The call sequence is very similar to a classic IC call, except the guarded class and the target are loaded indirectly from the constant pool instead of as immediates. In the monomorphic case, we call directly to the expected target with a class check in the callee. In the unlinked, polymorphic and megamorphic cases, we call a stub; these case are now call-through instead of call-and-return.

Every code, except stubs involved in switchable calls, includes the class check sequence at the beginning. So we now distinguish between a checked and an unchecked entry point. Generated code except the switchable call continues to use the unchecked entry point.

PC offsets are calculated relative to the beginning of the instruction stream, rather than either entry point.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2226893002 .
2016-08-12 11:18:35 -07:00
Florian Schneider d3810213b0 VM: Array bounds checks that don't deoptimize for precompiled code.
1. Make CheckArrayBoundInstr also check the index for smi. This allows easy replacement
of the deoptimizing checks with the slow-path checks in the precompiler.

2. Add GenericCheckBoundInstr which has a slow-path attached for
handling check failures.

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

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

Committed: 4a5f651c4b
2016-07-15 10:07:41 -07:00
Ryan Macnak 2a535414bc Revert "VM: Array bounds checks that don't deoptimize for precompiled code."
This reverts commit 4a5f651c4b.

Review URL: https://codereview.chromium.org/2152683003 .
2016-07-14 13:28:23 -07:00
Florian Schneider 4a5f651c4b VM: Array bounds checks that don't deoptimize for precompiled code.
1. Make CheckArrayBoundInstr also check the index for smi. This allows easy replacement
of the deoptimizing checks with the slow-path checks in the precompiler.

2. Add GenericCheckBoundInstr which has a slow-path attached for
handling check failures.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2149023002 .
2016-07-14 10:48:50 -07:00
Florian Schneider 4ab3a12a0c VM: Optimized calls to asin, acos, tan.
Reorganize a long chain of if-else-if into a switch.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1670113004 .
2016-02-08 14:21:51 +01:00
Florian Schneider 5e680a2938 VM: Support fast calls to atan and atan2 in optimized code.
BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1662153002 .
2016-02-04 13:57:36 -08: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: 1d343e5a7b

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
Ryan Macnak 9d8dcd1288 Load runtime entries from the Thread instead of the ObjectPool.
Removes the need to relocate their ObjectPool entries when loading a precompiled snapshot.

Saves about ~2kB of ObjectPool in hello_world at the cost of ~400B/Thread (64-bit).

R=fschneider@google.com

Review URL: https://codereview.chromium.org//1315893004 .
2015-09-02 14:58:26 -07:00