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

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

Issue 904763003: Redesign inlining interval computation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 months 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 12155 matching lines...) Expand 10 before | Expand all | Expand 10 after
12166 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); 12166 StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
12167 } 12167 }
12168 12168
12169 12169
12170 void Code::set_inlined_intervals(const Array& value) const { 12170 void Code::set_inlined_intervals(const Array& value) const {
12171 ASSERT(value.IsOld()); 12171 ASSERT(value.IsOld());
12172 StorePointer(&raw_ptr()->inlined_intervals_, value.raw()); 12172 StorePointer(&raw_ptr()->inlined_intervals_, value.raw());
12173 } 12173 }
12174 12174
12175 12175
12176 void Code::set_inlined_id_to_function(const Array& value) const {
12177 ASSERT(value.IsOld());
12178 StorePointer(&raw_ptr()->inlined_id_to_function_, value.raw());
12179 }
12180
12181
12176 RawCode* Code::New(intptr_t pointer_offsets_length) { 12182 RawCode* Code::New(intptr_t pointer_offsets_length) {
12177 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { 12183 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
12178 // This should be caught before we reach here. 12184 // This should be caught before we reach here.
12179 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", 12185 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n",
12180 pointer_offsets_length); 12186 pointer_offsets_length);
12181 } 12187 }
12182 ASSERT(Object::code_class() != Class::null()); 12188 ASSERT(Object::code_class() != Class::null());
12183 Code& result = Code::Handle(); 12189 Code& result = Code::Handle();
12184 { 12190 {
12185 uword size = Code::InstanceSize(pointer_offsets_length); 12191 uword size = Code::InstanceSize(pointer_offsets_length);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
12519 if (map->PcOffset() == pc_offset) { 12525 if (map->PcOffset() == pc_offset) {
12520 return map->raw(); // We found a stack map for this frame. 12526 return map->raw(); // We found a stack map for this frame.
12521 } 12527 }
12522 } 12528 }
12523 // If the code has stackmaps, it must have them for all safepoints. 12529 // If the code has stackmaps, it must have them for all safepoints.
12524 UNREACHABLE(); 12530 UNREACHABLE();
12525 return Stackmap::null(); 12531 return Stackmap::null();
12526 } 12532 }
12527 12533
12528 12534
12535 intptr_t Code::GetCallerId(intptr_t inlined_id) const {
12536 if (inlined_id < 0) return -1;
12537 const Array& intervals = Array::Handle(inlined_intervals());
12538 Smi& temp_smi = Smi::Handle();
12539 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries;
12540 i += Code::kInlIntNumEntries) {
12541 temp_smi ^= intervals.At(i + Code::kInlIntInliningId);
12542 if (temp_smi.Value() == inlined_id) {
12543 temp_smi ^= intervals.At(i + Code::kInlIntCallerId);
12544 return temp_smi.Value();
12545 }
12546 }
12547 return -1;
12548 }
12549
12550
12529 void Code::GetInlinedFunctionsAt( 12551 void Code::GetInlinedFunctionsAt(
12530 intptr_t offset, GrowableArray<Function*>* fs) const { 12552 intptr_t offset, GrowableArray<Function*>* fs) const {
12531 fs->Clear(); 12553 fs->Clear();
12532 const Array& intervals = Array::Handle(inlined_intervals()); 12554 const Array& intervals = Array::Handle(inlined_intervals());
12533 if (intervals.IsNull()) { 12555 if (intervals.IsNull()) {
12534 // E.g., for code stubs. 12556 // E.g., for code stubs.
12535 return; 12557 return;
12536 } 12558 }
12559 // First find the right interval. TODO(srdjan): use binary search since
12560 // intervals are sorted.
12537 Smi& start = Smi::Handle(); 12561 Smi& start = Smi::Handle();
12538 Smi& end = Smi::Handle(); 12562 Smi& end = Smi::Handle();
12539 Function& function = Function::Handle(); 12563 intptr_t found_interval_ix = 0;
Cutch 2015/02/09 20:48:23 How about: intptr_t found_interval_ix = -1; and
srdjan 2015/02/09 23:05:03 This does not work for code with a single interval
12540 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) { 12564 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries;
12565 i += Code::kInlIntNumEntries) {
12566 found_interval_ix = i;
12541 start ^= intervals.At(i + Code::kInlIntStart); 12567 start ^= intervals.At(i + Code::kInlIntStart);
12542 if (!start.IsNull()) { 12568 if (!start.IsNull()) {
12543 end ^= intervals.At(i + Code::kInlIntEnd); 12569 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart);
12544 if ((start.Value() <= offset) && (offset < end.Value())) { 12570 if ((start.Value() <= offset) && (offset < end.Value())) {
12545 function ^= intervals.At(i + Code::kInlIntFunction); 12571 break;
12546 fs->Add(&Function::ZoneHandle(function.raw()));
12547 } 12572 }
12548 } 12573 }
12549 } 12574 }
12575
12576 // Find all functions.
12577 const Array& id_map = Array::Handle(inlined_id_to_function());
12578 Smi& temp_smi = Smi::Handle();
12579 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntInliningId);
12580 intptr_t inlining_id = temp_smi.Value();
12581 ASSERT(inlining_id >= 0);
12582 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntCallerId);
12583 intptr_t caller_id = temp_smi.Value();
12584 while (inlining_id >= 0) {
12585 Function& function = Function::ZoneHandle();
12586 function ^= id_map.At(inlining_id);
12587 fs->Add(&function);
12588 inlining_id = caller_id;
12589 caller_id = GetCallerId(inlining_id);
12590 }
12550 } 12591 }
12551 12592
12552 12593
12553 void Code::DumpInlinedIntervals() const { 12594 void Code::DumpInlinedIntervals() const {
12554 OS::Print("Inlined intervals:\n"); 12595 OS::Print("Inlined intervals:\n");
12555 const Array& intervals = Array::Handle(inlined_intervals()); 12596 const Array& intervals = Array::Handle(inlined_intervals());
12556 Smi& start = Smi::Handle(); 12597 Smi& start = Smi::Handle();
12557 Smi& end = Smi::Handle(); 12598 Smi& inlining_id = Smi::Handle();
12558 Function& function = Function::Handle(); 12599 Smi& caller_id = Smi::Handle();
12559 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) { 12600 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) {
12560 start ^= intervals.At(i + Code::kInlIntStart); 12601 start ^= intervals.At(i + Code::kInlIntStart);
12561 if (!start.IsNull()) { 12602 ASSERT(!start.IsNull());
12562 end ^= intervals.At(i + Code::kInlIntEnd); 12603 if (start.IsNull()) continue;
12563 function ^= intervals.At(i + Code::kInlIntFunction); 12604 inlining_id ^= intervals.At(i + Code::kInlIntInliningId);
12564 OS::Print("%" Pd " .. %" Pd " %s\n", 12605 caller_id ^= intervals.At(i + Code::kInlIntCallerId);
12565 start.Value(), end.Value(), function.ToQualifiedCString()); 12606 OS::Print(" %" Px " id: %" Pd " caller-id: %" Pd " \n",
12607 start.Value(), inlining_id.Value(), caller_id.Value());
12608 }
12609 OS::Print("Inlined ids:\n");
12610 const Array& id_map = Array::Handle(inlined_id_to_function());
12611 Function& function = Function::Handle();
12612 for (intptr_t i = 0; i < id_map.Length(); i++) {
12613 function ^= id_map.At(i);
12614 if (!function.IsNull()) {
12615 OS::Print(" %" Pd ": %s\n", i, function.ToQualifiedCString());
12566 } 12616 }
12567 } 12617 }
12568 } 12618 }
12569 12619
12570 12620
12571 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 12621 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
12572 ASSERT(num_variables >= 0); 12622 ASSERT(num_variables >= 0);
12573 ASSERT(Object::context_class() != Class::null()); 12623 ASSERT(Object::context_class() != Class::null());
12574 12624
12575 if (num_variables < 0 || num_variables > kMaxElements) { 12625 if (num_variables < 0 || num_variables > kMaxElements) {
(...skipping 7990 matching lines...) Expand 10 before | Expand all | Expand 10 after
20566 return tag_label.ToCString(); 20616 return tag_label.ToCString();
20567 } 20617 }
20568 20618
20569 20619
20570 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20620 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20571 Instance::PrintJSONImpl(stream, ref); 20621 Instance::PrintJSONImpl(stream, ref);
20572 } 20622 }
20573 20623
20574 20624
20575 } // namespace dart 20625 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698