Commit Graph

36 Commits

Author SHA1 Message Date
Martin Kustermann 130c654dcd [vm/compiler] Avoid runtime call for _asyncStackTraceHelper if !FLAG_causal_async_stacks
Even though the FLAG_causal_async_stacks can be used to disable causal
async stack traces, the generated code would still call to the runtime,
which would simply return `null`.

To avoid this runtime call we recognize the method in the 2 flow graph builders.

Issue https://github.com/dart-lang/sdk/issues/37668

Change-Id: I896807060db911714d47a462c34696a0a3def62f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110919
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-07-31 19:49:51 +00:00
Ryan Macnak 38049f3cb6 [vm, interpreter] Handle implicit static getters as bytecode.
Handle bytecode without a function in stack trace collection.

Bug: https://github.com/dart-lang/sdk/issues/36410
Change-Id: I828fbc11fb0c7ad617ff7a31f44adb021f9b6edf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99378
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-17 19:48:37 +00:00
Daco Harkes 14ff2110ce [vm] refactor native entry and native entry type arguments
Change-Id: I03efbbf4340de1c8f23c60854ed991671ca2b647
Reviewed-on: https://dart-review.googlesource.com/c/87077
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-12-13 19:29:26 +00:00
Ryan Macnak e1ffe76a36 [vm] Replace StubEntry with Code handles.
StubEntry was holding raw pointers across safepoints in several places in the compiler.

Bug: https://github.com/dart-lang/sdk/issues/34934
Change-Id: Id17cb7651f4d3508915c8cb90f5cb2353df6dac0
Reviewed-on: https://dart-review.googlesource.com/c/85040
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-21 17:45:11 +00:00
Régis Crelier f721d52163 [VM runtime] Introduce a new VM class Bytecode.
Allow pc_marker slot to hold a Code object or a new Bytecode object.

Change-Id: If11c1df6dafc5b1cfcce6f0322c36d1d68e86df9
Reviewed-on: https://dart-review.googlesource.com/c/82526
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-14 02:48:03 +00:00
Martin Kustermann 35b17f3730 [VM] Consistently use ValidationPolicy in frame iteration APIs
Previously there were places in the code where an API accepted a
`bool validate_frames` and call sites passed an enum value (which
implicitly got converted to a bool).

By changing the APIs to require an enum, the compiler will tell us if a
caller doesn't pass one.

Change-Id: I29fcd0b018e6cdd7e00b5bb03e83b9636d1345d4
Reviewed-on: https://dart-review.googlesource.com/57823
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-04 14:46:26 +00:00
Zachary Anderson 952345ff84 Remove the debugger_ field from Isolate in a PRODUCT build.
This is the first in a series of CL in which I am removing fields from
classes that aren't used in PRODUCT mode. This CL removes the
debugger_ field from Isolate.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2981173002 .
2017-07-18 13:29:40 -07:00
Vyacheslav Egorov c6815e8522 Reapply 0489249d29 with a fix for front_end tests.
Proper sequencing of _asyncStackTraceHelper in Kernel

This helper function was being called before its argument was
initialized so it was passing null.  Instead, it should be called
after its argument is initialized.

Because the initialization happens in Kernel code, it is simplest to
insert the call explicitly in Kernel code as well as part of the async
transformation.  This has the consequence that we now call the helper
function even when the flag causal_async_stacks is false.

Fixes issue #29771.
Fixes issue #30178
Fixes issue #30058

BUG=
R=aam@google.com, asiva@google.com

Review-Url: https://codereview.chromium.org/2936793003 .
Review-Url: https://codereview.chromium.org/2982943002 .
2017-07-17 20:56:28 +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
Ryan Macnak f1b7e8ed8c Add gdb helper functions for creating a handle and using ToCString with RawObjects.
Improves gdb debugging when Object::Handle() is optimized away.

Replace some intermediate static_libraries with source_sets to fix export issue.

R=regis@google.com, vegorov@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2957843002 .
2017-06-29 14:31:44 -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
Kevin Millikin 8340cfda55 Revert "Proper sequencing of _asyncStackTraceHelper in Kernel"
This reverts commit 0489249d29.  The
change causes failures in the front end tests.

