Skip to content

Commit ead70c9

Browse files
committed
build,src: fix Intel VTune profiling support
This change fix the Intel Vtune profiling support for JITted JavaScript on IA32 / X64 / X32 platform. The advantage of this profiling is that the user / developer of NodeJS application can get the detailed profiling information for every line of the JavaScript source code. This information will be very useful for the owner to optimize their applications. This feature is a compile-time option. For windows platform, the user needs to pass the following parameter to vcbuild.bat: "enable-vtune" For other OS, the user needs to pass the following parameter to ./configure command: "--enable-vtune-profiling" Fixes: #29060
1 parent de85b1e commit ead70c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+16624
-1
lines changed

configure.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@
154154
help="Generate an executable with libgcc and libstdc++ libraries. This "
155155
"will not work on OSX when using the default compilation environment")
156156

157+
parser.add_argument("--enable-vtune-profiling",
158+
action="store_true",
159+
dest="enable_vtune_profiling",
160+
help="Enable profiling support for Intel VTune profiler to profile "
161+
"JavaScript code executed in nodejs. This feature is only available "
162+
"for x32, x86, and x64 architectures.")
163+
157164
parser.add_argument("--enable-pgo-generate",
158165
action="store_true",
159166
dest="enable_pgo_generate",
@@ -1209,6 +1216,15 @@ def configure_node(o):
12091216
if flavor == 'aix':
12101217
o['variables']['node_target_type'] = 'static_library'
12111218

1219+
if target_arch in ('x86', 'x64', 'ia32', 'x32'):
1220+
o['variables']['node_enable_v8_vtunejit'] = b(options.enable_vtune_profiling)
1221+
elif options.enable_vtune_profiling:
1222+
raise Exception(
1223+
'The VTune profiler for JavaScript is only supported on x32, x86, and x64 '
1224+
'architectures.')
1225+
else:
1226+
o['variables']['node_enable_v8_vtunejit'] = 'false'
1227+
12121228
if flavor != 'linux' and (options.enable_pgo_generate or options.enable_pgo_use):
12131229
raise Exception(
12141230
'The pgo option is supported only on linux.')

deps/v8/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,4 @@ v8.ignition_dispatches_table.json
118118
/third_party/zlib/contrib/bench
119119
/third_party/zlib/contrib/tests
120120
/third_party/zlib/google/test
121+
!/third_party/ittapi
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# Copyright (C) 2005-2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 2.8.12)
8+
9+
project(ittapi)
10+
11+
OPTION(FORCE_32 "Force a 32bit compile on 64bit" OFF)
12+
OPTION(ITT_API_IPT_SUPPORT "ptmarks support")
13+
14+
IF(FORCE_32 AND UNIX)
15+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
16+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
17+
ENDIF()
18+
19+
if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE_32))
20+
set(ARCH_64 1)
21+
endif()
22+
23+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
24+
add_definitions(-D_DEBUG)
25+
if (NOT WIN32)
26+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
27+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
28+
endif()
29+
else()
30+
if (NOT WIN32)
31+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
32+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
33+
endif()
34+
add_definitions(-DNDEBUG)
35+
endif()
36+
37+
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
38+
39+
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
40+
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
41+
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${LIBRARY_OUTPUT_PATH} )
42+
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
43+
44+
set(ITT_PUBLIC_HDRS
45+
include/ittnotify.h
46+
include/jitprofiling.h
47+
include/libittnotify.h
48+
)
49+
50+
if (ITT_API_IPT_SUPPORT)
51+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DITT_API_IPT_SUPPORT")
52+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DITT_API_IPT_SUPPORT")
53+
if (NOT WIN32)
54+
enable_language(ASM)
55+
if (ARCH_64)
56+
set(ITT_PT src/ittnotify/ittptmark64.S)
57+
else()
58+
set(ASM_OPTIONS "-m32")
59+
set(ITT_PT src/ittnotify/ittptmark32.S)
60+
endif()
61+
set(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" )
62+
else()
63+
enable_language(ASM_MASM)
64+
if (ARCH_64)
65+
set(ITT_PT src/ittnotify/ittptmark64.asm)
66+
else()
67+
set(ITT_PT src/ittnotify/ittptmark32.asm)
68+
endif()
69+
endif()
70+
endif()
71+
72+
file(GLOB ITT_SRCS "src/ittnotify/*.c" "src/ittnotify/*.h")
73+
74+
add_library(ittnotify STATIC ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PT})
75+
76+
if(WIN32)
77+
SET_TARGET_PROPERTIES(ittnotify PROPERTIES OUTPUT_NAME libittnotify)
78+
else()
79+
SET_TARGET_PROPERTIES(ittnotify PROPERTIES OUTPUT_NAME ittnotify)
80+
endif()
81+
82+
if (NOT WIN32)
83+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
84+
TARGET_LINK_LIBRARIES(ittnotify dl)
85+
endif()
86+
87+
SET_TARGET_PROPERTIES(ittnotify PROPERTIES LINKER_LANGUAGE C)
88+
89+
target_include_directories(ittnotify
90+
PUBLIC include src/ittnotify
91+
)
92+
93+
set(CMAKE_SUPPRESS_REGENERATION true)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Copyright (c) 2019 Intel Corporation. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)