v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
ic-stats.h
Go to the documentation of this file.
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 "include/v8-internal.h" // For Address.
14#include "src/base/atomicops.h"
16#include "src/sandbox/isolate.h"
17
18namespace v8 {
19
20namespace tracing {
21class TracedValue;
22} // namespace tracing
23
24namespace internal {
25
26class JSFunction;
27class Script;
28template <typename T>
29class Tagged;
30
31struct ICInfo {
32 ICInfo();
33 void Reset();
35 std::string type;
36 const char* function_name;
38 const char* script_name;
43 std::string state;
44 // Address of the map.
45 void* map;
46 // Whether map is a dictionary map.
48 // Number of own descriptors.
50 std::string instance_type;
51};
52
53class ICStats {
54 public:
55 const int MAX_IC_INFO = 4096;
56
57 ICStats();
58 void Dump();
59 void Begin();
60 void End();
61 void Reset();
63 DCHECK(pos_ >= 0 && pos_ < MAX_IC_INFO);
64 return ic_infos_[pos_];
65 }
66 const char* GetOrCacheScriptName(Tagged<Script> script);
67 const char* GetOrCacheFunctionName(IsolateForSandbox isolate,
68 Tagged<JSFunction> function);
69 V8_INLINE static ICStats* instance() { return instance_.Pointer(); }
70
71 private:
74 std::vector<ICInfo> ic_infos_;
75 // Keys are Script pointers; uses raw Address to keep includes light.
76 std::unordered_map<Address, std::unique_ptr<char[]>> script_name_map_;
77 // Keys are JSFunction pointers; uses raw Address to keep includes light.
78 std::unordered_map<Address, std::unique_ptr<char[]>> function_name_map_;
79 int pos_;
80};
81
82} // namespace internal
83} // namespace v8
84
85#endif // V8_IC_IC_STATS_H_
const char * GetOrCacheScriptName(Tagged< Script > script)
Definition ic-stats.cc:57
std::vector< ICInfo > ic_infos_
Definition ic-stats.h:74
std::unordered_map< Address, std::unique_ptr< char[]> > script_name_map_
Definition ic-stats.h:76
static V8_INLINE ICStats * instance()
Definition ic-stats.h:69
V8_INLINE ICInfo & Current()
Definition ic-stats.h:62
std::unordered_map< Address, std::unique_ptr< char[]> > function_name_map_
Definition ic-stats.h:78
const int MAX_IC_INFO
Definition ic-stats.h:55
const char * GetOrCacheFunctionName(IsolateForSandbox isolate, Tagged< JSFunction > function)
Definition ic-stats.cc:75
base::Atomic32 enabled_
Definition ic-stats.h:73
static base::LazyInstance< ICStats >::type instance_
Definition ic-stats.h:72
int32_t Atomic32
Definition atomicops.h:59
Tagged(T object) -> Tagged< T >
#define DCHECK(condition)
Definition logging.h:482
typename LazyStaticInstance< T, CreateTrait, InitOnceTrait, DestroyTrait >::type type
std::string state
Definition ic-stats.h:43
unsigned number_of_own_descriptors
Definition ic-stats.h:49
std::string type
Definition ic-stats.h:35
const char * function_name
Definition ic-stats.h:36
std::string instance_type
Definition ic-stats.h:50
void AppendToTracedValue(v8::tracing::TracedValue *value) const
Definition ic-stats.cc:116
const char * script_name
Definition ic-stats.h:38
#define V8_INLINE
Definition v8config.h:500