Skip to content

Commit

Permalink
deps: cherry-pick 3f4536894ac from V8 upstream
Browse files Browse the repository at this point in the history
Original commit message:

    d8: Make in process stack dumping optional

    Adds a flag (--disable-in-process-stack-traces) to not install
    signal handlers so that e.g. ASan signal handlers will work.

    This flag mirrors chromium's one.

    R=jochen@chromium.org
    BUG=chromium:716235

    Review-Url: https://codereview.chromium.org/2854173002
    Cr-Commit-Position: refs/heads/master@{#45142}

PR-URL: #13985
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
oliverchang authored and addaleax committed Jul 24, 2017
1 parent da93046 commit da1913c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion deps/v8/include/libplatform/libplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace v8 {
namespace platform {

enum class IdleTaskSupport { kDisabled, kEnabled };
enum class InProcessStackDumping { kDisabled, kEnabled };

/**
* Returns a new instance of the default v8::Platform implementation.
Expand All @@ -27,7 +28,9 @@ enum class IdleTaskSupport { kDisabled, kEnabled };
*/
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled);
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
InProcessStackDumping::kEnabled);

/**
* Pumps the message loop for the given isolate.
Expand Down
12 changes: 11 additions & 1 deletion deps/v8/src/d8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--lcov=", 7) == 0) {
options.lcov_file = argv[i] + 7;
argv[i] = NULL;
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
options.disable_in_process_stack_traces = true;
argv[i] = NULL;
}
}

Expand Down Expand Up @@ -2998,10 +3001,17 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);

v8::platform::InProcessStackDumping in_process_stack_dumping =
options.disable_in_process_stack_traces
? v8::platform::InProcessStackDumping::kDisabled
: v8::platform::InProcessStackDumping::kEnabled;

g_platform = i::FLAG_verify_predictable
? new PredictablePlatform()
: v8::platform::CreateDefaultPlatform(
0, v8::platform::IdleTaskSupport::kEnabled);
0, v8::platform::IdleTaskSupport::kEnabled,
in_process_stack_dumping);

platform::tracing::TracingController* tracing_controller;
if (options.trace_enabled) {
Expand Down
4 changes: 3 additions & 1 deletion deps/v8/src/d8.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ class ShellOptions {
snapshot_blob(NULL),
trace_enabled(false),
trace_config(NULL),
lcov_file(NULL) {}
lcov_file(NULL),
disable_in_process_stack_traces(false) {}

~ShellOptions() {
delete[] isolate_sources;
Expand Down Expand Up @@ -336,6 +337,7 @@ class ShellOptions {
bool trace_enabled;
const char* trace_config;
const char* lcov_file;
bool disable_in_process_stack_traces;
};

class Shell : public i::AllStatic {
Expand Down
9 changes: 6 additions & 3 deletions deps/v8/src/libplatform/default-platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ void PrintStackTrace() {

} // namespace

v8::Platform* CreateDefaultPlatform(int thread_pool_size,
IdleTaskSupport idle_task_support) {
v8::base::debug::EnableInProcessStackDumping();
v8::Platform* CreateDefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping) {
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
v8::base::debug::EnableInProcessStackDumping();
}
DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized();
Expand Down

0 comments on commit da1913c

Please sign in to comment.