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

Side by Side Diff: test/cctest/compiler/test-basic-block-profiler.cc

Issue 593563005: [turbofan] basic block profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/basic-block-profiler.h"
8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h"
10
11 #if V8_TURBOFAN_TARGET
12
13 using namespace v8::internal;
14 using namespace v8::internal::compiler;
15
16 typedef RawMachineAssembler::Label MLabel;
17
18 class BasicBlockProfilerTest : public RawMachineAssemblerTester<int32_t> {
19 public:
20 BasicBlockProfilerTest() : RawMachineAssemblerTester<int32_t>(kMachInt32) {
21 FLAG_turbo_profiling = true;
22 }
23
24 void ResetCounts() { isolate()->basic_block_profiler()->ResetCounts(); }
25
26 void Expect(size_t size, uint32_t* expected) {
27 CHECK_NE(NULL, isolate()->basic_block_profiler());
28 const BasicBlockProfiler::DataList* l =
29 isolate()->basic_block_profiler()->data_list();
30 CHECK_NE(0, static_cast<int>(l->size()));
31 const BasicBlockProfiler::Data* data = l->back();
32 CHECK_EQ(static_cast<int>(size), static_cast<int>(data->n_blocks()));
33 const uint32_t* counts = data->counts();
34 for (size_t i = 0; i < size; ++i) {
35 CHECK_EQ(static_cast<int>(expected[i]), static_cast<int>(counts[i]));
36 }
37 }
38 };
39
40
41 TEST(ProfileDiamond) {
42 BasicBlockProfilerTest m;
43
44 MLabel blocka, blockb, end;
45 m.Branch(m.Parameter(0), &blocka, &blockb);
46 m.Bind(&blocka);
47 m.Goto(&end);
48 m.Bind(&blockb);
49 m.Goto(&end);
50 m.Bind(&end);
51 m.Return(m.Int32Constant(0));
52
53 m.GenerateCode();
54 {
55 uint32_t expected[] = {0, 0, 0, 0};
56 m.Expect(arraysize(expected), expected);
57 }
58
59 m.Call(0);
60 {
61 uint32_t expected[] = {1, 1, 0, 1};
62 m.Expect(arraysize(expected), expected);
63 }
64
65 m.ResetCounts();
66
67 m.Call(1);
68 {
69 uint32_t expected[] = {1, 0, 1, 1};
70 m.Expect(arraysize(expected), expected);
71 }
72
73 m.Call(0);
74 {
75 uint32_t expected[] = {2, 1, 1, 2};
76 m.Expect(arraysize(expected), expected);
77 }
78 }
79
80
81 TEST(ProfileLoop) {
82 BasicBlockProfilerTest m;
83
84 MLabel header, body, end;
85 Node* one = m.Int32Constant(1);
86 m.Goto(&header);
87
88 m.Bind(&header);
89 Node* count = m.Phi(kMachInt32, m.Parameter(0), one);
90 m.Branch(count, &body, &end);
91
92 m.Bind(&body);
93 count->ReplaceInput(1, m.Int32Sub(count, one));
94 m.Goto(&header);
95
96 m.Bind(&end);
97 m.Return(one);
98
99 m.GenerateCode();
100 {
101 uint32_t expected[] = {0, 0, 0, 0};
102 m.Expect(arraysize(expected), expected);
103 }
104
105 uint32_t runs[] = {0, 1, 500, 10000};
106 for (size_t i = 0; i < arraysize(runs); i++) {
107 m.ResetCounts();
108 CHECK_EQ(1, m.Call(static_cast<int>(runs[i])));
109 uint32_t expected[] = {1, runs[i] + 1, runs[i], 1};
110 m.Expect(arraysize(expected), expected);
111 }
112 }
113
114 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698