Skip to content

Commit 88c4114

Browse files
authored
Update update_v8_wasm_profile.py
支持分包情况的函数名映射
1 parent 8a2bd99 commit 88c4114

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tools/update_v8_wasm_profile.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55
import os
66

77

8-
def main(cpuprofile_file, symbol_file):
8+
def main(cpuprofile_file, symbol_file, is_wasmsplit):
99
print('start parse symbol')
1010
symbol_map = {}
1111
with open(symbol_file) as f:
1212
symbol_text = f.read()
1313
result = re.findall(r'"(\d+)": "(.*)"', symbol_text)
14+
count = 0
1415
for p in result:
15-
symbol_map['wasm-function['+str(p[0])+']'] = p[1]
16+
func_name = p[1].replace('\\\\', '\\').replace('\\28', '(').replace('\\29', ')').replace('\\20', ' ').replace('\\2c', ',')
17+
if is_wasmsplit == 1:
18+
symbol_map['"j'+str(p[0]) + '"'] = func_name
19+
else:
20+
symbol_map['wasm-function['+str(p[0])+']'] = func_name
21+
1622

1723
parts = os.path.splitext(cpuprofile_file)
1824
out_file = parts[0] + '_out' + parts[1]
@@ -30,7 +36,10 @@ def main(cpuprofile_file, symbol_file):
3036
strip_name.append(p)
3137
else:
3238
all_md5s.append(p)
33-
profile_text = profile_text.replace(k, '_'.join(strip_name))
39+
if is_wasmsplit == 1:
40+
profile_text = profile_text.replace(k, '"' + '_'.join(strip_name) + '"')
41+
else:
42+
profile_text = profile_text.replace(k, '_'.join(strip_name))
3443
if count % 1000 == 0:
3544
print('symbol {0}/{1}'.format(count, total))
3645
print('remove md5 count {0}'.format(len(all_md5s)))
@@ -51,7 +60,7 @@ def main(cpuprofile_file, symbol_file):
5160

5261

5362
if __name__ == '__main__':
54-
if len(sys.argv) != 3:
55-
print('usage: python update_v8_wasm_profile.py xxx.cpuprofile xxx.symbols')
63+
if len(sys.argv) != 4:
64+
print('usage: python update_v8_wasm_profile.py xxx.cpuprofile xxx.symbols is_wasmsplit(0/1)')
5665
else:
57-
main(sys.argv[1], sys.argv[2])
66+
main(sys.argv[1], sys.argv[2], int(sys.argv[3]))

0 commit comments

Comments
 (0)