Commit Graph

58 Commits

Author SHA1 Message Date
Vyacheslav Egorov 229d793602 [vm/compiler] Support materializing unboxed variables when entering catch.
Previously we tried to rely on the assumption that all variables would be
boxed - so the machinery for setting correct catch-entry state only
supported tagged values and constants. However this both leads to worse code
and is not entirely correct assumption.

This also:

- renames various confusingly named classes: we move away from talking
about "catch entry state" to "catch entry moves" - because we only
record a subset of moves that needs to be performed and that does
not describe the whole state;
- refactors a bunch of associated code to be more readable and maintainable;
- adds documentation about catch implementation in optimized code
to runtime/docs/compiler;

Fixes https://github.com/flutter/flutter/issues/21685.

Change-Id: I03ae361a1bb7710acbd9f661ae014e663a163c59
Reviewed-on: https://dart-review.googlesource.com/74860
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 17:39:12 +00:00
Alexander Markov 2786b9ff43 [vm/aot] Add detailed error messages and stack traces for null checks
This CL fixes error message in NoSuchMethodError thrown by null checks
and line numbers in corresponding stack traces (in AOT).

Name of the called function is placed into object pool, and metadata
for null check site is generated in CodeSourceMap.

Size of flutter gallery in release mode:
	  Before	 After
RW	  2165286	 2201642	(+1.68%)
RO	  2122192	 2168224	(+2.17%)
RX	  6871072	 6871072	(+0.00%)
Total	 11163079	11245467	(+0.74%)

Closes https://github.com/dart-lang/sdk/issues/32863

Change-Id: I5ad1190f2ec9452a669863f7dd114ea5f9092d52
Reviewed-on: https://dart-review.googlesource.com/52703
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-26 20:33:15 +00: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
Ryan Macnak 8b96a31c7f Move runtime functions to the more logical runtime_entry.cc.
Make --trace-runtime-calls respect the isolate filter.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2827873002 .
2017-04-19 10:22:04 -07:00
Ryan Macnak a52db232d6 When generating CodeSourceMaps, reassign function ids once per function instead of once per inlining site.
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2768153002 .
2017-03-24 14:41:36 -07:00
Dmitry Olshansky 170aa90158 Re-landing of "replace TrySync with Metadata".
Use that to sync variables to predefined stack
slots inside of exception handler, not before
each MayThrow() instruction.

In JIT mode we can avoid storing extra metadata
by using deopt info instead.

Introduce caching of metadata and
exception handler based on PC.

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

Review-Url: https://codereview.chromium.org/2734323003 .
2017-03-13 13:27:00 +01:00
Dmitry Olshansky a1f784e643 Revert "Replacing TrySync with Metadata"
This reverts commit cf08eebc71.

TBR=vegorov@google.com

Review-Url: https://codereview.chromium.org/2739663002 .
2017-03-07 16:17:59 +01:00
Dmitry Olshansky cf08eebc71 Replacing TrySync with Metadata
Use that to sync variables to predefined stack
slots inside of exception handler, not before
each MayThrow() instruction.

In JIT mode we can avoid storing extra metadata
by using deopt info instead.

Introduce caching of metadata and
exception handler based on PC.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2640853002 .
2017-03-07 11:33:07 +01:00
Kevin Millikin f31b6d5e2c Reland "Track the 'awaiter return' call stack..."
Original CL: https://codereview.chromium.org/2692803006/

Original commit message:
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2725623003 .
2017-02-28 16:13:41 +01:00
Kevin Millikin a0965a641f Revert "Track the 'awaiter return' call stack..."
Revert a pair of commits that cause failure of the Kernel continuation
transformer:

  cba7e3e79a
  4fe4f177de

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2718353002 .
2017-02-28 12:46:31 +01:00
John McCutchan cba7e3e79a Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

