5
5
import os
6
6
7
7
8
- def main (cpuprofile_file , symbol_file ):
8
+ def main (cpuprofile_file , symbol_file , is_wasmsplit ):
9
9
print ('start parse symbol' )
10
10
symbol_map = {}
11
11
with open (symbol_file ) as f :
12
12
symbol_text = f .read ()
13
13
result = re .findall (r'"(\d+)": "(.*)"' , symbol_text )
14
+ count = 0
14
15
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
+
16
22
17
23
parts = os .path .splitext (cpuprofile_file )
18
24
out_file = parts [0 ] + '_out' + parts [1 ]
@@ -30,7 +36,10 @@ def main(cpuprofile_file, symbol_file):
30
36
strip_name .append (p )
31
37
else :
32
38
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 ))
34
43
if count % 1000 == 0 :
35
44
print ('symbol {0}/{1}' .format (count , total ))
36
45
print ('remove md5 count {0}' .format (len (all_md5s )))
@@ -51,7 +60,7 @@ def main(cpuprofile_file, symbol_file):
51
60
52
61
53
62
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) ' )
56
65
else :
57
- main (sys .argv [1 ], sys .argv [2 ])
66
+ main (sys .argv [1 ], sys .argv [2 ], int ( sys . argv [ 3 ]) )
0 commit comments