summaryrefslogtreecommitdiff
path: root/deps/v8/src/profiler/profile-generator.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/profiler/profile-generator.h')
-rw-r--r--deps/v8/src/profiler/profile-generator.h47
1 files changed, 42 insertions, 5 deletions
diff --git a/deps/v8/src/profiler/profile-generator.h b/deps/v8/src/profiler/profile-generator.h
index b0543c9d79..2f7273a086 100644
--- a/deps/v8/src/profiler/profile-generator.h
+++ b/deps/v8/src/profiler/profile-generator.h
@@ -234,7 +234,36 @@ struct CodeEntryAndLineNumber {
int line_number;
};
-using ProfileStackTrace = std::vector<CodeEntryAndLineNumber>;
+struct ProfileStackFrame {
+ CodeEntryAndLineNumber entry;
+ Address native_context;
+ bool filterable; // If true, the frame should be filtered by context (if a
+ // filter is present).
+};
+
+typedef std::vector<ProfileStackFrame> ProfileStackTrace;
+
+// Filters stack frames from sources other than a target native context.
+class ContextFilter {
+ public:
+ explicit ContextFilter(Address native_context_address)
+ : native_context_address_(native_context_address) {}
+
+ // Returns true if the stack frame passes a context check.
+ bool Accept(const ProfileStackFrame&);
+
+ // Invoked when a native context has changed address.
+ void OnMoveEvent(Address from_address, Address to_address);
+
+ // Update the context's tracked address based on VM-thread events.
+ void set_native_context_address(Address address) {
+ native_context_address_ = address;
+ }
+ Address native_context_address() const { return native_context_address_; }
+
+ private:
+ Address native_context_address_;
+};
class ProfileTree;
@@ -321,7 +350,8 @@ class V8_EXPORT_PRIVATE ProfileTree {
const ProfileStackTrace& path,
int src_line = v8::CpuProfileNode::kNoLineNumberInfo,
bool update_stats = true,
- ProfilingMode mode = ProfilingMode::kLeafNodeLineNumbers);
+ ProfilingMode mode = ProfilingMode::kLeafNodeLineNumbers,
+ ContextFilter* context_filter = nullptr);
ProfileNode* root() const { return root_; }
unsigned next_node_id() { return next_node_id_++; }
unsigned GetFunctionId(const ProfileNode* node);
@@ -389,6 +419,7 @@ class CpuProfile {
base::TimeTicks start_time() const { return start_time_; }
base::TimeTicks end_time() const { return end_time_; }
CpuProfiler* cpu_profiler() const { return profiler_; }
+ ContextFilter* context_filter() const { return context_filter_.get(); }
void UpdateTicksScale();
@@ -399,6 +430,7 @@ class CpuProfile {
const char* title_;
const CpuProfilingOptions options_;
+ std::unique_ptr<ContextFilter> context_filter_;
base::TimeTicks start_time_;
base::TimeTicks end_time_;
std::deque<SampleInfo> samples_;
@@ -477,6 +509,9 @@ class V8_EXPORT_PRIVATE CpuProfilesCollection {
bool update_stats,
base::TimeDelta sampling_interval);
+ // Called from profile generator thread.
+ void UpdateNativeContextAddressForCurrentProfiles(Address from, Address to);
+
// Limits the number of profiles that can be simultaneously collected.
static const int kMaxSimultaneousProfiles = 100;
@@ -494,18 +529,20 @@ class V8_EXPORT_PRIVATE CpuProfilesCollection {
class V8_EXPORT_PRIVATE ProfileGenerator {
public:
- explicit ProfileGenerator(CpuProfilesCollection* profiles);
+ explicit ProfileGenerator(CpuProfilesCollection* profiles, CodeMap* code_map);
void RecordTickSample(const TickSample& sample);
- CodeMap* code_map() { return &code_map_; }
+ void UpdateNativeContextAddress(Address from, Address to);
+
+ CodeMap* code_map() { return code_map_; }
private:
CodeEntry* FindEntry(Address address);
CodeEntry* EntryForVMState(StateTag tag);
CpuProfilesCollection* profiles_;
- CodeMap code_map_;
+ CodeMap* const code_map_;
DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
};