v8/test/cctest/heap
Benedikt Meurer 765ca6a0d3 [inspector] Capture stack trace only once for JSError objects.
When creating a new JSError object (or using the non-standard API
`Error.captureStackTrace`) V8 would previously capture the "simple stack
trace" (as FixedArray of CallSiteInfo instances) to be used for the non-
standard `error.stack` property, and if the inspector was active also
capture the "detailed stack trace" (as FixedArray of StackFrameInfo
instances). This turns out to be quite a lot of overhead, both in terms
of execution time as well as memory pressure, especially since the
information needed for the inspector is a proper subset of the
information needed by `error.stack`.

So this CL addresses the above issue by capturing only the "simple stack
trace" (in the common case) and computing the "detailed stack trace"
from the "simple stack trace" when on demand. This is accomplished by
introducing a new ErrorStackData container that is used to store the
stack trace information on JSErrors when the inspector is active. When
capturing stack trace for a JSError object while the inspector is
active, we take the maximum of the program controlled stack trace limit
and the inspector requested stack trace limit, and memorize the program
controlled stack trace limit for later formatting (to ensure that the
presence of the inspector is not observable by the program).

On the `standalone.js` benchmark from crbug.com/1283162 (with the
default max call stack size of 200) we reduce execution time by around
16% compared to ToT. And compared to V8 9.9.4 (the version prior to the
regression in crbug.com/1280831), we are 6% faster now.

Doc: https://bit.ly/v8-cheaper-inspector-stack-traces
Bug: chromium:1280831, chromium:1278650, chromium:1258599
Bug: chromium:1280803, chromium:1280832, chromium:1280818
Fixed: chromium:1283162
Change-Id: I57dac73e0ecf7d50ea57c3eb4981067deb28133e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3366660
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78542}
2022-01-10 14:55:18 +00:00
..
heap-tester.h Reland "Reland "[deoptimizer] Change deopt entries into builtins"" 2020-10-21 06:01:38 +00:00
heap-utils.cc [heap] Forces CodeSpaceMemoryModificationScope only in safepoints 2021-11-05 14:34:41 +00:00
heap-utils.h [heap, infra] Remove --local-heaps and --concurrent-allocation flags 2021-02-01 11:01:26 +00:00
test-alloc.cc [test] Fix StressJS 2021-11-17 13:31:02 +00:00
test-array-buffer-tracker.cc heap: Rename compaction flags 2021-11-10 09:01:59 +00:00
test-compaction.cc [test] Skip test with FLAG_single_generation 2021-11-11 12:17:28 +00:00
test-concurrent-allocation.cc [heap][cleanup] Rename kWordAligned to kTaggedAligned 2021-11-16 09:14:24 +00:00
test-concurrent-marking.cc heap: Remove unused Worklist 2021-12-02 12:43:01 +00:00
test-embedder-tracing.cc heap: Mark EmbedderHeapTracer::GarbageCollectionForTesting as deprecated 2021-11-22 23:15:28 +00:00
test-external-string-tracker.cc heap: Rename compaction flags 2021-11-10 09:01:59 +00:00
test-heap.cc [inspector] Capture stack trace only once for JSError objects. 2022-01-10 14:55:18 +00:00
test-incremental-marking.cc [test]: Fix platform lifetime in IncrementalMarkingUsingTasks. 2020-11-27 06:58:21 +00:00
test-invalidated-slots.cc [cctest] Fix -Wshadow warnings in cctest/heap 2021-10-18 16:34:30 +00:00
test-iterators.cc Reland "[include] Split out v8.h" 2021-08-24 13:08:55 +00:00
test-lab.cc [heap][cleanup] Rename kWordAligned to kTaggedAligned 2021-11-16 09:14:24 +00:00
test-mark-compact.cc heap: Rename compaction flags 2021-11-10 09:01:59 +00:00
test-memory-measurement.cc [build] Reduce dependencies on deserializer.h 2021-06-29 13:21:57 +00:00
test-page-promotion.cc [heap] Remove flag always_promote_young_mc 2021-11-09 19:37:39 +00:00
test-shared-heap.cc [heap] Find references in client heaps to shared objects in shared GC 2021-12-06 12:00:18 +00:00
test-spaces.cc heap: Place LABs in IsolateData 2021-12-01 08:51:33 +00:00
test-unmapper.cc [test]: Fix platform lifetime in EagerUnmappingInCollectAllAvailableGarbage. 2020-10-28 09:12:05 +00:00
test-weak-references.cc [ext-code-space][compiler] Support calling CodeT targets 2021-12-16 13:45:12 +00:00
test-write-barrier.cc [heap] Fix failed tests when enabling single generation 2021-04-21 07:33:51 +00:00