Fixes #27242

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2692803006 .
2017-02-27 14:16:15 -08:00
Ryan Macnak cfe5e5f075 Include metadata in AOT to expand inline frames in stack traces and provide line numbers.
Also fix stack trace collection to always include invisible frames. It can happen that a visible function is inlined into an invisible function, and we don't expand inlined frames until we print a stack trace.

dart2js product x64:
compile time: 12.459s
VMIsolate(CodeSize): 152292
Isolate(CodeSize): 3343117
ReadOnlyData(CodeSize): 3728928
Instructions(CodeSize): 8677600
Total(CodeSize): 15901937
->
compile time: 14.195s (+13%)
VMIsolate(CodeSize): 174034
Isolate(CodeSize): 3892418 (+16%)
ReadOnlyData(CodeSize): 5036320 (+35%)
Instructions(CodeSize): 8682624
Total(CodeSize): 17785396 (+12%)

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2687143005 .
2017-02-13 10:27:36 -08:00
Ryan Macnak b15b98bcc3 Reapply "Use CodeSourceMap for stack traces (still JIT only)."
- Fix missing null termination in initialization of ZoneTextBuffer.
 - Merge with John's async stack trace changes.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2686813006 .
2017-02-09 18:03:41 -08:00
Ryan Macnak 15a9eafb77 Revert "Reapply "Use CodeSourceMap for stack traces (still JIT only).""
This reverts commit bee82fef8b.

Revert "Use zone memory for StackTrace::ToCString."

This reverts commit 4e8b265ea0.

The later CL somehow caused hangs in some service tests.

Review-Url: https://codereview.chromium.org/2683033007 .
2017-02-09 13:14:01 -08:00
Ryan Macnak bee82fef8b Reapply "Use CodeSourceMap for stack traces (still JIT only)."
Include CodeSourceMaps in app-jit snapshots.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2686623006 .
2017-02-08 16:43:47 -08:00
Ryan Macnak 9e3bd0ef0a Revert "Use CodeSourceMap for stack traces (still JIT only)."
Failed with app-jit snapshots.

This reverts commit 7d2e6b1615.

Review-Url: https://codereview.chromium.org/2685723004 .
2017-02-08 13:33:23 -08:00
Ryan Macnak 7d2e6b1615 Use CodeSourceMap for stack traces (still JIT only).
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2684763002 .
2017-02-08 11:31:46 -08:00
Ryan Macnak 909ce02b12 Encode inlining information in CodeSourceMap and remove inlining interval arrays.
CodeSourceMap now contains a small bytecode that describes changes to the token position and inlining stack as one moves through a function. This information is used by the disassembler to display inlining comments and by the profiler to properly blame ticks against source code.

Slightly shrinks the total size of code metadata; on dart2js compiling hello world, the final heap is

 before 59.6MB total, 12.8MB List, 1.1MB CodeSourceMap
  after 59.4MB total, 12.1MB List, 1.5MB CodeSourceMap

To be filtered and included in AOT code to expand inline frames in stack traces.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2670843006 .
2017-02-07 12:52:21 -08:00
John McCutchan f125cc7d0b Improve the casing of Stackmap and Stacktrace.
- [x] Stackmap -> StackMap
- [x] Stacktrace -> StackTrace

This makes us consistent with the Dart language (StackTrace) and
corrects the casing of StackMap.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2572563004 .
2016-12-12 14:51:30 -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
John McCutchan d77d376124 Replace intptr_t with TokenDescriptor
- Use TokenDescriptor instead of intptr_t for all token positions.
- Use TokenDescriptor in raw_object instead of int32_t.
- TokenDescriptor is a POD with an int32_t (this shrinks the size of AST and IR nodes by 32-bits on 64-bit architectures).

There are some cleanups I plan on doing as a follow up CL:

- Replace TokenDescriptor::value() with TokenDescriptor::TokenPos()

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

