Go to file
Peter Marshall 3243506267 Revert "[cpu-profiler] Ensure sampled thread has Isolate lock under Windows"
This reverts commit dfb3f7daa5.

Reason for revert: Breaks LSAN & ASAN flakily: https://bugs.chromium.org/p/v8/issues/detail?id=10861

Original change's description:
> [cpu-profiler] Ensure sampled thread has Isolate lock under Windows
> 
> While the sampler checked if the sampled thread had the Isolate locked
> (if locks are being used) under Linux, the check was not done under
> Windows (or Fuchsia) which meant that in a multi-threading application
> under Windows, thread locking was not checked making it prone to seg
> faults and the like as the profiler would be extracting info from a
> heap in motion. The fix was to move the lock check into CpuSampler
> and Ticker (--prof) so all OSes would do the correct check.
> 
> The basic concept is that on all operating systems a CpuProfiler, and
> so its corresponding CpuCampler, the profiler is tied to a thread.
> This is not based on first principles or anything, it's simply the
> way it works in V8, though it is a useful conceit as it makes
> visualization and interpretation of profile data much easier.
> 
> To collect a sample on a thread associated with a profiler the thread
> must be stopped for obvious reasons -- walking the stack of a running
> thread is a formula for disaster. The mechanism for stopping a thread
> is OS-specific and is done in sample.cc. There are currently three
> basic approaches, one for Linux/Unix variants, one for Windows and one
> for Fuchsia. The approaches vary as to which thread actually collects
> the sample -- under Linux the sample is actually collected on the
> (interrupted) sampled thread whereas under Fuchsia/Windows it's on
> a separate thread.
> 
> However, in a multi-threaded environment (where Locker is used), it's
> not sufficient for the sampled thread to be stopped. Because the stack
> walk involves looking in the Isolate heap, no other thread can be
> messing with the heap while the sample is collected. The only ways to
> ensure this would be to either stop all threads whenever collecting a
> sample, or to ensure that the thread being sampled holds the Isolate
> lock so prevents other threads from messing with the heap. While there
> might be something to be said for the "stop all threads" approach, the
> current approach in V8 is to only stop the sampled thread so, if in a
> multi-threaded environment, the profiler must check if the thread being
> sampled holds the Isolate lock.
> 
> Since this check must be done, independent of which thread the sample
> is being collected on (since it varies from OS to OS), the approach is
> to save the thread id of the thread to be profiled/sampled when the
> CpuSampler is instantiated (on all OSes it is instantiated on the
> sampled thread) and then check that thread id against the Isolate lock
> holder thread id before collecting a sample. If it matches, we know
> sample.cc has stop the sampled thread, one way or another, and we know
> that no other thread can mess with the heap (since the stopped thread
> holds the Isolate lock) so it's safe to walk the stack and collect data
> from the heap so the sample can be taken. It it doesn't match, we can't
> safely collect the sample so we don't.
> 
> Bug: v8:10850
> Change-Id: Iab2493130b9328430d7e5f5d3cf90ad6d10b1892
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2377108
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#69623}

TBR=akodat@rocketsoftware.com,petermarshall@chromium.org,petermarshall@google.com

