OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_IC_IC_STATS_H_ | |
6 #define V8_IC_IC_STATS_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 #include <unordered_map> | |
11 #include <vector> | |
12 | |
13 #include "src/base/atomicops.h" | |
14 #include "src/base/lazy-instance.h" | |
15 | |
16 namespace v8 { | |
17 | |
18 namespace tracing { | |
19 class TracedValue; | |
20 } | |
21 | |
22 namespace internal { | |
23 | |
24 class JSFunction; | |
25 class Object; | |
26 | |
27 struct ICInfo { | |
28 ICInfo(); | |
29 void Reset(); | |
30 void AppendToTracedValue(v8::tracing::TracedValue* value) const; | |
31 std::string type; | |
32 std::string function_name; | |
33 int offset; | |
Camillo Bruni
2016/12/02 12:12:55
rename to script_offset
lpy
2016/12/05 17:49:11
Done.
| |
34 const char* script_name; | |
35 int line_num; | |
36 unsigned constructor; | |
Camillo Bruni
2016/12/02 12:12:55
bool is_constructor
lpy
2016/12/05 17:49:11
Done.
| |
37 std::string state; | |
38 // Address of the map. | |
39 void* map; | |
40 // Indicate whether map is a dictionary map. | |
41 unsigned dict; | |
Camillo Bruni
2016/12/02 12:12:55
this should be bool I guess (also maybe rename it
lpy
2016/12/05 17:49:11
Done.
| |
42 // Number of own descriptors. | |
43 unsigned own; | |
Camillo Bruni
2016/12/02 12:12:55
please rename to: number_of_own_descriptors (or a
lpy
2016/12/05 17:49:11
Done.
| |
44 std::string instance_type; | |
45 }; | |
46 | |
47 class ICStats { | |
48 public: | |
49 const int MAX_IC_INFO = 4096; | |
50 | |
51 ICStats(); | |
52 void Dump(); | |
53 void Begin(); | |
54 void End(); | |
55 void Reset(); | |
56 V8_INLINE ICInfo& Current() { | |
57 DCHECK(pos_ >= 0 && pos_ < MAX_IC_INFO); | |
58 return ic_infos_[pos_]; | |
59 } | |
60 const char* GetOrCacheScriptName(Object* obj); | |
61 std::string& GetOrCacheFunctionName(JSFunction* function); | |
62 V8_INLINE static ICStats* instance() { return instance_.Pointer(); } | |
63 | |
64 private: | |
65 static base::LazyInstance<ICStats>::type instance_; | |
66 base::Atomic32 being_used_; | |
Camillo Bruni
2016/12/02 12:12:55
How about "enabled"?
lpy
2016/12/05 17:49:11
Done.
| |
67 std::vector<ICInfo> ic_infos_; | |
68 std::unordered_map<Object*, std::unique_ptr<char[]>> script_name_map_; | |
69 std::unordered_map<JSFunction*, std::string> function_name_map_; | |
Camillo Bruni
2016/12/02 12:12:55
Did you try running this on a big website and see
lpy
2016/12/05 17:49:11
Thanks for the advice, will try it with Chrome TOT
| |
70 int pos_; | |
71 }; | |
72 | |
73 } // namespace internal | |
74 } // namespace v8 | |
75 | |
76 #endif // V8_IC_IC_STATS_H_ | |
OLD | NEW |