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

Side by Side Diff: runtime/vm/disassembler.cc

Issue 790213004: Add inlining ranges/intervals to code objects so that we can map a pc to the inlined stack. The map… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/disassembler.h" 5 #include "vm/disassembler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/json_stream.h" 10 #include "vm/json_stream.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // All three are strings. Comments only use the third slot. See above comment 73 // All three are strings. Comments only use the third slot. See above comment
74 // for more information. 74 // for more information.
75 jsarr_.AddValue(""); 75 jsarr_.AddValue("");
76 jsarr_.AddValue(""); 76 jsarr_.AddValue("");
77 jsarr_.AddValue(p); 77 jsarr_.AddValue(p);
78 free(p); 78 free(p);
79 } 79 }
80 80
81 81
82 class FindAddrVisitor : public FindObjectVisitor { 82 class FindAddrVisitor : public FindObjectVisitor {
83 public: 83 public:
84 explicit FindAddrVisitor(uword addr) 84 explicit FindAddrVisitor(uword addr)
85 : FindObjectVisitor(Isolate::Current()), addr_(addr) { } 85 : FindObjectVisitor(Isolate::Current()), addr_(addr) { }
86 virtual ~FindAddrVisitor() { } 86 virtual ~FindAddrVisitor() { }
87 87
88 virtual uword filter_addr() const { return addr_; } 88 virtual uword filter_addr() const { return addr_; }
89 89
90 // Check if object matches find condition. 90 // Check if object matches find condition.
91 virtual bool FindObject(RawObject* obj) const { 91 virtual bool FindObject(RawObject* obj) const {
92 return obj == reinterpret_cast<RawObject*>(addr_); 92 return obj == reinterpret_cast<RawObject*>(addr_);
93 } 93 }
94 94
95 private: 95 private:
96 const uword addr_; 96 const uword addr_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(FindAddrVisitor); 98 DISALLOW_COPY_AND_ASSIGN(FindAddrVisitor);
99 }; 99 };
100 100
101 101
102 bool Disassembler::CanFindOldObject(uword addr) { 102 bool Disassembler::CanFindOldObject(uword addr) {
103 FindAddrVisitor visitor(addr); 103 FindAddrVisitor visitor(addr);
104 NoGCScope no_gc; 104 NoGCScope no_gc;
105 return Isolate::Current()->heap()->FindOldObject(&visitor) != Object::null(); 105 return Isolate::Current()->heap()->FindOldObject(&visitor) != Object::null();
106 } 106 }
107 107
108
109 void Disassembler::Disassemble(uword start,
110 uword end,
111 DisassemblyFormatter* formatter,
112 const Code& code) {
113 const Code::Comments& comments =
114 code.IsNull() ? Code::Comments::New(0) : code.comments();
115 ASSERT(formatter != NULL);
116 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
117 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
118 uword pc = start;
119 intptr_t comment_finger = 0;
120 GrowableArray<Function*> inlined_functions;
121 while (pc < end) {
122 const intptr_t offset = pc - start;
123 const intptr_t old_comment_finger = comment_finger;
124 while (comment_finger < comments.Length() &&
125 comments.PCOffsetAt(comment_finger) <= offset) {
126 formatter->Print(
127 " ;; %s\n",
128 String::Handle(comments.CommentAt(comment_finger)).ToCString());
129 comment_finger++;
130 }
131 if (old_comment_finger != comment_finger) {
132 // Comment emitted, emit inlining information.
133 code.GetInlinedFunctionsAt(offset, &inlined_functions);
134 // Skip top scope function printing.
135 for (intptr_t i = 1; i < inlined_functions.length(); i++) {
136 if (i == 1) {
137 formatter->Print(" ;; Inlined ");
138 }
139 formatter->Print("-> %s ", inlined_functions[i]->ToQualifiedCString());
140 }
141 if (inlined_functions.length() > 1) {
142 formatter->Print("\n");
143 }
144 }
145 int instruction_length;
146 DecodeInstruction(hex_buffer,
147 sizeof(hex_buffer),
148 human_buffer,
149 sizeof(human_buffer),
150 &instruction_length, pc);
151 formatter->ConsumeInstruction(hex_buffer,
152 sizeof(hex_buffer),
153 human_buffer,
154 sizeof(human_buffer),
155 pc);
156 pc += instruction_length;
157 }
158 }
159
108 } // namespace dart 160 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698