Change-Id: Ib6b6dc4ce109d5aa4e504fa7c9769f5cd95ddd0c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:10850
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2387570
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69638}
2020-09-01 10:21:41 +00:00
build_overrides tracing: Enable using Perfetto client library from Chromium 2020-05-11 11:17:57 +00:00
custom_deps Use relative paths to OWNERS files 2019-08-12 13:52:52 +00:00
docs Add OWNERS for docs/ 2019-05-15 12:06:15 +00:00
gni [heap] Add object start bitmap for conservative stack scanning 2020-08-31 07:10:36 +00:00
include [API] Add missing include for <atomic> 2020-09-01 07:46:09 +00:00
infra [nci] Change testing mode to --turbo-nci-as-midtier 2020-08-20 12:54:40 +00:00
samples cppgc: Add DefaultPlatform and standalone sample 2020-07-23 09:54:32 +00:00
src Revert "[cpu-profiler] Ensure sampled thread has Isolate lock under Windows" 2020-09-01 10:21:41 +00:00
test Revert "[cpu-profiler] Ensure sampled thread has Isolate lock under Windows" 2020-09-01 10:21:41 +00:00
testing Roll v8/third_party/googletest/src/ 10b1902d8..e3f0319d8 (43 commits) 2020-04-15 07:23:10 +00:00
third_party [csa][cleanup] Remove ParameterMode/TNodify StoreFixedDoubleArrayElement 2020-08-26 17:14:44 +00:00
tools Revert "[cpu-profiler] Ensure sampled thread has Isolate lock under Windows" 2020-09-01 10:21:41 +00:00
.clang-format [clang-format] Don't derive pointer alignment 2017-01-17 09:28:19 +00:00
.clang-tidy [tool] Remove unfixed clang-tidy warnings to ease use. 2018-10-26 07:40:32 +00:00
.editorconfig Add .editorconfig 2017-07-28 13:39:24 +00:00
.flake8 Add .flake8 to allow for python style checking. 2019-07-19 21:44:03 +00:00
.git-blame-ignore-revs [infra] Update .git-blame-ignore-revs 2020-03-03 12:59:13 +00:00
.gitattributes .gitattributes: Mark minified emscripten js files as -diff 2018-09-19 16:27:10 +00:00
.gitignore Revert "[presubmit] Add JS formatting for tools/system-analyzer" 2020-07-17 10:33:40 +00:00
.gn [build] Dynamically decide if to use system xcode 2019-07-29 08:20:24 +00:00
.vpython [tools] Implement confidence-based number of runs 2019-05-09 09:42:28 +00:00
.ycm_extra_conf.py Fix ycm config for headers without source 2019-12-09 11:59:21 +00:00
AUTHORS Use NtCurrentTeb() in GetStackStart() to fix 64-bit Wine on macOS 2020-08-31 18:22:05 +00:00
BUILD.gn [regexp] Split experimental regexp code into multiple files 2020-09-01 10:15:38 +00:00
CODE_OF_CONDUCT.md Explicitly state that the Chromium Code of Conduct also applies to V8 2016-03-02 09:51:24 +00:00
codereview.settings Make Gerrit the default code review for V8 2017-06-30 17:37:37 +00:00
COMMON_OWNERS Adding vahl@ to the common owners to be able to handle 2020-08-21 09:04:56 +00:00
DEPS Update V8 DEPS. 2020-09-01 03:34:08 +00:00
ENG_REVIEW_OWNERS Add eng review owners as escalation path 2019-05-15 19:12:10 +00:00
INFRA_OWNERS Add team members as owners 2020-08-18 08:29:04 +00:00
INTL_OWNERS add ftang as owner 2020-04-24 19:19:36 +00:00
LICENSE [wasm] Draft version of C/C++ Wasm API 2019-04-17 16:00:26 +00:00
LICENSE.fdlibm Add LICENSE.fdlibm for all the fdlibm imported sources. 2016-06-09 07:17:03 +00:00
LICENSE.strongtalk Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
LICENSE.v8 Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
LICENSE.valgrind Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
MIPS_OWNERS Move architecture dependent files 2019-05-28 14:02:15 +00:00
OWNERS Add syg@chromium.org as DEPS owner for test262 rolls 2019-09-17 19:29:11 +00:00
PPC_OWNERS Move architecture dependent files 2019-05-28 14:02:15 +00:00
PRESUBMIT.py [presubmit] Allow use of test functions in runtime-test.cc 2020-08-10 12:12:55 +00:00
README.md [docs] Change links from old wiki to v8.dev 2019-03-07 12:13:30 +00:00
S390_OWNERS Move architecture dependent files 2019-05-28 14:02:15 +00:00
WATCHLISTS Stop watching for API changes in WATCHLISTS 2020-04-08 07:06:45 +00:00

V8 JavaScript Engine

V8 is Google's open source JavaScript engine.

V8 implements ECMAScript as specified in ECMA-262.

V8 is written in C++ and is used in Google Chrome, the open source browser from Google.

V8 can run standalone, or can be embedded into any C++ application.

V8 Project page: https://v8.dev/docs

Getting the Code

Checkout depot tools, and run

    fetch v8

This will checkout V8 into the directory v8 and fetch all of its dependencies. To stay up to date, run

    git pull origin
    gclient sync

For fetching all branches, add the following into your remote configuration in .git/config:

    fetch = +refs/branch-heads/*:refs/remotes/branch-heads/*
    fetch = +refs/tags/*:refs/tags/*

Contributing

Please follow the instructions mentioned at v8.dev/docs/contribute.