From 362306ea177eb9addd7aa7c2a169177195b59dbe Mon Sep 17 00:00:00 2001 From: Fanchen Kong Date: Wed, 27 Jul 2022 08:25:30 +0800 Subject: [PATCH] Fix vtunejit issues This change fixes two issues with VTune JIT Profiling API. 1. Update way of setting flag "--no-compact-code-space" to avoid changing flags after initialization v8. 2. Fix a crash from visiting uninitialized ptr. Change-Id: I4878ffd554ce53630db961fe09b49e081b0091bf Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3787321 Reviewed-by: Camillo Bruni Commit-Queue: Fanchen Kong Cr-Commit-Position: refs/heads/main@{#82003} --- include/v8-callbacks.h | 2 +- src/d8/d8.cc | 4 +++- src/flags/flag-definitions.h | 5 +++++ src/third_party/vtune/vtune-jit.cc | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/v8-callbacks.h b/include/v8-callbacks.h index b39921dea0..8cd160cd65 100644 --- a/include/v8-callbacks.h +++ b/include/v8-callbacks.h @@ -106,7 +106,7 @@ struct JitCodeEvent { size_t line_number_table_size; }; - wasm_source_info_t* wasm_source_info; + wasm_source_info_t* wasm_source_info = nullptr; union { // Only valid for CODE_ADDED. diff --git a/src/d8/d8.cc b/src/d8/d8.cc index 3eebb6330d..f540b932b0 100644 --- a/src/d8/d8.cc +++ b/src/d8/d8.cc @@ -5648,7 +5648,9 @@ int Shell::Main(int argc, char* argv[]) { } create_params.array_buffer_allocator = Shell::array_buffer_allocator; #ifdef ENABLE_VTUNE_JIT_INTERFACE - create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); + if (i::FLAG_enable_vtunejit) { + create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); + } #endif create_params.constraints.ConfigureDefaults( base::SysInfo::AmountOfPhysicalMemory(), diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h index 4b70c11840..6b30f2b6a6 100644 --- a/src/flags/flag-definitions.h +++ b/src/flags/flag-definitions.h @@ -1582,6 +1582,11 @@ DEFINE_STRING(expose_cputracemark_as, nullptr, DEFINE_BOOL(enable_vtune_domain_support, true, "enable vtune domain support") #endif // ENABLE_VTUNE_TRACEMARK +#ifdef ENABLE_VTUNE_JIT_INTERFACE +DEFINE_BOOL(enable_vtunejit, true, "enable vtune jit interface") +DEFINE_NEG_IMPLICATION(enable_vtunejit, compact_code_space) +#endif // ENABLE_VTUNE_JIT_INTERFACE + // builtins.cc DEFINE_BOOL(allow_unsafe_function_constructor, false, "allow invoking the function constructor without security checks") diff --git a/src/third_party/vtune/vtune-jit.cc b/src/third_party/vtune/vtune-jit.cc index 85159d3951..ee81e8e0df 100644 --- a/src/third_party/vtune/vtune-jit.cc +++ b/src/third_party/vtune/vtune-jit.cc @@ -295,7 +295,6 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) { } // namespace internal v8::JitCodeEventHandler GetVtuneCodeEventHandler() { - v8::V8::SetFlagsFromString("--no-compact-code-space"); return vTune::internal::VTUNEJITInterface::event_handler; }