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

Side by Side Diff: runtime/vm/object.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 12239 matching lines...) Expand 10 before | Expand all | Expand 10 after
12250 const bool fix_patch = CodePatcher::CodeIsPatchable(*this) && 12250 const bool fix_patch = CodePatcher::CodeIsPatchable(*this) &&
12251 CodePatcher::IsEntryPatched(*this); 12251 CodePatcher::IsEntryPatched(*this);
12252 if (fix_patch) { 12252 if (fix_patch) {
12253 // The disassembler may choke on illegal instructions if the code has been 12253 // The disassembler may choke on illegal instructions if the code has been
12254 // patched, un-patch the code before disassembling and re-patch after. 12254 // patched, un-patch the code before disassembling and re-patch after.
12255 CodePatcher::RestoreEntry(*this); 12255 CodePatcher::RestoreEntry(*this);
12256 } 12256 }
12257 const Instructions& instr = Instructions::Handle(instructions()); 12257 const Instructions& instr = Instructions::Handle(instructions());
12258 uword start = instr.EntryPoint(); 12258 uword start = instr.EntryPoint();
12259 if (formatter == NULL) { 12259 if (formatter == NULL) {
12260 Disassembler::Disassemble(start, start + instr.size(), comments()); 12260 Disassembler::Disassemble(start, start + instr.size(), *this);
12261 } else { 12261 } else {
12262 Disassembler::Disassemble(start, start + instr.size(), formatter, 12262 Disassembler::Disassemble(start, start + instr.size(), formatter, *this);
12263 comments());
12264 } 12263 }
12265 if (fix_patch) { 12264 if (fix_patch) {
12266 // Redo the patch. 12265 // Redo the patch.
12267 CodePatcher::PatchEntry(*this); 12266 CodePatcher::PatchEntry(*this);
12268 } 12267 }
12269 } 12268 }
12270 12269
12271 12270
12272 const Code::Comments& Code::comments() const { 12271 const Code::Comments& Code::comments() const {
12273 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); 12272 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_));
12274 return *comments; 12273 return *comments;
12275 } 12274 }
12276 12275
12277 12276
12278 void Code::set_comments(const Code::Comments& comments) const { 12277 void Code::set_comments(const Code::Comments& comments) const {
12279 ASSERT(comments.comments_.IsOld()); 12278 ASSERT(comments.comments_.IsOld());
12280 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); 12279 StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
12281 } 12280 }
12282 12281
12283 12282
12283 void Code::set_inlined_intervals(const Array& value) const {
12284 ASSERT(value.IsOld());
12285 StorePointer(&raw_ptr()->inlined_intervals_, value.raw());
12286 }
12287
12288
12284 RawCode* Code::New(intptr_t pointer_offsets_length) { 12289 RawCode* Code::New(intptr_t pointer_offsets_length) {
12285 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { 12290 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
12286 // This should be caught before we reach here. 12291 // This should be caught before we reach here.
12287 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", 12292 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n",
12288 pointer_offsets_length); 12293 pointer_offsets_length);
12289 } 12294 }
12290 ASSERT(Object::code_class() != Class::null()); 12295 ASSERT(Object::code_class() != Class::null());
12291 Code& result = Code::Handle(); 12296 Code& result = Code::Handle();
12292 { 12297 {
12293 uword size = Code::InstanceSize(pointer_offsets_length); 12298 uword size = Code::InstanceSize(pointer_offsets_length);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
12624 if (map->PcOffset() == pc_offset) { 12629 if (map->PcOffset() == pc_offset) {
12625 return map->raw(); // We found a stack map for this frame. 12630 return map->raw(); // We found a stack map for this frame.
12626 } 12631 }
12627 } 12632 }
12628 // If the code has stackmaps, it must have them for all safepoints. 12633 // If the code has stackmaps, it must have them for all safepoints.
12629 UNREACHABLE(); 12634 UNREACHABLE();
12630 return Stackmap::null(); 12635 return Stackmap::null();
12631 } 12636 }
12632 12637
12633 12638
12639 void Code::GetInlinedFunctionsAt(
12640 intptr_t offset, GrowableArray<Function*>* fs) const {
12641 fs->Clear();
12642 const Array& intervals = Array::Handle(inlined_intervals());
12643 Smi& start = Smi::Handle();
12644 Smi& end = Smi::Handle();
12645 Function& function = Function::Handle();
12646 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) {
12647 start ^= intervals.At(i + Code::kInlIntStart);
12648 if (!start.IsNull()) {
12649 end ^= intervals.At(i + Code::kInlIntEnd);
12650 if ((start.Value() <= offset) && (offset < end.Value())) {
12651 function ^= intervals.At(i + Code::kInlIntFunction);
12652 fs->Add(&Function::ZoneHandle(function.raw()));
12653 }
12654 }
12655 }
12656 }
12657
12658
12659 void Code::DumpInlinedIntervals() const {
12660 OS::Print("Inlined intervals:\n");
12661 const Array& intervals = Array::Handle(inlined_intervals());
12662 Smi& start = Smi::Handle();
12663 Smi& end = Smi::Handle();
12664 Function& function = Function::Handle();
12665 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) {
12666 start ^= intervals.At(i + Code::kInlIntStart);
12667 if (!start.IsNull()) {
12668 end ^= intervals.At(i + Code::kInlIntEnd);
12669 function ^= intervals.At(i + Code::kInlIntFunction);
12670 OS::Print("%" Pd " .. %" Pd " %s\n",
12671 start.Value(), end.Value(), function.ToQualifiedCString());
12672 }
12673 }
12674 }
12675
12676
12634 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 12677 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
12635 ASSERT(num_variables >= 0); 12678 ASSERT(num_variables >= 0);
12636 ASSERT(Object::context_class() != Class::null()); 12679 ASSERT(Object::context_class() != Class::null());
12637 12680
12638 if (num_variables < 0 || num_variables > kMaxElements) { 12681 if (num_variables < 0 || num_variables > kMaxElements) {
12639 // This should be caught before we reach here. 12682 // This should be caught before we reach here.
12640 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n", 12683 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n",
12641 num_variables); 12684 num_variables);
12642 } 12685 }
12643 Context& result = Context::Handle(); 12686 Context& result = Context::Handle();
(...skipping 7940 matching lines...) Expand 10 before | Expand all | Expand 10 after
20584 return tag_label.ToCString(); 20627 return tag_label.ToCString();
20585 } 20628 }
20586 20629
20587 20630
20588 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20631 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20589 Instance::PrintJSONImpl(stream, ref); 20632 Instance::PrintJSONImpl(stream, ref);
20590 } 20633 }
20591 20634
20592 20635
20593 } // namespace dart 20636 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698