BUG=
R=sivachandra@google.com

Review-Url: https://codereview.chromium.org/2949533003 .
2017-06-19 17:21:22 +02:00
Kevin Millikin 0489249d29 Proper sequencing of _asyncStackTraceHelper in Kernel
This helper function was being called before its argument was
initialized so it was passing null.  Instead, it should be called
after its argument is initialized.

Because the initialization happens in Kernel code, it is simplest to
insert the call explicitly in Kernel code as well as part of the async
transformation.  This has the consequence that we now call the helper
function even when the flag causal_async_stacks is false.

Fixes #29771.

BUG=
R=aam@google.com, asiva@google.com

Review-Url: https://codereview.chromium.org/2936793003 .
2017-06-19 16:52:58 +02:00
Martin Kustermann ac8d2056a3 Fix asserts in StackFrameIterator which were effectively disabled
The assertions which tried to assert that we only use
StackFrameIterator to walk frames of the current thread was incorrect.
We already have cases where other threads will walk the stack of the
mutator thread, see below for an example where this can happen.

Thread::VisitObjectPointers was incorrectly passing Thread::Current() to
the StackFrameIterator instead of 'this'.  (Code in thread_registry.cc will
loop over a number of threads and calls VisitObjectPointers on them)

  Mutator thread:

    0  pthread_cond_wait@@GLIBC_2.3.2
    1  dart::Monitor::WaitMicros
    2  dart::Monitor::Wait
    3  dart::MonitorLocker::Wait
    4  dart::ThreadBarrier::Sync
    5  dart::GCMarker::MarkObjects
    6  dart::PageSpace::MarkSweep
    7  dart::Heap::CollectOldSpaceGarbage
    8  dart::Heap::CollectNewSpaceGarbage
    9  dart::Heap::CollectGarbage
    10 dart::DN_HelperObject_<native>
    11 dart::BootstrapNatives::<native>
    <dart frames>

  MarkTask thread:

    1  dart::EntryFrame::VisitObjectPointers
    2  dart::Thread::VisitObjectPointers          <---- Walks mutator thread stack
    3  dart::ThreadRegistry::VisitObjectPointers  <---- Iterates over a number of threads
    4  dart::Isolate::VisitStackPointers
    5  dart::Isolate::VisitObjectPointers
    6  dart::GCMarker::IterateRoots
    7  dart::MarkTask::Run
    8  dart::ThreadPool::Worker::Loop
    9  dart::ThreadPool::Worker::Main
    10 dart::ThreadStart

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2845053003 .
2017-05-03 10:27:01 +02:00
John McCutchan dacadf89d1 Hacky fix for kernel bots
BUG=

Review-Url: https://codereview.chromium.org/2766353005 .
2017-03-24 12:18:21 -07:00
John McCutchan 07a257573d Debugger support for step-into async and async* functions.
- [x] Support stepping into an async function.
- [x] Support stepping into the async generator in an await for loop.
- [x] Unit test for async function.
- [x] Unit test for async* function.

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

Review-Url: https://codereview.chromium.org/2768103002 .
2017-03-24 07:56:50 -07:00
John McCutchan 2c52f8423d Fix missing top frame in exception stacks in product mode
BUG=

Review-Url: https://codereview.chromium.org/2688783002 .
2017-02-09 16:11:22 -08:00
John McCutchan a0ee5b24db Track async causal stack traces
This CL improves the stack traces that accompany exceptions. Whenever an
async function is entered, we remember how we got there. This is similar
in spirit to package:stack_trace but the implementation is more efficient
and memory usage can be more easily reasoned about.

Tracking causal stack traces:

- [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Before returning from an async function, clear the Thread's asynchronous stack trace.
- [x] After resuming an async function, load the sychronous stack trace prefix into the Thread.
- [x] Filter stack traces to remove async machinery.

Service protocol changes:

- [x] Send causal async stack trace.

Observatory changes:

- [x] Display causal async stack trace below async functions.

Fixes https://github.com/dart-lang/sdk/issues/27661

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

Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2646443005 .
2017-02-09 15:39:44 -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 2e4dfd3a2d clang-format runtime/lib
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2468093007 .
2016-11-04 12:14:41 -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
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
Todd Turnidge 2232a52ff8 Print stack trace when Dart_SetReturnValue is passed UnwindError.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1652873004 .
2016-02-01 10:46:49 -08:00
Lasse R.H. Nielsen 027b8dca39 Add StackTrace.current getter.
R=floitsch@google.com, iposva@google.com, sra@google.com

Review URL: https://codereview.chromium.org/1448003002.
2015-11-24 08:26:03 +01:00
iposva@google.com ebabd58de8 - Add a _fatal helper function into dart:core, so that we can
abort if we get into an unrecoverable state in the core library.

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44010 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 23:27:56 +00:00
iposva@google.com db9faebe98 - Simplify collection of stack traces. If we determine that a stack
trace is needed we collect the full stack trace instead of piecing
  it together as we walk up the stack.

R=rmacnak@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43863 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-19 02:18:53 +00:00
iposva@google.com 98e0500c87 - Remove obsolete stack trace functions.
R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43802 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-16 22:53:19 +00:00
rmacnak@google.com db79e9cca6 Rename is_visible to is_reflectable; use is_debuggable instead of is_reflectable to decide whether to filter a frame from stack traces.
Merge verbose_stacktrace flag into show_hidden_frames.

Don't mark native functions as non-debuggable (breakpoints don't actually work there now but nothing goes wrong).

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43121 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 21:16:40 +00:00
jacobr@google.com 8fd3f6a789 Workaround stacktrace crasher bug in the VM.
Fix for bug setting breakpoint after app reload.

BUG=
R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35401 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-24 20:34:19 +00:00
srdjan@google.com e3ce299913 Traverse inlined frames lazily when printing the stacktrace. No need to carry separate function and code array, since function can always be extracted from code.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27209 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-05 20:25:00 +00:00
asiva@google.com d6aaf0cc94 1. Add flag --trace-api to trace API function invocation
2. Add tracing of external native functions under --trace-natives flag
3. Added a _printCurrentStacktrace() function so that one could get a
   dart stack trace under 'gdb' when in a native or runtime function.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27166 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-04 23:42:13 +00:00
srdjan@google.com 8cd4bf5b92 Change inlined stack frame iterator to use code and pc instead of frame.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27140 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-04 19:36:20 +00:00
fschneider@google.com 98070a3bec Collect all Dart frames when creating a full stacktrace.
BUG=https://code.google.com/p/dart/issues/detail?id=11261
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25867 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-07 09:32:14 +00:00
regis@google.com 09bcdc6d6d Fix VM implementation of CastError not to extend TypeError (issue 5280).
Remove non-compliant fields in various Error classes (issue 10144).
Remove implicit constructor when patching in a constructor (issue 12217).
Patch corelib Error classes instead of declaring subclasses.
Update tests and status files.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25782 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-05 18:35:04 +00:00
asiva@google.com 48418a75f7 Fix stack frame index numbers for full stack traces
It used to be:
#0      getCurrentStackTrace (file:///tmp/junk.dart:3:5)
#0      func1 (file:///tmp/junk.dart:10:29)
#1      func2 (file:///tmp/junk.dart:14:8)
#2      func3 (file:///tmp/junk.dart:18:8)
#3      func4 (file:///tmp/junk.dart:22:8)
#4      main (file:///tmp/junk.dart:26:8)
(Notice the two #0 frames on top).

Now it will print this as:
#0      getCurrentStackTrace (file:///tmp/junk.dart:3:5)
#1      func1 (file:///tmp/junk.dart:10:29)
#2      func2 (file:///tmp/junk.dart:14:8)
#3      func3 (file:///tmp/junk.dart:18:8)
#4      func4 (file:///tmp/junk.dart:22:8)
#5      main (file:///tmp/junk.dart:26:8)
Review URL: https://codereview.chromium.org//12381030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19272 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-01 03:00:52 +00:00
asiva@google.com 3c90369ba6 Add functionality to get full stack trace when exceptions are thrown.
This should address the issue raised in 7813.

try {
 ...
 ...
} on Object catch(e, s) {
 print(s.fullStackTrace);  // This should print the full stack trace.
}
Review URL: https://codereview.chromium.org//12316116

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19179 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 22:47:06 +00:00