Review URL: https://codereview.chromium.org/1644793002 .
2016-02-02 10:15:44 -08:00
John McCutchan b5259257bd Introduce CodeSourceMap object to hold pc -> token position mappings
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1634863002 .
2016-01-26 13:07:22 -08:00
Florian Schneider e9968ca5ff Fix VM bug with try-catch inside of try-finally.
There were two exception handlers with the same index added to the code so that only the one added
last was executed. In case of an exception that means that a re-throw may be omitted, causing invalid
control flow.

Also, add assertion to ensure unique try-index for exception handlers.

BUG=#25333
R=hausner@google.com

Review URL: https://codereview.chromium.org/1569523002 .
2016-01-06 18:50:53 +01:00
Ryan Macnak 300a2f34cf Delta encode pc descriptors, and combine pc kind and try index into single field.
328.3kB -> 126.8kB (-61.4%) mirrors_reader_test

Avoid quadratic var-int decoding in extracting edge counters by decoding once into a temporary list.

R=fschneider@google.com

Review URL: https://codereview.chromium.org//1128183007
2015-05-18 11:04:45 -07:00
rmacnak@google.com 848ad67ee1 Revert "Delta encode pc descriptors."
32% regression on dart2js. Edge counters need to be redone first.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45776 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-13 20:24:47 +00:00
rmacnak@google.com ab784887a7 Delta encode pc descriptors.
328.3kB -> 160.1kB (-51.2%) for mirrors_reader_test

R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45715 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 20:27:21 +00:00
srdjan@google.com 5692c024bb Fix crash in x64: handler's pc-offset must be in 32-bit uword range ( x64 -1 is out of range). Use kInvalidPcOffset = 0.
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44443 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-12 21:40:05 +00:00
srdjan@google.com b232f6d070 Fix issue 22800: Unreachable exception handlers do not have their handler types initialized. Initialize the handler info for unreachable handlers as well (instead of crashing).
R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44440 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-12 19:18:18 +00:00
fschneider@google.com b79f717e89 VM: Use PC offset instead of absolute PC in exception handler info.
Similar to the change I did for PC descriptors: We can save space by
using a uint32_t for the offset, instead of a uword for the absolute pc.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43138 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-26 15:40:06 +00:00
regis@google.com ef1c21b293 Fix issue 21795.
Add regression test.

R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42824 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 17:16:50 +00:00
hausner@google.com 48807614ee Eliminate 99% of allocated ExceptionHandler objects
The vast majority of functions have no exception handlers, thus they can all
share a single ExceptionHandler descriptor.

This CL reduces the number of ExceptionHandler objects on the heap from
about 8400 to 16, from 132KB to less than 1KB, when running dart2js.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40323 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-16 16:27:04 +00:00
srdjan@google.com 9c8a395f6f More PcDescriptor cleanups, compress recors if no try index is needed (frequent).
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38242 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-15 17:07:03 +00:00
srdjan@google.com 2bb77cd8d5 Iterate over PcDescriptors only via iterators, not via an index. (preparation for more compression of PcDescriptors).
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38032 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-07 18:25:45 +00:00
srdjan@google.com 5ce61408ae Fix SIMARM64 to compile on Mac, fix compilation because of ICData change.
R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35460 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-26 00:13:32 +00:00
regis@google.com e0ab99b0b2 Remember all deopt reasons in ic_data, not just the last one.
Remember if a JS warning was issued in ic_data.
Save a word in ic_data on 64-bit platforms.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35457 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-25 23:45:14 +00:00
srdjan@google.com d78737298c Last cleanup int -> intptr_t. Also removed a hack (boolean is not an integer).
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28372 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-08 18:54:00 +00:00
srdjan@google.com 97891ce193 If a rethrow is encountered in the catch block, then its handler must be marked that it needs stacktrace. Fix issue r12584.
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26963 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-31 00:26:47 +00:00
srdjan@google.com cfb81a40aa Last round of cleanups in exception handler, before going to the next stage.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26941 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-30 20:47:02 +00:00
srdjan@google.com e06ea63b60 Mark exception handlers if they have a stacktrace specified. Do not build a stacktrace if the handler has no stacktrace.
R=asiva@google.com, hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26823 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-28 22:42:21 +00:00
hausner@google.com 79f4b5b61b Simplify exception handler table
Sort entries and drop the try_index field. This simplifies lookup
of exception handlers when walking the traces on exceptions.
Review URL: https://codereview.chromium.org//11970024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17179 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-17 01:10:42 +00:00
hausner@google.com 245c0e2c3e Collect debugging info for catch clauses
Collect info about try-statement nesting, and a list of
handled types in each catch clause. This will be used by
the debugger to determine whether an exception is handled
by any handler on the stack.
Review URL: https://codereview.chromium.org//11883023

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17100 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-15 22:43:00 +00:00
kmillikin@google.com d7115e5eda Remove deoptimization index PC descriptors.
Put the PC (offset) of the deoptimization point and the deoptimization
reason in the DeoptInfo table.  The table entries are now triples of
(PC offset, info, reason).

