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

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

Issue 2670843006: Encode inlining information in CodeSourceMap and remove inlining interval arrays. (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/profiler.h" 10 #include "vm/profiler.h"
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 // See OffsetForPC in profiler_service.cc for more context. 2442 // See OffsetForPC in profiler_service.cc for more context.
2443 const intptr_t return_address_offset = i > 0 ? 1 : 0; 2443 const intptr_t return_address_offset = i > 0 ? 1 : 0;
2444 sample->SetAt(i, pc_offsets[i] + return_address_offset); 2444 sample->SetAt(i, pc_offsets[i] + return_address_offset);
2445 i++; 2445 i++;
2446 } 2446 }
2447 sample->SetAt(i, 0); 2447 sample->SetAt(i, 0);
2448 } 2448 }
2449 2449
2450 2450
2451 static uword FindPCForTokenPosition(const Code& code, 2451 static uword FindPCForTokenPosition(const Code& code,
2452 const CodeSourceMap& code_source_map,
2453 TokenPosition tp) { 2452 TokenPosition tp) {
2454 CodeSourceMap::Iterator it(code_source_map); 2453 GrowableArray<const Function*> functions;
2455 2454 GrowableArray<TokenPosition> token_positions;
2456 while (it.MoveNext()) { 2455 for (intptr_t pc_offset = 0; pc_offset < code.Size(); pc_offset++) {
2457 if (it.TokenPos() == tp) { 2456 code.GetInlinedFunctionsAt(pc_offset, &functions, &token_positions);
2458 return it.PcOffset() + code.PayloadStart(); 2457 if (token_positions[0] == tp) {
2458 return code.PayloadStart() + pc_offset;
2459 } 2459 }
2460 } 2460 }
2461 2461
2462 return 0; 2462 return 0;
2463 } 2463 }
2464 2464
2465 2465
2466 TEST_CASE(Profiler_GetSourceReport) { 2466 TEST_CASE(Profiler_GetSourceReport) {
2467 const char* kScript = 2467 const char* kScript =
2468 "doWork(i) => i * i;\n" 2468 "doWork(i) => i * i;\n"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 2515
2516 const Script& script = Script::Handle(main.script()); 2516 const Script& script = Script::Handle(main.script());
2517 EXPECT(!script.IsNull()); 2517 EXPECT(!script.IsNull());
2518 2518
2519 const Code& main_code = Code::Handle(main.CurrentCode()); 2519 const Code& main_code = Code::Handle(main.CurrentCode());
2520 EXPECT(!main_code.IsNull()); 2520 EXPECT(!main_code.IsNull());
2521 2521
2522 const Code& do_work_code = Code::Handle(do_work.CurrentCode()); 2522 const Code& do_work_code = Code::Handle(do_work.CurrentCode());
2523 EXPECT(!do_work_code.IsNull()); 2523 EXPECT(!do_work_code.IsNull());
2524 2524
2525 const CodeSourceMap& main_code_source_map =
2526 CodeSourceMap::Handle(main_code.code_source_map());
2527 EXPECT(!main_code_source_map.IsNull());
2528
2529 const CodeSourceMap& do_work_code_source_map =
2530 CodeSourceMap::Handle(do_work_code.code_source_map());
2531 EXPECT(!do_work_code_source_map.IsNull());
2532
2533 // Dump code source map. 2525 // Dump code source map.
2534 CodeSourceMap::Dump(do_work_code_source_map, do_work_code, main); 2526 do_work_code.DumpSourcePositions();
2535 CodeSourceMap::Dump(main_code_source_map, main_code, main); 2527 main_code.DumpSourcePositions();
2536 2528
2537 // Look up some source token position's pc. 2529 // Look up some source token position's pc.
2538 uword squarePositionPc = FindPCForTokenPosition( 2530 uword squarePositionPc = FindPCForTokenPosition(do_work_code, squarePosition);
2539 do_work_code, do_work_code_source_map, squarePosition);
2540 EXPECT(squarePositionPc != 0); 2531 EXPECT(squarePositionPc != 0);
2541 2532
2542 uword callPositionPc = 2533 uword callPositionPc = FindPCForTokenPosition(main_code, callPosition);
2543 FindPCForTokenPosition(main_code, main_code_source_map, callPosition);
2544 EXPECT(callPositionPc != 0); 2534 EXPECT(callPositionPc != 0);
2545 2535
2546 // Look up some classifying token position's pc. 2536 // Look up some classifying token position's pc.
2547 uword controlFlowPc = FindPCForTokenPosition( 2537 uword controlFlowPc =
2548 do_work_code, do_work_code_source_map, TokenPosition::kControlFlow); 2538 FindPCForTokenPosition(do_work_code, TokenPosition::kControlFlow);
2549 EXPECT(controlFlowPc != 0); 2539 EXPECT(controlFlowPc != 0);
2550 2540
2551 uword tempMovePc = FindPCForTokenPosition(main_code, main_code_source_map, 2541 uword tempMovePc =
2552 TokenPosition::kTempMove); 2542 FindPCForTokenPosition(main_code, TokenPosition::kTempMove);
2553 EXPECT(tempMovePc != 0); 2543 EXPECT(tempMovePc != 0);
2554 2544
2555 // Insert fake samples. 2545 // Insert fake samples.
2556 2546
2557 // Sample 1: 2547 // Sample 1:
2558 // squarePositionPc exclusive. 2548 // squarePositionPc exclusive.
2559 // callPositionPc inclusive. 2549 // callPositionPc inclusive.
2560 uword sample1[] = {squarePositionPc, // doWork. 2550 uword sample1[] = {squarePositionPc, // doWork.
2561 callPositionPc, // main. 2551 callPositionPc, // main.
2562 0}; 2552 0};
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); 2592 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString());
2603 // Verify exclusive ticks in main. 2593 // Verify exclusive ticks in main.
2604 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); 2594 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString());
2605 // Verify inclusive ticks in main. 2595 // Verify inclusive ticks in main.
2606 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); 2596 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString());
2607 } 2597 }
2608 2598
2609 #endif // !PRODUCT 2599 #endif // !PRODUCT
2610 2600
2611 } // namespace dart 2601 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698