Index: src/ic/ic-stats.h |
diff --git a/src/ic/ic-stats.h b/src/ic/ic-stats.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8e3e8ab09b94456e9444578be46805adeefc42c6 |
--- /dev/null |
+++ b/src/ic/ic-stats.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef V8_IC_IC_STATS_H_ |
+#define V8_IC_IC_STATS_H_ |
+ |
+#include <memory> |
+#include <string> |
+#include <unordered_map> |
+#include <vector> |
+ |
+#include "src/base/atomicops.h" |
+#include "src/base/lazy-instance.h" |
+ |
+namespace v8 { |
+ |
+namespace tracing { |
+class TracedValue; |
+} |
+ |
+namespace internal { |
+ |
+class JSFunction; |
+class Object; |
+ |
+struct ICInfo { |
+ ICInfo(); |
+ void Reset(); |
+ void AppendToTracedValue(v8::tracing::TracedValue* value) const; |
+ std::string type; |
+ std::string function_name; |
+ int offset; |
Camillo Bruni
2016/12/02 12:12:55
rename to script_offset
lpy
2016/12/05 17:49:11
Done.
|
+ const char* script_name; |
+ int line_num; |
+ unsigned constructor; |
Camillo Bruni
2016/12/02 12:12:55
bool is_constructor
lpy
2016/12/05 17:49:11
Done.
|
+ std::string state; |
+ // Address of the map. |
+ void* map; |
+ // Indicate whether map is a dictionary map. |
+ 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.
|
+ // Number of own descriptors. |
+ 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.
|
+ std::string instance_type; |
+}; |
+ |
+class ICStats { |
+ public: |
+ const int MAX_IC_INFO = 4096; |
+ |
+ ICStats(); |
+ void Dump(); |
+ void Begin(); |
+ void End(); |
+ void Reset(); |
+ V8_INLINE ICInfo& Current() { |
+ DCHECK(pos_ >= 0 && pos_ < MAX_IC_INFO); |
+ return ic_infos_[pos_]; |
+ } |
+ const char* GetOrCacheScriptName(Object* obj); |
+ std::string& GetOrCacheFunctionName(JSFunction* function); |
+ V8_INLINE static ICStats* instance() { return instance_.Pointer(); } |
+ |
+ private: |
+ static base::LazyInstance<ICStats>::type instance_; |
+ base::Atomic32 being_used_; |
Camillo Bruni
2016/12/02 12:12:55
How about "enabled"?
lpy
2016/12/05 17:49:11
Done.
|
+ std::vector<ICInfo> ic_infos_; |
+ std::unordered_map<Object*, std::unique_ptr<char[]>> script_name_map_; |
+ 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
|
+ int pos_; |
+}; |
+ |
+} // namespace internal |
+} // namespace v8 |
+ |
+#endif // V8_IC_IC_STATS_H_ |