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 <cbruni@chromium.org>
Commit-Queue: Fanchen Kong <fanchen.kong@intel.com>
Cr-Commit-Position: refs/heads/main@{#82003}
This commit is contained in:
Fanchen Kong 2022-07-27 08:25:30 +08:00 committed by V8 LUCI CQ
parent 8ad95397fe
commit 362306ea17
4 changed files with 9 additions and 3 deletions

View File

@ -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.

View File

@ -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(),

View File

@ -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")

View File

@ -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;
}