@@ -8,27 +8,16 @@ use crate::global_lib_table::{GlobalLibIndex, GlobalLibTable};
8
8
use crate :: native_symbols:: NativeSymbolIndex ;
9
9
use crate :: resource_table:: ResourceTable ;
10
10
use crate :: serialization_helpers:: SerializableSingleValueColumn ;
11
- use crate :: string_table:: { ProfileStringTable , StringHandle } ;
11
+ use crate :: string_table:: StringHandle ;
12
12
use crate :: SourceLocation ;
13
13
14
14
#[ derive( Debug , Clone , Default ) ]
15
- pub struct FrameTable {
16
- func_table : FuncTable ,
17
- resource_table : ResourceTable ,
18
-
19
- func_col : Vec < FuncIndex > ,
20
- category_col : Vec < CategoryHandle > ,
21
- subcategory_col : Vec < SubcategoryIndex > ,
22
- line_col : Vec < Option < u32 > > ,
23
- column_col : Vec < Option < u32 > > ,
24
- address_col : Vec < Option < u32 > > ,
25
- native_symbol_col : Vec < Option < NativeSymbolIndex > > ,
26
- inline_depth_col : Vec < u16 > ,
27
-
15
+ pub struct FrameInterner {
28
16
frame_key_set : FastIndexSet < InternalFrame > ,
17
+ contains_js_frame : bool ,
29
18
}
30
19
31
- impl FrameTable {
20
+ impl FrameInterner {
32
21
pub fn new ( ) -> Self {
33
22
Default :: default ( )
34
23
}
@@ -37,86 +26,119 @@ impl FrameTable {
37
26
& mut self ,
38
27
frame : InternalFrame ,
39
28
global_libs : & mut GlobalLibTable ,
40
- string_table : & mut ProfileStringTable ,
41
29
) -> usize {
42
30
let ( frame_index, is_new) = self . frame_key_set . insert_full ( frame) ;
43
31
44
- if !is_new {
45
- return frame_index;
46
- }
47
-
48
- let func_key = frame. func_key ( ) ;
49
- let func = self . func_table . index_for_func (
50
- func_key,
51
- & mut self . resource_table ,
52
- global_libs,
53
- string_table,
54
- ) ;
55
-
56
- self . func_col . push ( func) ;
57
- let SubcategoryHandle ( category, subcategory) = frame. subcategory ;
58
- self . category_col . push ( category) ;
59
- self . subcategory_col . push ( subcategory) ;
60
- self . line_col . push ( frame. source_location . line ) ;
61
- self . column_col . push ( frame. source_location . col ) ;
62
-
63
- match frame. variant {
64
- InternalFrameVariant :: Label => {
65
- self . address_col . push ( None ) ;
66
- self . native_symbol_col . push ( None ) ;
67
- self . inline_depth_col . push ( 0 ) ;
32
+ if is_new {
33
+ if frame
34
+ . flags
35
+ . intersects ( FrameFlags :: IS_JS | FrameFlags :: IS_RELEVANT_FOR_JS )
36
+ {
37
+ self . contains_js_frame = true ;
68
38
}
69
- InternalFrameVariant :: Native ( NativeFrameData {
39
+
40
+ if let InternalFrameVariant :: Native ( NativeFrameData {
70
41
lib,
71
- native_symbol,
72
42
relative_address,
73
- inline_depth,
74
- } ) => {
43
+ ..
44
+ } ) = frame. variant
45
+ {
75
46
global_libs. add_lib_used_rva ( lib, relative_address) ;
76
-
77
- self . address_col . push ( Some ( relative_address) ) ;
78
- self . native_symbol_col . push ( native_symbol) ;
79
- self . inline_depth_col . push ( inline_depth) ;
80
47
}
81
48
}
82
-
83
49
frame_index
84
50
}
85
51
86
52
pub fn contains_js_frame ( & self ) -> bool {
87
- self . func_table . contains_js_func ( )
53
+ self . contains_js_frame
88
54
}
89
55
90
- pub fn get_serializable_tables (
91
- & self ,
92
- ) -> ( SerializableFrameTable < ' _ > , & ' _ FuncTable , & ' _ ResourceTable ) {
93
- (
94
- SerializableFrameTable ( self ) ,
95
- & self . func_table ,
96
- & self . resource_table ,
97
- )
56
+ pub fn create_tables ( & self ) -> ( FrameTable , FuncTable , ResourceTable ) {
57
+ let len = self . frame_key_set . len ( ) ;
58
+ let mut func_col = Vec :: with_capacity ( len) ;
59
+ let mut category_col = Vec :: with_capacity ( len) ;
60
+ let mut subcategory_col = Vec :: with_capacity ( len) ;
61
+ let mut line_col = Vec :: with_capacity ( len) ;
62
+ let mut column_col = Vec :: with_capacity ( len) ;
63
+ let mut address_col = Vec :: with_capacity ( len) ;
64
+ let mut native_symbol_col = Vec :: with_capacity ( len) ;
65
+ let mut inline_depth_col = Vec :: with_capacity ( len) ;
66
+
67
+ let mut func_table = FuncTable :: default ( ) ;
68
+ let mut resource_table = ResourceTable :: default ( ) ;
69
+
70
+ for frame in & self . frame_key_set {
71
+ let func_key = frame. func_key ( ) ;
72
+ let func = func_table. index_for_func ( func_key, & mut resource_table) ;
73
+
74
+ func_col. push ( func) ;
75
+ let SubcategoryHandle ( category, subcategory) = frame. subcategory ;
76
+ category_col. push ( category) ;
77
+ subcategory_col. push ( subcategory) ;
78
+ line_col. push ( frame. source_location . line ) ;
79
+ column_col. push ( frame. source_location . col ) ;
80
+
81
+ match frame. variant {
82
+ InternalFrameVariant :: Label => {
83
+ address_col. push ( None ) ;
84
+ native_symbol_col. push ( None ) ;
85
+ inline_depth_col. push ( 0 ) ;
86
+ }
87
+ InternalFrameVariant :: Native ( NativeFrameData {
88
+ native_symbol,
89
+ relative_address,
90
+ inline_depth,
91
+ ..
92
+ } ) => {
93
+ address_col. push ( Some ( relative_address) ) ;
94
+ native_symbol_col. push ( native_symbol) ;
95
+ inline_depth_col. push ( inline_depth) ;
96
+ }
97
+ }
98
+ }
99
+
100
+ let frame_table = FrameTable {
101
+ func_col,
102
+ category_col,
103
+ subcategory_col,
104
+ line_col,
105
+ column_col,
106
+ address_col,
107
+ native_symbol_col,
108
+ inline_depth_col,
109
+ } ;
110
+
111
+ ( frame_table, func_table, resource_table)
98
112
}
99
113
}
100
114
101
- pub struct SerializableFrameTable < ' a > ( & ' a FrameTable ) ;
115
+ pub struct FrameTable {
116
+ func_col : Vec < FuncIndex > ,
117
+ category_col : Vec < CategoryHandle > ,
118
+ subcategory_col : Vec < SubcategoryIndex > ,
119
+ line_col : Vec < Option < u32 > > ,
120
+ column_col : Vec < Option < u32 > > ,
121
+ address_col : Vec < Option < u32 > > ,
122
+ native_symbol_col : Vec < Option < NativeSymbolIndex > > ,
123
+ inline_depth_col : Vec < u16 > ,
124
+ }
102
125
103
- impl Serialize for SerializableFrameTable < ' _ > {
126
+ impl Serialize for FrameTable {
104
127
fn serialize < S : Serializer > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error > {
105
- let SerializableFrameTable ( table) = self ;
106
- let len = table. func_col . len ( ) ;
128
+ let len = self . func_col . len ( ) ;
107
129
let mut map = serializer. serialize_map ( None ) ?;
108
130
map. serialize_entry ( "length" , & len) ?;
109
- map. serialize_entry ( "func" , & table . func_col ) ?;
110
- map. serialize_entry ( "category" , & table . category_col ) ?;
111
- map. serialize_entry ( "subcategory" , & table . subcategory_col ) ?;
112
- map. serialize_entry ( "line" , & table . line_col ) ?;
113
- map. serialize_entry ( "column" , & table . column_col ) ?;
131
+ map. serialize_entry ( "func" , & self . func_col ) ?;
132
+ map. serialize_entry ( "category" , & self . category_col ) ?;
133
+ map. serialize_entry ( "subcategory" , & self . subcategory_col ) ?;
134
+ map. serialize_entry ( "line" , & self . line_col ) ?;
135
+ map. serialize_entry ( "column" , & self . column_col ) ?;
114
136
map. serialize_entry (
115
137
"address" ,
116
- & SerializableFrameTableAddressColumn ( & table . address_col ) ,
138
+ & SerializableFrameTableAddressColumn ( & self . address_col ) ,
117
139
) ?;
118
- map. serialize_entry ( "nativeSymbol" , & table . native_symbol_col ) ?;
119
- map. serialize_entry ( "inlineDepth" , & table . inline_depth_col ) ?;
140
+ map. serialize_entry ( "nativeSymbol" , & self . native_symbol_col ) ?;
141
+ map. serialize_entry ( "inlineDepth" , & self . inline_depth_col ) ?;
120
142
map. serialize_entry ( "innerWindowID" , & SerializableSingleValueColumn ( 0 , len) ) ?;
121
143
map. end ( )
122
144
}
0 commit comments