Commit Graph

66 Commits

Author SHA1 Message Date
Liam Appelbe e4196ce8c6 [vm] Namespace constants like offsets and sizeofs to use runtime_api.h
Second sub-CL of https://dart-review.googlesource.com/c/sdk/+/100644
The first was here https://dart-review.googlesource.com/c/sdk/+/103487

Now that offsets_extractor is checked in, and we have a big header full
of hard coded constants, the next step is to make sure everything is
using those constants. This is essentially everything in the original
CL, except the new simarm_x64 architecture.

Bug: https://github.com/dart-lang/sdk/issues/36839
Change-Id: I236e4f30aa1df6d92209891c983b792d1835b608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104286
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-10 02:55:25 +00:00
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
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
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
Ryan Macnak 04100796c1 [vm, aot] Further debugging aids for null function encountered when writing DWARF inlining data.
Bug: https://github.com/dart-lang/sdk/issues/31952
Change-Id: Iaf677c2dd15567772d1bb9f2482e749ef1139fe2
Reviewed-on: https://dart-review.googlesource.com/42060
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-02-16 20:48:59 +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
Aske Simon Christensen cec963f028 The current growth strategy for growable arrays allocates a backing array of size 2 at (empty) creation and doubles the size whenever the capacity is insufficient while adding elements.
I collected statistics for the sizes and capacities of growable arrays which are promoted to old-space or survive an old-space gc when running dart2js and Fasta. For these applications, the vast majority of arrays stay empty. More than half of the total object size of promoted backing arrays is backing for empty growable arrays.

Furthermore, since the overhead for an array is 3 words (header, type parameters and length), and object sizes are rounded up to an even number of words, we waste one word for all even-sized arrays.

This CL changes the growth strategy so that empty growable arrays are created with a shared, zero-sized array as backing, avoiding the allocation of a backing array if no elements are added. When the array needs to grow, it starts out at 3 and grows to double size plus one each time: 7, 15, 31, ...

A few places in the VM code need to handle these shared, zero-sized arrays specially. In particular, the Array::MakeArray function needs to allocate a new, empty array if its result is to be returned to Dart code.

Benchmarks suggest that the change improves memory usage by a few percent overall and does not significantly affect run time.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2949803002 .
2017-06-22 10:51:54 +02:00
Ryan Macnak 0867d87767 Resolve initialization order fiasco between code_descriptors.cc and token_position.cc.
BUG=b/36622728
R=asiva@google.com, johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2772193004 .
2017-03-27 10:24:01 -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
Matthias Hausner 356581ff76 Fix language/regress_28325 in precompiled mode
This is a follow-up CL to https://codereview.chromium.org/2727803002/
That fixes the stack trace in precompiled code.

BUG=#28770
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2731593002 .
2017-03-02 14:12:20 -08: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
Ryan Macnak 48af897a3e When a catch is unreachable, use the canonical empty array instead of null as its type array.
R=iposva@google.com

Review URL: https://codereview.chromium.org/1753053003 .
2016-03-02 09:46:21 -08:00
John McCutchan 761e6a5963 Build CodeSourceMap for each code object
- Add helpers for building CodeSourceMap to FlowGraphCompiler. Ensure that no duplicate pc offsets are added to a CodeSourceMap.
- Add a CodeSourceMap debug printer which incorporates inlining information.
- Add some new classifying token positions.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1740503002 .
2016-02-26 07:59:48 -08:00
Florian Schneider d8677964a3 Move precompilation-related flags to flags list.
They become compile-time constants in the precompiled runtime, and in product mode.

In precompiled product mode, the precompiled value has precedence.

BUG=
R=rmacnak@google.com

Committed: https://github.com/dart-lang/sdk/commit/5c9f18c6c87284395564051a052cc4acc9b6f59a

Review URL: https://codereview.chromium.org/1731743003 .
2016-02-25 07:53:39 -08:00
Ryan Macnak bd85deaf4e Revert "Move precompilation-related flags to flags list."
The default value of print_stop_message was architecture specific.

TBR=fschneider@google.com

Review URL: https://codereview.chromium.org/1739593002 .
2016-02-24 18:08:01 -08:00
Florian Schneider 5c9f18c6c8 Move precompilation-related flags to flags list.
They become compile-time constants in the precompiled runtime, and in product mode.

In precompiled product mode, the precompiled value has precedence.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1731743003 .
2016-02-24 17:31:08 -08: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
Florian Schneider d76fe1eacd Clean up global variables related to precompilation.
Replace always_optimize_ and allow_recompilation_ with
 FLAG_precompilation and !FLAG_precompilation.

They are equivalent and set only once according to the
--precompilation flag

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1657153002 .
2016-02-01 19:11:42 -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
Ryan Macnak 238c01b943 Precompilation: omit pc descriptors without a try index.
precompiled dart2js x64 24749045 -> 23713811 (-4.18%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1584393003 .
2016-01-19 14:53:23 -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
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 dd824bd017 Store pc offset instead of absolute pc in the pc descriptors.
This saves space on 64-bit platforms as the offset is stored
as a uint32_t compared to a pointer-size absolute address.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43100 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 12:30:11 +00:00
srdjan@google.com 054eeb87a6 Reduce number of times a deopt-id is computed.
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40716 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-26 16:42:50 +00:00
zra@google.com c686b2c624 Finishes removing intptr_t from raw object fields.
Also removes {Read,Write}IntptrValue from the snapshot reader and writer.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40048 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-09 19:51:22 +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
fschneider@google.com cc9e3b8068 Introduce a lazy-compile stub for functions.
The function's code pointer is either a lazy-compile stub
or the compiled code. The function is compiled on invocation.

There is no need to check for null when invoking a function. This means
one check less when invoking functions via a stub. For this I added a  LazyCompile
stub.

Additional cleanup in Stackmap and PcDescriptors (remove unused code pointer,
and changed smi-lengh into a raw integer).

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34643 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-02 12:37:48 +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 849e8b0385 Make sure that all objects store in the Code object live in old space.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25353 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-23 18:38:03 +00:00
asiva@google.com f4fe42c280 Added macros OBJECT_IMPLEMENTATION and FINAL_OBJECT_IMPLEMENTATION
which have different implementations of 'operator=' and 'operator^='.
In the case of FINAL_OBJECT_IMPLEMENTATION we do not do the vtable setting
in these methods (Note the |= operator functionality is now subsumed into
the new implementation of "operator^=")
Review URL: https://codereview.chromium.org//12052033

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17491 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-23 20:01:31 +00:00
srdjan@google.com d56766f251 More ^= to |=
Review URL: https://codereview.chromium.org//11941021

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17308 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-18 19:43:19 +00:00