Skip to content

Commit 1b84964

Browse files
nodejs-github-bottargos
authored andcommitted
deps: patch V8 to 12.4.254.21
Refs: v8/v8@12.4.254.20...12.4.254.21 PR-URL: #53470 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6acadeb commit 1b84964

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

deps/v8/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
!/third_party/v8
8787
!/third_party/wasm-api
8888
/tools/builtins-pgo/profiles/*.profile
89+
/tools/builtins-pgo/profiles/profiles_version
8990
/tools/clang
9091
/tools/gcmole/bootstrap
9192
/tools/gcmole/gcmole-tools

deps/v8/include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 12
1212
#define V8_MINOR_VERSION 4
1313
#define V8_BUILD_NUMBER 254
14-
#define V8_PATCH_LEVEL 20
14+
#define V8_PATCH_LEVEL 21
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/tools/builtins-pgo/download_profiles.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import argparse
14+
import contextlib
1415
import os
1516
import pathlib
1617
import re
@@ -79,6 +80,12 @@ def parse_args(cmd_args):
7980
default=DEPOT_TOOLS_DEFAULT_PATH,
8081
)
8182

83+
parser.add_argument(
84+
'--force',
85+
help=('force download, overwriting existing profiles'),
86+
action='store_true',
87+
)
88+
8289
return parser.parse_args(cmd_args)
8390

8491

@@ -109,14 +116,45 @@ def retrieve_version(args):
109116
return version
110117

111118

119+
def download_profiles(version_path, requested_version, args):
120+
if args.force:
121+
return True
122+
123+
if not version_path.is_file():
124+
return True
125+
126+
with open(version_path) as version_file:
127+
profiles_version = version_file.read()
128+
129+
if profiles_version != requested_version:
130+
return True
131+
132+
print('Profiles already downloaded, use --force to overwrite.')
133+
return False
134+
135+
136+
@contextlib.contextmanager
137+
def ensure_profiles(version, args):
138+
version_path = PGO_PROFILE_DIR / 'profiles_version'
139+
require_profiles = download_profiles(version_path, version, args)
140+
yield require_profiles
141+
if require_profiles:
142+
with open(version_path, 'w') as version_file:
143+
version_file.write(version)
144+
145+
112146
def perform_action(version, args):
113147
path = f'{PGO_PROFILE_BUCKET}/by-version/{version}'
114148

115149
if args.action == 'download':
116-
cmd = ['cp', '-R', f'gs://{path}/*.profile', str(PGO_PROFILE_DIR)]
117-
failure_hint = f'https://storage.googleapis.com/{path} does not exist.'
118-
call_gsutil(cmd, failure_hint)
119-
return
150+
with ensure_profiles(version, args) as require_profiles:
151+
if not require_profiles:
152+
return
153+
154+
cmd = ['cp', '-R', f'gs://{path}/*.profile', str(PGO_PROFILE_DIR)]
155+
failure_hint = f'https://storage.googleapis.com/{path} does not exist.'
156+
call_gsutil(cmd, failure_hint)
157+
return
120158

121159
if args.action == 'validate':
122160
meta_json = f'{path}/meta.json'

deps/v8/tools/builtins-pgo/download_profiles_test.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import contextlib
88
import io
99
import os
10+
import pathlib
1011
import unittest
1112

1213
from tempfile import TemporaryDirectory
@@ -34,12 +35,31 @@ def test_validate_profiles(self):
3435

3536
def test_download_profiles(self):
3637
with TemporaryDirectory() as td, \
37-
patch('download_profiles.PGO_PROFILE_DIR', td):
38+
patch('download_profiles.PGO_PROFILE_DIR', pathlib.Path(td)):
3839
out, err = self._test_cmd(['download', '--version', '11.1.0.0'], 0)
3940
self.assertEqual(len(out), 0)
4041
self.assertEqual(len(err), 0)
4142
self.assertGreater(
4243
len([f for f in os.listdir(td) if f.endswith('.profile')]), 0)
44+
with open(pathlib.Path(td) / 'profiles_version') as f:
45+
self.assertEqual(f.read(), '11.1.0.0')
46+
47+
# A second download should not be started as profiles exist already
48+
with patch('download_profiles.call_gsutil') as gsutil:
49+
out, err = self._test_cmd(['download', '--version', '11.1.0.0'], 0)
50+
self.assertEqual(
51+
out,
52+
'Profiles already downloaded, use --force to overwrite.\n',
53+
)
54+
gsutil.assert_not_called()
55+
56+
# A forced download should always trigger
57+
with patch('download_profiles.call_gsutil') as gsutil:
58+
cmd = ['download', '--version', '11.1.0.0', '--force']
59+
out, err = self._test_cmd(cmd, 0)
60+
self.assertEqual(len(out), 0)
61+
self.assertEqual(len(err), 0)
62+
gsutil.assert_called_once()
4363

4464
def test_invalid_args(self):
4565
out, err = self._test_cmd(['invalid-action'], 2)
@@ -83,14 +103,18 @@ def test_retrieve_parameter_version(self):
83103
self.assertEqual(version, '11.1.1.42')
84104

85105
def test_retrieve_untagged_version(self):
106+
out = io.StringIO()
86107
with patch(
87108
'builtins.open',
88109
new=mock_open(read_data=self.mock_version_file(11, 4, 0, 0))), \
110+
contextlib.redirect_stdout(out), \
89111
self.assertRaises(SystemExit) as se:
90112
args = parse_args(['download'])
91113
version = retrieve_version(args)
92114

93115
self.assertEqual(se.exception.code, 0)
116+
self.assertEqual(out.getvalue(),
117+
'The version file specifies 11.4.0.0, which has no profiles.\n')
94118

95119
if __name__ == '__main__':
96120
unittest.main()

0 commit comments

Comments
 (0)