Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Unified Diff: runtime/vm/profiler.h

Issue 1435533003: Make profiler work without Instructions -> Code pointer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/profiler.h
diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h
index ccdd9b96abd9db0f35b99e005892e6c6bd4a52ae..f4b481e9766379ea72c7325a4eed96f56b6b72a9 100644
--- a/runtime/vm/profiler.h
+++ b/runtime/vm/profiler.h
@@ -10,6 +10,7 @@
#include "vm/code_observers.h"
#include "vm/globals.h"
#include "vm/growable_array.h"
+#include "vm/object.h"
#include "vm/tags.h"
#include "vm/thread_interrupter.h"
@@ -355,6 +356,84 @@ class Sample {
};
+// A Code object descriptor.
+class CodeDescriptor : public ZoneAllocated {
+ public:
+ explicit CodeDescriptor(const Code& code);
+
+ uword Entry() const;
+
+ uword Size() const;
+
+ int64_t CompileTimestamp() const;
+
+ RawCode* code() const {
+ return code_.raw();
+ }
+
+ const char* Name() const {
+ const String& name = String::Handle(code_.Name());
+ return name.ToCString();
+ }
+
+ bool Contains(uword pc) const {
+ uword end = Entry() + Size();
+ return (pc >= Entry()) && (pc < end);
+ }
+
+ static int Compare(CodeDescriptor* const* a,
+ CodeDescriptor* const* b) {
+ ASSERT(a != NULL);
+ ASSERT(b != NULL);
+
+ uword a_entry = (*a)->Entry();
+ uword b_entry = (*b)->Entry();
+
+ if (a_entry < b_entry) {
+ return -1;
+ } else if (a_entry > b_entry) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ private:
+ const Code& code_;
+
+ DISALLOW_COPY_AND_ASSIGN(CodeDescriptor);
+};
+
+
+// Fast lookup of Dart code objects.
+class CodeLookupTable : public ZoneAllocated {
+ public:
+ explicit CodeLookupTable(Thread* thread);
+
+ intptr_t length() const {
+ return code_objects_.length();
+ }
+
+ const CodeDescriptor* At(intptr_t index) const {
+ return code_objects_.At(index);
+ }
+
+ const CodeDescriptor* FindCode(uword pc) const;
+
+ private:
+ void Build(Thread* thread);
+
+ void Add(const Code& code);
+
+ // Code objects sorted by entry.
+ ZoneGrowableArray<CodeDescriptor*> code_objects_;
+
+ friend class CodeLookupTableBuilder;
+
+ DISALLOW_COPY_AND_ASSIGN(CodeLookupTable);
+};
+
+
// Ring buffer of Samples that is (usually) shared by many isolates.
class SampleBuffer {
public:
@@ -411,7 +490,8 @@ class SampleBuffer {
ProcessedSampleBuffer* BuildProcessedSampleBuffer(SampleFilter* filter);
private:
- ProcessedSample* BuildProcessedSample(Sample* sample);
+ ProcessedSample* BuildProcessedSample(Sample* sample,
+ const CodeLookupTable& clt);
Sample* Next(Sample* sample);
Sample* samples_;
@@ -480,25 +560,15 @@ class ProcessedSample : public ZoneAllocated {
}
private:
- void FixupCaller(Thread* thread,
- Isolate* vm_isolate,
+ void FixupCaller(const CodeLookupTable& clt,
uword pc_marker,
uword* stack_buffer);
- void CheckForMissingDartFrame(Isolate* isolate,
- Isolate* vm_isolate,
- const Code& code,
+ void CheckForMissingDartFrame(const CodeLookupTable& clt,
+ const CodeDescriptor* code,
uword pc_marker,
uword* stack_buffer);
- static RawCode* FindCodeForPC(Isolate* isolate,
- Isolate* vm_isolate,
- uword pc);
-
- static bool ContainedInDartCodeHeaps(Isolate* isolate,
- Isolate* vm_isolate,
- uword pc);
-
ZoneGrowableArray<uword> pcs_;
int64_t timestamp_;
uword vm_tag_;
@@ -529,8 +599,13 @@ class ProcessedSampleBuffer : public ZoneAllocated {
return samples_.At(index);
}
+ const CodeLookupTable& code_lookup_table() const {
+ return *code_lookup_table_;
+ }
+
private:
ZoneGrowableArray<ProcessedSample*> samples_;
+ CodeLookupTable* code_lookup_table_;
DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer);
};
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/profiler.cc » ('j') | runtime/vm/profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698