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

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

Issue 1758653003: Add source position information to profile (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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 12741 matching lines...) Expand 10 before | Expand all | Expand 10 after
12752 12752
12753 12753
12754 bool Code::HasBreakpoint() const { 12754 bool Code::HasBreakpoint() const {
12755 if (!FLAG_support_debugger) { 12755 if (!FLAG_support_debugger) {
12756 return false; 12756 return false;
12757 } 12757 }
12758 return Isolate::Current()->debugger()->HasBreakpoint(*this); 12758 return Isolate::Current()->debugger()->HasBreakpoint(*this);
12759 } 12759 }
12760 12760
12761 12761
12762 TokenPosition Code::GetTokenPositionAt(intptr_t offset) const {
12763 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map());
12764 if (map.IsNull()) {
12765 return TokenPosition::kNoSource;
12766 }
12767 return map.TokenPositionForPCOffset(offset);
12768 }
12769
12770
12762 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, 12771 RawTypedData* Code::GetDeoptInfoAtPc(uword pc,
12763 ICData::DeoptReasonId* deopt_reason, 12772 ICData::DeoptReasonId* deopt_reason,
12764 uint32_t* deopt_flags) const { 12773 uint32_t* deopt_flags) const {
12765 ASSERT(is_optimized()); 12774 ASSERT(is_optimized());
12766 const Instructions& instrs = Instructions::Handle(instructions()); 12775 const Instructions& instrs = Instructions::Handle(instructions());
12767 uword code_entry = instrs.EntryPoint(); 12776 uword code_entry = instrs.EntryPoint();
12768 const Array& table = Array::Handle(deopt_info_array()); 12777 const Array& table = Array::Handle(deopt_info_array());
12769 if (table.IsNull()) { 12778 if (table.IsNull()) {
12770 ASSERT(Dart::IsRunningPrecompiledCode()); 12779 ASSERT(Dart::IsRunningPrecompiledCode());
12771 return TypedData::null(); 12780 return TypedData::null();
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
13356 if (map.IsNull() || (map.Length() == 0)) { 13365 if (map.IsNull() || (map.Length() == 0)) {
13357 return -1; 13366 return -1;
13358 } 13367 }
13359 Smi& smi = Smi::Handle(); 13368 Smi& smi = Smi::Handle();
13360 smi ^= map.At(inlined_id); 13369 smi ^= map.At(inlined_id);
13361 return smi.Value(); 13370 return smi.Value();
13362 } 13371 }
13363 13372
13364 13373
13365 void Code::GetInlinedFunctionsAt( 13374 void Code::GetInlinedFunctionsAt(
13366 intptr_t offset, GrowableArray<Function*>* fs) const { 13375 intptr_t offset,
13376 GrowableArray<Function*>* fs,
13377 GrowableArray<TokenPosition>* token_positions) const {
13367 fs->Clear(); 13378 fs->Clear();
13379 if (token_positions != NULL) {
13380 token_positions->Clear();
13381 }
13368 const Array& intervals = Array::Handle(GetInlinedIntervals()); 13382 const Array& intervals = Array::Handle(GetInlinedIntervals());
13369 if (intervals.IsNull() || (intervals.Length() == 0)) { 13383 if (intervals.IsNull() || (intervals.Length() == 0)) {
13370 // E.g., for code stubs. 13384 // E.g., for code stubs.
13371 return; 13385 return;
13372 } 13386 }
13373 // First find the right interval. TODO(srdjan): use binary search since 13387 // First find the right interval. TODO(srdjan): use binary search since
13374 // intervals are sorted. 13388 // intervals are sorted.
13375 Smi& start = Smi::Handle(); 13389 Smi& start = Smi::Handle();
13376 Smi& end = Smi::Handle(); 13390 Smi& end = Smi::Handle();
13377 intptr_t found_interval_ix = intervals.Length() - Code::kInlIntNumEntries; 13391 intptr_t found_interval_ix = intervals.Length() - Code::kInlIntNumEntries;
13378 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries; 13392 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries;
13379 i += Code::kInlIntNumEntries) { 13393 i += Code::kInlIntNumEntries) {
13380 start ^= intervals.At(i + Code::kInlIntStart); 13394 start ^= intervals.At(i + Code::kInlIntStart);
13381 if (!start.IsNull()) { 13395 if (!start.IsNull()) {
13382 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart); 13396 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart);
13383 if ((start.Value() <= offset) && (offset < end.Value())) { 13397 if ((start.Value() <= offset) && (offset < end.Value())) {
13384 found_interval_ix = i; 13398 found_interval_ix = i;
13385 break; 13399 break;
13386 } 13400 }
13387 } 13401 }
13388 } 13402 }
13389 13403
13390 // Find all functions. 13404 // Find all functions.
13391 const Array& id_map = Array::Handle(GetInlinedIdToFunction()); 13405 const Array& id_map = Array::Handle(GetInlinedIdToFunction());
13406 const Array& token_pos_map = Array::Handle(GetInlinedIdToTokenPos());
13392 Smi& temp_smi = Smi::Handle(); 13407 Smi& temp_smi = Smi::Handle();
13393 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntInliningId); 13408 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntInliningId);
13394 intptr_t inlining_id = temp_smi.Value(); 13409 intptr_t inlining_id = temp_smi.Value();
13395 ASSERT(inlining_id >= 0); 13410 ASSERT(inlining_id >= 0);
13396 intptr_t caller_id = GetCallerId(inlining_id); 13411 intptr_t caller_id = GetCallerId(inlining_id);
13397 while (inlining_id >= 0) { 13412 while (inlining_id >= 0) {
13398 Function& function = Function::ZoneHandle(); 13413 Function& function = Function::ZoneHandle();
13399 function ^= id_map.At(inlining_id); 13414 function ^= id_map.At(inlining_id);
13400 fs->Add(&function); 13415 fs->Add(&function);
13416 if ((token_positions != NULL) && (inlining_id < token_pos_map.Length())) {
13417 temp_smi ^= token_pos_map.At(inlining_id);
13418 token_positions->Add(TokenPosition(temp_smi.Value()));
13419 }
13401 inlining_id = caller_id; 13420 inlining_id = caller_id;
13402 caller_id = GetCallerId(inlining_id); 13421 caller_id = GetCallerId(inlining_id);
13403 } 13422 }
13404 } 13423 }
13405 13424
13406 13425
13407 void Code::DumpInlinedIntervals() const { 13426 void Code::DumpInlinedIntervals() const {
13408 LogBlock lb; 13427 LogBlock lb;
13409 THR_Print("Inlined intervals:\n"); 13428 THR_Print("Inlined intervals:\n");
13410 const Array& intervals = Array::Handle(GetInlinedIntervals()); 13429 const Array& intervals = Array::Handle(GetInlinedIntervals());
(...skipping 8248 matching lines...) Expand 10 before | Expand all | Expand 10 after
21659 return UserTag::null(); 21678 return UserTag::null();
21660 } 21679 }
21661 21680
21662 21681
21663 const char* UserTag::ToCString() const { 21682 const char* UserTag::ToCString() const {
21664 const String& tag_label = String::Handle(label()); 21683 const String& tag_label = String::Handle(label());
21665 return tag_label.ToCString(); 21684 return tag_label.ToCString();
21666 } 21685 }
21667 21686
21668 } // namespace dart 21687 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698