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

Side by Side Diff: test/unittests/interpreter/source-position-table-unittest.cc

Issue 1947403002: [interpreter] Introduce bytecode generation pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 7 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 | « test/unittests/interpreter/bytecodes-unittest.cc ('k') | test/unittests/unittests.gyp » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/source-position-table.h" 7 #include "src/interpreter/source-position-table.h"
8 #include "test/unittests/test-utils.h" 8 #include "test/unittests/test-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace interpreter { 12 namespace interpreter {
13 13
14 class SourcePositionTableTest : public TestWithIsolateAndZone { 14 class SourcePositionTableTest : public TestWithIsolateAndZone {
15 public: 15 public:
16 SourcePositionTableTest() {} 16 SourcePositionTableTest() {}
17 ~SourcePositionTableTest() override {} 17 ~SourcePositionTableTest() override {}
18 }; 18 };
19 19
20 // Some random offsets, mostly at 'suspicious' bit boundaries. 20 // Some random offsets, mostly at 'suspicious' bit boundaries.
21 static int offsets[] = {0, 1, 2, 3, 4, 30, 31, 32, 21 static int offsets[] = {0, 1, 2, 3, 4, 30, 31, 32,
22 33, 62, 63, 64, 65, 126, 127, 128, 22 33, 62, 63, 64, 65, 126, 127, 128,
23 129, 250, 1000, 9999, 12000, 31415926}; 23 129, 250, 1000, 9999, 12000, 31415926};
24 24
25 TEST_F(SourcePositionTableTest, EncodeStatement) { 25 TEST_F(SourcePositionTableTest, EncodeStatement) {
26 SourcePositionTableBuilder builder(isolate(), zone()); 26 SourcePositionTableBuilder builder(isolate(), zone());
27 for (int i = 0; i < arraysize(offsets); i++) { 27 for (int i = 0; i < arraysize(offsets); i++) {
28 builder.AddStatementPosition(offsets[i], offsets[i]); 28 builder.AddPosition(offsets[i], offsets[i], true);
29 } 29 }
30 30
31 // To test correctness, we rely on the assertions in ToSourcePositionTable(). 31 // To test correctness, we rely on the assertions in ToSourcePositionTable().
32 // (Also below.) 32 // (Also below.)
33 CHECK(!builder.ToSourcePositionTable().is_null()); 33 CHECK(!builder.ToSourcePositionTable().is_null());
34 } 34 }
35 35
36 TEST_F(SourcePositionTableTest, EncodeStatementDuplicates) { 36 TEST_F(SourcePositionTableTest, EncodeStatementDuplicates) {
37 SourcePositionTableBuilder builder(isolate(), zone()); 37 SourcePositionTableBuilder builder(isolate(), zone());
38 for (int i = 0; i < arraysize(offsets); i++) { 38 for (int i = 0; i < arraysize(offsets); i++) {
39 builder.AddStatementPosition(offsets[i], offsets[i]); 39 builder.AddPosition(offsets[i], offsets[i], true);
40 builder.AddStatementPosition(offsets[i], offsets[i] + 1); 40 builder.AddPosition(offsets[i], offsets[i] + 1, true);
41 } 41 }
42 42
43 // To test correctness, we rely on the assertions in ToSourcePositionTable(). 43 // To test correctness, we rely on the assertions in ToSourcePositionTable().
44 // (Also below.) 44 // (Also below.)
45 CHECK(!builder.ToSourcePositionTable().is_null()); 45 CHECK(!builder.ToSourcePositionTable().is_null());
46 } 46 }
47 47
48 TEST_F(SourcePositionTableTest, EncodeExpression) { 48 TEST_F(SourcePositionTableTest, EncodeExpression) {
49 SourcePositionTableBuilder builder(isolate(), zone()); 49 SourcePositionTableBuilder builder(isolate(), zone());
50 for (int i = 0; i < arraysize(offsets); i++) { 50 for (int i = 0; i < arraysize(offsets); i++) {
51 builder.AddExpressionPosition(offsets[i], offsets[i]); 51 builder.AddPosition(offsets[i], offsets[i], false);
52 } 52 }
53 CHECK(!builder.ToSourcePositionTable().is_null()); 53 CHECK(!builder.ToSourcePositionTable().is_null());
54 } 54 }
55 55
56 TEST_F(SourcePositionTableTest, EncodeAscending) { 56 TEST_F(SourcePositionTableTest, EncodeAscending) {
57 SourcePositionTableBuilder builder(isolate(), zone()); 57 SourcePositionTableBuilder builder(isolate(), zone());
58 58
59 int accumulator = 0; 59 int accumulator = 0;
60 for (int i = 0; i < arraysize(offsets); i++) { 60 for (int i = 0; i < arraysize(offsets); i++) {
61 accumulator += offsets[i]; 61 accumulator += offsets[i];
62 if (i % 2) { 62 if (i % 2) {
63 builder.AddStatementPosition(accumulator, accumulator); 63 builder.AddPosition(accumulator, accumulator, true);
64 } else { 64 } else {
65 builder.AddExpressionPosition(accumulator, accumulator); 65 builder.AddPosition(accumulator, accumulator, false);
66 } 66 }
67 } 67 }
68 68
69 // Also test negative offsets: 69 // Also test negative offsets:
70 for (int i = 0; i < arraysize(offsets); i++) { 70 for (int i = 0; i < arraysize(offsets); i++) {
71 accumulator -= offsets[i]; 71 accumulator -= offsets[i];
72 if (i % 2) { 72 if (i % 2) {
73 builder.AddStatementPosition(accumulator, accumulator); 73 builder.AddPosition(accumulator, accumulator, true);
74 } else { 74 } else {
75 builder.AddExpressionPosition(accumulator, accumulator); 75 builder.AddPosition(accumulator, accumulator, false);
76 } 76 }
77 } 77 }
78 78
79 CHECK(!builder.ToSourcePositionTable().is_null()); 79 CHECK(!builder.ToSourcePositionTable().is_null());
80 } 80 }
81 81
82 } // namespace interpreter 82 } // namespace interpreter
83 } // namespace internal 83 } // namespace internal
84 } // namespace v8 84 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/interpreter/bytecodes-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698