R=srdjan@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13056 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-01 10:16:22 +00:00
srdjan@google.com caf04303f7 Deoptimization can occur at Dart calls (includes native calls to C) but not at runtime calls. This assumption (verified with Todd and Gilad) simplifies the implementation of lazy deoptimization considerably.
Add flag --deoptimize-alot, which will lazily deoptimize all live optimized frames. Currently only the presence of deoptimization information is checked.

Add kDeoptAfter deoptimization point, which is the continuation for lazy deoptimization, after a call. Rename kDeopt to kDeoptBefore.

Removed a tests case that called into a native without properly setting up a Dart frame (Ok-d by Siva).

Native functions are not optimizable.

TODO: Split deoptimization information from DeoptimizationStubs. Check for redundant PcDescriptor information (what can be merged, especially at calls).
Review URL: https://chromiumcodereview.appspot.com//10885039

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11642 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-30 18:53:46 +00:00
kmillikin@google.com 8122966c80 Put live register bits in stackmaps.
Add a count of live registers to each stackmap and add bits describing the
registers.  This allows untagged values in general purpose registers at
safepoints.

R=vegorov@google.com
BUG=

Review URL: https://chromiumcodereview.appspot.com//10882055

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11595 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-30 10:20:26 +00:00
kmillikin@google.com a953c03b36 Use the location summary to represent safepoint information.
Pass a LocationSummary everywhere instead of a BitmapBuilder.  The
LocationSummary contains information about live registers.

R=vegorov@google.com
BUG=

Review URL: https://chromiumcodereview.appspot.com//10873027

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11219 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-23 10:08:37 +00:00
kmillikin@google.com 94a5b82f60 Make stackmaps store their actual length.
This allows stackmaps with varying lengths in the same function, necessary
for the way we plan to support bitmaps for saved live registers.

R=vegorov@google.com
BUG=

Review URL: https://chromiumcodereview.appspot.com//10837303

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11019 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-21 08:43:32 +00:00
kmillikin@google.com 6c7d65e482 Reduce space used for stackmaps.
Only allocate space for the bits covered by the stackmap, instead of
for the backing store of the utility class that built it.  Fix a bug
where the size in bytes was multiplied by the word size in bytes.

Also do some cleanup of the stackmap code and renaming in the tests.

BUG=

Review URL: https://chromiumcodereview.appspot.com//10832292

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10870 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-17 07:57:47 +00:00
regis@google.com 6f5281c404 Get rid of ast node ids.
Rename cid to deopt_id.
Review URL: https://chromiumcodereview.appspot.com//10832150

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10306 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-06 20:24:03 +00:00
srdjan@google.com 85f242dbb1 Adding deopt info to code object.
Review URL: https://chromiumcodereview.appspot.com//10830131

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10189 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 18:28:11 +00:00